From 39777f28f6b84faf7fd0c721d9215a3c6b14fe86 Mon Sep 17 00:00:00 2001 From: Shanush Prema Thasarathan Date: Thu, 24 Nov 2022 09:16:38 +1100 Subject: [PATCH 1/2] AGC exception bit is no longer used, so clean up all code that calculate/use the exception bit --- .gitignore | 4 +++ lib_com/ivas_rom_com.c | 4 +-- lib_com/ivas_stat_com.h | 2 ++ lib_com/options.h | 4 +++ lib_dec/ivas_agc_dec.c | 14 +++++++++++ lib_enc/ivas_agc_enc.c | 42 ++++++++++++++++++++++++++++--- tests/create_short_testvectors.py | 2 +- 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 591570d7d1..13dd28ed34 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,10 @@ tests/renderer/cut tests/renderer/ref tests/dut tests/ref +scripts/testv/*_cut*.pcm +# default reference binary name +IVAS_cod_ref +IVAS_dec_ref # Python files that pop up when running scripts __pycache__/ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index c843d5ddc4..c824c94a40 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -938,7 +938,7 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } }, { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 31, 1, 1, 1 } }, 1, 2, 0 }, - { 384000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, // not yet optimized + { 384000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, // not yet optimized { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, { 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational @@ -947,7 +947,7 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, // just added as a place holder, not necessarily operational { { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, - { 512000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, // not yet optimized + { 512000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, // not yet optimized { { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 }, { 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 8dd59f1d18..2ec890b57d 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -315,7 +315,9 @@ typedef struct ivas_huff_coeffs_t /* AGC structures */ typedef struct ivas_agc_chan_data_t { +#ifndef CLEANUP_185_NO_AGC_EXCEPTION int16_t gainException; +#endif int16_t absGainExp; int16_t absGainExpCurr; diff --git a/lib_com/options.h b/lib_com/options.h index edc0d9ae06..21fe824853 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,10 @@ #define BRATE_SWITCHING_FRAMEWORK /* Bitrate switching changes related to the general framework */ #define BRATE_SWITCHING_RENDERING /* Bitrate switching changes related to the renderers */ #define FIX_185_REDUCE_MD_BITS /* Issue 185: Crash in SBA encoder for 24.4 kbps HOA3 input with longer testvector */ +#ifdef FIX_185_REDUCE_MD_BITS +#define CLEANUP_185_NO_AGC_EXCEPTION /* Issue 185: Cleanup AGC EXCEPTION code */ +#endif + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_dec/ivas_agc_dec.c b/lib_dec/ivas_agc_dec.c index 99585a8829..d9aa86d7cf 100644 --- a/lib_dec/ivas_agc_dec.c +++ b/lib_dec/ivas_agc_dec.c @@ -78,7 +78,9 @@ static void ivas_agc_dec_init( /* gain_data */ ptr->absGainExp = hAgcDec->agc_com.absEmin; ptr->absGainExpCurr = hAgcDec->agc_com.absEmin; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION ptr->gainException = false; +#endif ptr++; } @@ -213,8 +215,10 @@ void ivas_agc_dec_process( pState->gain_state[i].lastGain = powf( pState->agc_com.winFunc[offset - 1], ( -1.f * (float) ( pState->gain_data[i].absGainExp - pState->agc_com.absEmin ) ) ); gainLast = 1.f / pState->gain_state[i].lastGain; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION if ( !pState->gain_data[i].gainException ) { +#endif if ( pState->gain_state[i].gainExpVal != 0 ) { for ( idx = 0; idx < output_frame; idx++ ) @@ -241,6 +245,7 @@ void ivas_agc_dec_process( pcm_out[i][idx] = pcm_in[i][idx] * gain; } } +#ifndef CLEANUP_185_NO_AGC_EXCEPTION } else { @@ -261,6 +266,7 @@ void ivas_agc_dec_process( } pState->gain_state[i].lastGain /= gainCurr; } +#endif pState->gain_data[i].absGainExp = pState->gain_data[i].absGainExpCurr; } @@ -309,7 +315,9 @@ void ivas_agc_read_bits( { pState->gain_data[i].absGainExpCurr = get_next_indice( st0, (int16_t) pState->agc_com.betaE ); #ifdef FIX_185_REDUCE_MD_BITS +#ifndef CLEANUP_185_NO_AGC_EXCEPTION pState->gain_data[i].gainException = false; +#endif #else pState->gain_data[i].gainException = get_next_indice( st0, 1 ); #endif @@ -317,7 +325,9 @@ void ivas_agc_read_bits( else { pState->gain_data[i].absGainExpCurr = (int32_t) pState->agc_com.absEmin; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION pState->gain_data[i].gainException = false; +#endif } } } @@ -326,7 +336,9 @@ void ivas_agc_read_bits( for ( i = 0; i < n_channels; i++ ) { pState->gain_data[i].absGainExpCurr = (int32_t) pState->agc_com.absEmin; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION pState->gain_data[i].gainException = false; +#endif } } @@ -337,8 +349,10 @@ void ivas_agc_read_bits( { fread( &( pState->gain_data[i].absGainExpCurr ), sizeof( int32_t ), 1, stream ); /* n bits */ num_bits += pState->agc_com.betaE; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION fread( &( pState->gain_data[i].gainException ), sizeof( int16_t ), 1, stream ); /* 1 bit */ num_bits++; +#endif num_dmx_bits[i]++; /*fprintf(stdout, "AbsGain[%d]:= %d[%d bits]; ", i, pState->gain_data[i].absGainExp, pState->betaE);*/ diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 0da76da143..3219807050 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -130,7 +130,9 @@ static void ivas_agc_enc_init( /* gain_data */ ptr->absGainExp = hAgcEnc->agc_com.absEmin; ptr->absGainExpCurr = hAgcEnc->agc_com.absEmin; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION ptr->gainException = FALSE; +#endif ptr++; } @@ -302,7 +304,9 @@ void ivas_agc_enc_process( isGainAdjusted = FALSE; if ( !isClipped ) { +#ifndef CLEANUP_185_NO_AGC_EXCEPTION pState->gain_data[i].gainException = FALSE; +#endif if ( pState->gain_state[i].lastExp == AGC_EMAX || MaxAbsVal < FLT_MIN ) { @@ -336,17 +340,26 @@ void ivas_agc_enc_process( if ( !isGainAdjusted ) { float actualMaxAbsVal = 0.f; - int16_t currMaxAttExp, gainExpValMaxRange; + int16_t currMaxAttExp +#ifndef CLEANUP_185_NO_AGC_EXCEPTION + , + gainExpValMaxRange +#endif + ; currMaxAttExp = min( ( pState->gain_state[i].lastExp + pState->agc_com.absEmin ), pState->agc_com.maxAttExp ); +#ifndef CLEANUP_185_NO_AGC_EXCEPTION gainExpValMaxRange = min( ( pState->gain_state[i].lastExp + pState->agc_com.absEmin ), pState->agc_com.maxAttExp + 1 ); +#endif extendedExpVal = FALSE; if ( isClipped ) { int16_t isCompensated = FALSE; actualMaxAbsVal = pState->gain_state[i].lastMaxAbs * pState->gain_state[i].lastGain; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION pState->gain_data[i].gainException = FALSE; +#endif pState->gain_state[i].gainExpVal = (int16_t) ceilf( -logf( actualMaxAbsVal * MDFT_NORM_SCALING ) / logf( pState->agc_com.winFunc[min( offset - 1, MaxAbsValIdx )] ) ); while ( !isCompensated ) @@ -384,6 +397,7 @@ void ivas_agc_enc_process( break; } +#ifndef CLEANUP_185_NO_AGC_EXCEPTION if ( pState->gain_state[i].gainExpVal > currMaxAttExp ) { pState->gain_data[i].gainException = TRUE; @@ -398,11 +412,14 @@ void ivas_agc_enc_process( } break; } +#endif } } +#ifndef CLEANUP_185_NO_AGC_EXCEPTION if ( !pState->gain_data[i].gainException ) { +#endif for ( idx = 0; idx < input_frame; idx++ ) { if ( idx < offset ) @@ -418,6 +435,7 @@ void ivas_agc_enc_process( } pState->gain_state[i].lastGain *= powf( pState->agc_com.winFunc[offset - 1], pState->gain_state[i].gainExpVal ); +#ifndef CLEANUP_185_NO_AGC_EXCEPTION } else { @@ -431,16 +449,18 @@ void ivas_agc_enc_process( } pState->gain_state[i].lastGain *= gain; } - +#endif /*safety check starts*/ if ( pState->gain_state[i].gainExpVal == pState->agc_com.maxAttExp + 1 ) { extendedExpVal = TRUE; } +#ifndef CLEANUP_185_NO_AGC_EXCEPTION else if ( pState->gain_state[i].gainExpVal == 0 ) { pState->gain_data[i].gainException = FALSE; } +#endif /*safety check ends*/ pState->gain_state[i].prevExp = pState->gain_state[i].lastExp; @@ -448,10 +468,14 @@ void ivas_agc_enc_process( pState->gain_state[i].lastExp -= pState->gain_state[i].gainExpVal; if ( extendedExpVal ) { + +#ifndef CLEANUP_185_NO_AGC_EXCEPTION if ( !pState->gain_data[i].gainException ) { pState->gain_data[i].gainException = TRUE; +#endif pState->gain_state[i].gainExpVal = -1; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION } else { @@ -460,18 +484,24 @@ void ivas_agc_enc_process( pState->gain_state[i].gainExpVal = 0; } } +#endif } } pState->gain_data[i].absGainExp = pState->gain_state[i].prevExp + pState->agc_com.absEmin; - if ( extendedExpVal && pState->gain_data[i].gainException && pState->gain_state[i].gainExpVal <= 0 ) + if ( extendedExpVal +#ifndef CLEANUP_185_NO_AGC_EXCEPTION + && pState->gain_data[i].gainException +#endif + && pState->gain_state[i].gainExpVal <= 0 ) { +#ifndef CLEANUP_185_NO_AGC_EXCEPTION if ( pState->gain_state[i].gainExpVal == -1 ) { pState->gain_data[i].gainException = FALSE; } - +#endif pState->gain_state[i].gainExpVal = pState->agc_com.maxAttExp + 1; } @@ -515,7 +545,9 @@ void ivas_agc_enc_process( #ifndef FIX_185_REDUCE_MD_BITS push_next_indice( hMetaData, (uint16_t) pState->gain_data[i].gainException, 1 ); #endif +#ifndef CLEANUP_185_NO_AGC_EXCEPTION assert( pState->gain_data[i].gainException == FALSE ); +#endif } } } @@ -552,8 +584,10 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_ fwrite( &( pState->gain_data[i].absGainExpCurr ), sizeof( int32_t ), 1, stream ); /* n bits */ num_bits += pState->agc_com.betaE; +#ifndef CLEANUP_185_NO_AGC_EXCEPTION fwrite( &( pState->gain_data[i].gainException ), sizeof( int16_t ), 1, stream ); /* 1 bit */ num_bits++; +#endif num_dmx_bits[i]++; /*fprintf(stdout, "absGainExpCurr[%d]:= %d[%d bits]; ", i, pState->gain_data[i].absGainExpCurr, pState->betaE); */ diff --git a/tests/create_short_testvectors.py b/tests/create_short_testvectors.py index 56c41d49b8..bb9207b75d 100755 --- a/tests/create_short_testvectors.py +++ b/tests/create_short_testvectors.py @@ -43,7 +43,7 @@ from cut_pcm import cut_samples HERE = Path(__file__).parent.resolve() TEST_VECTOR_DIR = str(HERE.joinpath("../scripts/testv").resolve()) -NUM_CHANNELS = "4" # currently only FOA +NUM_CHANNELS = "4" # currently only FOA CUT_FROM = "0.0" CUT_LEN = "5.0" -- GitLab From 438a483d112e8908ad32693005b263ef724b8174 Mon Sep 17 00:00:00 2001 From: knj Date: Thu, 24 Nov 2022 09:59:16 +0100 Subject: [PATCH 2/2] Revert "temporarily disable 24.4kkbps SBA in sanitizer tests" This reverts commit bc1f7d6fa1bf84d47c68ce76c24c690375c750c0. --- ci/run_scheduled_sanitizer_test.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ci/run_scheduled_sanitizer_test.py b/ci/run_scheduled_sanitizer_test.py index b07a42d6ac..bc794bf2d8 100755 --- a/ci/run_scheduled_sanitizer_test.py +++ b/ci/run_scheduled_sanitizer_test.py @@ -89,11 +89,6 @@ def get_modes(in_format: str) -> list: in_format = "MC_" + in_format + "_b" mode_list = [m for m in mode_list if in_format in m] - # TODO: remove once #185 is fixed - # temporarily skip 24.4kbps SBA bitrate - if in_format == "SBA": - mode_list = [m for m in mode_list if not "b24_4" in m] - return mode_list -- GitLab