From 71ab794662ee2fc061b1baa9af5bb333b79c10d9 Mon Sep 17 00:00:00 2001 From: Dominic Symes Date: Tue, 13 Apr 2021 11:50:18 +0100 Subject: RESIZE: Clarify the valid range of stride values. Clarify stride ranges so that the range of valid scales is independent of the shift value. Signed-off-by: Dominic Symes Change-Id: I56b4dd3b39df19da35fb2c6fe3035e2de42f4860 --- chapters/image.adoc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/chapters/image.adoc b/chapters/image.adoc index e91b3da..07f5a0e 100644 --- a/chapters/image.adoc +++ b/chapters/image.adoc @@ -53,9 +53,16 @@ None [source,c++] ---- -// scale assert prevents int32_t accumulator overflow for in_t==int8_t +// shift assert prevents int32_t accumulator overflow for in_t==int8_t assert((resize_t == float_t && shift == 0)||(0 < shift && shift <= 11)); -assert(stride_x > 0 && stride_y > 0); +// stride asserts set consistent lower limit of 1/16 downscale +// independent of the shift value to simplify implementations +assert(0 < stride_x && stride_x < (16 << shift)); +assert(0 < stride_y && stride_y < (16 << shift)); +// offset range is similarly limited to maximum 16 pixels irrespective +// of shift. Both stride and offset fit in int16_t when shift=11. +assert((-16 << shift) < offset_x && offset_x < (16 << shift)); +assert((-16 << shift) < offset_y && offset_y < (16 << shift)); for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW; 0 <= c < C) { unit = (resize_t == float_t) ? 1.0 : (1 << shift); y = oy * stride_y + offset_y; -- cgit v1.2.1