Commit a5deddec authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into...

Merge branch 'main' of ssh://forge.3gpp.org:29419/sa4/audio/ivas-basop into kiene/test-renderer-smoke-test-basop
parents 06151289 c0947d4a
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -448,12 +448,10 @@ int main(
            goto cleanup;
        }

#ifdef FIX_1449_RENDERER_FRAME_SIZE_UNCLEAR_IN_ISAR
        if ( !arg.renderConfigEnabled && ( arg.render_num_subframes != asked_num_subframes ) )
        {
            fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" );
        }
#endif
    }

    /*------------------------------------------------------------------------------------------*
@@ -913,9 +911,7 @@ static bool parseCmdlIVAS_dec(
    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
    arg->non_diegetic_pan_enabled = false;
    arg->non_diegetic_pan_gain = 0.f;
#ifdef FIX_2318_CLANG_DECODER
    arg->non_diegetic_pan_gain_fx = 0;
#endif
    arg->tsmEnabled = false;
    arg->render_num_subframes = IVAS_RENDER_NUM_SUBFR_20MS;
    arg->aeSequence.count = 0;
+0 −36
Original line number Diff line number Diff line
@@ -167,9 +167,6 @@ typedef struct
    int16_t numInMetadataFiles;
    char outMetadataFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char headRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    char splitRendBFIFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
#endif
    char referenceVectorFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char referenceRotationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char externalOrientationFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
@@ -220,9 +217,6 @@ typedef enum
    CmdLnOptionId_listFormats,
    CmdLnOptionId_inputGain,
    CmdLnOptionId_outputMetadata,
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    CmdLnOptionId_SplitRendBFIFile,
#endif
    CmdLnOptionId_referenceVectorFile,
    CmdLnOptionId_exteriorOrientationFile,
    CmdLnOptionId_framing,
@@ -281,14 +275,6 @@ static const CmdLnParser_Option cliOptions[] = {
        .matchShort = "om",
        .description = "coded metadata file for BINAURAL_SPLIT_PCM output mode",
    },
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    {
        .id = CmdLnOptionId_SplitRendBFIFile,
        .match = "post_rend_bfi_file",
        .matchShort = "prbfi",
        .description = "Split rendering option: bfi file",
    },
#endif
    {
        .id = CmdLnOptionId_refRotFile,
        .match = "reference_rotation_file",
@@ -764,9 +750,6 @@ int main(
    IVAS_CLDFB_FILTER_BANK_HANDLE cldfbAna[RENDERER_MAX_INPUT_CHANNELS];
    IVAS_CLDFB_FILTER_BANK_HANDLE cldfbSyn[RENDERER_MAX_INPUT_CHANNELS];
    int16_t cldfb_in_flag, CLDFBframeSize_smpls;
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    SplitRendBFIFileReader *splitRendBFIReader = NULL;
#endif
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
    IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
@@ -896,13 +879,6 @@ int main(
        }
    }

#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    if ( !isEmptyString( args.splitRendBFIFilePath ) )
    {
        convert_backslash( args.splitRendBFIFilePath );
        SplitRendBFIFileReader_open( args.splitRendBFIFilePath, &splitRendBFIReader );
    }
#endif
    if ( !isEmptyString( args.externalOrientationFilePath ) )
    {
        if ( RotationFileReader_open( args.externalOrientationFilePath, &externalOrientationFileReader ) != IVAS_ERR_OK )
@@ -2184,9 +2160,6 @@ cleanup:
    }

    split_rend_reader_writer_close( &hSplitRendFileReadWrite );
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    SplitRendBFIFileReader_close( &splitRendBFIReader );
#endif

    for ( i = 0; i < RENDERER_MAX_MC_INPUTS; ++i )
    {
@@ -2798,9 +2771,6 @@ static CmdlnArgs defaultArgs(

    clearString( args.headRotationFilePath );
    clearString( args.outMetadataFilePath );
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
    clearString( args.splitRendBFIFilePath );
#endif
    clearString( args.referenceVectorFilePath );
    clearString( args.referenceRotationFilePath );
    clearString( args.customHrtfFilePath );
@@ -2907,12 +2877,6 @@ static void parseOption(
            assert( numOptionValues == 1 );
            strncpy( args->outMetadataFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
            break;
#ifndef FIX_1494_SET_SPLITBFI_UNUSED
        case CmdLnOptionId_SplitRendBFIFile:
            assert( numOptionValues == 1 );
            strncpy( args->splitRendBFIFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
            break;
#endif
        case CmdLnOptionId_referenceVectorFile:
            assert( numOptionValues == 1 );
            strncpy( args->referenceVectorFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
+5 −0
Original line number Diff line number Diff line
@@ -996,6 +996,11 @@ ivas_error openCldfb(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

#ifdef FIX_2319_CLDFB_INIT_FLAGS
    hs->flags = 0;
    move16();
#endif

    hs->type = type;
    move16();

+0 −2
Original line number Diff line number Diff line
@@ -595,9 +595,7 @@ void cldfbAnalysis_ts_fx_var_q(
    IF( NE_16( h_cldfb->Q_cldfb_state, *q_cldfb ) )
    {
        Word16 norm_st = L_norm_arr( timeBuffer_fx, offset );
#ifdef FIX_2257_INCR_GUARD_BITS
        norm_st = sub( norm_st, find_guarded_bits_fx( shr( h_cldfb->no_channels, 2 ) ) );
#endif
        IF( GE_16( norm_st, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) ) )
        {
            scale_sig32( timeBuffer_fx, offset, sub( *q_cldfb, h_cldfb->Q_cldfb_state ) );
+0 −283
Original line number Diff line number Diff line
@@ -602,112 +602,6 @@ return;
 *-------------------------------------------------------*/

void cng_params_postupd_fx(
#ifndef HARM_NON_LINEARITY
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
    const Word16 *const cng_Qexc_buf,  /* i  : Q_exc buffer                                       Q0    */
    const Word32 *const cng_brate_buf, /* i  : bit rate buffer                                    Q0    */
    Word32 ho_env_circ[]               /* i/o: Envelope buffer                                    Q6    */
)
{
    Word16 i, j;
    Word16 Q_exc;
    const Word16 *exc2;
    Word16 fft_io[L_FFT];
    Word32 sp[129];
    Word16 *ptR, *ptI;
    Word32 env[NUM_ENV_CNG];
    Word32 L_tmp;
    Word16 tmp;
    Word16 temp_lo_fx, temp_hi_fx;
    Word16 exp_pow;
    Word16 exp1;
    Word16 CNG_mode;
    Word16 ptr;
    Word32 last_active_brate;

    ptr = add( sub( ho_circ_ptr, *cng_buf_cnt ), 1 );
    IF( ptr < 0 )
    {
        ptr = add( ptr, HO_HIST_SIZE );
    }

    FOR( j = 0; j < *cng_buf_cnt; j++ )
    {
        exc2 = &cng_exc2_buf[ptr * L_FFT];
        Q_exc = cng_Qexc_buf[ptr];
        move16();
        last_active_brate = cng_brate_buf[ptr];
        move32();

        /* calculate the spectrum of residual signal */
        Copy( exc2, fft_io, L_FFT );

        fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT );

        ptR = &fft_io[1];
        ptI = &fft_io[L_FFT - 1];
        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
            L_tmp = L_mult_sat( *ptR, *ptR );                     /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_tmp );                    /* 2*Q_exc+1 */
            L_tmp = Mult_32_16( L_tmp, 128 );                     /* 2*Q_exc+1 */
            tmp = add( add( Q_exc, Q_exc ), 1 );
            sp[i] = L_shr( L_tmp, sub( tmp, 6 ) );
            move32(); /* Q6 */

            ptR++;
            ptI--;
        }

        Copy32( sp, env, NUM_ENV_CNG );
        {

            CNG_mode = get_cng_mode( last_active_brate );

            /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
            L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */
            temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );

            exp_pow = sub( 14, temp_hi_fx );
            L_tmp = Pow2( 14, temp_lo_fx );             /* Qexp_pow */
            L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */
            tmp = extract_l( L_tmp );                   /* Q13 */

            exp1 = norm_s( tmp );
            tmp = shl( tmp, exp1 );           /*Q(exp1+13) */
            tmp = div_s( 16384, tmp );        /*Q(15+14-exp1-13) */
            tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */
        }

        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            env[i] = Mult_32_16( env[i], tmp );
            move32();
        }

        /* update the circular buffer of old residual envelope */
        Copy32( env, &( ho_env_circ[(ptr) *NUM_ENV_CNG] ), NUM_ENV_CNG );

        ptr = add( ptr, 1 );
        if ( EQ_16( ptr, HO_HIST_SIZE ) )
        {
            ptr = 0;
            move16();
        }
    }

    *cng_buf_cnt = 0;
    move16();

    return;
}

void cng_params_postupd_ivas_fx(
#endif
    const Word16 ho_circ_ptr,          /* i  : pointer for CNG averaging buffers                  Q0    */
    Word16 *cng_buf_cnt,               /* i/o: counter for CNG store buffers                      Q0    */
    const Word16 *const cng_exc2_buf,  /* i  : Excitation buffer                                  Q_exc */
@@ -833,183 +727,8 @@ void cng_params_postupd_ivas_fx(
 *
 * update CNG parameters
 *-------------------------------------------------------*/
#ifndef HARM_NON_LINEARITY
void cng_params_upd_fx(
    const Word16 lsp_new[],        /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],           /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,          /* i  : frame length                                       Q0    */
    Word16 *ho_circ_ptr,           /* i/o: pointer for CNG averaging buffers                  Q0    */
    Word32 ho_ener_circ[],         /* o  : energy buffer for CNG averaging                    Q6    */
    Word16 *ho_circ_size,          /* i/o: size of DTX hangover history buffer for averaging  Q0    */
    Word16 ho_lsp_circ[],          /* o  : old LSP buffer for CNG averaging                   Q15   */
    const Word16 Q_exc,            /* i  : Q value of excitation                                    */
    const Word16 enc_dec_flag,     /* i  : Flag indicating encoder or decoder (ENC,DEC)             */
    Word32 ho_env_circ[],          /* i/o: Envelope buffer                                    Q6    */
    Word16 *cng_buf_cnt,           /* i/o: Counter of postponed FFT-processing instances            */
    Word16 cng_exc2_buf[],         /* i/o: Excitation buffer                                  Q_exc */
    Word16 cng_Qexc_buf[],         /* i/o: Q_exc buffer                                       Q0    */
    Word32 cng_brate_buf[],        /* i/o: last_active_brate buffer                           Q0    */
    const Word32 last_active_brate /* i  : Last active bit rate                               Q0    */
)
{
    Word32 L_ener, L_tmp;
    Word16 i, j;
    const Word16 *pt_exc2;
    Word16 tmpv, maxv, scale;
    Word16 fft_io[L_FRAME16k];
    Word32 sp[129];
    Word16 *ptR, *ptI;
    Word32 env[NUM_ENV_CNG];
    Word16 exp1;
    Word16 CNG_mode;
    Word16 tmp;
    Word16 temp_lo_fx, temp_hi_fx;
    Word16 exp_pow;

    /* update the pointer to circular buffer of old LSP vectors */
    *ho_circ_ptr = add( *ho_circ_ptr, 1 );
    move16();

    if ( EQ_16( *ho_circ_ptr, HO_HIST_SIZE ) )
    {
        *ho_circ_ptr = 0;
        move16();
    }

    /* update the circular buffer of old LSP vectors with the new LSP vector */
    Copy( lsp_new, &( ho_lsp_circ[( *ho_circ_ptr ) * M] ), M );

    /* calculate the residual signal energy */
    /*enr = dotp( exc2, exc2, L_frame ) / L_frame; */

    maxv = 0;
    move16();
    FOR( i = 0; i < L_frame; i++ )
    {
        maxv = s_max( maxv, abs_s( exc2[i] ) );
    }
    scale = norm_s( maxv );

    pt_exc2 = exc2;
    L_ener = 0;
    move32();
    IF( EQ_16( L_frame, L_FRAME ) )
    {
        FOR( j = 0; j < 128; j++ )
        {
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */
            pt_exc2++;
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv );
            pt_exc2++;
            L_ener = L_add_sat( L_ener, L_shr_sat( L_tmp, 7 ) ); /* Q(2*(Q_exc+scale)+1) ,division by L_frame done here */
        }
    }
    ELSE /* L_FRAME16k */
    {
        FOR( j = 0; j < 160; j++ )
        {
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mult0( tmpv, tmpv ); /* 2*(Q_exc+scale) */
            pt_exc2++;
            tmpv = shl( *pt_exc2, scale );
            L_tmp = L_mac0_sat( L_tmp, tmpv, tmpv );
            pt_exc2++;
            L_ener = L_add_sat( L_ener, L_shr_sat( Mult_32_16( L_tmp, 26214 /* 256/320, Q15 */ ), 7 ) ); /* Q(2*(Q_exc+scale)+15+1-16+1) ,division by L_frame done here */
        }
    }
    L_ener = L_shr_sat( L_ener, sub( shl( add( Q_exc, scale ), 1 ), 5 ) ); /* Q6 (2*(Q_exc+scale)+1-2*(Q_exc+scale)+5) */

    /* update the circular buffer of old energies */
    ho_ener_circ[*ho_circ_ptr] = L_ener;
    move32();

    IF( enc_dec_flag == ENC )
    {
        /* Store residual signal for postponed FFT-processing*/
        *cng_buf_cnt = add( *cng_buf_cnt, 1 );
        move16();
        if ( GT_16( *cng_buf_cnt, HO_HIST_SIZE ) )
        {
            *cng_buf_cnt = HO_HIST_SIZE;
            move16();
        }
        Copy( exc2, &( cng_exc2_buf[( *ho_circ_ptr ) * L_FFT] ), L_FFT );
        cng_Qexc_buf[*ho_circ_ptr] = Q_exc;
        move16();
        cng_brate_buf[*ho_circ_ptr] = last_active_brate;
        move32();
    }
    ELSE
    {
        /* calculate the spectrum of residual signal */
        Copy( exc2, fft_io, L_frame );

        fft_rel_fx( fft_io, L_FFT, LOG2_L_FFT );

        ptR = &fft_io[1];
        ptI = &fft_io[L_FFT - 1];
        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            /* sp[i] = 2.0f*(*ptR * *ptR + *ptI * *ptI)/L_FFT; */
            L_tmp = L_mult_sat( *ptR, *ptR );                     /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_mult_sat( *ptI, *ptI ) ); /* 2*Q_exc+1 */
            L_tmp = L_add_sat( L_tmp, L_tmp );                    /* 2*Q_exc+1 */
            L_tmp = Mult_32_16( L_tmp, 128 );                     /* 2*Q_exc+1 */
            tmp = add( add( Q_exc, Q_exc ), 1 );
            sp[i] = L_shr( L_tmp, sub( tmp, 6 ) );
            move32(); /* Q6 */

            ptR++;
            ptI--;
        }

        Copy32( sp, env, NUM_ENV_CNG );
        {
            CNG_mode = get_cng_mode( last_active_brate );
            /* att = 1/pow(2,ENR_ATT_fx[CNG_mode]); */
            L_tmp = L_shl( L_deposit_l( ENR_ATT_fx[CNG_mode] ), 8 ); /* 16 */
            temp_lo_fx = L_Extract_lc( L_tmp, &temp_hi_fx );

            exp_pow = sub( 14, temp_hi_fx );
            L_tmp = Pow2( 14, temp_lo_fx );             /* Qexp_pow */
            L_tmp = L_shl( L_tmp, sub( 13, exp_pow ) ); /* Q13 */
            tmp = extract_l( L_tmp );                   /* Q13 */

            exp1 = norm_s( tmp );
            tmp = shl( tmp, exp1 );           /*Q(exp1+13) */
            tmp = div_s( 16384, tmp );        /*Q(15+14-exp1-13) */
            tmp = shr( tmp, sub( 1, exp1 ) ); /* Q15 */
        }

        FOR( i = 0; i < NUM_ENV_CNG; i++ )
        {
            env[i] = Mult_32_16( env[i], tmp );
            move32();
        }

        /* update the circular buffer of old residual envelope */
        /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */
        Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
    }
    *ho_circ_size = add( *ho_circ_size, 1 );
    move16();
    if ( GT_16( *ho_circ_size, HO_HIST_SIZE ) )
    {
        *ho_circ_size = HO_HIST_SIZE;
        move16();
    }

    return;
}
#endif

#ifdef HARM_NON_LINEARITY
void cng_params_upd_fx(
#else
void cng_params_upd_ivas_fx(
#endif
    const Word16 lsp_new[],         /* i  : LSP aprameters                                     Q15   */
    const Word16 exc2[],            /* i  : current enhanced excitation                        Q_exc */
    const Word16 L_frame,           /* i  : frame length                                       Q0    */
@@ -1187,9 +906,7 @@ void cng_params_upd_ivas_fx(
        /* update the circular buffer of old residual envelope */
        /* Copy32( env, &(ho_env_circ[add(shl(*ho_circ_ptr,4),shl(*ho_circ_ptr,2))]), NUM_ENV_CNG ); */
        Copy32( env, &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG );
#ifdef HARM_NON_LINEARITY
        IF( NE_16( element_mode, EVS_MONO ) )
#endif
        {
            scale_sig32( &( ho_env_circ[( *ho_circ_ptr ) * NUM_ENV_CNG] ), NUM_ENV_CNG, shift ); // Q(6+shift)
        }
Loading