Commit b014ae4a authored by thomas dettbarn's avatar thomas dettbarn
Browse files

Merge branch 'main' into dettbarn_exp4_-_lib_dec

parents 0eb6d175 c5a2b92f
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
     *------------------------------------------------------------------------------------------*/
+6 −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 */
@@ -75,6 +76,9 @@
#define FIX_1379_MASA_ANGLE_ROUND

/* Note: each compile switch (FIX_1101_...) is independent from the other ones */
#define OPT_SBA_REND_V1_BE
#define OPT_HEAD_ROT_REND_V1_BE
#define OPT_SBA_DEC_V2_BE
#define OPT_SBA_ENC_V1_BE
#define OPT_BIN_RENDERER_V1
#define OPT_BIN_RENDERER_V2
@@ -111,4 +115,6 @@
#define FIX_1733_CLDFB_BUG
#define FIX_1740_MISING_POP_WMOPS               /* VA: fix issue 1740: missing pop_wmops() */

#define NONBE_FIX_864_JBM_RENDER_FRAMESIZE                    /* FhG: issue #864: fix different behaviour of JBM TSM with different render frame sizes */

#endif
+57 −0
Original line number Diff line number Diff line
@@ -20,6 +20,63 @@
 *   (adaptive codebook excitation)                                  *
 *-------------------------------------------------------------------*/

void pred_lt4_ivas_fx(
    const Word16 excI[],   /* in : excitation buffer       Q_exc*/
    Word16 excO[],         /* out: excitation buffer       Q_exc*/
    const Word16 T0,       /* input : integer pitch lag    Q0*/
    Word16 frac,           /* input : fraction of lag      Q0*/
    const Word16 L_subfr,  /* input : subframe size        Q0*/
    const Word32 *win,     /* i  : interpolation window    Q31*/
    const Word16 nb_coef,  /* i  : nb of filter coef       Q0*/
    const Word16 up_sample /* i  : up_sample               Q0*/
)
{
    Word16 i, j;
    Word32 s;
    const Word16 *x0, *x1, *x2;
    const Word32 *c1, *c2;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
    x0 = &excI[-T0];

    frac = negate( frac );

    IF( frac < 0 )
    {
        frac = add( frac, up_sample ); /* Q0 */
        x0--;
    }

    FOR( j = 0; j < L_subfr; j++ )
    {
        x1 = x0++;                       /* Q_exc */
        x2 = x1 + 1;                     /* Q_exc */
        c1 = ( &win[frac] );             /* Q14 */
        c2 = ( &win[up_sample - frac] ); /* Q14 */

        {
            Word64 s64 = 0;
            move64();
            FOR( i = 0; i < nb_coef; i++ )
            {
                /*s += (*x1--) * (*c1) + (*x2++) * (*c2);*/
                s64 = W_mac_32_32( s64, L_deposit_l( *x1-- ), ( *c1 ) ); /* Q_exc + Q32 */
                s64 = W_mac_32_32( s64, L_deposit_l( *x2++ ), ( *c2 ) ); /* Q_exc + Q32 */

                c1 += up_sample;
                c2 += up_sample;
            }
            s = W_sat_l( W_shr( s64, 16 ) ); /* Q_exc + Q16 */
        }

        excO[j] = round_fx_o( s, &Overflow ); /* Q_exc */
        move16();
    }
    return;
}

void pred_lt4(
    const Word16 excI[],   /* in : excitation buffer       Q_exc*/
    Word16 excO[],         /* out: excitation buffer       Q_exc*/
+10 −0
Original line number Diff line number Diff line
@@ -7183,6 +7183,16 @@ void pred_lt4(
    const Word16 up_sample /* i  : up_sample               Q0*/
);
void pred_lt4_ivas_fx(
    const Word16 excI[],   /* in : excitation buffer       Q_exc*/
    Word16 excO[],         /* out: excitation buffer       Q_exc*/
    const Word16 T0,       /* input : integer pitch lag    Q0*/
    Word16 frac,           /* input : fraction of lag      Q0*/
    const Word16 L_subfr,  /* input : subframe size        Q0*/
    const Word32 *win,     /* i  : interpolation window    Q31*/
    const Word16 nb_coef,  /* i  : nb of filter coef       Q0*/
    const Word16 up_sample /* i  : up_sample               Q0*/
);
void pred_lt4_tc_fx(
    Word16 exc[],         /* i/o: excitation buffer        Q0*/
+12 −0
Original line number Diff line number Diff line
@@ -1332,6 +1332,18 @@ const Word16 inter4_2_fx[] =
};
/* 1/4 resolution interpolation filter (-3 dB at 0.856*fs/2) */
const Word32 L_pitch_inter4_2[PIT_FIR_SIZE2] = { /* Q31 */
    2018634624, 1839083520, 1357785216, 724904576, 126856152, -281447072,
    -428193216, -340524320, -121030032, 102233104, 229241728, 222704784,
    111802296, -32603096, -136805440, -158183648, -99851544, -2110976,
    82091856, 114123720, 86026048, 19988778, -46544560, -81104016,
    -71266392, -27977416, 22982370, 55621972, 56517476, 29680372,
    -7827578, -36105644, -42638288, -27414776, -1138166, 21646636,
    30326764, 22885734, 5570572, -11516955, -20066088, -17396766,
    -6833293, 5003637, 12101070, 11944304, 6107443, -1346472, -6427418,
    -7219840, -4389456, -249108, 2823941, 3633542, 2471753, 556198,
    -895500, -1327144, -932007, -285615, 135291, 210453, 103079, 15032, 0
};
const Word16 pitch_inter4_2[PIT_FIR_SIZE2] =
{
  /* cut-off frequency at 0.94*fs/2 */
Loading