Commit 4856d31e authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'basop_instrumentation_changes_decoder' into 'main'

BASOP addition and instrumentation changes

See merge request !392
parents 2d4ceef6 e6dbe888
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1603,6 +1603,10 @@ typedef enum
 *----------------------------------------------------------------------------------*/

#define BINAURAL_MAXBANDS                       60                          /* Max number of bands */
#ifdef IVAS_FLOAT_FIXED
#define BINAURAL_MAXBANDS_Q25                   2013265920                  /* Max number of bands in Q25 */
#define ONE_BY_48000_Q31                        44740
#endif
#define BINAURAL_CONVBANDS                      50                          /* Bands upto which convolution is performed */
#define BINAURAL_NTAPS                           3
#define BINAURAL_NTAPS_SBA                       BINAURAL_NTAPS
+1 −1
Original line number Diff line number Diff line
@@ -6656,7 +6656,7 @@ void ivas_binRenderer(
void ivas_binRenderer_fx(
  BINAURAL_RENDERER_HANDLE hBinRenderer,                                                 /* i/o: binaural renderer handle                     */
  COMBINED_ORIENTATION_HANDLE hCombinedOrientationData,                                  /* i  : combined head and external orientation handle*/
  const int16_t numTimeSlots,                                                            /* i  : number of time slots to render               */
  const Word16 numTimeSlots,                                                             /* i  : number of time slots to render               */
  Word32 Cldfb_RealBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o  : Binaural signals */
  Word32 Cldfb_ImagBuffer_Binaural_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* o  : Binaural signals */
  Word32 RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],                /* i  : LS signals       */
+212 −112

File changed.

Preview size limit exceeded, changes collapsed.

+407 −178

File changed.

Preview size limit exceeded, changes collapsed.

+69 −26
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "ivas_prot.h"
#ifdef IVAS_FLOAT_FIXED
#include "ivas_prot_fx.h"
#include "prot_fx1.h"
#include "prot_fx2.h"
#endif // IVAS_FLOAT_FIXED
#include "prot.h"
@@ -150,14 +151,22 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
            /* prepare bitstream buffers */
            FOR( n = 0; n < CPE_CHANNELS; n++ )
            {
                st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
                IF( GT_16( st_ivas->nCPE, 1 ) )
                {
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
                    move32();
                }
                ELSE
                {
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
                    move32();
                }
            }
        }

        IF( GT_16( st_ivas->nCPE, 1 ) )
        {
            IF( ( error = mct_dec_reconfigure_fx( st_ivas, 0 ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = mct_dec_reconfigure_fx( st_ivas, 0 ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -165,7 +174,14 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
    }
    ELSE
    {
        st0 = GT_16( nSCE_old, 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0];
        IF( nSCE_old > 0 )
        {
            st0 = st_ivas->hSCE[0]->hCoreCoder[0];
        }
        ELSE
        {
            st0 = st_ivas->hCPE[0]->hCoreCoder[0];
        }
        prev_bfi = st0->prev_bfi;
        move16();
        nSCE_existing = s_min( nSCE_old, st_ivas->nSCE );
@@ -180,9 +196,9 @@ ivas_error ivas_corecoder_dec_reconfig_fx(

        test();
        test();
        IF( sba_dirac_stereo_flag_old && EQ_16( nCPE_old, 0 ) && st_ivas->hCPE[0] )
        IF( sba_dirac_stereo_flag_old && ( nCPE_old == 0 ) && st_ivas->hCPE[0] )
        {
            st_ivas->hCPE[0]->hCoreCoder[0] = 0; /* this has been deallocated as part of the SCE it actually belongs to */
            st_ivas->hCPE[0]->hCoreCoder[0] = NULL; /* this has been deallocated as part of the SCE it actually belongs to */
            destroy_cpe_dec( st_ivas->hCPE[0] );
            st_ivas->hCPE[0] = NULL;
        }
@@ -192,7 +208,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
            /* don't deallocate first CPE in case of mono/stereo output of 1 TC SBA, only deallocate core coder */
            test();
            test();
            IF( EQ_16( cpe_id, 0 ) && st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old )
            IF( ( cpe_id == 0 ) && st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old )
            {
                FOR( n = 0; n < CPE_CHANNELS; n++ )
                {
@@ -248,7 +264,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
        }
        FOR( ; sce_id < st_ivas->nSCE; sce_id++ )
        {
            IF( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -258,7 +274,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
        test();
        test();
        test();
        IF( st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old && EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( nSCE_old, 0 ) )
        IF( st_ivas->sba_dirac_stereo_flag && sba_dirac_stereo_flag_old && EQ_16( st_ivas->nchan_transport, 1 ) && ( nSCE_old == 0 ) )
        {
            st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */
            st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
@@ -272,10 +288,18 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
            /* prepare bitstream buffers */
            FOR( n = 0; n < CPE_CHANNELS; n++ )
            {
                st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
                IF( GT_16( st_ivas->nCPE, 1 ) )
                {
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
                    move32();
                }
                ELSE
                {
                    st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = L_shr( st_ivas->hCPE[cpe_id]->element_brate, 1 ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
                    move32();
                }
            }
        }
        FOR( ; cpe_id < st_ivas->nCPE; cpe_id++ )
        {
            test();
@@ -285,7 +309,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
                move16();
            }

            IF( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -307,19 +331,20 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
                    st_ivas->hCPE[0]->hCoreCoder[n]->total_brate = st_ivas->hCPE[0]->element_brate;
                    move32();
                    st_ivas->hCPE[0]->hCoreCoder[n]->bits_frame_nominal = extract_l( Mpy_32_16_1( st_ivas->hCPE[0]->element_brate, INV_FRAME_PER_SEC_Q15 ) );
                    move16();
                    st_ivas->hCPE[0]->hCoreCoder[n]->igf = 0;
                    move16();
                }
            }

            IF( ( error = create_mct_dec_fx( st_ivas ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = create_mct_dec_fx( st_ivas ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
        }
        ELSE IF( st_ivas->hMCT != NULL && GT_16( st_ivas->nCPE, 1 ) )
        {
            IF( ( error = mct_dec_reconfigure_fx( st_ivas, (UWord16) NE_16( st_ivas->nchan_transport, nchan_transport_old ) ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = mct_dec_reconfigure_fx( st_ivas, (UWord16) NE_16( st_ivas->nchan_transport, nchan_transport_old ) ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -329,7 +354,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
        test();
        IF( EQ_16( st_ivas->nCPE, 1 ) && GT_16( nCPE_old, 1 ) )
        {
            IF( ( st_ivas->hCPE[sub( st_ivas->nCPE, 1 )]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL )
            IF( ( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL )
            {
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) );
            }
@@ -372,9 +397,9 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
        ( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) )
    {
        /* if at least one CPE is already available, only allocate DFT Stereo struct */
        IF( GT_16( st_ivas->nCPE, 0 ) )
        IF( ( st_ivas->nCPE > 0 ) )
        {
            IF( ( error = stereo_dft_dec_create_fx( &( st_ivas->hCPE[0]->hStereoDft ), st_ivas->hCPE[0]->element_brate, st_ivas->hDecoderConfig->output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = stereo_dft_dec_create_fx( &( st_ivas->hCPE[0]->hStereoDft ), st_ivas->hCPE[0]->element_brate, st_ivas->hDecoderConfig->output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -382,7 +407,9 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
        /* otherwise create extra dummy CPE */
        ELSE
        {
            IF( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
            Word32 quo, rem;
            iDiv_and_mod_32( ivas_total_brate, add( st_ivas->nSCE, st_ivas->nCPE ), &quo, &rem, 0 );
            IF( NE_32( ( error = create_cpe_dec( st_ivas, 0, quo ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -401,7 +428,6 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
            }
            set32_fx( st_ivas->hSCE[0]->save_synth_fx, 0, output_frame );
            st_ivas->hSCE[0]->q_save_synth_fx = 0;
            // st_ivas->hSCE[0]->q_save_synth_fx = Q11;
            move16();
        }

@@ -429,7 +455,7 @@ ivas_error ivas_corecoder_dec_reconfig_fx(
    test();
    IF( LE_32( hDecoderConfig->last_ivas_total_brate, IVAS_SID_5k2 ) && GE_16( st_ivas->nCPE, 1 ) )
    {
        IF( ( error = initMdctStereoDtxData_fx( st_ivas->hCPE[0] ) ) != IVAS_ERR_OK )
        IF( NE_32( ( error = initMdctStereoDtxData_fx( st_ivas->hCPE[0] ) ), IVAS_ERR_OK ) )
        {
            return error;
        }
@@ -778,6 +804,7 @@ ivas_error ivas_hp20_dec_reconfig_fx(
    ivas_error error;

    error = IVAS_ERR_OK;
    move32();

    /*-----------------------------------------------------------------*
     * HP20 memories
@@ -946,10 +973,13 @@ ivas_error ivas_cldfb_dec_reconfig_fx(

    /* 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 */
    test();
    test();
    test();
    IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && EQ_16( nchan_transport_old, 1 ) && EQ_16( numCldfbAnalyses_old, 2 ) && GT_16( st_ivas->nchan_transport, 1 ) )
    {
        deleteCldfb_ivas( &( st_ivas->cldfbAnaDec[1] ) );
        numCldfbAnalyses_old--;
        numCldfbAnalyses_old = sub( numCldfbAnalyses_old, 1 );
    }
    /* resample CLDFB analysis instances */
    FOR( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ )
@@ -974,7 +1004,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
        /* create additional CLDFB synthesis instances */
        FOR( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ )
        {
            IF( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
@@ -994,22 +1024,35 @@ ivas_error ivas_cldfb_dec_reconfig_fx(
        /* create additional CLDFB synthesis instances */
        FOR( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ )
        {
            IF( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
            IF( NE_32( ( error = openCldfb_ivas_fx( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ), IVAS_ERR_OK ) )
            {
                return error;
            }
        }
    }
    /* CLDFB Interpolation weights */
    IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( NE_16( numCldfbAnalyses_old, numCldfbAnalyses ) || NE_16( numCldfbSyntheses_old, numCldfbSyntheses ) || NE_16( nchan_transport_old, st_ivas->nchan_transport ) ) && NE_16( numCldfbAnalyses, 0 ) && NE_16( numCldfbSyntheses, 0 ) )
    test();
    test();
    test();
    test();
    test();
    IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) && ( NE_16( numCldfbAnalyses_old, numCldfbAnalyses ) || NE_16( numCldfbSyntheses_old, numCldfbSyntheses ) || NE_16( nchan_transport_old, st_ivas->nchan_transport ) ) && ( numCldfbAnalyses != 0 ) && ( numCldfbSyntheses != 0 ) )
    {
        ivas_spar_get_cldfb_gains_fx( st_ivas->hSpar, st_ivas->cldfbAnaDec[0], st_ivas->cldfbSynDec[0], hDecoderConfig );
        FOR( i = 0; i < st_ivas->cldfbAnaDec[0]->cldfb_state_length; i++ )
        st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11
        {
            st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], sub( Q27, Q11 ) ); // Scaling down from 27 to 11
            move32();
        }
        st_ivas->cldfbAnaDec[0]->Q_cldfb_state = Q11;
        move16();
        FOR( i = 0; i < st_ivas->cldfbSynDec[0]->cldfb_state_length; i++ )
        st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], 21 - 11 ); // Scaling down from 21 to 11
        {
            st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], sub( Q21, Q11 ) ); // Scaling down from 21 to 11
            move32();
        }
        st_ivas->cldfbSynDec[0]->Q_cldfb_state = Q11;
        move16();
    }
    return IVAS_ERR_OK;
}
Loading