simplify the main loop for downscaling

(part of bug #254 investigation)

no speed change observed.

Change-Id: Ie21b33171def367f37643fef6a0bd378e49468c7
This commit is contained in:
Pascal Massimino 2015-08-03 16:49:00 +02:00
parent 585d93dbba
commit c455676680
4 changed files with 9 additions and 8 deletions

View File

@ -28,16 +28,17 @@ static void RescalerImportRowC(WebPRescaler* const wrk,
if (!wrk->x_expand) {
int sum = 0;
for (x_out = channel; x_out < x_out_max; x_out += x_stride) {
uint32_t base = 0;
accum += wrk->x_add;
for (; accum > 0; accum -= wrk->x_sub) {
sum += src[x_in];
while (accum > 0) {
accum -= wrk->x_sub;
base = src[x_in];
sum += base;
x_in += x_stride;
}
{ // Emit next horizontal pixel.
const int32_t base = src[x_in];
const int32_t frac = base * (-accum);
x_in += x_stride;
wrk->frow[x_out] = (sum + base) * wrk->x_sub - frac;
wrk->frow[x_out] = sum * wrk->x_sub - frac;
// fresh fractional start for next pixel
sum = (int)MULT_FIX(frac, wrk->fx_scale);
}

View File

@ -22,7 +22,7 @@ static void ImportRow(WebPRescaler* const wrk,
const int x_stride = wrk->num_channels;
const int x_out_max = wrk->dst_width * wrk->num_channels;
const int fx_scale = wrk->fx_scale;
const int x_add = wrk->x_add;
const int x_add = wrk->x_add - wrk->x_sub;
const int x_sub = wrk->x_sub;
int* frow = wrk->frow + channel;
int* irow = wrk->irow + channel;

View File

@ -22,7 +22,7 @@ static void ImportRow(WebPRescaler* const wrk,
const int x_stride = wrk->num_channels;
const int x_out_max = wrk->dst_width * wrk->num_channels;
const int fx_scale = wrk->fx_scale;
const int x_add = wrk->x_add;
const int x_add = wrk->x_add - wrk->x_sub;
const int x_sub = wrk->x_sub;
int* frow = wrk->frow + channel;
int* irow = wrk->irow + channel;

View File

@ -31,7 +31,7 @@ void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height,
wrk->dst_stride = dst_stride;
wrk->num_channels = num_channels;
// for 'x_expand', we use bilinear interpolation
wrk->x_add = wrk->x_expand ? (x_sub - 1) : x_add - x_sub;
wrk->x_add = wrk->x_expand ? (x_sub - 1) : x_add;
wrk->x_sub = wrk->x_expand ? (x_add - 1) : x_sub;
wrk->y_accum = y_add;
wrk->y_add = y_add;