Commit 8134a30e authored by Nicolas Roussin's avatar Nicolas Roussin
Browse files

Merge branch 'main' into 2142-implement-basop-w_min-and-w_max-functions

parents 22e767ac 94987666
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ target_include_directories(lib_util PRIVATE lib_lc3plus lib_isar)

if(NOT WMOPS)
  add_executable(ivas_lc3plus_unit_test ${CMAKE_SOURCE_DIR}/scripts/split_rendering/lc3plus_basop/ivas_lc3plus_unit_test.c)
  target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_basop lib_com lib_debug lib_isar)
  target_link_libraries(ivas_lc3plus_unit_test lib_rend lib_dec lib_util lib_com lib_basop lib_debug lib_isar)
endif()

file(GLOB libISARSrcs "lib_isar/*.c")
+11 −11
Original line number Diff line number Diff line
@@ -109,19 +109,20 @@
    <ClCompile Include="..\lib_lc3plus\basop_mpy_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\basop_util_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\constants.c" />
    <ClCompile Include="..\lib_lc3plus\com_entropy.c" />
    <ClCompile Include="..\lib_lc3plus\cutoff_bandwidth.c" />
    <ClCompile Include="..\lib_lc3plus\dct2_fx.c" />
    <ClCompile Include="..\lib_lc3plus\dct4_fx.c" />
    <ClCompile Include="..\lib_lc3plus\dec_entropy.c" />
    <ClCompile Include="..\lib_lc3plus\dec_lc3.c" />
    <ClCompile Include="..\lib_lc3plus\dec_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\detect_cutoff_warped_fx.c" />
    <ClCompile Include="..\lib_lc3plus\dynmem.c" />
    <ClCompile Include="..\lib_lc3plus\enc_entropy.c" />
    <ClCompile Include="..\lib_lc3plus\enc_lc3.c" />
    <ClCompile Include="..\lib_lc3plus\enc_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\estimate_global_gain_fx.c" />
    <ClCompile Include="..\lib_lc3plus\fft_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\imdct_fx.c" />
    <ClCompile Include="..\lib_lc3plus\lc3.c" />
    <ClCompile Include="..\lib_lc3plus\lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\levinson_fx.c" />
    <ClCompile Include="..\lib_lc3plus\ltpf_coder_fx.c" />
    <ClCompile Include="..\lib_lc3plus\ltpf_decoder_fx.c" />
@@ -166,8 +167,9 @@
    <ClCompile Include="..\lib_lc3plus\residual_decoding_fx.c" />
    <ClCompile Include="..\lib_lc3plus\rom_basop_util_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\scale_signal24_fx.c" />
    <ClCompile Include="..\lib_lc3plus\setup_dec_lc3.c" />
    <ClCompile Include="..\lib_lc3plus\setup_enc_lc3.c" />
    <ClCompile Include="..\lib_lc3plus\setup_com_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\setup_dec_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\setup_enc_lc3plus.c" />
    <ClCompile Include="..\lib_lc3plus\sns_compute_scf_fx.c" />
    <ClCompile Include="..\lib_lc3plus\sns_interpolate_scf_fx.c" />
    <ClCompile Include="..\lib_lc3plus\sns_quantize_scf_fx.c" />
@@ -181,13 +183,11 @@
    <ClInclude Include="..\lib_lc3plus\defines.h" />
    <ClInclude Include="..\lib_lc3plus\dynmem.h" />
    <ClInclude Include="..\lib_lc3plus\functions.h" />
    <ClInclude Include="..\lib_lc3plus\lc3.h" />
    <ClInclude Include="..\lib_lc3plus\lc3plus.h" />
    <ClInclude Include="..\lib_lc3plus\license.h" />
    <ClInclude Include="..\lib_lc3plus\rom_basop_util_lc3plus.h" />
    <ClInclude Include="..\lib_lc3plus\setup_dec_lc3.h" />
    <ClInclude Include="..\lib_lc3plus\setup_enc_lc3.h" />
    <ClInclude Include="..\lib_lc3plus\tinywavein_c.h" />
    <ClInclude Include="..\lib_lc3plus\tinywaveout_c.h" />
    <ClInclude Include="..\lib_lc3plus\setup_dec_lc3plus.h" />
    <ClInclude Include="..\lib_lc3plus\setup_enc_lc3plus.h" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  <ImportGroup Label="ExtensionTargets">
+3 −1
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@
    </Lib>
  </ItemDefinitionGroup>
  <ItemGroup>
    <ClCompile Include="..\lib_rend\ivas_cldfb_ring_buffer.c" />
    <ClCompile Include="..\lib_rend\ivas_dirac_decorr_dec_fx.c" />
    <ClCompile Include="..\lib_rend\ivas_dirac_dec_binaural_functions_fx.c" />
    <ClCompile Include="..\lib_rend\ivas_dirac_onsets_dec_fx.c" />
@@ -175,6 +176,7 @@
    <ClCompile Include="..\lib_rend\ivas_rom_rend_fx.c" />
    <ClCompile Include="..\lib_rend\ivas_shoebox_fx.c" />
    <ClCompile Include="..\lib_rend\ivas_td_decorr_fx.c" />
    <ClCompile Include="..\lib_rend\ivas_td_ring_buffer_fx.c" />
    <ClCompile Include="..\lib_rend\ivas_vbap_fx.c" />
    <ClCompile Include="..\lib_rend\lib_rend_fx.c" />
  </ItemGroup>
+3 −0
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@
    <ClCompile Include="..\lib_rend\ivas_td_decorr_fx.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_cldfb_ring_buffer.c">
      <Filter>rend_c</Filter>
    </ClCompile>
    <ClCompile Include="..\lib_rend\ivas_vbap_fx.c">
      <Filter>rend_c</Filter>
    </ClCompile>
+124 −13
Original line number Diff line number Diff line
@@ -158,7 +158,11 @@ typedef struct
static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
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 hIvasDec, int16_t *pcmBuf );
#else
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ObjectEditFileReader *objectEditFileReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
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 );

@@ -632,7 +636,11 @@ int main(

    if ( arg.voipMode )
    {
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, &splitRendBits, hIvasDec, pcmBuf );
#else
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, objectEditFileReader, hIvasDec, pcmBuf );
#endif
    }
    else
    {
@@ -1701,7 +1709,11 @@ static ivas_error initOnFirstGoodFrame(

    for ( int16_t i = 0; i < numInitialBadFrames; ++i )
    {
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
        if ( isSplitRend )
#else
        if ( *splitRendWriter != NULL )
#endif
        {
            ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero;
            splitRendBitsZero.bits_buf = NULL;
@@ -1719,7 +1731,12 @@ static ivas_error initOnFirstGoodFrame(
                return error;
            }
        }

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
        if ( !isSplitCoded )
#else
        else
#endif
        {
            if ( *pRemainingDelayNumSamples < *numOutSamples )
            {
@@ -1919,6 +1936,14 @@ static ivas_error decodeG192(
        return error;
    }

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    if ( !isSplitRend )
    {
        /* Ensure split rendering output struct is not used when not outputting to a split rendering output configuration */
        splitRendBits = NULL;
    }
#endif

    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 );
@@ -2180,7 +2205,11 @@ static ivas_error decodeG192(
                }

                /* decode transport channels, do TSM and feed to renderer */
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
                if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, splitRendBits ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
@@ -2622,6 +2651,9 @@ static ivas_error decodeVoIP(
    RotFileReader *refRotReader,
    Vector3PairFileReader *referenceVectorReader,
    ObjectEditFileReader *objectEditFileReader,
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
#endif
    IVAS_DEC_HANDLE hIvasDec,
    int16_t *pcmBuf )
{
@@ -2671,6 +2703,29 @@ static ivas_error decodeVoIP(
    bool parametersAvailableForEditing = false;
    uint16_t nSamplesRendered;

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    SplitFileReadWrite *splitRendWriter = NULL;
    int16_t isSplitRend, isSplitCoded;

    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 ( !isSplitRend )
    {
        /* Ensure split rendering output struct is not used when not outputting to a split rendering format */
        splitRendBits = NULL;
    }

    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;
    }
#endif

    vec_pos_update = 0;
    if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK )
    {
@@ -2962,6 +3017,22 @@ static ivas_error decodeVoIP(
        /* decode and get samples */
        while ( nSamplesRendered < nOutSamples )
        {
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
            if ( isSplitRend )
            {
#ifdef SUPPORT_JBM_TRACEFILE
                if ( ( error = IVAS_DEC_VoIP_GetSplitBinauralBitstream( hIvasDec, (void *) pcmBuf, splitRendBits, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, &parametersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_VoIP_GetSplitBinauralBitstream( hIvasDec, (void *) pcmBuf, splitRendBits, &bitstreamReadDone, &nSamplesRendered, &parametersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSplitBinauralBitstream: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            }
            else
            {
#endif
#ifdef SUPPORT_JBM_TRACEFILE
                if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, &parametersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK )
#else
@@ -2971,6 +3042,9 @@ static ivas_error decodeVoIP(
                    fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
            }
#endif

            if ( bitstreamReadDone == true )
            {
@@ -3050,9 +3124,15 @@ static ivas_error decodeVoIP(
            /* Once good frame decoded, catch up */
            if ( decodedGoodFrame )
            {
#ifndef FIX_1119_SPLIT_RENDERING_VOIP
                SplitFileReadWrite *splitRendWriter = NULL;

#endif
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale,
#else
                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale,
#endif
                                                     &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK )
                {
                    goto cleanup;
@@ -3067,6 +3147,19 @@ static ivas_error decodeVoIP(
        /* Write current frame */
        if ( decodedGoodFrame )
        {
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
            if ( isSplitRend )
            {
                if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nUnable to write to bitstream file!\n" );
                    goto cleanup;
                }
            }

            if ( !isSplitCoded )
            {
#endif
                if ( delayNumSamples < nOutSamples )
                {
                    if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK )
@@ -3080,6 +3173,9 @@ static ivas_error decodeVoIP(
                {
                    delayNumSamples -= nOutSamples;
                }
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
            }
#endif

            /* Write ISM metadata to external file(s) */
            if ( decodedGoodFrame && arg.outputConfig == IVAS_AUDIO_CONFIG_EXTERNAL )
@@ -3167,7 +3263,11 @@ static ivas_error decodeVoIP(
        goto cleanup;
    }

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    if ( nSamplesFlushed && !isSplitCoded )
#else
    if ( nSamplesFlushed )
#endif
    {
        /* Write current frame */
        if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK )
@@ -3238,11 +3338,19 @@ static ivas_error decodeVoIP(
     *------------------------------------------------------------------------------------------*/

    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );

#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    if ( afWriter != NULL )
    {
#endif
        if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
            goto cleanup;
        }
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Printouts after decoding has finished
@@ -3287,6 +3395,9 @@ cleanup:

    EVS_RTPDUMP_DEPACKER_close( &rtpdumpDepacker );
    AudioFileWriter_close( &afWriter );
#ifdef FIX_1119_SPLIT_RENDERING_VOIP
    split_rend_reader_writer_close( &splitRendWriter );
#endif
    JbmOffsetFileWriter_close( &jbmOffsetWriter );
#ifdef SUPPORT_JBM_TRACEFILE
    JbmTraceFileWriter_close( &jbmTraceWriter );
Loading