Commit a1c10ea3 authored by Devansh Kandpal's avatar Devansh Kandpal
Browse files

Merge branch 'ivas-float-update' of...

Merge branch 'ivas-float-update' of https://forge.3gpp.org/rep/sa4/audio/ivas-basop into 1863_ref_port_fl1678
parents d5377f98 8435dd9f
Loading
Loading
Loading
Loading
Loading
+45 −38
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ int main(
    {
        if ( ( error = IVAS_DEC_EnableSplitRendering( hIvasDec ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            fprintf( stderr, "\nSplit rendering configure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

@@ -638,6 +638,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;
        }

#ifdef CONF_DISTATT
        if ( ( error = RenderConfigReader_getDistanceAttenuation( renderConfigReader, renderConfig.distAtt ) ) != IVAS_ERR_OK )
        {
@@ -645,8 +646,8 @@ int main(
            goto cleanup;
        }
#endif
        if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ||
               arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )

        if ( ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
        {
            if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS &&
                 ( renderConfig.split_rend_config.poseCorrectionMode == ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ||
@@ -696,6 +697,7 @@ int main(
            }
            renderConfig.roomAcoustics.override = true;
        }

        /* ISAR frame size is set from command line, not renderer config file.
         * This will be ignored if output format is not split rendering. */
        renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5;
@@ -1444,7 +1446,7 @@ static bool parseCmdlIVAS_dec(
            arg->outputMdFilename = argv[i + 1];
            if ( arg->outputMdFilename[0] == '\0' )
            {
                fprintf( stderr, "Error: output metadata file path not specified\n\n" );
                fprintf( stderr, "Error: Split rendering output metadata file path not specified\n\n" );
                usage_dec();
                return false;
            }
@@ -1895,6 +1897,7 @@ static ivas_error initOnFirstGoodFrame(
    uint16_t *pNumObj,                               /* o  : */
    SplitFileReadWrite **splitRendWriter )
{
    int16_t isSplitRend, isSplitCoded;
    ivas_error error = IVAS_ERR_UNKNOWN;

    /* Now delay, number of output channels and frame size are known */
@@ -1904,7 +1907,19 @@ static ivas_error initOnFirstGoodFrame(
        return error;
    }

    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error );
        return error;
    }

    if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error );
        return error;
    }

    if ( isSplitRend )
    {
        pFullDelayNumSamples[0] = 0;
    }
@@ -1929,7 +1944,7 @@ static ivas_error initOnFirstGoodFrame(
        return error;
    }

    if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
    if ( isSplitRend )
    {
        /* Open split rendering metadata writer */
        int16_t delayNumSamples_temp[3];
@@ -1946,29 +1961,15 @@ static ivas_error initOnFirstGoodFrame(
            return error;
        }

        if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec,
                                                             &splitRendCodec,
                                                             &poseCorrection,
                                                             &splitRendIsarFrameSizeMs,
                                                             &splitRendCodecFrameSizeMs,
                                                             &lc3plusHighRes ) ) != IVAS_ERR_OK )
        if ( ( error = IVAS_DEC_GetSplitRendBitstreamHeader( hIvasDec, &splitRendCodec, &poseCorrection, &splitRendIsarFrameSizeMs, &splitRendCodecFrameSizeMs, &lc3plusHighRes ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nUnable to get split renderer bitstream header: %s\n", ivas_error_to_string( error ) );
            return error;
        }

        if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) )
        if ( isSplitCoded )
        {
            if ( ( error = split_rend_writer_open( splitRendWriter,
                                                   arg.outputWavFilename,
                                                   delayNumSamples_temp[0],
                                                   delayTimeScale_temp,
                                                   splitRendCodec,
                                                   poseCorrection,
                                                   splitRendCodecFrameSizeMs,
                                                   splitRendIsarFrameSizeMs,
                                                   arg.output_Fs,
                                                   lc3plusHighRes ) ) != IVAS_ERR_OK )
            if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename );
                return error;
@@ -1982,16 +1983,7 @@ static ivas_error initOnFirstGoodFrame(
                return IVAS_ERR_INVALID_SPLIT_REND_CONFIG;
            }

            if ( ( error = split_rend_writer_open( splitRendWriter,
                                                   arg.outputMdFilename,
                                                   delayNumSamples_temp[0],
                                                   delayTimeScale_temp,
                                                   splitRendCodec,
                                                   poseCorrection,
                                                   splitRendCodecFrameSizeMs,
                                                   splitRendIsarFrameSizeMs,
                                                   arg.output_Fs,
                                                   lc3plusHighRes ) ) != IVAS_ERR_OK )
            if ( ( error = split_rend_writer_open( splitRendWriter, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp, splitRendCodec, poseCorrection, splitRendCodecFrameSizeMs, splitRendIsarFrameSizeMs, arg.output_Fs, lc3plusHighRes ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nUnable to open output split rendering metadata file %s\n", arg.outputWavFilename );
                return error;
@@ -1999,7 +1991,7 @@ static ivas_error initOnFirstGoodFrame(
        }
    }

    if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 )
    if ( !isSplitCoded )
    {
        /* Open audio writer and write all previously skipped bad frames now that frame size is known */
        if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK )
@@ -2213,10 +2205,23 @@ static ivas_error decodeG192(
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
    int16_t vec_pos_update, vec_pos_len;
    SplitFileReadWrite *splitRendWriter = NULL;
    int16_t isSplitRend, isSplitCoded;
#ifdef FIX_1053_REVERB_RECONFIGURATION
    IVAS_RENDER_CONFIG_DATA renderConfig;
    RenderConfigReader *renderConfigReader = NULL;

    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error );
        return error;
    }

    if ( ( error = IVAS_DEC_is_split_rendering_coded_out( hIvasDec, &isSplitCoded ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error );
        return error;
    }

    if ( arg.renderConfigEnabled )
    {
        if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK )
@@ -2238,6 +2243,7 @@ static ivas_error decodeG192(
        }
    }
#endif

    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
        ismWriters[i] = NULL;
@@ -2246,7 +2252,6 @@ static ivas_error decodeG192(
    /* we always start with needing a new frame */
    needNewFrame = true;


    if ( !arg.quietModeEnabled )
    {
        fprintf( stdout, "\n------ Running the decoder ------\n\n" );
@@ -2524,7 +2529,7 @@ static ivas_error decodeG192(
                }
            }

            if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
            if ( isSplitRend )
            {
                if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
                {
@@ -2592,7 +2597,7 @@ static ivas_error decodeG192(
        /* Write current frame */
        if ( decodedGoodFrame )
        {
            if ( IVAS_DEC_is_split_rendering_enabled( hIvasDec ) )
            if ( isSplitRend )
            {
                if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK )
                {
@@ -2601,7 +2606,7 @@ static ivas_error decodeG192(
                }
            }

            if ( IVAS_DEC_is_split_rendering_coded_out( hIvasDec ) == 0 )
            if ( !isSplitCoded )
            {
                if ( delayNumSamples < nOutSamples )
                {
@@ -2662,11 +2667,13 @@ static ivas_error decodeG192(
                    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 )
+6 −0
Original line number Diff line number Diff line
@@ -3547,14 +3547,20 @@ static void parseCombinedFormatInput(
        inConfig->numAmbisonicsBuses = 1;
        inConfig->ambisonicsBuses[0].audioConfig = audioConfig;
        inConfig->ambisonicsBuses[0].inputChannelIndex = inConfig->numAudioObjects;
#ifdef NONBE_1352_HARMONIZE_OSBA_LOUDNESS
        inConfig->ambisonicsBuses[0].gain_dB = 0.f;
#else
        inConfig->ambisonicsBuses[0].gain_dB = -6.f;
#endif
        *configString += 4;

        /* Modify input gain for objects too */
#ifndef NONBE_1352_HARMONIZE_OSBA_LOUDNESS
        for ( int16_t i = 0; i < inConfig->numAudioObjects; ++i )
        {
            inConfig->audioObjects[i].gain_dB = -6.f;
        }
#endif
    }
    else if ( audioConfig == IVAS_AUDIO_CONFIG_MASA1 || audioConfig == IVAS_AUDIO_CONFIG_MASA2 )
    {
+15 −11
Original line number Diff line number Diff line
@@ -3286,7 +3286,6 @@ uint16_t get_indice_1(
    return st->bit_stream[pos];
}

#define WMC_TOOL_SKIP

/*-------------------------------------------------------------------*
 * reset_indices_enc()
@@ -4719,8 +4718,9 @@ ivas_error preview_indices(
/*-------------------------------------------------------------------*
 * read_indices()
 *
 * Read indices from an ITU-T G.192 bitstream to the buffer
 * Simulate packet losses by inserting frame erasures
 * Detect SID, NO_DATA, BFI, etc. and set bitstream pointers
 * Set ivas_total_brate
 * Note: each bit is represented in bitsream buffer as a uint16_t of value 0 or 1
 *-------------------------------------------------------------------*/

/*! r: 1 = reading OK, 0 = problem */
@@ -4765,8 +4765,8 @@ ivas_error read_indices(
    /* convert the frame length to total bitrate */
    total_brate = (int32_t) ( num_bits * FRAMES_PER_SEC );

    /*  verify that a  valid  num bits value  is present in the G.192 file */
    /*  only AMRWB, EVS or IVAS bitrates or 0(NO DATA) are  allowed  in G.192 file frame reading  */
    /*  verify that a  valid  num bits value  is present */
    /*  only AMRWB, EVS or IVAS bitrates or 0 (NO DATA) are allowed */
    if ( st_ivas->ivas_format != MONO_FORMAT )
    {
        k = 0;
@@ -4785,7 +4785,7 @@ ivas_error read_indices(
        }
        else if ( k == SIZE_IVAS_BRATE_TBL )
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the  G.192 frame ! Exiting ! \n", total_brate );
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) detected! Exiting ! \n", total_brate );
        }
        else
        {
@@ -4798,12 +4798,12 @@ ivas_error read_indices(

        if ( rate2EVSmode( total_brate, NULL ) < 0 ) /* negative value means that a valid rate was not found */
        {
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in  the  G.192 frame ! Exiting ! \n", total_brate );
            return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) detected! Exiting ! \n", total_brate );
        }
    }

    /* G.192 RX DTX handler*/
    /* handle SID_FIRST, SID_BAD, SPEECH_LOST,  NO_DATA as properly  as possible for the ITU-T  G.192 format  */
    /* RX DTX handler*/
    /* handle SID_FIRST, SID_BAD, SPEECH_LOST,  NO_DATA */
    /* (total_brate, bfi , st_CNG)   =  rx_handler(received frame type, [previous frame type],  past CNG state, past core) */
    curr_ft_good_sp = 0;
    curr_ft_bad_sp = 0;
@@ -4977,6 +4977,7 @@ ivas_error read_indices(
    return error;
}


/*-------------------------------------------------------------------*
 * get_rfFrameType()
 *
@@ -5003,6 +5004,7 @@ static void get_rfFrameType(
    return;
}


/*-------------------------------------------------------------------*
 * get_rfFlag()
 *
@@ -5058,6 +5060,7 @@ static void get_rfFlag(
    return;
}


/*-------------------------------------------------------------------*
 * get_rf_fec_offset()
 *
@@ -5093,6 +5096,7 @@ static void get_rf_fec_offset(
    return;
}


/*-------------------------------------------------------------------*
 * get_rfTargetBits()
 *
@@ -5141,6 +5145,7 @@ static void get_rfTargetBits(
    return;
}


/*-------------------------------------------------------------------*
 * berCheck()
 *
@@ -5168,6 +5173,7 @@ static void berCheck(
    return;
}


/*-------------------------------------------------------------------*
 * getPartialCopyInfo()
 *
@@ -5394,5 +5400,3 @@ void dtx_read_padding_bits(

    return;
}

#undef WMC_TOOL_SKIP
+1 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ typedef struct _ISAR_SPLIT_REND_CONFIG
                                 2 - (2dof correction. By default YAW and PITCH correction)
                                 3 - (3dof correction. By default YAW, PITCH and ROLL correction)
                                 */
    int16_t codec_delay_ms;      /*PLACEHOLDER (currently being ignored) : look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/
    int16_t codec_delay_ms;      /* look ahead delay of the codec that is used to code BIN signal output of pre-renderer*/
    int16_t isar_frame_size_ms;  /* ISAR bit stream frame size in milliseconds */
    int16_t codec_frame_size_ms; /* Codec frame size in milliseconds, only relevant with LC3plus */
    ISAR_SPLIT_REND_POSE_CORRECTION_MODE poseCorrectionMode;
+6 −6
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ int32_t get_delay(
    const int32_t io_fs,                    /* i  : input/output sampling frequency     */
    const IVAS_FORMAT ivas_format,          /* i  : IVAS format                         */
    HANDLE_CLDFB_FILTER_BANK hCldfb,        /* i  : Handle of Cldfb analysis            */
    const AUDIO_CONFIG output_config /* i  : decoder output config              */
    const int16_t flag_binaural_split_coded /* i  : split rendering on/off flag         */
)
{
    int32_t delay = 0;
@@ -98,7 +98,7 @@ int32_t get_delay(
        {
            delay = IVAS_DEC_DELAY_NS;

            if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
            if ( !flag_binaural_split_coded )
            {
                if ( hCldfb != NULL )
                {
Loading