mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 22:28:22 +01:00
smartYUV: simplify main loop
we don't need to centralize best_uv[] since target_uv[] and best_rgb_uv[] are already centralized. The diff 'W' was just in the ~[-2,2] range, so we can ignore the correction. Overall speed-impact is not large, though. Around ~4% faster conversion. Output with -pre 4 is expected to be slightly different Change-Id: Ib59f033955577c49b084d0560108020f42d84102 also: remove the useless clipping in StoreGray()
This commit is contained in:
parent
490ae5b13d
commit
0779529616
@ -281,7 +281,7 @@ static void UpdateChroma(const fixed_y_t* src1, const fixed_y_t* src2,
|
||||
static void StoreGray(const fixed_y_t* rgb, fixed_y_t* y, int len) {
|
||||
int i;
|
||||
for (i = 0; i < len; ++i) {
|
||||
y[i] = clip_y(RGBToGray(rgb[0], rgb[1], rgb[2]));
|
||||
y[i] = RGBToGray(rgb[0], rgb[1], rgb[2]);
|
||||
rgb += 3;
|
||||
}
|
||||
}
|
||||
@ -470,21 +470,22 @@ static int PreprocessARGB(const uint8_t* const r_ptr,
|
||||
} else {
|
||||
memcpy(src2, src1, 3 * w * sizeof(*src2));
|
||||
}
|
||||
StoreGray(src1, dst_y, 2 * w); // convert two lines at a time
|
||||
|
||||
UpdateW(src1, target_y + (j + 0) * w, w);
|
||||
UpdateW(src2, target_y + (j + 1) * w, w);
|
||||
UpdateChroma(src1, src2, target_uv + uv_off, uv_w);
|
||||
memcpy(best_uv + uv_off, target_uv + uv_off, 3 * uv_w * sizeof(*best_uv));
|
||||
// convert two lines at a time
|
||||
StoreGray(src1, dst_y, 2 * w);
|
||||
}
|
||||
|
||||
// Iterate and resolve clipping conflicts.
|
||||
for (iter = 0; iter < kNumIterations; ++iter) {
|
||||
int k;
|
||||
const fixed_t* cur_uv = best_uv;
|
||||
const fixed_t* prev_uv = best_uv;
|
||||
uint64_t diff_y_sum = 0;
|
||||
|
||||
for (j = 0; j < h; j += 2) {
|
||||
const int uv_off = (j >> 1) * 3 * uv_w;
|
||||
fixed_y_t* const src1 = tmp_buffer;
|
||||
fixed_y_t* const src2 = tmp_buffer + 3 * w;
|
||||
{
|
||||
@ -507,17 +508,9 @@ static int PreprocessARGB(const uint8_t* const r_ptr,
|
||||
best_y[off] = clip_y(new_y);
|
||||
diff_y_sum += (uint64_t)abs(diff_y);
|
||||
}
|
||||
for (i = 0; i < uv_w; ++i) {
|
||||
const int off = 3 * (i + (j >> 1) * uv_w);
|
||||
int W;
|
||||
for (k = 0; k <= 2; ++k) {
|
||||
const int diff_uv = (int)target_uv[off + k] - best_rgb_uv[3 * i + k];
|
||||
best_uv[off + k] += diff_uv;
|
||||
}
|
||||
W = RGBToGray(best_uv[off + 0], best_uv[off + 1], best_uv[off + 2]);
|
||||
for (k = 0; k <= 2; ++k) {
|
||||
best_uv[off + k] -= W;
|
||||
}
|
||||
for (i = 0; i < 3 * uv_w; ++i) {
|
||||
const int diff_uv = (int)target_uv[uv_off + i] - best_rgb_uv[i];
|
||||
best_uv[uv_off + i] += diff_uv;
|
||||
}
|
||||
}
|
||||
// test exit condition
|
||||
|
Loading…
Reference in New Issue
Block a user