MIPS: dspr2: added optimization for function TransformColorRed

added new function CollectColorRedTransforms to C, which calls
TransformColorRed and it is realized via pointer to function

Change-Id: Ia68d73bfcf1ca2cb443dc2825910946221f87835
This commit is contained in:
Djordje Pesut
2015-01-14 10:25:40 +01:00
parent 2cb39180cc
commit a7e7caa486
3 changed files with 68 additions and 5 deletions

View File

@ -424,6 +424,51 @@ static void CollectColorBlueTransforms(
}
}
static WEBP_INLINE uint8_t TransformColorRed(uint8_t green_to_red,
uint32_t argb) {
const uint32_t green = argb >> 8;
uint32_t new_red = argb >> 16;
new_red -= ColorTransformDelta(green_to_red, green);
return (new_red & 0xff);
}
static void CollectColorRedTransforms(
int tile_x_offset, int tile_y_offset, int all_x_max, int all_y_max,
int xsize, int green_to_red, int* histo, const uint32_t* const argb) {
const int gtr = (green_to_red << 16) | (green_to_red & 0xffff);
int ix = tile_y_offset * xsize + tile_x_offset;
int all_y;
for (all_y = tile_y_offset; all_y < all_y_max; ++all_y) {
uint32_t* p_argb = (uint32_t*)&argb[ix];
const int loop_cnt = all_x_max - tile_x_offset;
int all_x;
ix += xsize;
for (all_x = 0; all_x < (loop_cnt >> 1); ++all_x) {
int temp0, temp1, temp2, temp3, temp4;
__asm__ volatile (
"lw %[temp0], 0(%[p_argb]) \n\t"
"lw %[temp1], 4(%[p_argb]) \n\t"
"precrq.ph.w %[temp4], %[temp0], %[temp1] \n\t"
"ins %[temp1], %[temp0], 16, 16 \n\t"
"shra.ph %[temp3], %[temp1], 8 \n\t"
"mul.ph %[temp2], %[temp3], %[gtr] \n\t"
"addiu %[p_argb], %[p_argb], 8 \n\t"
"shra.ph %[temp2], %[temp2], 5 \n\t"
"subu.qb %[temp2], %[temp4], %[temp2] \n\t"
: [p_argb]"+&r"(p_argb), [temp0]"=&r"(temp0), [temp1]"=&r"(temp1),
[temp2]"=&r"(temp2), [temp3]"=&r"(temp3), [temp4]"=&r"(temp4)
: [gtr]"r"(gtr)
: "memory", "hi", "lo"
);
++histo[(uint8_t)(temp2 >> 16)];
++histo[(uint8_t)temp2];
}
if (loop_cnt & 1) {
++histo[TransformColorRed(green_to_red, *p_argb)];
}
}
}
#endif // WEBP_USE_MIPS_DSP_R2
//------------------------------------------------------------------------------
@ -446,6 +491,7 @@ void VP8LDspInitMIPSdspR2(void) {
VP8LSubtractGreenFromBlueAndRed = SubtractGreenFromBlueAndRed;
VP8LTransformColor = TransformColor;
VP8LCollectColorBlueTransforms = CollectColorBlueTransforms;
VP8LCollectColorRedTransforms = CollectColorRedTransforms;
#endif // WEBP_USE_MIPS_DSP_R2
}