Commit 9619a7d5 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch 'main' into 407-verify-and-possibly-fix-metadata-access-for-rotateaziele_dirac

parents 38e2bd91 1bfc64ea
Loading
Loading
Loading
Loading
Loading
+64 −9
Original line number Diff line number Diff line
@@ -106,7 +106,12 @@ typedef struct
    bool customLsOutputEnabled;
    char *customLsSetupFilename;
    int16_t orientation_tracking;
#ifdef NON_DIEGETIC_PAN
    int16_t Opt_non_diegetic_pan;
    float non_diegetic_pan_gain;
#else
    float no_diegetic_pan;
#endif
    bool renderConfigEnabled;
    char *renderConfigFilename;
#ifdef COMPLEXITY_LEVEL_INDICATION
@@ -193,7 +198,11 @@ int main(
     * Open decoder handle
     *------------------------------------------------------------------------------------------*/

#ifdef NON_DIEGETIC_PAN
    if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.decMode, arg.orientation_tracking ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Open( &hIvasDec, arg.decMode, arg.orientation_tracking, arg.no_diegetic_pan ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Open failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
@@ -358,7 +367,11 @@ int main(
     * Configure the decoder
     *------------------------------------------------------------------------------------------*/

#ifdef NON_DIEGETIC_PAN
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.renderConfigEnabled ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
@@ -793,7 +806,12 @@ static bool parseCmdlIVAS_dec(
    arg->renderConfigFilename = NULL;

    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
#ifdef NON_DIEGETIC_PAN
    arg->Opt_non_diegetic_pan = 0;
    arg->non_diegetic_pan_gain = 0.f;
#else
    arg->no_diegetic_pan = 0.f;
#endif

    /*-----------------------------------------------------------------*
     * Initialization
@@ -1019,38 +1037,61 @@ static bool parseCmdlIVAS_dec(
            }
            i += 2;
        }
        else if ( strcmp( argv_to_upper, "-NO_DIEGETIC_PAN" ) == 0 )
        else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 )
        {
            i++;

            if ( argc - i <= 4 || argv[i][0] == '-' )
#ifdef NON_DIEGETIC_PAN
            arg->Opt_non_diegetic_pan = 1;
#else
            if ( argc - i <= 4 || ( argv[i][0] == '-' ) )
            {
                fprintf( stderr, "Error: Argument for panning option not specified!\n\n" );
                usage_dec();
                return false;
            }

#endif
            strncpy( argv_to_upper, argv[i], sizeof( argv_to_upper ) - 1 );
            argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0';
#ifdef NON_DIEGETIC_PAN
            to_upper( argv_to_upper );
#endif
            if ( ( strcmp( argv_to_upper, "CENTER" ) == 0 ) || ( strchr( argv_to_upper, 'C' ) != NULL ) )
            {
#ifdef NON_DIEGETIC_PAN
                arg->non_diegetic_pan_gain = 0.f;
#else
                arg->no_diegetic_pan = 0.f;
#endif
            }
            else if ( ( strcmp( argv_to_upper, "LEFT" ) == 0 ) || ( strchr( argv_to_upper, 'L' ) != NULL ) )
            {
                arg->no_diegetic_pan = -1.f;
#ifdef NON_DIEGETIC_PAN
                arg->non_diegetic_pan_gain = 1.f;
#else
                arg->no_diegetic_pan = 1.f;
#endif
            }
            else if ( ( strcmp( argv_to_upper, "RIGHT" ) == 0 ) || ( strchr( argv_to_upper, 'R' ) != NULL ) )
            {
                arg->no_diegetic_pan = 1.f;
#ifdef NON_DIEGETIC_PAN
                arg->non_diegetic_pan_gain = -1.f;
#else
                arg->no_diegetic_pan = -1.f;
#endif
            }
            else
            {
#ifdef NON_DIEGETIC_PAN
                arg->non_diegetic_pan_gain = (float) atof( argv_to_upper ) / 90.f;

                if ( arg->non_diegetic_pan_gain > 1.0f || arg->non_diegetic_pan_gain < -1.0f )
#else
                arg->no_diegetic_pan = (float) atof( argv_to_upper );

                if ( arg->no_diegetic_pan > 1.0f || arg->no_diegetic_pan < -1.0f )
#endif
                {
                    fprintf( stderr, "Error: Incorrect value for panning option argument specified: %s\n\n", argv[i] );
                    fprintf( stderr, "Error: Incorrect value for panning gain value specified: %s\n\n", argv[i] );
                    usage_dec();
                    return false;
                }
@@ -1104,11 +1145,25 @@ static bool parseCmdlIVAS_dec(
            arg->customLsSetupFilename = argv[i];
        }
        i++;
#ifdef NON_DIEGETIC_PAN
        if ( ( arg->Opt_non_diegetic_pan ) && ( arg->outputFormat != IVAS_DEC_OUTPUT_STEREO ) )
        {
            fprintf( stderr, "Error: non-diegetic panning is supported in stereo only\n\n" );
            usage_dec();
            return false;
        }
#endif
    }
    else
    {
        arg->outputFormat = IVAS_DEC_OUTPUT_MONO;
        arg->decMode = IVAS_DEC_MODE_EVS;
#ifdef NON_DIEGETIC_PAN
        if ( ( arg->Opt_non_diegetic_pan ) )
        {
            arg->outputFormat = IVAS_DEC_OUTPUT_STEREO;
        }
#endif
    }

    /*-----------------------------------------------------------------*
@@ -1216,8 +1271,8 @@ static void usage_dec( void )
    fprintf( stdout, "-rvf File           : Reference vector specified by external trajectory file\n" );
    fprintf( stdout, "                      works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" );
    fprintf( stdout, "-render_config File : Renderer configuration File\n" );
    fprintf( stdout, "-no_diegetic_pan    : panning mono non-diegetic sound to stereo -1<= pan <=1,\n" );
    fprintf( stdout, "                      left or l or 1->left, right or r or -1->right, center or c or  0->middle\n" );
    fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" );
    fprintf( stdout, "                      left or l or 90->left, right or r or -90->right, center or c or  0->middle\n" );
    fprintf( stdout, "-q                  : Quiet mode, no frame counter\n" );
    fprintf( stdout, "                      default is deactivated\n" );
#ifdef DEBUGGING
+92 −5
Original line number Diff line number Diff line
@@ -136,7 +136,12 @@ typedef struct
    char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    int8_t orientationTracking;
#ifdef NON_DIEGETIC_PAN
    int16_t nonDiegeticPan;
    float nonDiegeticPanGain;
#else
    float noDiegeticPan;
#endif
    bool delayCompensationEnabled;
    bool quietModeEnabled;
    bool sceneDescriptionInput;
@@ -160,7 +165,7 @@ typedef enum
    CmdLnOptionId_refRotFile,
    CmdLnOptionId_customHrtfFile,
    CmdLnOptionId_renderConfigFile,
    CmdLnOptionId_noDiegeticPan,
    CmdLnOptionId_nonDiegeticPan,
    CmdLnOptionId_orientationTracking,
    CmdlnOptionId_lfePosition,
    CmdlnOptionId_lfeMatrix,
@@ -234,10 +239,10 @@ static const CmdLnParser_Option cliOptions[] = {
        .description = "Binaural renderer configuration file (only for BINAURAL and BINAURAL_ROOM outputs)",
    },
    {
        .id = CmdLnOptionId_noDiegeticPan,
        .match = "no_diegetic_pan",
        .id = CmdLnOptionId_nonDiegeticPan,
        .match = "non_diegetic_pan",
        .matchShort = "ndp",
        .description = "Panning mono no diegetic sound to stereo -1<= pan <= 1\nleft or l or 1->left, right or r or -1->right, center or c or 0 ->middle\n(todo: implementation)",
        .description = "Panning mono non diegetic sound to stereo -90<= pan <= 90\nleft or l or 90->left, right or r or -90->right, center or c or 0 ->middle\n(todo: implementation)",
    },
    {
        .id = CmdLnOptionId_orientationTracking,
@@ -551,6 +556,21 @@ int main(

    CmdlnArgs args = parseCmdlnArgs( argc, argv );

#ifdef NON_DIEGETIC_PAN
    if ( args.nonDiegeticPan && !( ( args.inConfig.numAudioObjects == 0 && args.inConfig.multiChannelBuses[0].audioConfig == IVAS_REND_AUDIO_CONFIG_MONO ) ||
                                   ( args.inConfig.numAudioObjects > 0 && args.inConfig.audioObjects[0].audioConfig == IVAS_REND_AUDIO_CONFIG_OBJECT && args.inConfig.numAudioObjects == 1 ) ) )
    {
        fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires mono or ISM1 input\n" );
        exit( -1 );
    }

    if ( args.nonDiegeticPan && args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_STEREO )
    {
        fprintf( stderr, "\ninvalid configuration - non-diegetic panning requires stereo output\n" );
        exit( -1 );
    }
#endif

    positionProvider = IsmPositionProvider_open();

    convert_backslash( args.inputFilePath );
@@ -665,7 +685,11 @@ int main(
    IVAS_REND_InputId sbaIds[RENDERER_MAX_SBA_INPUTS] = { 0 };
    IVAS_REND_InputId masaIds[RENDERER_MAX_MASA_INPUTS] = { 0 };

#ifdef NON_DIEGETIC_PAN
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, args.nonDiegeticPan, args.nonDiegeticPanGain ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
@@ -1334,6 +1358,38 @@ static bool parseOutConfig(
    return true;
}

#ifdef NON_DIEGETIC_PAN
static bool parseDiegeticPan(
    char *value,
    float *nonDiegeticPan )
{
    to_upper( value );

    if ( ( strcmp( value, "CENTER" ) == 0 ) || ( strchr( value, 'C' ) != NULL ) )
    {
        *nonDiegeticPan = 0.f;
    }
    else if ( ( strcmp( value, "LEFT" ) == 0 ) || ( strchr( value, 'L' ) != NULL ) )
    {
        *nonDiegeticPan = 1.f;
    }
    else if ( ( strcmp( value, "RIGHT" ) == 0 ) || ( strchr( value, 'R' ) != NULL ) )
    {
        *nonDiegeticPan = -1.f;
    }
    else
    {
        *nonDiegeticPan = (float) atof( value ) / 90.f;

        if ( *nonDiegeticPan > 1.0f || *nonDiegeticPan < -1.0f )
        {
            fprintf( stderr, "Error: Incorrect value for panning option argument specified!\n\n" );
            return false;
        }
    }
    return true;

#else
static bool parseDiegeticPan(
    char *value,
    float *noDiegeticPan )
@@ -1363,6 +1419,7 @@ static bool parseDiegeticPan(
        }
    }
    return false;
#endif
}

static bool parseOrientationTracking(
@@ -1615,7 +1672,12 @@ static CmdlnArgs defaultArgs(
    clearString( args.renderConfigFilePath );

    args.orientationTracking = IVAS_ORIENT_TRK_NONE;
#ifdef NON_DIEGETIC_PAN
    args.nonDiegeticPan = 0;
    args.nonDiegeticPanGain = 0.f;
#else
    args.noDiegeticPan = 0.0f;
#endif

    args.delayCompensationEnabled = true;
    args.quietModeEnabled = false;
@@ -1705,13 +1767,20 @@ static void parseOption(
            assert( numOptionValues == 1 );
            strncpy( args->renderConfigFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_noDiegeticPan:
        case CmdLnOptionId_nonDiegeticPan:
            assert( numOptionValues == 1 );
#ifdef NON_DIEGETIC_PAN
            if ( !parseDiegeticPan( optionValues[0], &args->nonDiegeticPanGain ) )
#else
            if ( !parseDiegeticPan( optionValues[0], &args->noDiegeticPan ) )
#endif
            {
                fprintf( stderr, "Unknown option for diegetic panning: %s\n", optionValues[0] );
                exit( -1 );
            }
#ifdef NON_DIEGETIC_PAN
            args->nonDiegeticPan = 1;
#endif
            break;
        case CmdLnOptionId_orientationTracking:
            assert( numOptionValues == 1 );
@@ -1822,6 +1891,9 @@ void getMetadataFromFileReader(
    objectMetadataBuffer->positions[objIdx].radius = ismMetadata.radius;
    objectMetadataBuffer->positions[objIdx].yaw = ismMetadata.yaw;
    objectMetadataBuffer->positions[objIdx].pitch = ismMetadata.pitch;
#ifdef ISM_NON_DIEGETIC_PAN
    objectMetadataBuffer->positions[objIdx].non_diegetic_flag = ismMetadata.non_diegetic_flag;
#endif

    return;
}
@@ -1879,6 +1951,9 @@ static void IsmPositionProvider_getNextFrame(
            objectMetadataBuffer->positions[objIdx].radius = 1.0f;
            objectMetadataBuffer->positions[objIdx].yaw = 0.0f;
            objectMetadataBuffer->positions[objIdx].pitch = 0.0f;
#ifdef ISM_NON_DIEGETIC_PAN
            objectMetadataBuffer->positions[objIdx].non_diegetic_flag = 0;
#endif
        }

        /* Wrap azimuth to lie within (-180, 180] range */
@@ -2140,13 +2215,22 @@ static void parseObjectPosition(
{
    char *endptr;
    int16_t read_values;
#ifdef ISM_NON_DIEGETIC_PAN
    float meta_prm[8] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f };
#else
    float meta_prm[7] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f };
#endif


    readNextMetadataChunk( line, "," );
    *positionDuration = (uint16_t) strtol( line, &endptr, 10 );
    readNextMetadataChunk( line, "\n" );

#ifdef ISM_NON_DIEGETIC_PAN
    read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6], &meta_prm[7] );
#else
    read_values = (int16_t) sscanf( line, "%f,%f,%f,%f,%f,%f,%f", &meta_prm[0], &meta_prm[1], &meta_prm[2], &meta_prm[3], &meta_prm[4], &meta_prm[5], &meta_prm[6] );
#endif

    if ( read_values < 2 )
    {
@@ -2159,6 +2243,9 @@ static void parseObjectPosition(
    position->radius = meta_prm[2];
    position->yaw = meta_prm[5];
    position->pitch = meta_prm[6];
#ifdef ISM_NON_DIEGETIC_PAN
    position->non_diegetic_flag = (int16_t) meta_prm[7];
#endif
    return;
}

+6 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ typedef struct _IVAS_ISM_METADATA
    float gainFactor;
    float yaw;
    float pitch;
#ifdef ISM_NON_DIEGETIC_PAN
    int16_t non_diegetic_flag;
#endif
} IVAS_ISM_METADATA;

typedef struct
@@ -118,6 +121,9 @@ typedef struct
    float radius;
    float yaw;
    float pitch;
#ifdef ISM_NON_DIEGETIC_PAN
    int16_t non_diegetic_flag;
#endif
} IVAS_REND_AudioObjectPosition;

typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
+0 −1
Original line number Diff line number Diff line
@@ -1290,7 +1290,6 @@ int16_t calc_nor_delta_hf(
                ynrm[i] += delta;
                add_bits_denv += bitsforDelta;


                temp_num++;
            }
        }
+22 −0
Original line number Diff line number Diff line
@@ -156,7 +156,12 @@ typedef enum
    RENDERER_MCMASA_MONO_STEREO,
    RENDERER_PARAM_ISM,
    RENDERER_BINAURAL_MIXER_CONV,
#if defined NON_DIEGETIC_PAN || defined ISM_NON_DIEGETIC_PAN
    RENDERER_BINAURAL_MIXER_CONV_ROOM,
    RENDERER_NON_DIEGETIC_DOWNMIX
#else
    RENDERER_BINAURAL_MIXER_CONV_ROOM
#endif

} RENDERER_TYPE;

@@ -170,6 +175,9 @@ typedef enum
#define HEAD_ROTATION_HOA_ORDER                 3                           /* HOA 3rd order */
#define MAX_CICP_CHANNELS                       16                          /* max channels for loudspeaker layouts (16 for custom layouts)*/
#define MAX_OUTPUT_CHANNELS                     16                          /* Maximum number of output channels (HOA 3rd order) */
#ifdef NON_DIEGETIC_PAN
#define MAX_OUTPUT_CHANNELS_IN_DIEGETIC_PAN     2                           /* Maximum number of output channels with non diegetic panning */
#endif

#define BINAURAL_CHANNELS                       2                           /* number of channels for binaural output configuration */
#define CPE_CHANNELS                            2                           /* number of CPE (stereo) channels */
@@ -332,6 +340,9 @@ typedef enum
#define ISM_RADIUS_MIN                          0.0f
#define ISM_RADIUS_DELTA                        0.25f /* Max radius = (2^ISM_RADIUS_NBITS-1)*0.25 = 15.75 */
#define ISM_EXTENDED_METADATA_BRATE             IVAS_64k
#ifdef ISM_NON_DIEGETIC_PAN
#define ISM_METADATA_IS_NDP_BITS                1
#endif
#define ISM_EXTENDED_METADATA_BITS              1
#define ISM_METADATA_RS_MAX_FRAMES              5 /* Number of frames with opposite extended metadata flags before switching */

@@ -373,6 +384,9 @@ enum
{
    IND_ISM_NUM_OBJECTS,
    IND_ISM_EXTENDED_FLAG = IND_ISM_NUM_OBJECTS + MAX_NUM_OBJECTS,
#ifdef ISM_NON_DIEGETIC_PAN    
    IND_ISM_EXTENDED_NDP_FLAG, 
#endif    
    IND_ISM_METADATA_FLAG,
    IND_ISM_VAD_FLAG = IND_ISM_METADATA_FLAG + MAX_NUM_OBJECTS,
    IND_ISM_NOISY_SPEECH_FLAG = IND_ISM_VAD_FLAG + MAX_NUM_OBJECTS,
@@ -381,6 +395,9 @@ enum

    /* ------------- loop for objects -------------- */
    TAG_ISM_LOOP_START = IND_ISM_DTX_COH_SCA + MAX_NUM_OBJECTS,
#ifdef ISM_NON_DIEGETIC_PAN    
    IND_ISM_NDP_FLAG = TAG_ISM_LOOP_START,
#endif    
    IND_ISM_AZIMUTH_DIFF_FLAG = TAG_ISM_LOOP_START,
    IND_ISM_AZIMUTH = TAG_ISM_LOOP_START,
    IND_ISM_ELEVATION_DIFF_FLAG = TAG_ISM_LOOP_START,
@@ -1572,7 +1589,12 @@ typedef enum
typedef enum
{
    TDREND_PLAYSTATUS_INITIAL,
#ifdef ISM_NON_DIEGETIC_PAN   
    TDREND_PLAYSTATUS_PLAYING,
    TDREND_PLAYSTATUS_PLAYING_NON_DIEGETIC
#else
    TDREND_PLAYSTATUS_PLAYING
#endif    
} TDREND_PlayStatus_t;

typedef enum
Loading