Commit 645633d0 authored by vaclav's avatar vaclav
Browse files

maintenance - port FLP changes to BASOP

parent ac900052
Loading
Loading
Loading
Loading
Loading
+60 −43
Original line number Diff line number Diff line
@@ -1616,6 +1616,38 @@ static void usage_dec( void )
}


/*---------------------------------------------------------------------*
 * resetHeadRotation()
 *
 *
 *---------------------------------------------------------------------*/

static void resetHeadRotation(
    const int16_t num_subframes,  /* i  : number of subframes   */
    IVAS_QUATERNION *pQuaternion, /* o  : head-tracking data    */
    IVAS_VECTOR3 *pPos            /* o  : listener position     */

)
{
    int16_t i;

    for ( i = 0; i < num_subframes; i++ )
    {
        pQuaternion[i].w_fx = -12582912;
        pQuaternion[i].x_fx = 0;
        pQuaternion[i].y_fx = 0;
        pQuaternion[i].z_fx = 0;
        pQuaternion[i].q_fact = 22;
        pPos[i].x_fx = 0;
        pPos[i].y_fx = 0;
        pPos[i].z_fx = 0;
        pPos[i].q_fact = 25;
    }

    return;
}


/*---------------------------------------------------------------------*
 * initOnFirstGoodFrame()
 *
@@ -2093,7 +2125,6 @@ static ivas_error decodeG192(

    while ( 1 )
    {
        /* Read next frame if not enough samples availble */
        /* reference vector */
        if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 )
        {
@@ -2140,18 +2171,7 @@ static ivas_error decodeG192(
        {
            if ( headRotReader == NULL )
            {
                for ( i = 0; i < (int16_t) num_subframes; i++ )
                {
                    Quaternions[i].w_fx = -12582912;
                    Quaternions[i].x_fx = 0;
                    Quaternions[i].y_fx = 0;
                    Quaternions[i].z_fx = 0;
                    Quaternions[i].q_fact = 22;
                    Pos[i].x_fx = 0;
                    Pos[i].y_fx = 0;
                    Pos[i].z_fx = 0;
                    Pos[i].q_fact = 25;
                }
                resetHeadRotation( num_subframes, Quaternions, Pos );
            }
            else
            {
@@ -2327,9 +2347,6 @@ static ivas_error decodeG192(
                    fprintf( stderr, "\nError in IVAS_DEC_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

                nSamplesRendered += nSamplesRendered_loop;
                nSamplesToRender -= nSamplesRendered_loop;
            }
            else
            {
@@ -2338,12 +2355,13 @@ static ivas_error decodeG192(
                    fprintf( stderr, "\nError in IVAS_DEC_GetSamplesRenderer(): %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            }

            nSamplesRendered += nSamplesRendered_loop;
            nSamplesToRender -= nSamplesRendered_loop;
            }

            if ( needNewFrame )
            {

                frame++;
                if ( !arg.quietModeEnabled )
                {
@@ -2352,7 +2370,6 @@ static ivas_error decodeG192(
            }
        } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK );


        if ( error == IVAS_ERR_END_OF_FILE )
        {
            break;
@@ -2412,7 +2429,7 @@ static ivas_error decodeG192(
            }
        }

        /* Write ISm metadata to external file(s) */
        /* 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 )
@@ -2452,6 +2469,7 @@ static ivas_error decodeG192(
                {
                    fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
                }

                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -2486,8 +2504,6 @@ static ivas_error decodeG192(
    {
        int16_t nSamplesFlushed;

        /* Feed into decoder */

        /* reference vector */
        if ( arg.enableReferenceVectorTracking )
        {
@@ -2553,7 +2569,7 @@ static ivas_error decodeG192(
            }
        }

        /* decode and get samples */
        /* flush remaining audio */
        if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -2567,7 +2583,7 @@ static ivas_error decodeG192(
            goto cleanup;
        }

        /* Write ISm metadata to external file(s) */
        /* 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 )
@@ -2606,6 +2622,7 @@ static ivas_error decodeG192(
                {
                    fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
                }

                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -2708,14 +2725,22 @@ cleanup:
    return error;
}


#ifdef SUPPORT_JBM_TRACEFILE
static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer )

/*---------------------------------------------------------------------*
 * writeJbmTraceFileFrameWrapper()
 *
 *
 *---------------------------------------------------------------------*/

static ivas_error writeJbmTraceFileFrameWrapper(
    const void *data,
    void *writer )
{
    return JbmTraceFileWriter_writeFrame( data, writer );
}
#endif

#endif

/*---------------------------------------------------------------------*
 * decodeVoIP()
@@ -2813,11 +2838,13 @@ static ivas_error decodeVoIP(
        fprintf( stderr, "\nError getting render frame size in samples\n" );
        return error;
    }

    if ( ( error = IVAS_DEC_GetRenderFramesizeSamples( hIvasDec, &nOutSamples ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError getting render frame size in samples\n" );
        return error;
    }

    if ( ( error = IVAS_DEC_GetReferencesUpdateFrequency( hIvasDec, &vec_pos_len ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError getting render frame size in samples\n" );
@@ -2983,18 +3010,7 @@ static ivas_error decodeVoIP(
        {
            if ( headRotReader == NULL )
            {
                for ( i = 0; i < (int16_t) num_subframes; i++ )
                {
                    Quaternions[i].w_fx = -12582912;
                    Quaternions[i].x_fx = 0;
                    Quaternions[i].y_fx = 0;
                    Quaternions[i].z_fx = 0;
                    Quaternions[i].q_fact = 22;
                    Pos[i].x = 0.0f;
                    Pos[i].y = 0.0f;
                    Pos[i].z = 0.0f;
                    Pos[i].q_fact = 25;
                }
                resetHeadRotation( num_subframes, Quaternions, Pos );
            }
            else
            {
@@ -3030,8 +3046,7 @@ static ivas_error decodeVoIP(

                if ( ( error = ExternalOrientationFileReading( externalOrientationFileReader, &Quaternions[i], &enableHeadRotation[i], &enableExternalOrientation[i], &enableRotationInterpolation[i], &numFramesToTargetOrientation[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ),
                             RotationFileReader_getFilePath( externalOrientationFileReader ) );
                    fprintf( stderr, "\nError %s while reading external orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), RotationFileReader_getFilePath( externalOrientationFileReader ) );
                    goto cleanup;
                }
            }
@@ -3347,6 +3362,7 @@ static ivas_error decodeVoIP(
                    {
                        fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
                    }

                    if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 1 ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -3418,7 +3434,7 @@ static ivas_error decodeVoIP(
            goto cleanup;
        }

        /* Write ISm metadata to external file(s) */
        /* 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 )
@@ -3458,6 +3474,7 @@ static ivas_error decodeVoIP(
                {
                    fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
                }

                if ( ( error = IVAS_DEC_GetMasaMetadata( hIvasDec, &hMasaExtOutMeta, 0 ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetMasaMetadata: %s\n", IVAS_DEC_GetErrorMessage( error ) );
+10 −8
Original line number Diff line number Diff line
@@ -292,6 +292,8 @@ void tcx_hm_modify_envelope(
        h = add( h, 1 );                                          /* Q0 */
        k = extract_l( L_shr( imult3216( lag, h ), fract_res ) ); /* Q0 */
    }

    return;
}

#undef WMC_TOOL_SKIP
+25 −20
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@
#include "cnst.h"

/* Fixed point implementation of exp(negate()) */
Word32 expfp(                    /* o: Q31 */
/* o: Q31 */
Word32 expfp(
    const Word16 x,    /* i  : mantissa  Q-e */
    const Word16 x_e ) /* i  : exponent  Q0  */
{
@@ -177,6 +178,7 @@ void powfp_odd2(
 * NOTE: This function must be bit-exact on all platforms such that encoder
 * and decoder remain synchronized.
 *-------------------------------------------------------------------------*/

void tcx_arith_scale_envelope(
    const Word16 L_spec_core,    /* i  : number of lines to scale    Q0 */
    Word16 L_frame,              /* i  : number of lines             Q0 */
@@ -412,8 +414,11 @@ void tcx_arith_scale_envelope(
        s_env[k] = round_fx( L_tmp );                        /* Q15 - e */
        move16();
    }

    return;
}


/*------------------------------------------------------------------------
 * Function: tcx_arith_render_envelope
 *
@@ -426,6 +431,7 @@ void tcx_arith_scale_envelope(
 * NOTE: This function must be bit-exact on all platforms such that encoder
 * and decoder remain synchronized.
 *-------------------------------------------------------------------------*/

void tcx_arith_render_envelope(
    const Word16 A_ind[],     /* i  : LPC coefficients of signal envelope            Q12*/
    const Word16 L_frame,     /* i  : number of spectral lines                        Q0*/
@@ -463,10 +469,7 @@ void tcx_arith_render_envelope(
    /* Adaptive low frequency emphasis */
    set32_fx( env, 0x10000 /* 1 in Q16 */, L_frame );

    AdaptLowFreqDeemph( env, 15,
                        1,
                        gainlpc, gainlpc_e,
                        L_frame, NULL );
    AdaptLowFreqDeemph( env, 15, 1, gainlpc, gainlpc_e, L_frame, NULL );

    /* Scale from FDNS_NPTS to L_frame and multiply LFE gains */
    mdct_noiseShaping_interp( env, L_frame, signal_env, signal_env_e );
@@ -476,6 +479,8 @@ void tcx_arith_render_envelope(
        env[k] = env[k - 1]; /* Q16 */
        move32();
    }

    return;
}

#define WMC_TOOL_SKIP
+8 −10
Original line number Diff line number Diff line
@@ -109,6 +109,8 @@ void BITS_ALLOC_init_config_acelp(
        pConfigAcelp->formant_tilt = 0;
        pConfigAcelp->voice_tilt = 2;
    }

    return;
}


@@ -132,7 +134,6 @@ Word16 BITS_ALLOC_config_acelp(
    Word16 i;
    Word16 remaining_bits, bits;


    move16();
    move16();
    move16();
@@ -244,7 +245,6 @@ Word16 BITS_ALLOC_config_acelp(
    }
    bits = add( bits, pConfigAcelp->ltf_bits );


    FOR( i = 0; i < nb_subfr; i++ )
    {
        pConfigAcelp->gains_mode[i] = ACELP_GAINS_MODE[mode_index][band_index][coder_type];
@@ -267,7 +267,6 @@ Word16 BITS_ALLOC_config_acelp(
    }

    /*Innovation*/

    IF( LT_16( bits_frame, bits ) )
    {
        printf( "Warning: bits per frame too low\n" );
@@ -394,6 +393,7 @@ static Word16 BITS_ALLOC_adjust_generic(
    return mult_r( bitsused, inb_subfr );
}


static Word16 BITS_ALLOC_adjust_acelp_fixed_cdk(
    const Word16 bits_frame, /*i  : bit budget*/
    Word16 *fixed_cdk_index,
@@ -401,10 +401,8 @@ static Word16 BITS_ALLOC_adjust_acelp_fixed_cdk(
{
    Word16 bitsused;


    bitsused = BITS_ALLOC_adjust_generic( bits_frame, fixed_cdk_index, nb_subfr, ACELP_CDK_BITS, ACELP_FIXED_CDK_NB );


    return bitsused;
}

+27 −27
Original line number Diff line number Diff line
@@ -605,7 +605,7 @@ void spt_shorten_domain_band_save_fx(
/*--------------------------------------------------------------------------*
 * spt_shorten_domain_band_restore()
 *
 * Restrore the subband information
 * Restore the subband information
 *--------------------------------------------------------------------------*/

void spt_shorten_domain_band_restore_fx(
Loading