summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Su <huisu@google.com>2016-08-11 18:28:40 +0000
committerJames Zern <jzern@google.com>2016-12-09 20:22:25 -0800
commit408858308a05e094a553bb405a3cbd8c4e28724e (patch)
tree72f4d0c4bc367a822c7171f6e3ab3b738827e80b
parent8f38c72e11f26b75593bed1946f02b922b0521fb (diff)
downloadlibwebp-408858308a05e094a553bb405a3cbd8c4e28724e.tar.gz
Fix assertions in WebPRescalerExportRow()
Change-Id: I25711dd54e71c90a25f7b18e0ef9155e8151a15e (cherry picked from commit 27b5d991e2a3d87bd45610765af6f2a9a3530d69)
-rw-r--r--src/dsp/rescaler.c4
-rw-r--r--src/utils/rescaler.c8
2 files changed, 8 insertions, 4 deletions
diff --git a/src/dsp/rescaler.c b/src/dsp/rescaler.c
index bc743d5d..f5b07756 100644
--- a/src/dsp/rescaler.c
+++ b/src/dsp/rescaler.c
@@ -173,10 +173,10 @@ void WebPRescalerExportRow(WebPRescaler* const wrk) {
WebPRescalerExportRowExpand(wrk);
} else if (wrk->fxy_scale) {
WebPRescalerExportRowShrink(wrk);
- } else { // very special case for src = dst = 1x1
+ } else { // special case
int i;
+ assert(wrk->src_height == wrk->dst_height && wrk->x_add == 1);
assert(wrk->src_width == 1 && wrk->dst_width <= 2);
- assert(wrk->src_height == 1 && wrk->dst_height == 1);
for (i = 0; i < wrk->num_channels * wrk->dst_width; ++i) {
wrk->dst[i] = wrk->irow[i];
wrk->irow[i] = 0;
diff --git a/src/utils/rescaler.c b/src/utils/rescaler.c
index 00c9300b..d2278a52 100644
--- a/src/utils/rescaler.c
+++ b/src/utils/rescaler.c
@@ -48,11 +48,15 @@ void WebPRescalerInit(WebPRescaler* const wrk, int src_width, int src_height,
wrk->y_sub = wrk->y_expand ? y_sub - 1 : y_sub;
wrk->y_accum = wrk->y_expand ? wrk->y_sub : wrk->y_add;
if (!wrk->y_expand) {
- // this is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
+ // This is WEBP_RESCALER_FRAC(dst_height, x_add * y_add) without the cast.
+ // Its value is <= WEBP_RESCALER_ONE, because dst_height <= wrk->y_add, and
+ // wrk->x_add >= 1;
const uint64_t ratio =
(uint64_t)dst_height * WEBP_RESCALER_ONE / (wrk->x_add * wrk->y_add);
if (ratio != (uint32_t)ratio) {
- // We can't represent the ratio with the current fixed-point precision.
+ // When ratio == WEBP_RESCALER_ONE, we can't represent the ratio with the
+ // current fixed-point precision. This happens when src_height ==
+ // wrk->y_add (which == src_height), and wrk->x_add == 1.
// => We special-case fxy_scale = 0, in WebPRescalerExportRow().
wrk->fxy_scale = 0;
} else {