shithub: libvpx

Download patch

ref: 0a2b25dcb9e3a2ad6f4d8f1bbb9a192429f32831
parent: 0fa4777b1c82ef8b2d6d3f023180e870f7c69835
author: Yaowu Xu <[email protected]>
date: Tue Jul 29 09:40:55 EDT 2014

configure: add --enable-coefficient-range-checking

This commit adds a configure time option used to enable strict error
checking in decoder to make sure intermediate stage cofficients of
inverse transforms are within valid range of signed 16 bit integer.

For valid VP9 input streams, intermediate stage coefficients should
always stay within the range of a signed 16 bit integer. Coefficients
can go out of this range for invalid/corrupt VP9 streams. However,
strictly checking this range for every intermediate coefficient can
be a burden for decoder, therefore such validation is only enabled
with configure option --enable-coefficient-range-checking.

Change-Id: I47d47c8c4e48a922c3d223ca59064f51b3f0f5ed

--- a/configure
+++ b/configure
@@ -46,6 +46,9 @@
   ${toggle_realtime_only}         enable this option while building for real-time encoding
   ${toggle_onthefly_bitpacking}   enable on-the-fly bitpacking in real-time encoding
   ${toggle_error_concealment}     enable this option to get a decoder which is able to conceal losses
+  ${toggle_coefficient_range_checking}
+                                  enable decoder to check if intermediate
+                                  transform coefficients are in valid range
   ${toggle_runtime_cpu_detect}    runtime cpu detection
   ${toggle_shared}                shared library support
   ${toggle_static}                static library support
@@ -327,6 +330,7 @@
     encode_perf_tests
     multi_res_encoding
     temporal_denoising
+    coefficient_range_checking
     experimental
     size_limit
     ${EXPERIMENT_LIST}
@@ -384,6 +388,7 @@
     encode_perf_tests
     multi_res_encoding
     temporal_denoising
+    coefficient_range_checking
     experimental
 "
 
--- a/vp9/common/vp9_idct.h
+++ b/vp9/common/vp9_idct.h
@@ -81,6 +81,16 @@
 
 static INLINE int dct_const_round_shift(int input) {
   int rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+  // For valid VP9 input streams, intermediate stage coefficients should always
+  // stay within the range of a signed 16 bit integer. Coefficients can go out
+  // of this range for invalid/corrupt VP9 streams. However, strictly checking
+  // this range for every intermediate coefficient can burdensome for a decoder,
+  // therefore the following assertion is only enabled when configured with
+  // --enable-coefficient-range-checking.
+  assert(INT16_MIN <= rv);
+  assert(rv <= INT16_MAX);
+#endif
   return (int16_t)rv;
 }