Commit 89ed086d authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fix duplication of ivas_get_nchan_buffers_dec by removing ivas_fx variant....

Fix duplication of ivas_get_nchan_buffers_dec by removing ivas_fx variant. Also fix minor BASOP issues in the function.
parent e81dcc6b
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx(
    ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    st_ivas->ism_mode = ism_mode;
    move16();
    nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );

    IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
    {
+1 −1
Original line number Diff line number Diff line
@@ -1609,7 +1609,7 @@ static ivas_error ivas_mc_dec_reconfig_fx(
     * floating-point output audio buffers
     *-----------------------------------------------------------------*/

    nchan_out_buff = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
    nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );

    IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
    {
+1 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ ivas_error ivas_omasa_dec_config_fx(
    st_ivas->ivas_format = st_ivas->last_ivas_format;
    move16();
    ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
    nchan_out_buff_old = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 );
    nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 );
    move16();

    st_ivas->ivas_format = ivas_format_orig;
+1 −1
Original line number Diff line number Diff line
@@ -1793,7 +1793,7 @@ static ivas_error IVAS_DEC_GetTcSamples(

        IF( st_ivas->hDecoderConfig->Opt_tsm == 0 )
        {
            FOR( n = 0; n < ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
            FOR( n = 0; n < ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ )
            {
                set32_fx( st_ivas->p_output_fx[n], 0, L_FRAME48k );
                st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; // Q11
+3 −157
Original line number Diff line number Diff line
@@ -367,6 +367,8 @@ Word16 ivas_get_nchan_buffers_dec(
        nchan_out_buff = CPE_CHANNELS;
        move16();

        test();
        test();
        test();
        test();
        test();
@@ -374,7 +376,7 @@ Word16 ivas_get_nchan_buffers_dec(
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
        ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ||
                  EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
            nchan_out_buff = shl( CPE_CHANNELS, 1 );
@@ -464,162 +466,6 @@ Word16 ivas_get_nchan_buffers_dec(
    return nchan_out_buff;
}

Word16 ivas_get_nchan_buffers_dec_ivas_fx(
    Decoder_Struct *st_ivas,         /* i/o: IVAS decoder structure                */
    const Word16 sba_analysis_order, /* i  : SBA order evaluated in SBA decoder    */
    const Word32 ivas_total_brate    /* i  : total IVAS bitrate                    */
)
{
    Word16 nchan_out_buff;
    AUDIO_CONFIG output_config;

    output_config = st_ivas->hDecoderConfig->output_config;
    move16();

    nchan_out_buff = MAX_OUTPUT_CHANNELS;
    move16();

    IF( EQ_16( st_ivas->ivas_format, MONO_FORMAT ) )
    {
        nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
        move16();
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, STEREO_FORMAT ) )
    {
        nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS );
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) )
    {
        nchan_out_buff = st_ivas->nchan_ism;
        move16();

        IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
        {
            nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
        }
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) )
    {
        Word16 nchan_internal;
        nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
        nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
        move16();

        IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE
        {
            nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
        }
        nchan_out_buff = s_max( nchan_out_buff, nchan_internal );
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, MASA_FORMAT ) )
    {
        nchan_out_buff = CPE_CHANNELS;
        move16();

        test();
        test();
        test();
        IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
        {
            nchan_out_buff = shl( CPE_CHANNELS, 1 );
            move16();
        }
        ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
        }
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) )
    {
        nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS );

        IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
        }
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
    {
        Word16 nchan_internal;
        nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate );
        nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport );

        IF( st_ivas->hMCT != NULL )
        {
            nchan_out_buff = shl( shr( add( nchan_out_buff, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */
        }

        IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE IF( NE_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );

            move16();
            IF( EQ_16( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_16( st_ivas->renderer_type, RENDERER_OSBA_LS ) )
            {
                nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */
            }
            ELSE
            {
                nchan_out_buff = s_max( add( nchan_out_buff, st_ivas->nchan_ism ), audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */
            }
        }
        ELSE IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
        {
            nchan_out_buff = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*take into account sba_ch_idx' in ivas_dec() */
        }

        test();
        IF( !( EQ_16( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) );
        }
        nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS );
    }
    ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) )
    {
        nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
        move16();

        IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) )
        {
            nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) );
        }
        ELSE
        {
            nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
            nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) );
        }
    }


    return nchan_out_buff;
}


/*-------------------------------------------------------------------*
 * ivas_output_buff_dec()