Commit fe56c0f3 authored by vaclav's avatar vaclav
Browse files

Merge branch 'main' into 351-hrtf-command-option

parents 27e685ce 5c521ecb
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -112,45 +112,42 @@ project(stereo-evs)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # make Visual Studio projects look nicer
include(CTest)

include_directories(
  lib_com
  lib_debug
  lib_dec
  lib_enc
  lib_rend
  lib_util
)

file(GLOB libComSrcs "lib_com/*.c")
file(GLOB libComHeaders "lib_com/*.h")
add_library(lib_com ${libComSrcs} ${libComHeaders})
if(UNIX)
  target_link_libraries(lib_com m)
endif()
target_include_directories(lib_com PUBLIC lib_com PRIVATE lib_enc lib_dec lib_rend lib_debug)

file(GLOB libDebugSrcs "lib_debug/*.c")
file(GLOB libDebugHeaders "lib_debug/*.h")
add_library(lib_debug ${libDebugSrcs} ${libDebugHeaders})
target_link_libraries(lib_debug lib_com)
target_include_directories(lib_debug PUBLIC lib_debug PRIVATE lib_enc lib_dec lib_rend)

file(GLOB libEncSrcs "lib_enc/*.c")
file(GLOB libEncHeaders "lib_enc/*.h")
add_library(lib_enc ${libEncSrcs} ${libEncHeaders})
target_link_libraries(lib_enc lib_com lib_debug)
target_include_directories(lib_enc PUBLIC lib_enc PRIVATE lib_dec lib_rend)

file(GLOB libRendSrcs "lib_rend/*.c")
file(GLOB libRendHeaders "lib_rend/*.h")
add_library(lib_rend ${libRendSrcs} ${libRendHeaders})
target_link_libraries(lib_rend lib_dec lib_com lib_debug) # Todo refactor: This dependency on lib_dec should be removed.
target_include_directories(lib_rend PUBLIC lib_rend PRIVATE lib_enc)

file(GLOB libDecSrcs "lib_dec/*.c")
file(GLOB libDecHeaders "lib_dec/*.h")
add_library(lib_dec ${libDecSrcs} ${libDecHeaders})
target_link_libraries(lib_dec lib_com lib_rend lib_debug)
target_include_directories(lib_dec PUBLIC lib_dec lib_rend PRIVATE lib_enc)

file(GLOB libUtilSrcs "lib_util/*.c")
file(GLOB libUtilHeaders "lib_util/*.h")
add_library(lib_util ${libUtilSrcs} ${libUtilHeaders})
target_include_directories(lib_util PUBLIC lib_util PRIVATE lib_com lib_enc lib_dec lib_rend lib_debug)

add_executable(IVAS_cod apps/encoder.c)
target_link_libraries(IVAS_cod lib_enc lib_util)
@@ -166,6 +163,7 @@ endif()

add_executable(IVAS_rend apps/renderer.c)
target_link_libraries(IVAS_rend lib_rend lib_util)
target_include_directories(IVAS_rend PRIVATE lib_enc)

if(COPY_EXECUTABLES_FROM_BUILD_DIR)
  # Optionally copy executables to the same place where Make puts them (useful for tests that expect executables in specific places)
+89 −9
Original line number Diff line number Diff line
@@ -105,7 +105,9 @@ typedef struct
    char *renderConfigFilename;

#ifdef DEBUGGING
#ifndef REMOVE_FORCE_SUBFRAME_BIN
    bool forceSubframeBinauralization;
#endif
    IVAS_DEC_FORCED_REND_MODE forcedRendMode;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
@@ -311,6 +313,9 @@ int main(
     * Configure the decoder
     *------------------------------------------------------------------------------------------*/

#ifdef REMOVE_FORCE_SUBFRAME_BIN
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK )
#else
#ifdef DEBUGGING
#ifdef FIX_351_HRTF_COMMAND
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK )
@@ -323,6 +328,7 @@ int main(
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK )
#endif
#endif
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -714,7 +720,9 @@ static bool parseCmdlIVAS_dec(
    float ftmp;

    arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED;
#ifndef REMOVE_FORCE_SUBFRAME_BIN
    arg->forceSubframeBinauralization = false;
#endif
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
#endif
@@ -866,11 +874,13 @@ static bool parseCmdlIVAS_dec(
                i++;
            }
        }
#ifndef REMOVE_FORCE_SUBFRAME_BIN
        else if ( strcmp( argv_to_upper, "-FORCE_SUBFRAME_BIN" ) == 0 ) /* Force binauralization to subframe (5 ms) resolution */
        {
            arg->forceSubframeBinauralization = true;
            i++;
        }
#endif
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
        /*-----------------------------------------------------------------*
@@ -1120,8 +1130,10 @@ static void usage_dec( void )
    fprintf( stdout, "-T File             : Head rotation specified by external trajectory File\n" );
    fprintf( stdout, "-hrtf File          : HRTF filter File used in BINAURAL output configuration\n" );
#ifdef DEBUGGING
#ifndef REMOVE_FORCE_SUBFRAME_BIN
    fprintf( stdout, "-force_subframe_bin : Forces parametric binauralizer code to use 5 ms time resolution even when\n" );
    fprintf( stdout, "                      output time resolution is larger.\n" );
#endif
    fprintf( stdout, "-FEC X              : Insert frame erasures, X = 0-10 is the percentage\n" );
    fprintf( stdout, "                      of erased frames, or X may be the name of binary file or \n" );
    fprintf( stdout, "                      file with G192 headers indicating GOOD FRAME or BAD FRAME\n" );
@@ -1189,9 +1201,17 @@ static ivas_error initOnFirstGoodFrame(
    }
    else
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        pFullDelayNumSamples[0] = 0;
#else
        *pFullDelayNumSamples = 0;
#endif
    }
#ifdef BINAURALIZATION_DELAY_REPORT
    *pRemainingDelayNumSamples = pFullDelayNumSamples[0];
#else
    *pRemainingDelayNumSamples = *pFullDelayNumSamples;
#endif

    if ( ( error = IVAS_DEC_GetNumOutputChannels( hIvasDec, pNumOutChannels ) ) != IVAS_ERR_OK )
    {
@@ -1342,7 +1362,11 @@ static ivas_error decodeG192(
    int16_t numInitialBadFrames = 0; /* Number of bad frames received until first good frame is decoded */
    int16_t nOutChannels = 0;
    int16_t delayNumSamples = -1;
#ifdef BINAURALIZATION_DELAY_REPORT
    int16_t delayNumSamples_orig[3]; /* stores: overall delay, dec+rend delay, and binauralization delay */
#else
    int16_t delayNumSamples_orig = 0;
#endif
    int16_t nOutSamples = 0;
    int32_t delayTimeScale = 0;
    ivas_error error = IVAS_ERR_UNKNOWN;
@@ -1365,6 +1389,10 @@ static ivas_error decodeG192(
        fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" );
    }

#ifdef BINAURALIZATION_DELAY_REPORT
    delayNumSamples_orig[0] = -1;
#endif

#ifdef WMOPS
    reset_stack();
    reset_wmops();
@@ -1455,7 +1483,11 @@ static ivas_error decodeG192(
                    arg,
                    numInitialBadFrames,
                    nOutSamples,
#ifdef BINAURALIZATION_DELAY_REPORT
                    delayNumSamples_orig,
#else
                    &delayNumSamples_orig,
#endif
                    &delayNumSamples,
                    &delayTimeScale,
                    &bsFormat,
@@ -1556,13 +1588,39 @@ static ivas_error decodeG192(
#endif
    }

    /*------------------------------------------------------------------------------------------*
     * Add zeros at the end to have equal length of synthesized signals
     *------------------------------------------------------------------------------------------*/

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

    /*------------------------------------------------------------------------------------------*
     * Printouts after decoding has finished
     *------------------------------------------------------------------------------------------*/

    if ( !arg.quietModeEnabled )
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        printf( "\n\nDecoder+renderer delay: %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[1] / (float) delayTimeScale, delayNumSamples_orig[1], delayTimeScale );

        if ( delayNumSamples_orig[2] > 0 )
        {
            printf( "HRIR/BRIR delay:        %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[2] / (float) delayTimeScale, delayNumSamples_orig[2], delayTimeScale );
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[0] / (float) delayTimeScale, delayNumSamples_orig[0], delayTimeScale );
        }
#else
        fprintf( stdout, "\nDecoder delay:          %-5u [samples]  - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale );
#endif
    }

    /* Print output metadata file name(s) */
@@ -1582,14 +1640,6 @@ static ivas_error decodeG192(
        }
    }

    /* add zeros at the end to have equal length of synthesized signals */
    memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
    }

    /*------------------------------------------------------------------------------------------*
     * Close files and deallocate resources
     *------------------------------------------------------------------------------------------*/
@@ -1759,7 +1809,11 @@ static ivas_error decodeVoIP(
#endif
    JbmOffsetFileWriter *jbmOffsetWriter = NULL;

#ifdef BINAURALIZATION_DELAY_REPORT
    int16_t delayNumSamples_orig[3]; /* stores: overall delay, dec+rend delay, and binauralization delay */
#else
    int16_t delayNumSamples_orig = -1;
#endif
    int16_t delayNumSamples = -1;
    int32_t delayTimeScale = -1;

@@ -1773,11 +1827,15 @@ static ivas_error decodeVoIP(

    IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;
    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];

    for ( int16_t i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
        ismWriters[i] = NULL;
    }

#ifdef BINAURALIZATION_DELAY_REPORT
    delayNumSamples_orig[0] = -1;
#endif

    rtpdumpDepacker.rtpdump = NULL;
    switch ( arg.inputFormat )
@@ -1974,7 +2032,11 @@ static ivas_error decodeVoIP(
                    arg,
                    numInitialBadFrames,
                    nOutSamples,
#ifdef BINAURALIZATION_DELAY_REPORT
                    delayNumSamples_orig,
#else
                    &delayNumSamples_orig,
#endif
                    &delayNumSamples,
                    &delayTimeScale,
                    &bsFormat,
@@ -2027,9 +2089,17 @@ static ivas_error decodeVoIP(
#endif
    }

    /* add zeros at the end to have equal length of synthesized signals */
    /*------------------------------------------------------------------------------------------*
     * Add zeros at the end to have equal length of synthesized signals
     *------------------------------------------------------------------------------------------*/

#ifdef BINAURALIZATION_DELAY_REPORT
    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
#else
    memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
@@ -2041,7 +2111,17 @@ static ivas_error decodeVoIP(

    if ( !arg.quietModeEnabled )
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        printf( "\n\nDecoder+renderer delay: %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[1] / (float) delayTimeScale, delayNumSamples_orig[1], delayTimeScale );

        if ( delayNumSamples_orig[2] > 0 )
        {
            printf( "HRIR/BRIR delay:        %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[2] / (float) delayTimeScale, delayNumSamples_orig[2], delayTimeScale );
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[0] / (float) delayTimeScale, delayNumSamples_orig[0], delayTimeScale );
        }
#else
        printf( "\nDecoder delay:       %5u [samples]  - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale );
#endif
    }

    /*------------------------------------------------------------------------------------------*
+9 −4
Original line number Diff line number Diff line
@@ -54,8 +54,11 @@ int32_t get_delay(
    const int16_t enc_dec,          /* i  : encoder/decoder flag                */
    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            */
    HANDLE_CLDFB_FILTER_BANK hCldfb /* i  : Handle of Cldfb analysis            */
#ifndef BINAURALIZATION_DELAY_REPORT
    ,
    const int32_t binaural_latency_ns /* i  : binaural renderer HRTF delay in ns  */
#endif
)
{
    int32_t delay = 0;
@@ -100,8 +103,10 @@ int32_t get_delay(
                delay += IVAS_FB_DEC_DELAY_NS;
            }

#ifndef BINAURALIZATION_DELAY_REPORT
            /* compensate for binauralization delay */
            delay += binaural_latency_ns;
#endif
        }
    }

+0 −1
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@
    EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
  ====================================================================================*/

#include "typedef.h"
#include <stdint.h>
#include "options.h"
#ifdef DEBUGGING
+4 −4
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ int16_t ivas_map_num_pred_r_to_idx(
                pred_r_to_idx = PRED_Q_31;
                break;
            default:
                assert( "Forbidden value for prediction quantization strategy index" );
                assert( !"Forbidden value for prediction quantization strategy index" );
                break;
        }
    }
@@ -145,7 +145,7 @@ int16_t ivas_map_num_pred_r_to_idx(
                pred_r_to_idx = PRED_Q_21_ACTIVE_W;
                break;
            default:
                assert( "Forbidden value for prediction quantization strategy index" );
                assert( !"Forbidden value for prediction quantization strategy index" );
                break;
        }
    }
@@ -179,7 +179,7 @@ int16_t ivas_map_num_drct_r_to_idx(
            drct_r_to_idx = DRCT_Q_11;
            break;
        default:
            assert( "Forbidden value for DRCT quantization strategy index" );
            assert( !"Forbidden value for DRCT quantization strategy index" );
            break;
    }
    return drct_r_to_idx;
@@ -217,7 +217,7 @@ int16_t ivas_map_num_decd_r_to_idx(
            decd_r_to_idx = DECD_Q_11;
            break;
        default:
            assert( "Forbidden value for DECD quantization strategy index" );
            assert( !"Forbidden value for DECD quantization strategy index" );
            break;
    }

Loading