summaryrefslogtreecommitdiff
path: root/vpx_dsp
diff options
context:
space:
mode:
authorAngie Chiang <angiebird@google.com>2016-10-04 16:57:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-10-04 16:57:37 +0000
commit5d635365bb9166d0207c878f92c98835474c9e11 (patch)
treebbb4c4bf4a2745ab15d4ce9bd88012c9fa73e24d /vpx_dsp
parent0a92dd73198fef0e208466a96acefbfecb9bac0b (diff)
parent5b073c695ba70c87daa1ff843e57ff59f5e3034d (diff)
downloadlibvpx-5d635365bb9166d0207c878f92c98835474c9e11.tar
libvpx-5d635365bb9166d0207c878f92c98835474c9e11.tar.gz
libvpx-5d635365bb9166d0207c878f92c98835474c9e11.tar.bz2
libvpx-5d635365bb9166d0207c878f92c98835474c9e11.zip
Merge "Move highbd txfm input range check from 2d iht transform to 1d idct/iadst"
Diffstat (limited to 'vpx_dsp')
-rw-r--r--vpx_dsp/inv_txfm.c75
1 files changed, 72 insertions, 3 deletions
diff --git a/vpx_dsp/inv_txfm.c b/vpx_dsp/inv_txfm.c
index 1526663d8..46ddd1da0 100644
--- a/vpx_dsp/inv_txfm.c
+++ b/vpx_dsp/inv_txfm.c
@@ -9,6 +9,7 @@
*/
#include <math.h>
+#include <stdlib.h>
#include <string.h>
#include "./vpx_dsp_rtcd.h"
@@ -1252,6 +1253,19 @@ void vpx_idct32x32_1_add_c(const tran_low_t *input, uint8_t *dest, int stride) {
}
#if CONFIG_VP9_HIGHBITDEPTH
+
+// 12 signal input bits + 7 2D forward transform amplify bits + 5 1D inverse
+// transform amplify bits + 1 bit for contingency in rounding and quantizing
+#define HIGHBD_VALID_TXFM_MAGNITUDE_RANGE (1 << 25)
+
+static INLINE int detect_invalid_highbd_input(const tran_low_t *input,
+ int size) {
+ int i;
+ for (i = 0; i < size; ++i)
+ if (abs(input[i]) >= HIGHBD_VALID_TXFM_MAGNITUDE_RANGE) return 1;
+ return 0;
+}
+
void vpx_highbd_iwht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
int stride, int bd) {
/* 4-point reversible, orthonormal inverse Walsh-Hadamard in 3.5 adds,
@@ -1347,6 +1361,15 @@ void vpx_highbd_idct4_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_low_t step[4];
tran_high_t temp1, temp2;
(void)bd;
+
+ if (detect_invalid_highbd_input(input, 4)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 4);
+ return;
+ }
+
// stage 1
temp1 = (input[0] + input[2]) * cospi_16_64;
temp2 = (input[0] - input[2]) * cospi_16_64;
@@ -1413,6 +1436,15 @@ void vpx_highbd_idct4x4_1_add_c(const tran_low_t *input, uint8_t *dest8,
void vpx_highbd_idct8_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_low_t step1[8], step2[8];
tran_high_t temp1, temp2;
+
+ if (detect_invalid_highbd_input(input, 8)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 8);
+ return;
+ }
+
// stage 1
step1[0] = input[0];
step1[2] = input[4];
@@ -1498,13 +1530,20 @@ void vpx_highbd_idct8x8_1_add_c(const tran_low_t *input, uint8_t *dest8,
void vpx_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_high_t s0, s1, s2, s3, s4, s5, s6, s7;
-
tran_low_t x0 = input[0];
tran_low_t x1 = input[1];
tran_low_t x2 = input[2];
tran_low_t x3 = input[3];
(void)bd;
+ if (detect_invalid_highbd_input(input, 4)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 4);
+ return;
+ }
+
if (!(x0 | x1 | x2 | x3)) {
memset(output, 0, 4 * sizeof(*output));
return;
@@ -1536,7 +1575,6 @@ void vpx_highbd_iadst4_c(const tran_low_t *input, tran_low_t *output, int bd) {
void vpx_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_high_t s0, s1, s2, s3, s4, s5, s6, s7;
-
tran_low_t x0 = input[7];
tran_low_t x1 = input[0];
tran_low_t x2 = input[5];
@@ -1547,6 +1585,14 @@ void vpx_highbd_iadst8_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_low_t x7 = input[6];
(void)bd;
+ if (detect_invalid_highbd_input(input, 8)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 8);
+ return;
+ }
+
if (!(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7)) {
memset(output, 0, 8 * sizeof(*output));
return;
@@ -1642,6 +1688,14 @@ void vpx_highbd_idct16_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_high_t temp1, temp2;
(void)bd;
+ if (detect_invalid_highbd_input(input, 16)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 16);
+ return;
+ }
+
// stage 1
step1[0] = input[0 / 2];
step1[1] = input[16 / 2];
@@ -1832,7 +1886,6 @@ void vpx_highbd_idct16x16_256_add_c(const tran_low_t *input, uint8_t *dest8,
void vpx_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_high_t s0, s1, s2, s3, s4, s5, s6, s7, s8;
tran_high_t s9, s10, s11, s12, s13, s14, s15;
-
tran_low_t x0 = input[15];
tran_low_t x1 = input[0];
tran_low_t x2 = input[13];
@@ -1851,6 +1904,14 @@ void vpx_highbd_iadst16_c(const tran_low_t *input, tran_low_t *output, int bd) {
tran_low_t x15 = input[14];
(void)bd;
+ if (detect_invalid_highbd_input(input, 16)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 16);
+ return;
+ }
+
if (!(x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 |
x13 | x14 | x15)) {
memset(output, 0, 16 * sizeof(*output));
@@ -2048,6 +2109,14 @@ static void highbd_idct32_c(const tran_low_t *input, tran_low_t *output,
tran_high_t temp1, temp2;
(void)bd;
+ if (detect_invalid_highbd_input(input, 32)) {
+#if CONFIG_COEFFICIENT_RANGE_CHECKING
+ assert(0 && "invalid highbd txfm input");
+#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
+ memset(output, 0, sizeof(*output) * 32);
+ return;
+ }
+
// stage 1
step1[0] = input[0];
step1[1] = input[16];