From e52816bf8ff4e93f9b5aba2328aebfa5006a428d Mon Sep 17 00:00:00 2001 From: Debargha Mukherjee Date: Wed, 12 Oct 2016 10:49:29 -0700 Subject: [PATCH] Fix a bug in inverse halfright 32x32 transform Fix a bug in the C implementation of the ihalfright32 transform, in the case that its input and output buffers are the same. This occurs when it is called by av1_iht32x16_512_add_c. Change-Id: I61c652e2662178520c0639a2879ae128a9c7ec3f --- av1/common/idct.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/av1/common/idct.c b/av1/common/idct.c index 328f360b1..eedbc7980 100644 --- a/av1/common/idct.c +++ b/av1/common/idct.c @@ -33,6 +33,9 @@ int get_tx_scale(const MACROBLOCKD *const xd, const TX_TYPE tx_type, return txsize_sqr_up_map[tx_size] == TX_32X32; } +// NOTE: The implementation of all inverses need to be aware of the fact +// that input and output could be the same buffer. + #if CONFIG_EXT_TX static void iidtx4_c(const tran_low_t *input, tran_low_t *output) { int i; @@ -56,17 +59,17 @@ static void iidtx32_c(const tran_low_t *input, tran_low_t *output) { for (i = 0; i < 32; ++i) output[i] = input[i] * 4; } -// For use in lieu of DST +// For use in lieu of ADST static void ihalfright32_c(const tran_low_t *input, tran_low_t *output) { int i; tran_low_t inputhalf[16]; - for (i = 0; i < 16; ++i) { - output[i] = input[16 + i] * 4; - } // Multiply input by sqrt(2) for (i = 0; i < 16; ++i) { inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); } + for (i = 0; i < 16; ++i) { + output[i] = input[16 + i] * 4; + } idct16_c(inputhalf, output + 16); // Note overall scaling factor is 4 times orthogonal } @@ -106,14 +109,14 @@ static void highbd_ihalfright32_c(const tran_low_t *input, tran_low_t *output, int bd) { int i; tran_low_t inputhalf[16]; - for (i = 0; i < 16; ++i) { - output[i] = input[16 + i] * 4; - } // Multiply input by sqrt(2) for (i = 0; i < 16; ++i) { inputhalf[i] = HIGHBD_WRAPLOW(highbd_dct_const_round_shift(input[i] * Sqrt2), bd); } + for (i = 0; i < 16; ++i) { + output[i] = input[16 + i] * 4; + } aom_highbd_idct16_c(inputhalf, output + 16, bd); // Note overall scaling factor is 4 times orthogonal }