Commit 54a58936 authored by Ripinder Singh's avatar Ripinder Singh
Browse files

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: default avatarRipinder Singh <ripinder.singh@dolby.com>
parent 3007be98
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 ################################## */

+12 −0
Original line number Diff line number Diff line
@@ -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 )
            {