Commit 006a21f5 authored by Sumeyra Demir Kanik's avatar Sumeyra Demir Kanik
Browse files

Merge branch '730-directivity-pattern-id-not-set-correctly' into 'main'

Resolve "Directivity pattern id read while parsing config file is not stored in the correct index"

See merge request !997
parents 0ec6c4d1 534afb84
Loading
Loading
Loading
Loading
Loading
+65 −4
Original line number Diff line number Diff line
@@ -146,6 +146,9 @@ typedef struct
#endif
#endif
    uint16_t acousticEnvironmentId;
#ifdef FIX_708_DPID_COMMAND_LINE
    int16_t Opt_dpid_on;
#endif
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
} DecArguments;

@@ -473,9 +476,6 @@ int main(
     * Configure the decoder
     *------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------*
 * Configure the decoder
 *------------------------------------------------------------------------------------------*/
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
@@ -496,7 +496,11 @@ int main(

    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig,
                                       arg.tsmEnabled, arg.enable5ms,
                                       arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
                                       arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain,
#ifdef FIX_708_DPID_COMMAND_LINE
                                       arg.Opt_dpid_on,
#endif
                                       arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
@@ -674,7 +678,11 @@ int main(

        if ( ( error = RenderConfigReader_getDirectivity( renderConfigReader, arg.directivityPatternId, renderConfig.directivity ) ) != IVAS_ERR_OK )
        {
#ifdef FIX_730_DPID_NOT_SET_CORRECTLY
            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] );
#else
            fprintf( stderr, "Failed to get directivity for objects: %d %d %d %d\n\n", arg.directivityPatternId[0], arg.directivityPatternId[1], arg.directivityPatternId[2], arg.directivityPatternId[3] );
#endif
            goto cleanup;
        }

@@ -1035,6 +1043,9 @@ static bool parseCmdlIVAS_dec(

    arg->renderConfigEnabled = false;
    arg->renderConfigFilename = NULL;
#ifdef FIX_708_DPID_COMMAND_LINE
    arg->Opt_dpid_on = 0;
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    arg->outputMdFilename = NULL;
@@ -1062,7 +1073,11 @@ static bool parseCmdlIVAS_dec(
    arg->acousticEnvironmentId = 0;
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
#ifdef FIX_730_DPID_NOT_SET_CORRECTLY
        arg->directivityPatternId[i] = 65535;
#else
        arg->directivityPatternId[i] = 0;
#endif
    }
    /*-----------------------------------------------------------------*
     * Initialization
@@ -1437,14 +1452,52 @@ static bool parseCmdlIVAS_dec(
        }
        else if ( strcmp( argv_to_upper, "-DPID" ) == 0 )
        {
#ifdef FIX_708_DPID_COMMAND_LINE
            int16_t id;

            arg->Opt_dpid_on = 1;
#endif
            ++i;
            int16_t tmp;
            tmp = 0;
            while ( is_number( argv[i + tmp] ) && tmp < IVAS_MAX_NUM_OBJECTS )
            {
#ifdef FIX_708_DPID_COMMAND_LINE
                id = (int16_t) atoi( argv[i + tmp] );

                if ( !is_digits_only( argv[i + tmp] ) || id < 0 )
                {
                    fprintf( stdout, "Error: Invalid directivity pattern ID specified: %s\n\n", argv[i + tmp] );
                    usage_dec();
                    return false;
                }

                arg->directivityPatternId[tmp] = id;
#else
                arg->directivityPatternId[tmp] = (int16_t) atoi( argv[i + tmp] );
#endif
                ++tmp;
            }

#ifdef FIX_708_DPID_COMMAND_LINE
            if ( tmp == 0 )
            {
                if ( argc - i <= 4 || argv[i][0] == '-' )
                {
                    fprintf( stderr, "Error: Directivity pattern ID not specified!\n\n" );
                    usage_dec();
                    return false;
                }

                if ( !is_digits_only( argv[i + tmp] ) )
                {
                    fprintf( stdout, "Error: Invalid directivity pattern ID specified: %s\n\n", argv[i + tmp] );
                    usage_dec();
                    return false;
                }
            }
#endif

            i += tmp;
        }

@@ -1633,7 +1686,15 @@ static void usage_dec( void )
    fprintf( stdout, "-force R            : Force specific binaural rendering mode, R = (TDREND, CLDFBREND),\n" );
#endif
    fprintf( stdout, "-exof File          : External orientation File for external orientation trajectory\n" );
#ifdef FIX_708_DPID_COMMAND_LINE
    fprintf( stdout, "-dpid ID            : Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up\n" );
    fprintf( stdout, "                      to 4 numbers (unsigned integers) can be specified for BINAURAL output configuration.\n" );
    fprintf( stdout, "                      ID1, ID2, ID3, ID4 specify the directivity pattern IDs used for ISMs 1,2,3 and 4 respectively.\n" );
    fprintf( stdout, "                      This options needs to be accompanied by a render_config file, otherwise a default\n" );
    fprintf( stdout, "                      directivity pattern is used.\n" );
#else
    fprintf( stdout, "-dpid ID            : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration\n" );
#endif
    fprintf( stdout, "-aeid ID            : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output configuration\n" );
    fprintf( stdout, "-level level        : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" );
    fprintf( stdout, "                      Currently, all values default to level 3 (full functionality).\n" );
+8 −0
Original line number Diff line number Diff line
@@ -383,7 +383,11 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_directivityPatternId,
        .match = "ism_directivity_pattern_id",
        .matchShort = "dpid",
#ifdef FIX_708_DPID_COMMAND_LINE
        .description = "Directivity pattern ID(s) = [ID1, ID2, ID3, ID4]. Space-separated list of up to 4 numbers (unsigned integers) can be specified for BINAURAL output configuration.\nID1, ID2, ID3, ID4 specify the directivity pattern IDs used for ISMs 1,2,3 and 4 respectively.\nThis options needs to be accompanied by a render_config file, otherwise a default directivity pattern is used.",
#else
        .description = "Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration",
#endif
    },
    {
        .id = CmdLnOptionId_acousticEnvironmentId,
@@ -2570,7 +2574,11 @@ static CmdlnArgs defaultArgs(

    for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
    {
#ifdef FIX_730_DPID_NOT_SET_CORRECTLY
        args.directivityPatternId[i] = 65535;
#else
        args.directivityPatternId[i] = 0;
#endif
    }

    args.acousticEnvironmentId = 0;
+7 −0
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@ typedef enum
    IVAS_ERR_INVALID_OUTPUT_FORMAT,
    IVAS_ERR_HEAD_ROTATION_NOT_SUPPORTED,
    IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED,
#ifdef FIX_708_DPID_COMMAND_LINE
    IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED,
#endif
    IVAS_ERR_INVALID_HRTF,
    IVAS_ERR_INVALID_INPUT_FORMAT,
    IVAS_ERR_INVALID_INDEX, /* ToDo: should be merged with IVAS_ERR_INDEX_OUT_OF_BOUNDS */
@@ -251,6 +254,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
#endif
        case IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED:
            return "External orientation not supported";
#ifdef FIX_708_DPID_COMMAND_LINE
        case IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED:
            return "Directivity not supported";
#endif
        case IVAS_ERR_INVALID_HRTF:
            return "Unsupported HRTF filter set";
        case IVAS_ERR_INVALID_INPUT_FORMAT:
+3 −0
Original line number Diff line number Diff line
@@ -158,6 +158,9 @@
#define OSBA_SPLIT_RENDERING
#endif

#define FIX_708_DPID_COMMAND_LINE                       /* issue 708: sanity checks for '-dpid' command-line */
#define FIX_730_DPID_NOT_SET_CORRECTLY                  /* Eri: issue 730: write dpid read from file in correct index, print informative error message when DPID specified is not found. */

#define FIX_RAM_COUNTING_5MS_RENDERING                  /* FhG: fix for correct RAM reporting with 5ms rendering */

/* #################### End BE switches ################################## */
+10 −0
Original line number Diff line number Diff line
@@ -3041,6 +3041,16 @@ static ivas_error doSanityChecks_IVAS(
        }
    }

#ifdef FIX_708_DPID_COMMAND_LINE
    if ( st_ivas->hDecoderConfig->Opt_dpid_on )
    {
        if ( !( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
        {
            return IVAS_ERROR( IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, "Wrong set-up: Directivity is not supported in this output configuration." );
        }
    }
#endif

    if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
    {
        if ( st_ivas->ism_mode != ISM_MASA_MODE_DISC && output_config == AUDIO_CONFIG_EXTERNAL )
Loading