Yu-Ping Wu has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/45235 )
Change subject: libpayload: cbgfx: Fix 'equals' counter for Lanczos resampling ......................................................................
libpayload: cbgfx: Fix 'equals' counter for Lanczos resampling
The 'equals' counter stores the number of latest pixels that were exactly equal. Since the sample array is updated in a column-based manner, we should also initialize the 'equals' counter in the same order.
BUG=b:167739127 TEST=emerge-puff libpayload TEST=Character 'k' is rendered correctly on puff BRANCH=zork
Change-Id: Ibc91ad1af85adcf093eff40797cd54f32f57111d Signed-off-by: Yu-Ping Wu yupingso@chromium.org --- M payloads/libpayload/drivers/video/graphics.c 1 file changed, 22 insertions(+), 20 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/45235/1
diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c index 2bf5e19..a8c9612 100644 --- a/payloads/libpayload/drivers/video/graphics.c +++ b/payloads/libpayload/drivers/video/graphics.c @@ -858,36 +858,38 @@ }
/* - * Initialize the sample array for this line. For pixels to the - * left of S0 there are no corresponding input pixels so just - * copy the S0 values over. - * - * Also initialize the equals counter, which counts how many of - * the latest pixels were exactly equal. We know the columns - * left of S0 must be equal to S0, so start with that number. + * Initialize the sample array for this line, and also + * the equals counter, which counts how many of the latest + * pixels were exactly equal. */ - int equals = S0 * SSZ; - uint8_t last_equal = ypix[0][0]; - for (sy = 0; sy < SSZ; sy++) { - for (sx = S0; sx < SSZ; sx++) { + int equals = 0; + uint8_t last_equal = -1; + struct rgb_color *last_sample = NULL; + for (sx = 0; sx < SSZ; sx++) { + for (sy = 0; sy < SSZ; sy++) { if (sx >= dim_org->width) { sample[sx][sy] = sample[sx - 1][sy]; equals++; continue; } - uint8_t i = ypix[sy][sx - S0]; + /* + * For pixels to the left of S0 there are no + * corresponding input pixels so just use + * ypix[sy][0]. + */ + uint8_t i = ypix[sy][MAX(0, sx - S0)]; + if (last_sample && i == last_equal) { + sample[sx][sy] = *last_sample; + equals++; + continue; + } if (pal_to_rgb(i, pal, header->colors_used, &sample[sx][sy])) goto bitmap_error; - if (i == last_equal) { - equals++; - } else { - last_equal = i; - equals = 1; - } + last_equal = i; + last_sample = &sample[sx][sy]; + equals = 1; } - for (sx = S0 - 1; sx >= 0; sx--) - sample[sx][sy] = sample[S0][sy]; }
ix = 0;