summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
authorAngie Chiang <angiebird@google.com>2016-09-22 01:06:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-09-22 01:06:38 +0000
commit99ef84c65a2b5760bec5d9300974946303090afb (patch)
tree0aed1bcf6252e8537ed4418c94954cbf774e95ee /vp9/common
parentfcf281b6a148ea80d2fe84cc0b0b59b22e9a08f8 (diff)
parent80338b91d352d3a961d9cee44be29eae9f425804 (diff)
downloadlibvpx-99ef84c65a2b5760bec5d9300974946303090afb.tar
libvpx-99ef84c65a2b5760bec5d9300974946303090afb.tar.gz
libvpx-99ef84c65a2b5760bec5d9300974946303090afb.tar.bz2
libvpx-99ef84c65a2b5760bec5d9300974946303090afb.zip
Merge "Detect invalid highbd iht input"
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_idct.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/vp9/common/vp9_idct.c b/vp9/common/vp9_idct.c
index ff7c1dd3f..ec5cd33ce 100644
--- a/vp9/common/vp9_idct.c
+++ b/vp9/common/vp9_idct.c
@@ -204,6 +204,18 @@ void vp9_iht16x16_add(TX_TYPE tx_type, const tran_low_t *input, uint8_t *dest,
}
#if CONFIG_VP9_HIGHBITDEPTH
+
+// 12 signal input bits + 7 forward transform amplify bits + 1 bit
+// for contingency in rounding and quantizing
+#define VALID_IHT_MAGNITUDE_RANGE (1 << 20)
+
+static INLINE int detect_invalid_iht_input(const tran_low_t *input, int size) {
+ int i;
+ for (i = 0; i < size; ++i)
+ if (abs(input[i]) >= VALID_IHT_MAGNITUDE_RANGE) return 1;
+ return 0;
+}
+
void vp9_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
int stride, int tx_type, int bd) {
const highbd_transform_2d IHT_4[] = {
@@ -219,6 +231,13 @@ void vp9_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
tran_low_t *outptr = out;
tran_low_t temp_in[4], temp_out[4];
+ if (detect_invalid_iht_input(input, 16)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd iht input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ return;
+ }
+
// Inverse transform row vectors.
for (i = 0; i < 4; ++i) {
IHT_4[tx_type].rows(input, outptr, bd);
@@ -253,6 +272,13 @@ void vp9_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest8,
const highbd_transform_2d ht = HIGH_IHT_8[tx_type];
uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
+ if (detect_invalid_iht_input(input, 64)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd iht input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ return;
+ }
+
// Inverse transform row vectors.
for (i = 0; i < 8; ++i) {
ht.rows(input, outptr, bd);
@@ -287,6 +313,13 @@ void vp9_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest8,
const highbd_transform_2d ht = HIGH_IHT_16[tx_type];
uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
+ if (detect_invalid_iht_input(input, 256)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd iht input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ return;
+ }
+
// Rows
for (i = 0; i < 16; ++i) {
ht.rows(input, outptr, bd);