Commit 7e44f316 authored by vaclav's avatar vaclav
Browse files

introduce function ivas_cldfb_dec_reconfig()

parent 46c805e8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -3053,6 +3053,7 @@ ivas_error ivas_sba_dec_reinit(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);
#endif

ivas_error ivas_sba_dec_reconfigure(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);
@@ -3063,6 +3064,14 @@ void ivas_init_dec_get_num_cldfb_instances(
    int16_t *numCldfbSyntheses                                  /* o  : number of CLDFB synthesis instances     */
);

#ifdef BRATE_SWITCHING_RENDERING
ivas_error ivas_cldfb_dec_reconfig(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                */
    const int16_t nchan_transport_old,                          /* i  : number of TCs in previous frame                       */
    int16_t numCldfbAnalyses_old,                               /* i  : number of CLDFB analysis instances in previous frame  */
    const int16_t numCldfbSyntheses_old                         /* i  : number of CLDFB synthesis instances in previous frame */
);
#endif
/*! r: Ambisonic (SBA) order */
int16_t ivas_sba_get_order(
    const int16_t nb_channels,                                  /* i  : Number of ambisonic channels            */
+89 −0
Original line number Diff line number Diff line
@@ -398,3 +398,92 @@ ivas_error ivas_hp20_dec_reconfig(

    return error;
}


#ifdef BRATE_SWITCHING_RENDERING
/*-------------------------------------------------------------------*
 * ivas_cldfb_dec_reconfig()
 *
 * Allocate, initialize, and configure CLDFB handles in case of bitrate switching
 *-------------------------------------------------------------------*/

ivas_error ivas_cldfb_dec_reconfig(
    Decoder_Struct *st_ivas,            /* i/o: IVAS decoder structure                                */
    const int16_t nchan_transport_old,  /* i  : number of TCs in previous frame                       */
    int16_t numCldfbAnalyses_old,       /* i  : number of CLDFB analysis instances in previous frame  */
    const int16_t numCldfbSyntheses_old /* i  : number of CLDFB synthesis instances in previous frame */
)
{
    int16_t i, numCldfbAnalyses, numCldfbSyntheses;
    DECODER_CONFIG_HANDLE hDecoderConfig;
    ivas_error error;

    hDecoderConfig = st_ivas->hDecoderConfig;

    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );

    /* special case, if there was one transport channel in the previous frame and more than one in the current frame,
       remove the second CLDFB here, it was for CNA/CNG */
    if ( st_ivas->ivas_format == SBA_FORMAT && nchan_transport_old == 1 && numCldfbAnalyses_old == 2 && st_ivas->nchan_transport > 1 )
    {
        deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) );
        st_ivas->cldfbAnaDec[1] = NULL;
        numCldfbAnalyses_old--;
    }

    /* resample CLDFB analysis instances */
    for ( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ )
    {
        if ( ( st_ivas->cldfbAnaDec[i]->no_channels * st_ivas->cldfbAnaDec[i]->no_col ) != ( hDecoderConfig->output_Fs / FRAMES_PER_SEC ) )
        {
            resampleCldfb( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs );
        }
    }

    /* Analysis*/
    if ( numCldfbAnalyses_old > numCldfbAnalyses )
    {
        /* delete superfluous CLDFB synthesis instances */
        for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ )
        {
            deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) );
            st_ivas->cldfbAnaDec[i] = NULL;
        }
    }
    else if ( numCldfbAnalyses_old < numCldfbAnalyses )
    {
        /* create additional CLDFB synthesis instances */
        for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ )
        {
            if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
    }

    /* Synthesis */
    if ( numCldfbSyntheses_old > numCldfbSyntheses )
    {
        /* delete superfluous CLDFB synthesis instances */
        for ( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ )
        {
            deleteCldfb( &( st_ivas->cldfbSynDec[i] ) );
            st_ivas->cldfbSynDec[i] = NULL;
        }
    }
    else if ( numCldfbSyntheses_old < numCldfbSyntheses )
    {
        /* create additional CLDFB synthesis instances */
        for ( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ )
        {
            if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            {
                return error;
            }
        }
    }

    return IVAS_ERR_OK;
}
#endif
+12 −0
Original line number Diff line number Diff line
@@ -549,9 +549,17 @@ ivas_error ivas_sba_dec_reconfigure(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
)
{
#ifdef BRATE_SWITCHING_RENDERING
    int16_t nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old;
#else
    int16_t i, nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old;
#endif
    AUDIO_CONFIG intern_config_old;
#ifdef BRATE_SWITCHING_RENDERING
    int16_t numCldfbAnalyses_old, numCldfbSyntheses_old;
#else
    int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old;
#endif
    int16_t sba_dirac_stereo_flag_old;
    int32_t ivas_total_brate, last_ivas_total_brate;
    DECODER_CONFIG_HANDLE hDecoderConfig;
@@ -704,6 +712,9 @@ ivas_error ivas_sba_dec_reconfigure(
     * CLDFB instances
     *-----------------------------------------------------------------*/

#ifdef BRATE_SWITCHING_RENDERING
    ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old );
#else
    ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );

    /* special case, if there was one transport channel in the previous frame and more than one in the current frame,
@@ -769,6 +780,7 @@ ivas_error ivas_sba_dec_reconfigure(
            }
        }
    }
#endif

#ifndef BRATE_SWITCHING_RENDERING
    /*-------------------------------------------------------------------*