diff options
author | Fraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de> | 2020-04-17 15:15:06 +0200 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2021-04-30 15:00:27 +0000 |
commit | a43c9f8822c3066efc91de366bb1b3c3bf88387a (patch) | |
tree | 1c5471a0916b097ab56f860f565bb4856be9e819 | |
parent | 5a83a8e5e1cafceba6bef7ac61e68a57cc93d786 (diff) | |
download | fdk-aac-a43c9f8822c3066efc91de366bb1b3c3bf88387a.tar.gz fdk-aac-a43c9f8822c3066efc91de366bb1b3c3bf88387a.tar.bz2 fdk-aac-a43c9f8822c3066efc91de366bb1b3c3bf88387a.zip |
Prevent undefined values for CODING_SCHEME type in huff_decode().
Bug: 186706541
Test: atest android.media.cts.DecoderTestAacFormat android.media.cts.DecoderTestXheAac android.media.cts.DecoderTestAacDrc
Change-Id: I82da4a5660289d1c96888d48c315f96a4a5c1c2a
-rw-r--r-- | libFDK/include/nlc_dec.h | 5 | ||||
-rw-r--r-- | libFDK/src/nlc_dec.cpp | 28 |
2 files changed, 14 insertions, 19 deletions
diff --git a/libFDK/include/nlc_dec.h b/libFDK/include/nlc_dec.h index cca97f1..aded569 100644 --- a/libFDK/include/nlc_dec.h +++ b/libFDK/include/nlc_dec.h @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -159,9 +159,6 @@ typedef enum { #ifndef HUFFDEC_PARAMS #define HUFFDEC_PARMS -#define PAIR_SHIFT 4 -#define PAIR_MASK 0xf - #define MAX_ENTRIES 168 #define HANDLE_HUFF_NODE const SHORT(*)[MAX_ENTRIES][2] diff --git a/libFDK/src/nlc_dec.cpp b/libFDK/src/nlc_dec.cpp index 6e98ce0..3733d98 100644 --- a/libFDK/src/nlc_dec.cpp +++ b/libFDK/src/nlc_dec.cpp @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright 1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright 1995 - 2020 Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. All rights reserved. 1. INTRODUCTION @@ -568,12 +568,12 @@ bail: static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, SCHAR* out_data_2, DATA_TYPE data_type, DIFF_TYPE diff_type_1, DIFF_TYPE diff_type_2, - int num_val, CODING_SCHEME* cdg_scheme, int ldMode) { + int num_val, PAIRING* pairing_scheme, int ldMode) { ERROR_t err = HUFFDEC_OK; + CODING_SCHEME coding_scheme = HUFF_1D; DIFF_TYPE diff_type; int i = 0; - ULONG data = 0; SCHAR pair_vec[28][2]; @@ -596,15 +596,13 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, int hufYY; /* Coding scheme */ - data = FDKreadBits(strm, 1); - *cdg_scheme = (CODING_SCHEME)(data << PAIR_SHIFT); + coding_scheme = (CODING_SCHEME)FDKreadBits(strm, 1); - if (*cdg_scheme >> PAIR_SHIFT == HUFF_2D) { + if (coding_scheme == HUFF_2D) { if ((out_data_1 != NULL) && (out_data_2 != NULL) && (ldMode == 0)) { - data = FDKreadBits(strm, 1); - *cdg_scheme = (CODING_SCHEME)(*cdg_scheme | data); + *pairing_scheme = (PAIRING)FDKreadBits(strm, 1); } else { - *cdg_scheme = (CODING_SCHEME)(*cdg_scheme | FREQ_PAIR); + *pairing_scheme = FREQ_PAIR; } } @@ -613,7 +611,7 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, hufYY2 = diff_type_2; } - switch (*cdg_scheme >> PAIR_SHIFT) { + switch (coding_scheme) { case HUFF_1D: p0_flag[0] = (diff_type_1 == DIFF_FREQ); p0_flag[1] = (diff_type_2 == DIFF_FREQ); @@ -634,7 +632,7 @@ static ERROR_t huff_decode(HANDLE_FDK_BITSTREAM strm, SCHAR* out_data_1, case HUFF_2D: - switch (*cdg_scheme & PAIR_MASK) { + switch (*pairing_scheme) { case FREQ_PAIR: if (out_data_1 != NULL) { @@ -843,7 +841,7 @@ ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm, SCHAR* pDataVec[2] = {NULL, NULL}; DIFF_TYPE diff_type[2] = {DIFF_FREQ, DIFF_FREQ}; - CODING_SCHEME cdg_scheme = HUFF_1D; + PAIRING pairing = FREQ_PAIR; DIRECTION direction = BACKWARDS; switch (data_type) { @@ -959,7 +957,7 @@ ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm, } /* Huffman decoding */ err = huff_decode(strm, pDataVec[0], pDataVec[1], data_type, diff_type[0], - diff_type[1], dataBands, &cdg_scheme, + diff_type[1], dataBands, &pairing, (DECODER == SAOC_DECODER)); if (err != HUFFDEC_OK) { return HUFFDEC_NOTOK; @@ -986,8 +984,8 @@ ERROR_t EcDataPairDec(DECODER_TYPE DECODER, HANDLE_FDK_BITSTREAM strm, } } - mixed_time_pair = (diff_type[0] != diff_type[1]) && - ((cdg_scheme & PAIR_MASK) == TIME_PAIR); + mixed_time_pair = + (diff_type[0] != diff_type[1]) && (pairing == TIME_PAIR); if (direction == BACKWARDS) { if (diff_type[0] == DIFF_FREQ) { |