Commit 5b6926af authored by Anjaneyulu Sana's avatar Anjaneyulu Sana
Browse files

Fix for 3GPP issue 1477: Encoder crash (assert) in ISM1, HQ core fine gain quantization

parent 4f234b04
Loading
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -483,7 +483,7 @@ void apply_gain_fx(
    const Word16 *band_end,   /* i  : Sub band end indices                   Q0      */
    const Word16 num_sfm,     /* i  : Number of bands                        Q0      */
    const Word16 *gains,      /* i  : Band gain vector                       Qx     */
    Word16 *xq                /* i/o: Float synthesis / Gain adjusted synth  Q15/Qx */
    Word16 *xq                /* i/o: Float synthesis / Gain adjusted synth  Q15/Qx+1 */
)
{
    Word16 band, i;
@@ -496,8 +496,10 @@ void apply_gain_fx(
        FOR( i = band_start[band]; i < band_end[band]; i++ )
        {
            /*xq[i] *= g; */
            xq[i] = mult_r( g, xq[i] );
            move16(); /*12+15+1-16=12 */
            xq[i] = mult_r( g, xq[i] ); /*11+15+1-16=11 */
            xq[i] = shl( xq[i], 1 );    /*Q11 -> Q12 : Align Q for furthur operations*/
            move16();
            move16();
        }
    }

@@ -514,7 +516,7 @@ void fine_gain_quant_fx(
    const Word16 *ord,       /* i  : Indices for energy order                 Q0  */
    const Word16 num_sfm,    /* i  : Number of bands                          Q0  */
    const Word16 *gain_bits, /* i  : Gain adjustment bits per sub band        Q0  */
    Word16 *fg_pred,         /* i/o: Predicted gains / Corrected gains        Q12 */
    Word16 *fg_pred,         /* i/o: Predicted gains / Corrected gains        Q12/Q11 */
    const Word16 *gopt       /* i  : Optimal gains                            Q12 */
)
{
@@ -565,9 +567,13 @@ void fine_gain_quant_fx(
            exp1 = sub( 14, exp1 );

            L_tmp = L_mult0( fg_pred[band], tmp1 );                      /*12+exp1 */
            fg_pred[band] = round_fx( L_shl( L_tmp, sub( 16, exp1 ) ) ); /*12+exp1+16-exp1-16=12 */
            fg_pred[band] = round_fx( L_shl( L_tmp, sub( 15, exp1 ) ) ); /*12+exp1+15-exp1-16=11 */
            move16();
        }
        ELSE
        {
            fg_pred[band] = shr( fg_pred[band], 1 ); // Q12 -> Q11 To align all the fg_pred indices in same Q.
        }
    }

    return;