Commit da856650 authored by Arthur Tritthart's avatar Arthur Tritthart
Browse files

merged with main, fixed conflicts

parents 34450602 888873ba
Loading
Loading
Loading
Loading
Loading
+95 −0
Original line number Diff line number Diff line
@@ -2462,7 +2462,14 @@ static ivas_error decodeVoIP(
        }
        vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len;
        frame++;
#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
        if ( vec_pos_update == 0 )
        {
            systemTime_ms += vec_pos_len * systemTimeInc_ms;
        }
#else
        systemTime_ms += systemTimeInc_ms;
#endif

#ifdef WMOPS
        update_mem();
@@ -2470,6 +2477,94 @@ static ivas_error decodeVoIP(
#endif
    }


#ifdef NONBE_FIX_864_JBM_RENDER_FRAMESIZE
    int16_t nSamplesFlushed = 0;

    /* decode and get samples */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
    }

    if ( nSamplesFlushed )
    {
        /* Write current frame */
        if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nOutput audio file writer error\n" );
            goto cleanup;
        }

        /* Write ISm metadata to external file(s) */
        if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL )
        {
            if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM || bsFormat == IVAS_DEC_BS_SBA_ISM )
            {
                if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, &numObj ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

                for ( i = 0; i < numObj; ++i )
                {
                    IVAS_ISM_METADATA IsmMetadata;

                    if ( ( error = IVAS_DEC_GetObjectMetadata( hIvasDec, &IsmMetadata, 0, i ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetObjectMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }

                    if ( ( IsmFileWriter_writeFrame( IsmMetadata, ismWriters[i] ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError writing ISM metadata to file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) );
                        goto cleanup;
                    }
                }
            }

            if ( bsFormat == IVAS_DEC_BS_MASA || bsFormat == IVAS_DEC_BS_MASA_ISM )
            {
                IVAS_MASA_DECODER_EXT_OUT_META_HANDLE hMasaExtOutMeta;
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
                int16_t fullDelayNumSamples[3];
                float delayMs;

                /* delayNumSamples is zeroed, and delayNumSamples_orig is updated only on first good frame, so need to re-fetch delay info */
                if ( ( error = IVAS_DEC_GetDelay( hIvasDec, fullDelayNumSamples, &delayTimeScale ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
                }
#endif
                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
                delayMs = (float) ( fullDelayNumSamples[0] ) / (float) ( delayTimeScale );
                if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta, &delayMs ) ) != IVAS_ERR_OK )
#else
                if ( ( error = MasaFileWriter_writeFrame( masaWriter, hMasaExtOutMeta ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError writing MASA metadata to file: %s\n", MasaFileWriter_getFilePath( masaWriter ) );
                    goto cleanup;
                }
            }
        }
    }
#endif


    /*------------------------------------------------------------------------------------------*
     * Add zeros at the end to have equal length of synthesized signals
     *------------------------------------------------------------------------------------------*/
+5 −0
Original line number Diff line number Diff line
@@ -70,9 +70,14 @@ Word32 Interpol_lc_fx( /* o : interpolated value
            c2 += up_samp; /* move16() not needed, since the coefficient can be rearrange in bit exact way */
            c1 += up_samp;
        }
#ifdef OPT_SBA_ENC_V2_BE
        L_sum = W_shl_sat_l( L_sum64, 1 ); /*Q15*/
    }
#else
        L_sum = W_sat_l( L_sum64 ); /*Q14*/
    }
    L_sum = L_shl_sat( L_sum, 1 ); /*Q15*/
#endif
    return L_sum;
}

+87 −1
Original line number Diff line number Diff line
@@ -2361,18 +2361,30 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                Word32 re1, re2;

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ pSparMd->band_coeffs[b_ts_idx].q_C_re_fx*/
#ifdef OPT_SBA_ENC_V2_BE
                q_tmp1 = sub( W_norm( W_tmp ), 32 );
                re1 = W_shl_sat_l( W_tmp, q_tmp1 ); /*q_cov_dd_re+ q_C_re+q_tmp1*/
                q_tmp1 = add( add( q_C_re, q_tmp1 ), q_cov_dd_re );
#else
                q_tmp1 = W_norm( W_tmp );
                re1 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); /*q_cov_dd_re+ q_C_re+q_tmp1-32*/
                q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_cov_dd_re ), 32 );
#endif
                if ( W_tmp == 0 )
                {
                    q_tmp1 = 31;
                    move16();
                }
                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], cov_dd_re[0][0] ); /*q_cov_dd_re+ q_C_re*/
#ifdef OPT_SBA_ENC_V2_BE
                q_tmp = sub( W_norm( W_tmp ), 32 );
                re2 = W_shl_sat_l( W_tmp, q_tmp ); /*q_cov_dd_re+ q_C_re+q_tmp*/
                q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re );
#else
                q_tmp = W_norm( W_tmp );
                re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); /*q_cov_dd_re+ q_C_re+q_tmp-32*/
                q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 );
#endif
                if ( W_tmp == 0 )
                {
                    q_tmp = 31;
@@ -2380,12 +2392,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                }

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1 ); // q_tmp1+q_C_re
#ifdef OPT_SBA_ENC_V2_BE
                q_factor = sub( W_norm( W_tmp ), 32 );
                recon_uu_re[0][0] = W_shl_sat_l( W_tmp, q_factor ); // q_tmp1+q_C_re+q_recon_uu_re[0][0]
                move32();
                q_recon_uu_re[0][0] = add( add( q_C_re, q_factor ), q_tmp1 );
                move16();
#else
                q_recon_uu_re[0][0] = W_norm( W_tmp );
                move16();
                recon_uu_re[0][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][0] ) ); // q_tmp1+q_C_re+q_recon_uu_re[0][0]-32
                move32();
                q_recon_uu_re[0][0] = sub( add( add( q_C_re, q_recon_uu_re[0][0] ), q_tmp1 ), 32 );
                move16();
#endif
                if ( W_tmp == 0 )
                {
                    q_recon_uu_re[0][0] = 31;
@@ -2393,12 +2413,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                }

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re1 ); // q_C_re+q_tmp1
#ifdef OPT_SBA_ENC_V2_BE
                q_factor = sub( W_norm( W_tmp ), 32 );
                recon_uu_re[0][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp1+q_recon_uu_re[0][1]
                move32();
                q_recon_uu_re[0][1] = add( add( q_C_re, q_factor ), q_tmp1 );
                move16();
#else
                q_recon_uu_re[0][1] = W_norm( W_tmp );
                move16();
                recon_uu_re[0][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[0][1] ) ); // q_C_re+q_tmp1+q_recon_uu_re[0][1]-32
                move32();
                q_recon_uu_re[0][1] = sub( add( add( q_C_re, q_recon_uu_re[0][1] ), q_tmp1 ), 32 );
                move16();
#endif
                if ( W_tmp == 0 )
                {
                    q_recon_uu_re[0][1] = 31;
@@ -2406,12 +2434,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                }

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re2 ); // q_C_re+q_tmp
#ifdef OPT_SBA_ENC_V2_BE
                q_factor = sub( W_norm( W_tmp ), 32 );
                recon_uu_re[1][0] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][0]
                move32();
                q_recon_uu_re[1][0] = add( add( q_C_re, q_factor ), q_tmp );
                move16();
#else
                q_recon_uu_re[1][0] = W_norm( W_tmp );
                move16();
                recon_uu_re[1][0] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][0] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][0]-32
                move32();
                q_recon_uu_re[1][0] = sub( add( add( q_C_re, q_recon_uu_re[1][0] ), q_tmp ), 32 );
                move16();
#endif
                if ( W_tmp == 0 )
                {
                    q_recon_uu_re[1][0] = 31;
@@ -2419,12 +2455,20 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                }

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[1][0], re2 ); // q_C_re+q_tmp
#ifdef OPT_SBA_ENC_V2_BE
                q_factor = sub( W_norm( W_tmp ), 32 );
                recon_uu_re[1][1] = W_shl_sat_l( W_tmp, q_factor ); // q_C_re+q_tmp+q_recon_uu_re[1][1]
                move32();
                q_recon_uu_re[1][1] = add( add( q_C_re, q_factor ), q_tmp );
                move16();
#else
                q_recon_uu_re[1][1] = W_norm( W_tmp );
                move16();
                recon_uu_re[1][1] = W_extract_h( W_shl( W_tmp, q_recon_uu_re[1][1] ) ); // q_C_re+q_tmp+q_recon_uu_re[1][1]-32
                move32();
                q_recon_uu_re[1][1] = sub( add( add( q_C_re, q_recon_uu_re[1][1] ), q_tmp ), 32 );
                move16();
#endif
                if ( W_tmp == 0 )
                {
                    q_recon_uu_re[1][1] = 31;
@@ -2441,12 +2485,18 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                    }
                }
                q_tmp = sub( s_min( q_tmp, q_cov_uu_re ), 1 );

#ifdef OPT_SBA_ENC_V2_BE
                q_factor = sub( q_cov_uu_re, q_tmp );
#endif
                FOR( i = 0; i < 2; i++ )
                {
                    FOR( j = 0; j < 2; j++ )
                    {
#ifdef OPT_SBA_ENC_V2_BE
                        cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], q_factor ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp
#else
                        cov_uu_re[i][j] = L_sub( L_shr( cov_uu_re[i][j], sub( q_cov_uu_re, q_tmp ) ), L_shr( recon_uu_re[i][j], sub( q_recon_uu_re[i][j], q_tmp ) ) ); // q_tmp
#endif
                        move32();
                    }
                }
@@ -2466,9 +2516,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                    {
                        Word32 re;
                        W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][k], cov_dd_re[k][j] ); // q_C_re+q_cov_dd_re
#ifdef OPT_SBA_ENC_V2_BE
                        q_tmp = sub( W_norm( W_tmp ), 33 );
                        re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp
                        q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re );
#else
                        q_tmp = sub( W_norm( W_tmp ), 1 );
                        re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32
                        q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 );
#endif
                        if ( W_tmp == 0 )
                        {
                            q_tmp = 31;
@@ -2492,9 +2548,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                }

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][0], re1[0] ); // q_C_re+q_re1[0]
#ifdef OPT_SBA_ENC_V2_BE
                q_tmp = sub( W_norm( W_tmp ), 33 );
                re2 = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[0]+q_tmp
                q_tmp = add( add( q_C_re, q_tmp ), q_re1[0] );
#else
                q_tmp = sub( W_norm( W_tmp ), 1 );
                re2 = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[0]+q_tmp-32
                q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[0] ), 32 );
#endif
                if ( W_tmp == 0 )
                {
                    q_tmp = 31;
@@ -2504,9 +2566,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                move32();

                W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[0][1], re1[1] ); // q_C_re+q_re1[1]
#ifdef OPT_SBA_ENC_V2_BE
                q_tmp1 = sub( W_norm( W_tmp ), 33 );
                re2 = W_shl_sat_l( W_tmp, q_tmp1 ); // q_C_re+q_re1[1]+q_tmp1
                q_tmp1 = add( add( q_C_re, q_tmp1 ), q_re1[1] );
#else
                q_tmp1 = sub( W_norm( W_tmp ), 1 );
                re2 = W_extract_h( W_shl( W_tmp, q_tmp1 ) ); // q_C_re+q_re1[1]+q_tmp1-32
                q_tmp1 = sub( add( add( q_C_re, q_tmp1 ), q_re1[1] ), 32 );
#endif
                if ( W_tmp == 0 )
                {
                    q_tmp1 = 31;
@@ -2585,9 +2653,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                        FOR( k = 0; k < num_dmx - 1; k++ )
                        {
                            W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[i][k], cov_dd_re[k][m] ); // q_C_re+q_cov_dd_re
#ifdef OPT_SBA_ENC_V2_BE
                            q_tmp = sub( W_norm( W_tmp ), 34 );
                            re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_cov_dd_re+q_tmp
                            q_tmp = add( add( q_C_re, q_tmp ), q_cov_dd_re );
#else
                            q_tmp = sub( W_norm( W_tmp ), 2 );
                            re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_cov_dd_re+q_tmp-32
                            q_tmp = sub( add( add( q_C_re, q_tmp ), q_cov_dd_re ), 32 );
#endif
                            if ( W_tmp == 0 )
                            {
                                q_tmp = 31;
@@ -2627,9 +2701,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
                        FOR( m = 0; m < num_dmx - 1; m++ )
                        {
                            W_tmp = W_mult0_32_32( pSparMd->band_coeffs[b_ts_idx].C_re_fx[j][m], re1[m] ); // q_C_re+q_re1[m]
#ifdef OPT_SBA_ENC_V2_BE
                            q_tmp = sub( W_norm( W_tmp ), 34 );
                            re = W_shl_sat_l( W_tmp, q_tmp ); // q_C_re+q_re1[m]+q_tmp
                            q_tmp = add( add( q_C_re, q_tmp ), q_re1[m] );
#else
                            q_tmp = sub( W_norm( W_tmp ), 2 );
                            re = W_extract_h( W_shl( W_tmp, q_tmp ) ); // q_C_re+q_re1[m]+q_tmp-32
                            q_tmp = sub( add( add( q_C_re, q_tmp ), q_re1[m] ), 32 );
#endif
                            if ( W_tmp == 0 )
                            {
                                q_tmp = 31;
@@ -2714,9 +2794,15 @@ static void ivas_calc_p_coeffs_per_band_enc_fx(
        move16();
        IF( trace != 0 )
        {
#ifdef OPT_SBA_ENC_V2_BE
            q_factor = sub( W_norm( trace ), 32 );
            tmp = Mpy_32_32( p_norm_scaling, W_shl_sat_l( trace, q_factor ) ); // q_cov_uu_re+q_factor
            q_factor = add( q_cov_uu_re, q_factor );
#else
            q_factor = W_norm( trace );
            tmp = Mpy_32_32( p_norm_scaling, W_extract_h( W_shl( trace, q_factor ) ) ); // q_cov_uu_re+q_factor-32
            q_factor = sub( add( q_cov_uu_re, q_factor ), 32 );
#endif
            IF( GT_16( q_factor, q_postpred_cov_re ) )
            {
                tmp = L_shr( tmp, sub( q_factor, q_postpred_cov_re ) ); // q_postpred_cov_re
+5 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
/*#define DEBUG_FORCE_DIR*/                       /* Force modes/parameters by reading from external binary files */
/*#define DBG_WAV_WRITER*/                    /* Enable dbgwrite_wav() function for generating ".wav" files */
#define SUPPORT_FORCE_TCX10_TCX20             /* VA: Enable -force tcx10|tcx20 command-line option */
/*#define DEBUG_MODE_JBM */                     /* define to output JBM relevant parameters */
#endif

#define SUPPORT_JBM_TRACEFILE                   /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */
@@ -67,6 +68,7 @@
#ifndef BASOP_NOGLOB_DEV_USE_GLOBALS
#define BASOP_NOGLOB_DECLARE_LOCAL
#endif
#define FIX_732_MS_PERIODOG_FLOOR                /* Eri: Issue-732: Dynamic range of msPeriodog leads to minimum value 1e-5 being truncated to zero. This uses the smallest non-zero value instead. */

#define FIX_867_CLDFB_NRG_SCALE

@@ -78,6 +80,7 @@
#define OPT_SBA_REND_V1_BE
#define OPT_HEAD_ROT_REND_V1_BE
#define OPT_SBA_DEC_V2_BE
#define OPT_SBA_ENC_V2_BE
#define OPT_SBA_ENC_V1_BE
#define OPT_BIN_RENDERER_V1
#define OPT_BIN_RENDERER_V2
@@ -116,5 +119,7 @@

#define FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC       /* FhG: NON-BE!!! Simplify azimuth & elevation calculations, remove parameter mismatch for divide3232, fix copy/paste error for elevation */
#define FIX_ISSUE_1744_IVAS_DIRAC_GET_MONO_FLAG /* FhG: NON-BE!!! Simplify threshold - comparison, change (wrong) Equal-comparion to (correct) Greater-Than-comparison */
=======
#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE                    /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */

#endif
+7 −22
Original line number Diff line number Diff line
@@ -1273,28 +1273,6 @@ const Word16 sin_table256_fx[] =
 * 1/4 resolution interpolation filter (-3 dB at 0.913*fs/2)
 *----------------------------------------------------------------------------------*/
const Word16 inter4_2_fx_Q15[65] =
{//Q15
    30801,
    28062, 20718, 11061, 1935,
    -4294, -6533, -5195, -1846,
    1559, 3497, 3398, 1705,
    -497, -2087, -2413, -1523,
    -32, 1252, 1741, 1312,
    305, -710, -1237, -1087,
    -426, 350, 848, 862,
    452, -119, -550, -650,
    -418, -17, 330, 462,
    349, 85, -175, -306,
    -265, -104, 76, 184,
    182, 93, -20, -98,
    -110, -66, -3, 43,
    55, 37, 8, -13,
    -20, -14, -4, 2,
    3, 1, 0, 0,
};
const Word16 inter4_2_fx[] =
{//evs table , some mismatch in values compared to float is observed
    0,     1,      2,      1,
@@ -1366,6 +1344,13 @@ const Word16 pitch_inter4_2[PIT_FIR_SIZE2] =
  3/*0.000098f Q15*/,        2/*0.000048f Q15*/,        0/*0.000007f Q15*/,        0/*0.000000f Q15*/
};
/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */
const Word32 L_pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] = /* Q31 */
{
    1932735283, 1758701061, 1298905484, 711630983, 180298432, -162768528,
    -280712608, -226956816, -100446400, 9592809, 59676424, 55065776,
    26996016, 4138201, -3373696, -1617055, 0
};
/* 1/4 resolution interpolation filter (-3 dB at 0.791*fs/2) */
const Word16 pitch_inter4_1[UP_SAMP * L_INTERPOL1 + 1] =
{
    29491/*0.900000F Q15*/,
Loading