From 0b10348cb03fd53ea760dc1e148f2d6c6352f8ef Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 4 Oct 2023 10:26:29 +0200 Subject: [PATCH 1/3] [strip] LC3PLUS_DEC_COLLECT_STATS --- lib_rend/ivas_lc3plus_dec.c | 49 ------------------------------------- lib_rend/ivas_lc3plus_dec.h | 12 --------- 2 files changed, 61 deletions(-) diff --git a/lib_rend/ivas_lc3plus_dec.c b/lib_rend/ivas_lc3plus_dec.c index 78372c4fbb..6ef8e2bf3a 100644 --- a/lib_rend/ivas_lc3plus_dec.c +++ b/lib_rend/ivas_lc3plus_dec.c @@ -75,13 +75,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( #endif numLC3plusFramesPerIvasFrame = (int16_t) ( config.ivas_frame_duration_us / config.lc3plus_frame_duration_us ); -#ifdef LC3PLUS_DEC_COLLECT_STATS - ( *handle )->stats.action_histogram[DEC_ACTION_DECODE_AND_DROP] = 0; - ( *handle )->stats.action_histogram[DEC_ACTION_DECODE_AND_USE] = 0; - ( *handle )->stats.action_histogram[DEC_ACTION_SKIP] = 0; - ( *handle )->stats.action_histogram[DEC_ACTION_CACHE] = 0; - ( *handle )->stats.num_cached_frames_decoded_and_dropped = 0; -#endif ( *handle )->num_decs = 0; ( *handle )->pcm_conversion_buffer = NULL; @@ -456,9 +449,6 @@ void IVAS_LC3PLUS_DEC_Close( { return; } -#ifdef LC3PLUS_DEC_COLLECT_STATS - printLC3plusDecStats( &( *handle )->stats ); -#endif for ( uint32_t iDec = 0; iDec < ( *handle )->num_decs; iDec++ ) { if ( NULL != ( *handle )->handles && NULL != ( *handle )->handles[iDec] ) @@ -604,9 +594,6 @@ static ivas_error IVAS_LC3PLUS_DEC_Decode_or_Conceal_internal( } handle->selective_decoding_states[iDec]->shall_decode_cached_frame = 0; handle->selective_decoding_states[iDec]->has_skipped_a_frame = 0; -#ifdef LC3PLUS_DEC_COLLECT_STATS - handle->stats.num_cached_frames_decoded_and_dropped++; -#endif } /* reset cache if caching is enabled - it has either been decoded or is not needed */ @@ -614,9 +601,6 @@ static ivas_error IVAS_LC3PLUS_DEC_Decode_or_Conceal_internal( { handle->bitstream_caches[iDec]->bitstream_cache_size = 0; } -#ifdef LC3PLUS_DEC_COLLECT_STATS - handle->stats.action_histogram[handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame]]++; -#endif switch ( handle->selective_decoding_states[iDec]->frame_actions[iLc3plusFrame] ) { case DEC_ACTION_DECODE_AND_DROP: @@ -747,36 +731,3 @@ ivas_error IVAS_LC3PLUS_DEC_Conceal( } -#ifdef LC3PLUS_DEC_COLLECT_STATS -void printLC3plusDecStats( const IVAS_LC3PLUS_DEC_COLLECT_STATS *stats ) -{ - int32_t sum_pushed_frames = 0; - int32_t sum_decoded_and_dropped_frames, sum_skipped_frames; - - sum_pushed_frames = stats->action_histogram[DEC_ACTION_DECODE_AND_USE] + stats->action_histogram[DEC_ACTION_SKIP] + stats->action_histogram[DEC_ACTION_CACHE]; - - sum_decoded_and_dropped_frames = - stats->action_histogram[DEC_ACTION_DECODE_AND_DROP] + stats->num_cached_frames_decoded_and_dropped; - - sum_skipped_frames = stats->action_histogram[DEC_ACTION_SKIP] + stats->action_histogram[DEC_ACTION_CACHE]; - - if ( sum_pushed_frames == 0 ) - { - printf( "\n Dec didn't run" ); - return; - } - - printf( "\nsum_pushed_frames: %i\n", sum_pushed_frames ); - printf( " DECODE_AND_USE count: %i \n", stats->action_histogram[DEC_ACTION_DECODE_AND_USE] ); - printf( " SKIP count: %i\n", stats->action_histogram[DEC_ACTION_SKIP] ); - printf( " CACHE count: %i\n", stats->action_histogram[DEC_ACTION_CACHE] ); - printf( "Decoded-and-Dropped:\n" ); - printf( " DECODE_AND_DROP count: %i \n", stats->action_histogram[DEC_ACTION_DECODE_AND_DROP] ); - printf( " DEC_CACHE count: %i\n", stats->num_cached_frames_decoded_and_dropped ); - printf( " perc of req : %f\n", 100.f * (float) sum_decoded_and_dropped_frames / sum_pushed_frames ); - printf( "Workload saved: \n" ); - printf( " Skipped perc. of req %f\n", 100.f * (float) sum_skipped_frames / sum_pushed_frames ); - - return; -} -#endif diff --git a/lib_rend/ivas_lc3plus_dec.h b/lib_rend/ivas_lc3plus_dec.h index 0bd14280e6..e767592e1b 100644 --- a/lib_rend/ivas_lc3plus_dec.h +++ b/lib_rend/ivas_lc3plus_dec.h @@ -56,15 +56,6 @@ typedef enum DEC_ACTION_NUM_ENUMS } SelectiveDecAction; -#ifdef LC3PLUS_DEC_COLLECT_STATS -typedef struct IVAS_LC3PLUS_DEC_COLLECT_STATS -{ - int32_t action_histogram[DEC_ACTION_NUM_ENUMS]; - int32_t num_cached_frames_decoded_and_dropped; -} IVAS_LC3PLUS_DEC_COLLECT_STATS; - -void printLC3plusDecStats( const IVAS_LC3PLUS_DEC_COLLECT_STATS *stats ); -#endif typedef struct IVAS_LC3PLUS_DEC_SELECTIVE_DECODING_STATE { @@ -95,9 +86,6 @@ typedef struct IVAS_LC3PLUS_DEC_HANDLE #ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING int16_t cachingEnabled; #endif -#ifdef LC3PLUS_DEC_COLLECT_STATS - IVAS_LC3PLUS_DEC_COLLECT_STATS stats; -#endif } * IVAS_LC3PLUS_DEC_HANDLE; ivas_error IVAS_LC3PLUS_DEC_Open( -- GitLab From bcf96f3586c2bcabf17c1cf82db1855ff35474fa Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 4 Oct 2023 10:27:36 +0200 Subject: [PATCH 2/3] [strip] LC3PLUS_DEC_ALLOW_DISABLE_CACHING --- lib_rend/ivas_lc3plus_dec.c | 30 ------------------------------ lib_rend/ivas_lc3plus_dec.h | 6 ------ lib_rend/lib_rend.c | 3 --- 3 files changed, 39 deletions(-) diff --git a/lib_rend/ivas_lc3plus_dec.c b/lib_rend/ivas_lc3plus_dec.c index 6ef8e2bf3a..0f1983380e 100644 --- a/lib_rend/ivas_lc3plus_dec.c +++ b/lib_rend/ivas_lc3plus_dec.c @@ -49,9 +49,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - const int16_t enableCaching, /* i : if set to 0, the decoder will NOT use cached frame to flush algorithmic delay after skipped frames */ -#endif IVAS_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ) { @@ -70,9 +67,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid lc3plus_frame_duration_us (0)\n" ); } -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - ( *handle )->cachingEnabled = enableCaching; -#endif numLC3plusFramesPerIvasFrame = (int16_t) ( config.ivas_frame_duration_us / config.lc3plus_frame_duration_us ); @@ -100,10 +94,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( ( *handle )->selective_decoding_states[i] = NULL; } -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - if ( enableCaching ) - { -#endif if ( ( ( *handle )->bitstream_caches = malloc( config.channels * sizeof( IVAS_LC3PLUS_DEC_BITSTREAM_CACHE * ) ) ) == NULL ) { IVAS_LC3PLUS_DEC_Close( handle ); @@ -113,9 +103,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( { ( *handle )->bitstream_caches[i] = NULL; } -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - } -#endif ( *handle )->num_decs = config.channels; for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) @@ -173,10 +160,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( ( *handle )->selective_decoding_states[iCh]->frame_actions[lc3plusFrameIdx] = DEC_ACTION_DECODE_AND_USE; } -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - if ( enableCaching ) - { -#endif /* allocate and configure per LC3plus decoder bitstream cache */ if ( ( ( *handle )->bitstream_caches[iCh] = malloc( sizeof( IVAS_LC3PLUS_DEC_BITSTREAM_CACHE ) ) ) == NULL ) { @@ -190,9 +173,6 @@ ivas_error IVAS_LC3PLUS_DEC_Open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); } ( *handle )->bitstream_caches[iCh]->bitstream_cache_size = 0; -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - } -#endif } ( *handle )->config = config; @@ -323,9 +303,6 @@ ivas_error IVAS_LC3PLUS_DEC_SetSelectiveDecodingMatrix( /* subframe not needed by the user, but might be required to re-initialize a decoder after inactivity */ if ( -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - handle->cachingEnabled && -#endif ( ivasSubframeIdx != actual_num_spatial_subframes - 1 ) && 1 == subframeChannelMatrix[ivasSubframeIdx + 1][decIdx] ) { /* ... but if the following subframe is required, it needs to be decoded and dropped */ @@ -339,10 +316,6 @@ ivas_error IVAS_LC3PLUS_DEC_SetSelectiveDecodingMatrix( } } -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - if ( handle->cachingEnabled ) - { -#endif /* if a decoder was paused before, it needs to either: * - Decode the cached frame (if available) and the first required frame OR * - Decode the previous LC3plus subframe, even if it isn't needed by the user */ @@ -383,9 +356,6 @@ ivas_error IVAS_LC3PLUS_DEC_SetSelectiveDecodingMatrix( } } } -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - } -#endif return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_lc3plus_dec.h b/lib_rend/ivas_lc3plus_dec.h index e767592e1b..1474d7f37b 100644 --- a/lib_rend/ivas_lc3plus_dec.h +++ b/lib_rend/ivas_lc3plus_dec.h @@ -83,16 +83,10 @@ typedef struct IVAS_LC3PLUS_DEC_HANDLE uint32_t num_decs; int16_t *pcm_conversion_buffer; LC3PLUS_CONFIG config; -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - int16_t cachingEnabled; -#endif } * IVAS_LC3PLUS_DEC_HANDLE; ivas_error IVAS_LC3PLUS_DEC_Open( const LC3PLUS_CONFIG config, /* i : decoder configuration */ -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - const int16_t enableCaching, /* i : if set to 0, the decoder will NOT use cached frame to flush algorithmic delay after skipped frames */ -#endif IVAS_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ); diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 3df316dd64..3ef67b02ea 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -7435,9 +7435,6 @@ static ivas_error renderSplitBinauralWithPostRot( config.samplerate = *splitBinInput->base.ctx.pOutSampleRate; if ( ( error = IVAS_LC3PLUS_DEC_Open( config, -#ifdef LC3PLUS_DEC_ALLOW_DISABLE_CACHING - 0 /* caching disabled */, -#endif &splitBinInput->splitPostRendWrapper.hLc3plusDec ) ) != IVAS_ERR_OK ) { return error; -- GitLab From 4ec82b092a592b0b6a96e342076b8b8c5736c083 Mon Sep 17 00:00:00 2001 From: Archit Tamarapu Date: Wed, 4 Oct 2023 11:12:12 +0200 Subject: [PATCH 3/3] remove commented defines and clang-format --- lib_rend/ivas_lc3plus_dec.c | 102 ++++++++++++++++++------------------ lib_rend/ivas_lc3plus_dec.h | 9 +--- 2 files changed, 51 insertions(+), 60 deletions(-) diff --git a/lib_rend/ivas_lc3plus_dec.c b/lib_rend/ivas_lc3plus_dec.c index 0f1983380e..d2258e7e13 100644 --- a/lib_rend/ivas_lc3plus_dec.c +++ b/lib_rend/ivas_lc3plus_dec.c @@ -48,7 +48,7 @@ *------------------------------------------------------------------------*/ ivas_error IVAS_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ + const LC3PLUS_CONFIG config, /* i : LC3plus decoder configuration */ IVAS_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ) { @@ -94,15 +94,15 @@ ivas_error IVAS_LC3PLUS_DEC_Open( ( *handle )->selective_decoding_states[i] = NULL; } - if ( ( ( *handle )->bitstream_caches = malloc( config.channels * sizeof( IVAS_LC3PLUS_DEC_BITSTREAM_CACHE * ) ) ) == NULL ) - { - IVAS_LC3PLUS_DEC_Close( handle ); - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); - } - for ( i = 0; i < config.channels; ++i ) - { - ( *handle )->bitstream_caches[i] = NULL; - } + if ( ( ( *handle )->bitstream_caches = malloc( config.channels * sizeof( IVAS_LC3PLUS_DEC_BITSTREAM_CACHE * ) ) ) == NULL ) + { + IVAS_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus wrapper handle\n" ); + } + for ( i = 0; i < config.channels; ++i ) + { + ( *handle )->bitstream_caches[i] = NULL; + } ( *handle )->num_decs = config.channels; for ( int32_t iCh = 0; iCh < config.channels; iCh++ ) @@ -160,19 +160,19 @@ ivas_error IVAS_LC3PLUS_DEC_Open( ( *handle )->selective_decoding_states[iCh]->frame_actions[lc3plusFrameIdx] = DEC_ACTION_DECODE_AND_USE; } - /* allocate and configure per LC3plus decoder bitstream cache */ - if ( ( ( *handle )->bitstream_caches[iCh] = malloc( sizeof( IVAS_LC3PLUS_DEC_BITSTREAM_CACHE ) ) ) == NULL ) - { - IVAS_LC3PLUS_DEC_Close( handle ); - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); - } - ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; - if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) - { - IVAS_LC3PLUS_DEC_Close( handle ); - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); - } - ( *handle )->bitstream_caches[iCh]->bitstream_cache_size = 0; + /* allocate and configure per LC3plus decoder bitstream cache */ + if ( ( ( *handle )->bitstream_caches[iCh] = malloc( sizeof( IVAS_LC3PLUS_DEC_BITSTREAM_CACHE ) ) ) == NULL ) + { + IVAS_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity = 400 /*LC3plus max non-HR octet count*/ * numLC3plusFramesPerIvasFrame; + if ( ( ( *handle )->bitstream_caches[iCh]->bitstream_cache = malloc( ( *handle )->bitstream_caches[iCh]->bitstream_cache_capacity ) ) == NULL ) + { + IVAS_LC3PLUS_DEC_Close( handle ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LC3plus decoder\n" ); + } + ( *handle )->bitstream_caches[iCh]->bitstream_cache_size = 0; } ( *handle )->config = config; @@ -316,46 +316,46 @@ ivas_error IVAS_LC3PLUS_DEC_SetSelectiveDecodingMatrix( } } - /* if a decoder was paused before, it needs to either: - * - Decode the cached frame (if available) and the first required frame OR - * - Decode the previous LC3plus subframe, even if it isn't needed by the user */ - for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + /* if a decoder was paused before, it needs to either: + * - Decode the cached frame (if available) and the first required frame OR + * - Decode the previous LC3plus subframe, even if it isn't needed by the user */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + if ( handle->selective_decoding_states[decIdx]->has_skipped_a_frame ) { - if ( handle->selective_decoding_states[decIdx]->has_skipped_a_frame ) + /* find the first frame required by the user */ + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) { - /* find the first frame required by the user */ - for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + if ( DEC_ACTION_DECODE_AND_USE == handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] ) { - if ( DEC_ACTION_DECODE_AND_USE == handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] ) + /* The first required frame is the first subframe. To flush the decoder, the cached frame must be decoded and dropped */ + if ( 0 == ivasSubframeIdx ) { - /* The first required frame is the first subframe. To flush the decoder, the cached frame must be decoded and dropped */ - if ( 0 == ivasSubframeIdx ) - { - handle->selective_decoding_states[decIdx]->shall_decode_cached_frame = 1; - break; - } - /* The first required frame is not the first frame, so the cache is useless. Instead we decode & drop the previous frame*/ - else - { - handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx - 1] = DEC_ACTION_DECODE_AND_DROP; - break; - } + handle->selective_decoding_states[decIdx]->shall_decode_cached_frame = 1; + break; + } + /* The first required frame is not the first frame, so the cache is useless. Instead we decode & drop the previous frame*/ + else + { + handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx - 1] = DEC_ACTION_DECODE_AND_DROP; + break; } } } } + } - /* if a dec gets paused & caching is activated we need to flag the last useful LC3plus frame for caching */ - for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + /* if a dec gets paused & caching is activated we need to flag the last useful LC3plus frame for caching */ + for ( decIdx = 0; decIdx < handle->num_decs; decIdx++ ) + { + for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) { - for ( ivasSubframeIdx = 0; ivasSubframeIdx < actual_num_spatial_subframes; ivasSubframeIdx++ ) + if ( handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] == DEC_ACTION_SKIP && handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] != DEC_ACTION_DECODE_AND_USE ) { - if ( handle->selective_decoding_states[decIdx]->frame_actions[ivasSubframeIdx] == DEC_ACTION_SKIP && handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] != DEC_ACTION_DECODE_AND_USE ) - { - handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] = DEC_ACTION_CACHE; - } + handle->selective_decoding_states[decIdx]->frame_actions[actual_num_spatial_subframes - 1] = DEC_ACTION_CACHE; } } + } return IVAS_ERR_OK; } @@ -699,5 +699,3 @@ ivas_error IVAS_LC3PLUS_DEC_Conceal( return IVAS_LC3PLUS_DEC_Decode_or_Conceal_internal( handle, bitstream_in, 0, badFrameIndicator, pcm_out ); } - - diff --git a/lib_rend/ivas_lc3plus_dec.h b/lib_rend/ivas_lc3plus_dec.h index 1474d7f37b..6e6f13f626 100644 --- a/lib_rend/ivas_lc3plus_dec.h +++ b/lib_rend/ivas_lc3plus_dec.h @@ -40,13 +40,6 @@ #include "ivas_lc3plus_common.h" #include "ivas_cnst.h" -#ifdef DEBUGGING -/* if defined, collects runtime stats and prints them in the DTOR */ -// #define LC3PLUS_DEC_COLLECT_STATS -/* if defined, caching can be disabled, otherwise it's always active */ -// #define LC3PLUS_DEC_ALLOW_DISABLE_CACHING -#endif - typedef enum { DEC_ACTION_DECODE_AND_DROP = 0, @@ -86,7 +79,7 @@ typedef struct IVAS_LC3PLUS_DEC_HANDLE } * IVAS_LC3PLUS_DEC_HANDLE; ivas_error IVAS_LC3PLUS_DEC_Open( - const LC3PLUS_CONFIG config, /* i : decoder configuration */ + const LC3PLUS_CONFIG config, /* i : decoder configuration */ IVAS_LC3PLUS_DEC_HANDLE *handle /* o : decoder handle */ ); -- GitLab