2014-11-20 16:53:05 +01:00
|
|
|
// Copyright 2014 Google Inc. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style license
|
|
|
|
// that can be found in the COPYING file in the root of the source
|
|
|
|
// tree. An additional intellectual property rights grant can be found
|
|
|
|
// in the file PATENTS. All contributing project authors may
|
|
|
|
// be found in the AUTHORS file in the root of the source tree.
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// ARGB making functions.
|
|
|
|
//
|
|
|
|
// Author: Djordje Pesut (djordje.pesut@imgtec.com)
|
|
|
|
|
|
|
|
#include "./dsp.h"
|
|
|
|
|
|
|
|
static WEBP_INLINE uint32_t MakeARGB32(int a, int r, int g, int b) {
|
|
|
|
return (((uint32_t)a << 24) | (r << 16) | (g << 8) | b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PackARGB(const uint8_t* a, const uint8_t* r, const uint8_t* g,
|
2015-01-01 21:13:45 +01:00
|
|
|
const uint8_t* b, int len, uint32_t* out) {
|
|
|
|
int i;
|
2014-11-20 16:53:05 +01:00
|
|
|
for (i = 0; i < len; ++i) {
|
2015-01-01 21:13:45 +01:00
|
|
|
out[i] = MakeARGB32(a[4 * i], r[4 * i], g[4 * i], b[4 * i]);
|
2014-11-20 16:53:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PackRGB(const uint8_t* r, const uint8_t* g, const uint8_t* b,
|
|
|
|
int len, int step, uint32_t* out) {
|
|
|
|
int i, offset = 0;
|
|
|
|
for (i = 0; i < len; ++i) {
|
|
|
|
out[i] = MakeARGB32(0xff, r[offset], g[offset], b[offset]);
|
|
|
|
offset += step;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void (*VP8PackARGB)(const uint8_t*, const uint8_t*, const uint8_t*,
|
2015-01-01 21:13:45 +01:00
|
|
|
const uint8_t*, int, uint32_t*);
|
2014-11-20 16:53:05 +01:00
|
|
|
void (*VP8PackRGB)(const uint8_t*, const uint8_t*, const uint8_t*,
|
|
|
|
int, int, uint32_t*);
|
|
|
|
|
|
|
|
extern void VP8EncDspARGBInitMIPSdspR2(void);
|
2015-01-05 13:44:58 +01:00
|
|
|
extern void VP8EncDspARGBInitSSE2(void);
|
2014-11-20 16:53:05 +01:00
|
|
|
|
2015-01-05 15:51:54 +01:00
|
|
|
static volatile VP8CPUInfo last_cpuinfo_used = (VP8CPUInfo)&last_cpuinfo_used;
|
|
|
|
|
2014-11-20 16:53:05 +01:00
|
|
|
WEBP_TSAN_IGNORE_FUNCTION void VP8EncDspARGBInit(void) {
|
2015-01-05 15:51:54 +01:00
|
|
|
if (last_cpuinfo_used == VP8GetCPUInfo) return;
|
|
|
|
|
2014-11-20 16:53:05 +01:00
|
|
|
VP8PackARGB = PackARGB;
|
|
|
|
VP8PackRGB = PackRGB;
|
|
|
|
|
|
|
|
// If defined, use CPUInfo() to overwrite some pointers with faster versions.
|
|
|
|
if (VP8GetCPUInfo != NULL) {
|
2015-01-05 13:44:58 +01:00
|
|
|
#if defined(WEBP_USE_SSE2)
|
|
|
|
if (VP8GetCPUInfo(kSSE2)) {
|
|
|
|
VP8EncDspARGBInitSSE2();
|
|
|
|
}
|
|
|
|
#endif
|
2014-11-20 16:53:05 +01:00
|
|
|
#if defined(WEBP_USE_MIPS_DSP_R2)
|
|
|
|
if (VP8GetCPUInfo(kMIPSdspR2)) {
|
|
|
|
VP8EncDspARGBInitMIPSdspR2();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2015-01-05 15:51:54 +01:00
|
|
|
last_cpuinfo_used = VP8GetCPUInfo;
|
2014-11-20 16:53:05 +01:00
|
|
|
}
|