From 54a58936a95dd4eaad04be5765c800d98fcbf0af Mon Sep 17 00:00:00 2001 From: Ripinder Singh Date: Fri, 27 Mar 2026 11:35:54 +1100 Subject: [PATCH] 1527: Fix for incorrect bitrate idx reported in CMR requests * The size tables for CMR should be restricted to allowed selection range Signed-off-by: Ripinder Singh --- lib_com/options.h | 1 + lib_util/ivas_rtp_payload.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8d9ea4072..591c86138 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -89,6 +89,7 @@ #define FIX_2480_HARM_TONALMDCT /* FhG: basop issue 2480: Harmonize TonalMDCTConceal_Detect_fx() and TonalMDCTConceal_Detect_ivas_fx() */ #define FIX_2479_HARM_PITCH_GAIN /* FhG: basop issue 2479: Harmonize tcx_ltp_pitch_search_*(), tcx_ltp_find_gain_*fx() */ #define HARMONIZE_2481_EXTEND_SHRINK /* FhG: basop issue 2481: Harmonize extend_frm_*fx() and shrink_frm_*fx() */ +#define FIX_1527_CMR_BITRATE_IDX /* Fix for incorrect bitrate idx packed in rtp CMR E-byte */ /* #################### End BE switches ################################## */ diff --git a/lib_util/ivas_rtp_payload.c b/lib_util/ivas_rtp_payload.c index 137c44119..582482074 100644 --- a/lib_util/ivas_rtp_payload.c +++ b/lib_util/ivas_rtp_payload.c @@ -640,7 +640,11 @@ static uint32_t getBitrateIdx( const uint32_t *table, uint32_t tableLen, uint32_ for ( n = 0; n < tableLen; n++ ) { +#ifdef FIX_1527_CMR_BITRATE_IDX + if ( bitrate >= ( table[n] * IVAS_NUM_FRAMES_PER_SEC ) ) +#else if ( bitrate > ( table[n] * IVAS_NUM_FRAMES_PER_SEC ) ) +#endif { idx = n; } @@ -706,7 +710,11 @@ static void packEBytes( /* EVS Modes */ bitrate = ( bitrate > 128000 ) ? 128000 : bitrate; bitrate = ( bitrate < 5900 ) ? 5900 : bitrate; +#ifdef FIX_1527_CMR_BITRATE_IDX + bitrateIdx = getBitrateIdx( evsFrameSizeInBits, ( sizeof( evsFrameSizeInBits ) / sizeof( evsFrameSizeInBits[0] ) ) - 1, bitrate ); +#else bitrateIdx = getBitrateIdx( evsFrameSizeInBits, sizeof( evsFrameSizeInBits ) / sizeof( evsFrameSizeInBits[0] ), bitrate ); +#endif BR = (uint8_t) bitrateIdx & MASK_4BIT; /* If a bandwidth choice cannot be signalled for a given bitrate @@ -770,7 +778,11 @@ static void packEBytes( /* Initial E-Byte */ bitrate = ( bitrate > 512000 ) ? 512000 : bitrate; bitrate = ( bitrate < 13200 ) ? 13200 : bitrate; +#ifdef FIX_1527_CMR_BITRATE_IDX + bitrateIdx = getBitrateIdx( ivasFrameSizeInBits, ( sizeof( ivasFrameSizeInBits ) / sizeof( ivasFrameSizeInBits[0] ) ) - 2, bitrate ); +#else bitrateIdx = getBitrateIdx( ivasFrameSizeInBits, sizeof( ivasFrameSizeInBits ) / sizeof( ivasFrameSizeInBits[0] ), bitrate ); +#endif BR = (uint8_t) bitrateIdx & MASK_4BIT; if ( nByte < maxNumEBytes ) { -- GitLab