Commit 890dec82 authored by emerit's avatar emerit
Browse files

fix switch build

parent b0af6bd7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -799,7 +799,7 @@ cleanup:
            destroy_SetOfHRTF( hSetOfHRTF );
        }
        IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
        destroy_hrtf_statistics();
        destroy_hrtf_statistics( hHrtfStatistics );
#endif
    }
#ifdef FIX_CREND_SIMPLIFY_CODE
+231 −1
Original line number Diff line number Diff line
@@ -2096,7 +2096,7 @@ void ivas_rend_closeCldfbRend(
 *
 * Convolver block
 *-----------------------------------------------------------------------------------------*/

#ifdef FIX_CREND_SIMPLIFY_CODE
static ivas_error ivas_rend_crendConvolver(
    const CREND_WRAPPER *pCrend,
    AUDIO_CONFIG inConfig,
@@ -2302,7 +2302,237 @@ static ivas_error ivas_rend_crendConvolver(

    return IVAS_ERR_OK;
}
#else
static ivas_error ivas_rend_crendConvolver(
    const CREND_WRAPPER *pCrend,
    AUDIO_CONFIG inConfig,
    AUDIO_CONFIG outConfig,
    Word32 *pcm_in[],  // Qx
    Word32 *pcm_out[], // Qx
    const Word32 output_Fs,
    const Word16 i_ts,
    const Word16 pos_idx )
{
    Word16 i, j, k, m;
    Word16 subframe_length, idx_in;
    Word16 lfe_idx_in;
    Word32 offset, offset_in, offset_diffuse;
    Word16 index_in;
    Word16 nchan_in, nchan_out;
    const Word32 *pIn;
    Word32 *pFreq_buf_re, *pFreq_buf_im;
    Word32 *pFreq_buf2_re, *pFreq_buf2_im;
    const Word32 *pFreq_filt_re, *pFreq_filt_im;
    Word32 pOut[L_FRAME48k * 2];
    Word32 tmp_out_re[L_FRAME48k];
    Word32 tmp_out_im[L_FRAME48k];
    CREND_HANDLE hCrend;
    ivas_error error;

    hCrend = pCrend->hCrend[pos_idx];

    IF( NE_32( ( error = getAudioConfigNumChannels( inConfig, &nchan_in ) ), IVAS_ERR_OK ) )
    {
        return error;
    }

    IF( NE_32( ( error = getAudioConfigNumChannels( outConfig, &nchan_out ) ), IVAS_ERR_OK ) )
    {
        return error;
    }

    /* subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; */
    subframe_length = extract_l( Mpy_32_32_r( output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) );

    lfe_idx_in = -1;
    move16();
    IF( EQ_32( getAudioConfigType( inConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) )
    {
        IF( NE_32( inConfig, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            lfe_idx_in = LFE_CHANNEL;
            move16();
        }
        ELSE
        {
            assert( 0 && "Custom LS not supported in CRend" );
        }
    }

    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 ); */

    IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    {
        set32_fx( &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse], 0, subframe_length );
        set32_fx( &hCrend->freq_buffer_im_diffuse_fx[0][offset_diffuse], 0, subframe_length );
        if ( pCrend->hHrtfCrend->same_inv_diffuse_weight == 0 )
        {
            set32_fx( &hCrend->freq_buffer_re_diffuse_fx[1][offset_diffuse], 0, subframe_length );
            set32_fx( &hCrend->freq_buffer_im_diffuse_fx[1][offset_diffuse], 0, subframe_length );
        }
    }

    i = 0;
    move16();
    FOR( idx_in = 0; idx_in < nchan_in; idx_in++ )
    {
        pIn = &pcm_in[idx_in][i_ts * subframe_length];

        IF( NE_16( idx_in, lfe_idx_in ) )
        {
            IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
            {
                IF( pCrend->hHrtfCrend->same_inv_diffuse_weight )
                {
                    pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse];
                    pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[0][offset_diffuse];
                    pFreq_filt_re = &hCrend->freq_buffer_re_fx[i][offset];
                    pFreq_filt_im = &hCrend->freq_buffer_im_fx[i][offset];

                    FOR( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
                    {
                        pFreq_buf_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_re[k] ); // Qx
                        pFreq_buf_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_im[k] ); // Qx
                        move32();
                        move32();
                    }
                }
                ELSE
                {
                    pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse];
                    pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[0][offset_diffuse];
                    pFreq_buf2_re = &hCrend->freq_buffer_re_diffuse_fx[1][offset_diffuse];
                    pFreq_buf2_im = &hCrend->freq_buffer_im_diffuse_fx[1][offset_diffuse];
                    pFreq_filt_re = &hCrend->freq_buffer_re_fx[i][offset];
                    pFreq_filt_im = &hCrend->freq_buffer_im_fx[i][offset];

                    for ( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
                    {
                        pFreq_buf_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_re[k] ); // Qx
                        pFreq_buf_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[0][i] ), pFreq_buf_im[k] ); // Qx
                        move32();
                        move32();
                        pFreq_buf2_re[k] = L_add( Mpy_32_16_r( pFreq_filt_re[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[1][i] ), pFreq_buf2_re[k] ); // Qx
                        pFreq_buf2_im[k] = L_add( Mpy_32_16_r( pFreq_filt_im[k], pCrend->hHrtfCrend->inv_diffuse_weight_fx[1][i] ), pFreq_buf2_im[k] ); // Qx
                        move32();
                        move32();
                    }
                }
            }
            pFreq_buf_re = &hCrend->freq_buffer_re_fx[i][offset]; // Qx
            pFreq_buf_im = &hCrend->freq_buffer_im_fx[i][offset]; // Qx


            ivas_mdft_fx( pIn, pFreq_buf_re, pFreq_buf_im, subframe_length, subframe_length );
#ifdef DEBUGGING
            dbgwrite_txt( (const float *) pFreq_buf_re, subframe_length, "Fixed_pFreq_buf_re_mdft.txt", NULL );
            dbgwrite_txt( (const float *) pFreq_buf_im, subframe_length, "Fixed_pFreq_buf_im_mdft.txt", NULL );
#endif
            i = add( i, 1 );
        }
    }

    FOR( j = 0; j < nchan_out; j++ )
    {
        set32_fx( tmp_out_re, 0, subframe_length );
        set32_fx( tmp_out_im, 0, subframe_length );
        i = 0;
        move16();
        FOR( idx_in = 0; idx_in < nchan_in; idx_in++ )
        {
            IF( NE_16( idx_in, lfe_idx_in ) )
            {
                offset = 0;
                move16();
                FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations[i][j]; m++ )
                {
                    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 );

                    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
                    pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_im_fx[i][j][offset]; // Q29

                    FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max[i][j][m]; k++ )
                    {
                        tmp_out_re[k] = L_add( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), tmp_out_re[k] ); // Qx - 2
                        tmp_out_im[k] = L_add( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), tmp_out_im[k] ); // Qx - 2
                        move32();
                        move32();
                    }

                    offset = L_add( offset, k );
                }
                i = add( i, 1 );
            }
        }

        offset = 0;
        move16();
        FOR( m = 0; m < pCrend->hHrtfCrend->num_iterations_diffuse[j]; m++ )
        {
            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 );
            if ( pCrend->hHrtfCrend->same_inv_diffuse_weight )
            {
                pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[0][offset_diffuse];
                pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[0][offset_diffuse];
            }
            else
            {
                pFreq_buf_re = &hCrend->freq_buffer_re_diffuse_fx[j][offset_diffuse];
                pFreq_buf_im = &hCrend->freq_buffer_im_diffuse_fx[j][offset_diffuse];
            }
            pFreq_filt_re = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_re_fx[j][offset]; // Q31
            pFreq_filt_im = &pCrend->hHrtfCrend->pOut_to_bin_diffuse_im_fx[j][offset]; // Q31
            FOR( k = 0; k < pCrend->hHrtfCrend->pIndex_frequency_max_diffuse[j][m]; k++ )
            {
                tmp_out_re[k] = L_add( L_shr( Msub_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_re[k] ), pFreq_buf_im[k], pFreq_filt_im[k] ), 2 ), tmp_out_re[k] ); // Qx - 2
                tmp_out_im[k] = L_add( L_shr( Madd_32_32( Mpy_32_32( pFreq_buf_re[k], pFreq_filt_im[k] ), pFreq_buf_im[k], pFreq_filt_re[k] ), 2 ), tmp_out_im[k] ); // Qx - 2
                move32();
                move32();
            }
            offset = L_add( offset, k );
            move32();
        }

        ivas_imdft_fx( tmp_out_re, tmp_out_im, pOut, subframe_length );
        scale_sig32( pOut, shl( subframe_length, 1 ), 2 );
#ifdef DEBUGGING
        dbgwrite_txt( (const float *) pOut, subframe_length << 1, "Fixed_imdft_out.txt", NULL );
#endif
        pFreq_buf_re = &pcm_out[j][i_ts * subframe_length];
        FOR( k = 0; k < subframe_length; k++ )
        {
            pFreq_buf_re[k] = L_add( pOut[k], hCrend->prev_out_buffer_fx[j][k] ); // Qx
            hCrend->prev_out_buffer_fx[j][k] = pOut[k + subframe_length];         // Qx
            move32();
            move32();
        }
    }

    hCrend->delay_line_rw_index = add( hCrend->delay_line_rw_index, 1 );
    hCrend->delay_line_rw_index = hCrend->delay_line_rw_index % ( pCrend->hHrtfCrend->max_num_iterations );
    move16();
    move16();
    IF( pCrend->hHrtfCrend->num_iterations_diffuse[0] > 0 )
    {
        hCrend->diffuse_delay_line_rw_index = add( hCrend->diffuse_delay_line_rw_index, 1 );
        hCrend->diffuse_delay_line_rw_index = hCrend->diffuse_delay_line_rw_index % ( pCrend->hHrtfCrend->num_iterations_diffuse[0] );
        move16();
        move16();
    }

    return IVAS_ERR_OK;
}

#endif
/*-----------------------------------------------------------------------------------------*
 * Function ivas_rend_crendProcessSubframe()
 *
+147 −136

File changed.

Preview size limit exceeded, changes collapsed.