Commit 6e9a2b1a authored by vaclav's avatar vaclav
Browse files

Issue 354 - improve "-hrtf" command-line option; under FIX_351_HRTF_COMMAND

parent 67e28dc3
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
@@ -221,8 +221,21 @@ int main(

    if ( arg.hrtfReaderEnabled )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            arg.hrtfReaderEnabled = false;
            fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = hrtfFileReader_open( arg.hrtfFileName, &hrtfReader ) ) != IVAS_ERR_OK )
        {
#ifdef FIX_351_HRTF_COMMAND
            arg.hrtfReaderEnabled = false;
#endif
            fprintf( stderr, "\nError: Can't open HRTF binary file %s \n\n", arg.hrtfFileName );
            goto cleanup;
        }
@@ -234,6 +247,15 @@ int main(

    if ( arg.enableHeadRotation )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = HeadRotationFileReader_open( arg.headrotTrajFileName, &headRotReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open head-rotation file %s \n\n", arg.headrotTrajFileName );
@@ -247,6 +269,15 @@ int main(

    if ( arg.customLsOutputEnabled )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_LS_CUSTOM )
        {
            fprintf( stderr, "\nError: Custom loudspeaker setup cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = CustomLsReader_open( arg.customLsSetupFilename, &hLsCustomReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open Custom loudspeaker setup file %s \n\n", arg.customLsSetupFilename );
@@ -260,6 +291,15 @@ int main(

    if ( arg.renderConfigEnabled )
    {
#ifdef FIX_351_HRTF_COMMAND
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = RenderConfigReader_open( arg.renderConfigFilename, &renderConfigReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open Renderer configuration file %s \n\n", arg.renderConfigFilename );
@@ -272,9 +312,17 @@ int main(
     *------------------------------------------------------------------------------------------*/

#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 )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.forceSubframeBinauralization ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef FIX_351_HRTF_COMMAND
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation ) ) != IVAS_ERR_OK )
#endif
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -530,6 +578,7 @@ cleanup:
#ifdef DEBUG_SBA_AUDIO_DUMP
    IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels );
#endif

    if ( arg.hrtfReaderEnabled )
    {
        IVAS_DEC_HRTF_HANDLE hHrtfTD;
+3 −0
Original line number Diff line number Diff line
@@ -158,6 +158,9 @@
#define SMOOTH_WITH_TRANS_DET
#endif

#define FIX_351_HRTF_COMMAND                            /* VA: Issue 354 - improve "-hrtf" command-line option */


/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
#endif
+4 −1
Original line number Diff line number Diff line
@@ -1127,6 +1127,9 @@ typedef struct decoder_config_structure
    int16_t Opt_LsCustom;          /* indicates whether loudspeaker custom setup is used */
    int16_t Opt_HRTF_binary;       /* indicates whether HRTF binary file is used */
    int16_t Opt_Headrotation;      /* indicates whether head-rotation is used */
#ifdef FIX_351_HRTF_COMMAND
    int16_t Opt_RendConfigCustom; /* indicates whether Renderer configuration custom setup is used */
#endif
    int16_t orientation_tracking; /* indicates orientation tracking type */
    float no_diegetic_pan;
    int16_t Opt_AMR_WB; /* flag indicating AMR-WB IO mode */
+22 −0
Original line number Diff line number Diff line
@@ -223,6 +223,9 @@ static void init_decoder_config(
    hDecoderConfig->Opt_LsCustom = 0;
    hDecoderConfig->Opt_HRTF_binary = 0;
    hDecoderConfig->Opt_Headrotation = 0;
#ifdef FIX_351_HRTF_COMMAND
    hDecoderConfig->Opt_RendConfigCustom = 0;
#endif
#ifdef DEBUGGING
    hDecoderConfig->forceSubframeBinauralization = 0;
#endif
@@ -390,6 +393,10 @@ ivas_error IVAS_DEC_Configure(
    const int16_t customLsOutputEnabled,      /* i  : enable custom loudspeaker setup handle     */
    const int16_t hrtfReaderEnabled,          /* i  : enable HRTF binary file input              */
    const int16_t enableHeadRotation          /* i  : enable head rotation for binaural output   */
#ifdef FIX_351_HRTF_COMMAND
    ,
    const int16_t renderConfigEnabled /* i  : enable Renderer config. file for binaural output */
#endif
#ifdef DEBUGGING
    ,
    const int16_t forceSubframeBinauralization /* i  : enable subframe binauralization             */
@@ -445,6 +452,9 @@ ivas_error IVAS_DEC_Configure(
    hDecoderConfig->Opt_LsCustom = customLsOutputEnabled;
    hDecoderConfig->Opt_Headrotation = enableHeadRotation;
    hDecoderConfig->Opt_HRTF_binary = hrtfReaderEnabled;
#ifdef FIX_351_HRTF_COMMAND
    hDecoderConfig->Opt_RendConfigCustom = renderConfigEnabled;
#endif

    /* Set decoder parameters to initial values */
    if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK )
@@ -1911,6 +1921,18 @@ static ivas_error printConfigInfo_dec(
        get_channel_config( st_ivas->hDecoderConfig->output_config, &config_str[0] );
        fprintf( stdout, "Output configuration:   %s\n", config_str );

#ifdef FIX_351_HRTF_COMMAND
        if ( st_ivas->hDecoderConfig->Opt_HRTF_binary )
        {
            fprintf( stdout, "HRIR/BRIR file:         ON\n" );
        }

        if ( st_ivas->hDecoderConfig->Opt_RendConfigCustom )
        {
            fprintf( stdout, "Renderer config. file:  ON\n" );
        }
#endif

        if ( st_ivas->hDecoderConfig->Opt_Headrotation )
        {
            fprintf( stdout, "Head rotation:          ON\n" );
+4 −0
Original line number Diff line number Diff line
@@ -132,6 +132,10 @@ ivas_error IVAS_DEC_Configure(
    const int16_t customLsOutputEnabled,        /* i  : enable custom loudspeaker setup handle                                  */
    const int16_t hrtfReaderEnabled,            /* i  : enable HRTF binary file input                                           */
    const int16_t enableHeadRotation            /* i  : enable head rotation for binaural output                                */
#ifdef FIX_351_HRTF_COMMAND
   ,const int16_t renderConfigEnabled           /* i  : enable Renderer config. file for binaural output                        */
#endif

#ifdef DEBUGGING
    ,
    const int16_t forceSubframeBinauralization  /* i  : enable subframe binauralization                                         */