diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2018-12-26 18:19:10 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-12-26 18:19:10 -0800 |
commit | f87befcf3b88a973e375f4b20b5587e1a6d35530 (patch) | |
tree | 6135959bd6a4806f235fbab38167ce0dab2a935f | |
parent | 3f50499c9c8f95725c13e7eee25a3439822c7307 (diff) | |
parent | 0f7ae8601cef080fd87345c980834f9a4c87059b (diff) | |
download | fdk-aac-f87befcf3b88a973e375f4b20b5587e1a6d35530.tar.gz fdk-aac-f87befcf3b88a973e375f4b20b5587e1a6d35530.tar.bz2 fdk-aac-f87befcf3b88a973e375f4b20b5587e1a6d35530.zip |
Merge "Improve error robustness in arithmetic decoder" am: ecdec651da am: 485d02df73
am: 0f7ae8601c
Change-Id: I65666dfc9df6d4d7cda7b3c2781171e16170ff77
-rw-r--r-- | libArithCoding/src/ac_arith_coder.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libArithCoding/src/ac_arith_coder.cpp b/libArithCoding/src/ac_arith_coder.cpp index b791f39..a433b08 100644 --- a/libArithCoding/src/ac_arith_coder.cpp +++ b/libArithCoding/src/ac_arith_coder.cpp @@ -609,13 +609,16 @@ static inline ULONG get_pk_v2(ULONG s) { return (j & 0x3F); } -static void decode2(HANDLE_FDK_BITSTREAM bbuf, UCHAR *RESTRICT c_prev, - FIXP_DBL *RESTRICT pSpectralCoefficient, INT n, INT nt) { +static ARITH_CODING_ERROR decode2(HANDLE_FDK_BITSTREAM bbuf, + UCHAR *RESTRICT c_prev, + FIXP_DBL *RESTRICT pSpectralCoefficient, + INT n, INT nt) { Tastat as; int i, l, r; INT lev, esc_nb, pki; USHORT state_inc; UINT s; + ARITH_CODING_ERROR ErrorStatus = ARITH_CODER_OK; int c_3 = 0; /* context of current frame 3 time steps ago */ int c_2 = 0; /* context of current frame 2 time steps ago */ @@ -655,6 +658,8 @@ static void decode2(HANDLE_FDK_BITSTREAM bbuf, UCHAR *RESTRICT c_prev, lev++; + if (lev > 23) return ARITH_CODER_ERROR; + if (esc_nb < 7) { esc_nb++; } @@ -721,6 +726,8 @@ static void decode2(HANDLE_FDK_BITSTREAM bbuf, UCHAR *RESTRICT c_prev, } FDKmemset(&c_prev[i], 1, sizeof(c_prev[0]) * (nt - i)); + + return ErrorStatus; } CArcoData *CArco_Create(void) { return GetArcoData(); } @@ -763,7 +770,8 @@ ARITH_CODING_ERROR CArco_DecodeArithData(CArcoData *pArcoData, pArcoData->m_numberLinesPrev = lg_max; if (lg > 0) { - decode2(hBs, pArcoData->c_prev + 2, mdctSpectrum, lg >> 1, lg_max >> 1); + ErrorStatus = + decode2(hBs, pArcoData->c_prev + 2, mdctSpectrum, lg >> 1, lg_max >> 1); } else { FDKmemset(&pArcoData->c_prev[2], 1, sizeof(pArcoData->c_prev[2]) * (lg_max >> 1)); |