Commit e9b82f91 authored by multrus's avatar multrus
Browse files

merge from main

parents 8c4cbf5a e3d6b8bb
Loading
Loading
Loading
Loading
Loading
+114 −4
Original line number Diff line number Diff line
@@ -163,6 +163,9 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE *phIvasDec, int16_t *pcmBuf );
static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs );
static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );
#ifdef FIX_FMSW_DEC_EXT
static ivas_error updateOnFormatSwitching( IVAS_DEC_HANDLE hIvasDec, IVAS_DEC_BS_FORMAT *pBsFormat, const char *outputWavFilename, MasaFileWriter **ppMasaWriter, IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], int16_t *pNumOutChannels, uint16_t *pNumObj, const bool delayCompensationEnabled );
#endif


/*------------------------------------------------------------------------------------------*
@@ -203,7 +206,6 @@ int main(
    reset_mem( USE_BYTES );
#endif


    splitRendBits.bits_buf = splitRendBitsBuf;

    /*------------------------------------------------------------------------------------------*
@@ -453,7 +455,6 @@ int main(
        }
    }


    /*-------------------------------------------------------------------*
     * Load renderer configuration from file
     *--------------------------------------------------------------------*/
@@ -538,6 +539,7 @@ int main(
            fprintf( stderr, "Failed to get directivity patterns for one or more of IDs: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] );
            goto cleanup;
        }

        if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt_fx ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to get Distance Attenuation \n\n" );
@@ -608,6 +610,7 @@ int main(
            hLsCustomData.azimuth_fx[i] = (Word32) ( hLsCustomData.azimuth[i] * ( 1u << 22 ) );
            hLsCustomData.elevation_fx[i] = (Word32) ( hLsCustomData.elevation[i] * ( 1u << 22 ) );
        }

        if ( ( error = IVAS_DEC_FeedCustomLsData( hIvasDec, hLsCustomData ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedCustomLsData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -686,7 +689,6 @@ int main(
        goto cleanup;
    }


    /*------------------------------------------------------------------------------------------*
     * Close files and deallocate resources
     *------------------------------------------------------------------------------------------*/
@@ -734,7 +736,6 @@ cleanup:
    print_wmops();
    print_mem( NULL );
#endif

    if ( !arg.quietModeEnabled )
    {
        printf( "\n" );
@@ -2026,7 +2027,11 @@ static ivas_error decodeG192(
    int16_t isSplitRend, isSplitCoded;
    IVAS_RENDER_CONFIG_DATA renderConfig;
    RenderConfigReader *renderConfigReader = NULL;
#ifdef FIX_FMSW_DEC_EXT
    bool restartNeeded = false;
#else
    bool restartNeeded;
#endif

#ifdef VARIABLE_SPEED_DECODING
    if ( arg.tsmEnabled )
@@ -2117,6 +2122,7 @@ static ivas_error decodeG192(
        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" );
@@ -2412,6 +2418,18 @@ static ivas_error decodeG192(
            }
        }

#ifdef FIX_FMSW_DEC_EXT
        /* Output writing update in case of format switching and EXTERNAL output */
        if ( restartNeeded && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL )
        {
            if ( ( error = updateOnFormatSwitching( hIvasDec, &bsFormat, arg.outputWavFilename, &masaWriter, ismWriters, &nOutChannels, &numObj, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error in updateOnFormatSwitching(): %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }
#endif

        /* Write current frame */
        if ( decodedGoodFrame )
        {
@@ -2805,7 +2823,11 @@ static ivas_error decodeVoIP(
    int16_t i;
    IVAS_DEC_HANDLE hIvasDec = *phIvasDec;

#ifdef FIX_FMSW_DEC_EXT
    bool restartNeeded = false;
#else
    bool restartNeeded;
#endif
    IVAS_RTP ivasRtp = { 0 };
    IVAS_RTP srRtp = { 0 };
    IVAS_RTP_SR_INFO srInfo = { true, false, 0, 20, IVAS_SR_TRANSPORT_LCLD };
@@ -3292,6 +3314,18 @@ static ivas_error decodeVoIP(
            }
        }

#ifdef FIX_FMSW_DEC_EXT
        /* Output writing update in case of format switching and EXTERNAL output */
        if ( restartNeeded && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL )
        {
            if ( ( error = updateOnFormatSwitching( hIvasDec, &bsFormat, arg.outputWavFilename, &masaWriter, ismWriters, &nOutChannels, &numObj, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "Error in updateOnFormatSwitching(): %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
            }
        }
#endif

        /* Write current frame */
        if ( !srRtp.hPack && decodedGoodFrame )
        {
@@ -3900,4 +3934,80 @@ static ivas_error load_hrtf_from_file(
    return IVAS_ERR_OK;
}

#ifdef FIX_FMSW_DEC_EXT

/*---------------------------------------------------------------------*
 * updateOnFormatSwitching()
 *
 * In case of IVAS format switching and EXTERNAL output,
 * update decoder wrt. output writing
 *---------------------------------------------------------------------*/

static ivas_error updateOnFormatSwitching(
    IVAS_DEC_HANDLE hIvasDec,                        /* i/o: IVAS decoder handle                             */
    IVAS_DEC_BS_FORMAT *pBsFormat,                   /* o  : format of currently decoded bitstream           */
    const char *outputWavFilename,                   /* i  : name of the output audio file                   */
    MasaFileWriter **ppMasaWriter,                   /* o  : MasaFileWriter handle                           */
    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o  : 1-4 ismWriters handles                          */
    int16_t *pNumOutChannels,                        /* o  : number of output channels                       */
    uint16_t *pNumObj,                               /* o  : number of ISM objects                           */
    const bool delayCompensationEnabled              /* i  : is delay compensation enabled                   */
)
{
    ivas_error error;

    /* in case of EXT output, the number of output audio channels can change */
    if ( ( error = IVAS_DEC_GetNumOutputChannels( hIvasDec, pNumOutChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_GetNumOutputChannels, code: %d\n", error );
        return error;
    }

    /* Get the format of currently decoded bitstream */
    if ( ( error = IVAS_DEC_GetFormat( hIvasDec, pBsFormat ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_GetFormat, code: %d\n", error );
        return error;
    }

    *pNumObj = 0;
    if ( *pBsFormat == IVAS_DEC_BS_OBJ || *pBsFormat == IVAS_DEC_BS_MASA_ISM || *pBsFormat == IVAS_DEC_BS_SBA_ISM )
    {
        if ( ( error = IVAS_DEC_GetNumObjects( hIvasDec, pNumObj ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_DEC_GetNumObjects: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            return error;
        }

        /* If outputting ISM/OMASA/OSBA, ensure the output metadata files are opened */
        for ( int16_t i = 0; i < *pNumObj; ++i )
        {
            if ( ismWriters[i] == NULL )
            {
                if ( ( error = IsmFileWriter_open( outputWavFilename, i, &ismWriters[i] ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError: Error opening ISM decoded metadata file %s\n", IsmFileWriter_getFilePath( ismWriters[i] ) );
                    return error;
                }
            }
        }
    }

    /* If outputting MASA, ensure the output file metadata is opened */
    if ( *pBsFormat == IVAS_DEC_BS_MASA || *pBsFormat == IVAS_DEC_BS_MASA_ISM )
    {
        if ( ppMasaWriter != NULL )
        {
            if ( ( error = MasaFileWriter_open( outputWavFilename, delayCompensationEnabled, ppMasaWriter ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nError: Error opening MASA decoded metadata file %s\n", MasaFileWriter_getFilePath( *ppMasaWriter ) );
                return error;
            }
        }
    }

    return IVAS_ERR_OK;
}
#endif

#undef WMC_TOOL_SKIP
+4 −0
Original line number Diff line number Diff line
@@ -716,7 +716,11 @@ void tdm_SCh_LSF_intra_pred_fx(
        fixed_beta = 30801; // 0.94f in Q15
        move16();
    }
#ifndef FIX_ISSUE_2613_WRONG_COMP_MACRO
    ELSE IF( element_brate <= IVAS_24k4 )
#else
    ELSE IF( LE_32( element_brate, IVAS_24k4 ) )
#endif // !FIX_ISSUE_2613_WRONG_COMP_MACRO
    {
        fixed_beta = 29818; // 0.91f in Q15
        move16();
+4 −0
Original line number Diff line number Diff line
@@ -96,6 +96,9 @@
#define HARMONIZE_2598_tcx_arith_decode_envelope        /* FhG: harmonize tcx_arith_decode_envelope between EVS and IVAS versions */
#define HARMONIZE_2598_tcx_arith_encode_envelope        /* FhG: harmonize tcx_arith_encode_envelope between EVS and IVAS versions */
#define FIX_ISSUE_2594_FALSE_COMMENT                    /* FhG: basop issue 2594: fixing false comments about Q value*/
#define FIX_ISSUE_2616_BOUNDARY_CONDITION               /* FhG: basop issue 2616: Inconsistent boundary conditions in function stereo_dft_dequantize_res_gains*/
#define FIX_ISSUE_2613_WRONG_COMP_MACRO                 /* FhG: basop issue 2613: Inconsistent comparison macros in function tdm_SCh_LSF_intra_pred_fx*/
#define FIX_ISSUE_2611_WRONG_COMMENT                    /* FhG: basop issue 2611: Wrong Q value comment in fucntion stereo_dft_sg_recovery_fx()*/
#define FIX_BASOP_2550_TCX_ENC_MEM_UPDATE               /* FhG: fix condition in tcx_encoder_memory_update_*_fx(), bring inline with float */

/* #################### End BE switches ################################## */
@@ -107,6 +110,7 @@
#define FIX_BASOP_2599_TCA_OVERFLOW                     /* VA: issue 2599, Fix TCA overflow */
#define FIX_2588_MISSING_CONDITIONS                     /* VA: Proposed fix to 2588, addition of a condition in lsf_dec */
#define FIX_BASOP_2442_MASA2TC_TO_MONO_AND_AMBI         /* Nokia: BASOP issue 2442: Increase accuracy of computations and add additional gain clamp for low energy decorrelated signal rendering. */
#define FIX_FMSW_DEC_EXT                                /* float issue 1566: fix EXT output in format switching */

/* ##################### End NON-BE switches ########################### */

+8 −0
Original line number Diff line number Diff line
@@ -445,7 +445,11 @@ static void stereo_dft_dequantize_res_gains_fx(
        move16();
        ind2[i] = check_bounds_s_fx( ind2[i], 0, 7 ); /* Q0 */
        move16();
#ifndef FIX_ISSUE_2616_BOUNDARY_CONDITION
        IF( LE_16( ind1[i], 15 ) )
#else
        IF( LT_16( ind1[i], 15 ) )
#endif // !FIX_ISSUE_2616_BOUNDARY_CONDITION
        {
            tmp = sub( 15, ind1[i] );
        }
@@ -456,7 +460,11 @@ static void stereo_dft_dequantize_res_gains_fx(
        // index = add( shl( LE_16( ind1[i], 15 ) ? sub( 15, ind1[i] ) : sub( ind1[i], 15 ), 3 ), ind2[i] );
        index = add( shl( tmp, 3 ), ind2[i] );
        // gout[i] = LE_16( ind1[i], 15 ) ? L_negate( dft_res_gains_q_fx[index][0] ) : dft_res_gains_q_fx[index][0];
#ifndef FIX_ISSUE_2616_BOUNDARY_CONDITION
        IF( LE_16( ind1[i], 15 ) )
#else
        IF( LT_16( ind1[i], 15 ) )
#endif // !FIX_ISSUE_2616_BOUNDARY_CONDITION
        {
            gout[i] = L_negate( dft_res_gains_q_fx[index][0] ); /* Q31 */
            move16();
+4 −0
Original line number Diff line number Diff line
@@ -844,7 +844,11 @@ Word16 stereo_dft_sg_recovery_fx(
        test();
        IF( LT_32( sg_m, (Word32) 0x4CCCCCCD ) && GT_32( sg_m, (Word32) ( 0xB3333333 ) ) )
        {
#ifndef FIX_ISSUE_2611_WRONG_COMMENT
            hStereoDft->sg_mean_fx = 0; /* Q13 */
#else
            hStereoDft->sg_mean_fx = 0; /* Q31 */
#endif // !FIX_ISSUE_2611_WRONG_COMMENT
            move32();
        }
        ELSE