Commit a4e00205 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix assertion/memory overflow errors

parent abbe5fa9
Loading
Loading
Loading
Loading
Loading
+24 −23
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@
 *
 * Bitbudget distribution between Primary and Secondary channel in TD stereo
 *-------------------------------------------------------------------*/
#ifndef IVAS_FLOAT_FIXED_
#ifndef IVAS_FLOAT_FIXED
void tdm_bit_alloc(
    const int16_t ivas_format,           /* i  : IVAS format                         */
    const int16_t ism_mode,              /* i  : ISM mode in combined format         */
@@ -508,22 +508,22 @@ void tdm_bit_alloc(
            /* further adjustment in function of the energy/correlation ratio */
            IF( coder_type == INACTIVE )
            {
                //Word32 res_fix = 0;
                //res_fix = Mpy_32_32( 6442450, ( element_brate_wo_meta - 500 ) );
                //res_fix = res_fix * 100;
                //*total_brate_sec = max( *total_brate_sec, (Word16) res_fix );
                Word32 res_fix = 0;
                res_fix = Mpy_32_32(644245094, ( element_brate_wo_meta - 500 ) );
                res_fix = ( ( res_fix / 100 ) * 100 );
                *total_brate_sec = max( *total_brate_sec, res_fix );

                *total_brate_sec = max(*total_brate_sec, (int16_t)(0.3f * (element_brate_wo_meta - 500) / 100) * 100);
                //*total_brate_sec = max(*total_brate_sec, (int16_t)(0.3f * (element_brate_wo_meta - 500) / 100) * 100);
                tmp_bits = (Word16) ( -abs( tdm_inst_ratio_idx - 16 ) * 200 * idx );
            }
            ELSE
            {
                //Word32 res_fix = 0;
                //res_fix = Mpy_32_32( 10737418, ( element_brate_wo_meta - 500 ) );
                //res_fix = res_fix * 100;
                //*total_brate_sec = max( *total_brate_sec, res_fix );
                Word32 res_fix = 0;
                res_fix = Mpy_32_32(1073741824, ( element_brate_wo_meta - 500 ) );
                res_fix = ( ( res_fix / 100 ) * 100 );
                *total_brate_sec = max(*total_brate_sec, res_fix );

                *total_brate_sec = max(*total_brate_sec, (int16_t)(0.5f * (element_brate_wo_meta - 500) / 100) * 100);
                //*total_brate_sec = max(*total_brate_sec, (int16_t)(0.5f * (element_brate_wo_meta - 500) / 100) * 100);
                /* tmp_bits = -abs(tdm_inst_ratio_idx-16)*200*idx; */
                tmp_bits = (Word16) ( -abs( tdm_inst_ratio_idx - 16 ) * 100 * idx );
            }
@@ -537,7 +537,8 @@ void tdm_bit_alloc(
            bit_rate_diff_fx = tmp_bits;
        }
        ELSE{
            IF( ener_ratio_idx < LRTD_STEREO_MID_IS_PRIM ){
            IF( ener_ratio_idx < LRTD_STEREO_MID_IS_PRIM )
            {

                bit_rate_diff_fx = ( LRTD_STEREO_MID_IS_PRIM - ener_ratio_idx ) * bit_rate_diff_fx;
                bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 );
@@ -546,7 +547,7 @@ void tdm_bit_alloc(
            ELSE
            {
                bit_rate_diff_fx = ( ener_ratio_idx - LRTD_STEREO_MID_IS_PRIM ) * bit_rate_diff_fx;
        bit_rate_diff_fx = Mpy_32_32( 107374182, bit_rate_diff_fx );
                bit_rate_diff_fx = L_shr(bit_rate_diff_fx, 1);
                bit_rate_diff_fx = bit_rate_diff_fx / 10; // basop gives very minor deviation
            }
        }
@@ -591,7 +592,7 @@ IF( ( ener_ratio_idx <= 1 || ener_ratio_idx >= 29 ) && coder_type >= UNVOICED )
}
ELSE
{
    *total_brate_sec = min( *total_brate_sec, (Word16) ( 0.0045f * element_brate_wo_meta ) * 100 );
    *total_brate_sec = min(*total_brate_sec, Mpy_32_32(9663677, element_brate_wo_meta)* 100);    
}

*total_brate_sec = min( *total_brate_sec, 18000 );
+2 −19
Original line number Diff line number Diff line
@@ -4089,7 +4089,7 @@ ivas_error ivas_jbm_dec_render(
                {
                  for (j = 0; j < *nSamplesRendered; j++)
                  {
                    p_tc_fx[i][j] = (Word32)float_to_fixed(p_tc[i][j], *st_ivas->hCrendWrapper->p_io_qfactor);
                    p_output_fx[i][j] = (Word32)float_to_fixed(p_output[i][j], *st_ivas->hCrendWrapper->p_io_qfactor);
                  }
                }
                if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
@@ -4099,22 +4099,13 @@ ivas_error ivas_jbm_dec_render(
                {
                    return error;
                }
                //scaling all Tc to output q // needed
                for (i = nchan_out; i < nchan_in; i++)
                {
                  for (j = 0; j < *nSamplesRendered; j++)
                  {
                    p_tc_fx[i][j] = (Word32)L_shr(p_tc_fx[i][j], exp - *st_ivas->hCrendWrapper->p_io_qfactor);
                  }
                }
                ivas_binaural_add_LFE_fix(st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx);

                for (i = 0; i < nchan_in; i++)
                {
                  for (j = 0; j < *nSamplesRendered; j++)
                  {
                    //                    p_output[i][j] = fixed_to_float(p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor);
                    p_tc[i][j] = fixed_to_float(p_tc_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor);
                    p_output[i][j] = fixed_to_float(p_output_fx[i][j], *st_ivas->hCrendWrapper->p_io_qfactor);
                  }
                }

@@ -4700,14 +4691,6 @@ ivas_error ivas_jbm_dec_flush_renderer(
                    {
                        return error;
                    }
                    //scaling all Tc to output q // needed
                    for (i = nchan_out; i < nchan_in; i++)
                    {
                      for (j = 0; j < *nSamplesRendered; j++)
                      {
                        hTcBuffer->tc_fx[i][j] = (Word32)L_shr(hTcBuffer->tc_fx[i][j], exp - *st_ivas->hCrendWrapper->p_io_qfactor);
                      }
                    }

                    ivas_binaural_add_LFE_fix(st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc_fx, p_output_fx);

+7 −0
Original line number Diff line number Diff line
@@ -4099,6 +4099,13 @@ ivas_error ivas_rend_crendProcessSubframe(
    IF ( pCrend->hCrend->hReverb != NULL )
    {
        *pCrend->p_io_qfactor -= 2;
        for (int i = nchan_out; i < nchan_in; i++)
        {
          for (int j = 0; j < n_samples_to_render; j++)
          {
            output[i][j] = (Word32)L_shr(output[i][j], 2);
          }
        }
    }
    /* move to output */
    FOR ( ch = 0; ch < nchan_out; ch++ )