From 2ff79fe6b31f41685cf2cecfca5410db40440aaf Mon Sep 17 00:00:00 2001 From: Dominic Symes Date: Thu, 27 Jan 2022 15:44:26 +0000 Subject: TABLE: Clarify the interpolation slope range The interpolation slope must not exceed int16_t range. Signed-off-by: Dominic Symes Change-Id: Ic9037dcc11c293c78b9398952118a129e3be66f5 --- chapters/introduction.adoc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc index 51247bc..2827399 100644 --- a/chapters/introduction.adoc +++ b/chapters/introduction.adoc @@ -444,7 +444,9 @@ int32_t apply_lookup(int16_t *table, int32_t value) int32_t fraction = clipped_value & 0x7f; int16_t base = table[index]; int16_t next = table[index+1]; - int32_t return_value = (base << 7) + (next - base) * fraction; + int32_t slope = next - base; + REQUIRE(slope >= minimum && slope <= maximum) + int32_t return_value = (base << 7) + slope * fraction; return return_value; // return interpolated value of 16 + 7 = 23 bits } ---- -- cgit v1.2.1