Commit 14515531 authored by Lauros Pajunen's avatar Lauros Pajunen
Browse files

Fix gain ranges for reverse ISM gain

parent f0f35c7e
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -757,13 +757,13 @@ static ivas_error packReverseISMGain( const IVAS_PIDATA_GENERIC *piData, uint8_t

    buffer[nBytes++] = ( r_ism_gain->piDataType & MASK_5BIT ); /* PF/PM populated during final packing */
    gain = (int16_t) r_ism_gain->dB;
    idx = min( -gain, 97 );
    idx = min( -gain, 25 );
    if ( gain > 0 )
    {
        idx += 97;
        idx += 25;
    }

    buffer[nBytes++] = ( idx & MASK_7BIT ) << 1;
    buffer[nBytes++] = ( idx & MASK_6BIT ) << 2;
    *nBytesWritten = nBytes;
    return IVAS_ERR_OK;
}
@@ -785,19 +785,19 @@ static ivas_error unpackReverseISMGain( const uint8_t *buffer, uint32_t numDataB
    /* Unpack gain */
    idx = ( *buffer ) >> 1;
    /* negative gains*/
    if ( idx < 97 )
    if ( idx < 25 )
    {
        r_ism_gain->dB = -(int8_t) ( idx );
    }
    /* Set to min for muting, to be interpreted as -Inf */
    else if ( idx == 97 )
    else if ( idx == 25 )
    {
        r_ism_gain->dB = -128;
    }
    /* postive gains */
    else if ( idx < 101 )
    else if ( idx < 38 )
    {
        r_ism_gain->dB = (int8_t) idx - 97;
        r_ism_gain->dB = (int8_t) idx - 25;
    }
    else
    {