simplify the PackARGB signature

Change-Id: I51570e362126b2681f93211a4f59a3fedb5fd4b5
This commit is contained in:
Pascal Massimino 2015-01-01 12:13:45 -08:00
parent 4e2589ff81
commit 72d573f693
4 changed files with 12 additions and 10 deletions

View File

@ -18,11 +18,10 @@ static WEBP_INLINE uint32_t MakeARGB32(int a, int r, int g, int b) {
} }
static void PackARGB(const uint8_t* a, const uint8_t* r, const uint8_t* g, static void PackARGB(const uint8_t* a, const uint8_t* r, const uint8_t* g,
const uint8_t* b, int len, int step, uint32_t* out) { const uint8_t* b, int len, uint32_t* out) {
int i, offset = 0; int i;
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
out[i] = MakeARGB32(a[offset], r[offset], g[offset], b[offset]); out[i] = MakeARGB32(a[4 * i], r[4 * i], g[4 * i], b[4 * i]);
offset += step;
} }
} }
@ -36,7 +35,7 @@ static void PackRGB(const uint8_t* r, const uint8_t* g, const uint8_t* b,
} }
void (*VP8PackARGB)(const uint8_t*, const uint8_t*, const uint8_t*, void (*VP8PackARGB)(const uint8_t*, const uint8_t*, const uint8_t*,
const uint8_t*, int, int, uint32_t*); const uint8_t*, int, uint32_t*);
void (*VP8PackRGB)(const uint8_t*, const uint8_t*, const uint8_t*, void (*VP8PackRGB)(const uint8_t*, const uint8_t*, const uint8_t*,
int, int, uint32_t*); int, int, uint32_t*);

View File

@ -16,10 +16,11 @@
#if defined(WEBP_USE_MIPS_DSP_R2) #if defined(WEBP_USE_MIPS_DSP_R2)
static void PackARGB(const uint8_t* a, const uint8_t* r, const uint8_t* g, static void PackARGB(const uint8_t* a, const uint8_t* r, const uint8_t* g,
const uint8_t* b, int len, int step, uint32_t* out) { const uint8_t* b, int len, uint32_t* out) {
int temp0, temp1, temp2, temp3, offset; int temp0, temp1, temp2, temp3, offset;
const int rest = len & 1; const int rest = len & 1;
const uint32_t* const loop_end = out + len - rest; const uint32_t* const loop_end = out + len - rest;
const int step = 4;
__asm__ volatile ( __asm__ volatile (
"xor %[offset], %[offset], %[offset] \n\t" "xor %[offset], %[offset], %[offset] \n\t"
"beq %[loop_end], %[out], 0f \n\t" "beq %[loop_end], %[out], 0f \n\t"

View File

@ -337,10 +337,11 @@ void WebPMultARGBRowC(uint32_t* const ptr, int width, int inverse);
// To be called first before using the above. // To be called first before using the above.
WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void); WEBP_TSAN_IGNORE_FUNCTION void WebPInitAlphaProcessing(void);
// ARGB making functions. // ARGB packing function: a/r/g/b input is rgba or bgra order.
extern void (*VP8PackARGB)(const uint8_t* a, const uint8_t* r, extern void (*VP8PackARGB)(const uint8_t* a, const uint8_t* r,
const uint8_t* g, const uint8_t* b, int len, const uint8_t* g, const uint8_t* b, int len,
int step, uint32_t* out); uint32_t* out);
// RGB packing function. 'step' can be 3 or 4. r/g/b input is rgb or bgr order.
extern void (*VP8PackRGB)(const uint8_t* r, const uint8_t* g, const uint8_t* b, extern void (*VP8PackRGB)(const uint8_t* r, const uint8_t* g, const uint8_t* b,
int len, int step, uint32_t* out); int len, int step, uint32_t* out);

View File

@ -1062,15 +1062,16 @@ static int Import(WebPPicture* const picture,
VP8EncDspARGBInit(); VP8EncDspARGBInit();
assert(step >= (import_alpha ? 4 : 3));
if (import_alpha) { if (import_alpha) {
assert(step == 4);
for (y = 0; y < height; ++y) { for (y = 0; y < height; ++y) {
uint32_t* const dst = &picture->argb[y * picture->argb_stride]; uint32_t* const dst = &picture->argb[y * picture->argb_stride];
const int offset = y * rgb_stride; const int offset = y * rgb_stride;
VP8PackARGB(a_ptr + offset, r_ptr + offset, g_ptr + offset, VP8PackARGB(a_ptr + offset, r_ptr + offset, g_ptr + offset,
b_ptr + offset, width, step, dst); b_ptr + offset, width, dst);
} }
} else { } else {
assert(step >= 3);
for (y = 0; y < height; ++y) { for (y = 0; y < height; ++y) {
uint32_t* const dst = &picture->argb[y * picture->argb_stride]; uint32_t* const dst = &picture->argb[y * picture->argb_stride];
const int offset = y * rgb_stride; const int offset = y * rgb_stride;