Commit 64b4d63f authored by emerit's avatar emerit
Browse files

port MER 1202 no set_zero_l replace by existing set_zero2_l

parent a43b5c15
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -71,4 +71,7 @@
//#define OPT_STEREO_32KBPS_V1                    /* Optimization made in stereo decoding path for 32kbps decoding */
#define FIX_1310_SPEEDUP_ivas_dirac_dec_get_response_fx                 /*FhG: WMOPS tuning, nonbe*/
#define FIX_1310_SPEEDUP_ivas_dirac_dec_output_synthesis_process_slot   /*FhG: WMOPS tuning, nonbe*/

#define FIX_1440_PORT_1202_FROM_FLT_REPO                /* Orange : port 1202 Fix crash when long BRIR is set */

#endif
+159 −92
Original line number Diff line number Diff line
@@ -1472,7 +1472,11 @@ ivas_error ivas_rend_openCrend(
    const Word32 output_Fs )
{
    Word16 i, subframe_length;
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
    Word32 max_total_ir_len;
#else
    Word16 max_total_ir_len;
#endif
    HRTFS_HANDLE hHrtf;
    CREND_HANDLE hCrend;
    ivas_error error;
@@ -1487,8 +1491,10 @@ ivas_error ivas_rend_openCrend(

    subframe_length = extract_l( Mult_32_16( output_Fs, 164 ) ); /*( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES(i/o:164=(32768/FRAMES_PER_SEC)/MAX_PARAM_SPATIAL_SUBFRAMES*/

    IF( ( *pCrend )->hHrtfCrend == NULL ){
        IF( NE_32( ( error = ivas_rend_initCrend_fx( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ), IVAS_ERR_OK ) ){
    IF( ( *pCrend )->hHrtfCrend == NULL )
    {
        IF( NE_32( ( error = ivas_rend_initCrend_fx( *pCrend, inConfig, outConfig, hSetOfHRTF, output_Fs ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
    }
@@ -1499,7 +1505,11 @@ ivas_error ivas_rend_openCrend(

        IF( hHrtf != NULL )
        {
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
            max_total_ir_len = L_mult0( hHrtf->max_num_iterations, subframe_length );
#else
            max_total_ir_len = imult1616( hHrtf->max_num_iterations, subframe_length );
#endif

            FOR( i = 0; i < hHrtf->max_num_ir; i++ )
            {
@@ -1507,12 +1517,20 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
                set_zero2_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len );
#else
                set_zero_fx( hCrend->freq_buffer_re_fx[i], max_total_ir_len );
#endif
                IF( ( hCrend->freq_buffer_im_fx[i] = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
                set_zero2_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len );
#else
                set_zero_fx( hCrend->freq_buffer_im_fx[i], max_total_ir_len );
#endif
            }

            FOR( i = 0; i < BINAURAL_CHANNELS; i++ )
@@ -1524,7 +1542,11 @@ ivas_error ivas_rend_openCrend(
                set_zero_fx( hCrend->prev_out_buffer_fx[i], subframe_length );
            }

#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
            max_total_ir_len = L_mult0( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length );
#else
            max_total_ir_len = imult1616( (Word16) hHrtf->num_iterations_diffuse[0], subframe_length );
#endif

            IF( max_total_ir_len > 0 )
            {
@@ -1532,12 +1554,20 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
                set_zero2_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len );
#else
                set_zero_fx( hCrend->freq_buffer_re_diffuse_fx, max_total_ir_len );
#endif
                IF( ( hCrend->freq_buffer_im_diffuse_fx = (Word32 *) malloc( sizeof( Word32 ) * max_total_ir_len ) ) == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
                set_zero2_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len );
#else
                set_zero_fx( hCrend->freq_buffer_im_diffuse_fx, max_total_ir_len );
#endif
            }
            ELSE
            {
@@ -1552,7 +1582,11 @@ ivas_error ivas_rend_openCrend(
                {
                    return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend" );
                }
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
                set_zero2_fx( hCrend->lfe_delay_line_fx, max_total_ir_len );
#else
                set_zero_fx( hCrend->lfe_delay_line_fx, max_total_ir_len );
#endif
            }
            ELSE
            {
@@ -1741,7 +1775,12 @@ static ivas_error ivas_rend_crendConvolver(
    Word16 i, j, k, m;
    Word16 subframe_length, idx_in;
    Word16 lfe_idx_in;
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
    Word32 offset, offset_in, offset_diffuse;
    Word16 index_in;
#else
    Word16 offset, offset_in, offset_diffuse;
#endif
    Word16 nchan_in, nchan_out;
    const Word32 *pIn;
    Word32 *pFreq_buf_re, *pFreq_buf_im;
@@ -1783,9 +1822,13 @@ static ivas_error ivas_rend_crendConvolver(
        }
    }

#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
    offset = L_mult0( hCrend->delay_line_rw_index, subframe_length );                 /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */
    offset_diffuse = L_mult0( hCrend->diffuse_delay_line_rw_index, subframe_length ); /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */
#else
    offset = imult1616( hCrend->delay_line_rw_index, subframe_length );                 /* subframe_length * ( pCrend->hHrtfCrend->max_num_iterations - 1 ); */
    offset_diffuse = imult1616( hCrend->diffuse_delay_line_rw_index, subframe_length ); /* subframe_length *( pCrend->hHrtfCrend->num_iterations_diffuse[0] - 1 ); */

#endif
    IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    {
        set32_fx( &hCrend->freq_buffer_re_diffuse_fx[offset_diffuse], 0, subframe_length );
@@ -1841,10 +1884,17 @@ static ivas_error ivas_rend_crendConvolver(
                move16();
                FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations[i][j]; m++ )
                {
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
                    index_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) );
                    index_in = index_in % ( pCrend->hHrtfCrend->max_num_iterations );
                    move16();
                    offset_in = L_mult0( index_in, subframe_length );
#else
                    offset_in = add( add( hCrend->delay_line_rw_index, sub( pCrend->hHrtfCrend->max_num_iterations, pCrend->hHrtfCrend->num_iterations[i][j] ) ), add( m, 1 ) );
                    offset_in = offset_in % ( pCrend->hHrtfCrend->max_num_iterations );
                    move16();
                    offset_in = imult1616( offset_in, subframe_length );
#endif
                    pFreq_buf_re = &hCrend->freq_buffer_re_fx[i][offset_in];              // Qx
                    pFreq_buf_im = &hCrend->freq_buffer_im_fx[i][offset_in];              // Qx
                    pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_re_fx[i][j][offset]; // Q29
@@ -1857,7 +1907,11 @@ static ivas_error ivas_rend_crendConvolver(
                        move32();
                        move32();
                    }
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
                    offset = L_add( offset, k );
#else
                    offset = add( offset, k );
#endif
                }
                i = add( i, 1 );
            }
@@ -1867,10 +1921,17 @@ static ivas_error ivas_rend_crendConvolver(
        move16();
        FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations_diffuse[j]; m++ )
        {
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
            index_in = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) );
            index_in = index_in % pCrend->hHrtfCrend->num_iterations_diffuse[0];
            move16();
            offset_diffuse = L_mult0( index_in, subframe_length );
#else
            offset_diffuse = add( hCrend->diffuse_delay_line_rw_index, add( m, 1 ) );
            offset_diffuse = offset_diffuse % pCrend->hHrtfCrend->num_iterations_diffuse[0];
            move16();
            offset_diffuse = imult1616( offset_diffuse, subframe_length );
#endif
            pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[offset_diffuse];         // Qx
            pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[offset_diffuse];         // Qx
            pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re_fx[j][offset]; // Q31
@@ -1882,7 +1943,13 @@ static ivas_error ivas_rend_crendConvolver(
                move32();
                move32();
            }
#ifdef FIX_1440_PORT_1202_FROM_FLT_REPO
            offset = L_add( offset, k );
            move32();
#else
            offset = add( offset, k );
            move16();
#endif
        }

        ivas_imdft_fx( tmp_out_re, tmp_out_im, pOut, subframe_length );