Commit d1517cab authored by multrus's avatar multrus
Browse files

[cleanup] accept REND_CFG_LFE

parent 3dc57ea7
Loading
Loading
Loading
Loading
+0 −80
Original line number Diff line number Diff line
@@ -132,14 +132,12 @@ typedef struct
    bool quietModeEnabled;
    bool sceneDescriptionInput;
    float inputGainGlobal; /* Linear gain (not in dB) */
#ifdef REND_CFG_LFE
    bool lfePanningEnabled;
    float lfeConfigGain; /* Linear gain (not in dB) */
    float lfeConfigAzimuth;
    float lfeConfigElevation;
    bool lfeCustomRoutingEnabled;
    char inLfePanningMatrixFile[RENDERER_MAX_CLI_ARG_LENGTH];
#endif
} CmdlnArgs;

typedef enum
@@ -154,12 +152,8 @@ typedef enum
    CmdLnOptionId_renderConfigFile,
    CmdLnOptionId_noDiegeticPan,
    CmdLnOptionId_orientationTracking,
#ifdef REND_CFG_LFE
    CmdlnOptionId_lfePosition,
    CmdlnOptionId_lfeMatrix,
#else
    CmdLnOptionId_customLfeRouting,
#endif
    CmdLnOptionId_noDelayCmp,
    CmdLnOptionId_quietModeEnabled,
    CmdLnOptionId_inputMetadata,
@@ -235,26 +229,15 @@ static const CmdLnParser_Option cliOptions[] = {
        .description = "Head orientation tracking type: 'ref' or 'avg' (only for BINAURAL and BINAURAL_ROOM) (todo: check implementation)",
    },
    {
#ifdef REND_CFG_LFE
        .id = CmdlnOptionId_lfePosition,
        .match = "lfe_position",
        .matchShort = "lp",
        .description = "Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees.\nIf specified, overrides the default behavior which attempts to map input to output LFE channel(s)",
#else
        /* TODO(sgi): Replace with more configurable input, e.g. ask for a list of triplets: (gain, azimuth, elevation) to place LFE signal */
        /* rename to "lfeHandling" */
        .id = CmdLnOptionId_customLfeRouting,
        .match = "neverDropLfe",
        .matchShort = "ndl",
        .description = "[flag] If set, renderer tries to render LFE into other channels in an optimal way when rendering to configs w/o LFE",
#endif
    },
#ifdef REND_CFG_LFE
    { .id = CmdlnOptionId_lfeMatrix,
      .match = "lfe_matrix",
      .matchShort = "lm",
      .description = "LFE panning matrix. File (CSV table) containing a matrix of dimensions [ num_input_lfe x num_output_channels ] with elements specifying linear routing gain (like --gain, -g). \nIf specified, overrides the output LFE position option and the default behavior which attempts to map input to output LFE channel(s)" },
#endif
    {
        .id = CmdLnOptionId_noDelayCmp,
        .match = "no_delay_cmp",
@@ -360,11 +343,9 @@ static void parseMetadata(
    IsmPositionProvider *positionProvider,
    MasaFileReader **masaReaders );

#ifdef REND_CFG_LFE
static ivas_error parseLfePanMtxFile(
    const char *lfeRoutingMatrixFilePath,
    IVAS_REND_LfePanMtx *lfePanMtx );
#endif

static void convert_backslash( char *str );

@@ -582,9 +563,7 @@ int main(
    convert_backslash( args.inputFilePath );
    convert_backslash( args.outputFilePath );
    convert_backslash( args.headRotationFilePath );
#ifdef REND_CFG_LFE
    convert_backslash( args.inLfePanningMatrixFile );
#endif

    if ( !isEmptyString( args.headRotationFilePath ) )
    {
@@ -691,7 +670,6 @@ int main(
        }
    }

#ifdef REND_CFG_LFE
    IVAS_REND_LfePanMtx lfePanMatrix;

    /* parse input LFE panning matrix */
@@ -704,7 +682,6 @@ int main(
            exit( -1 );
        }
    }
#endif

    for ( i = 0; i < args.inConfig.numMultiChannelBuses; ++i )
    {
@@ -729,7 +706,6 @@ int main(
            }
        }

#ifdef REND_CFG_LFE
        /* set panning matrix for input LFE */
        if ( args.lfeCustomRoutingEnabled )
        {
@@ -754,9 +730,6 @@ int main(
                exit( -1 );
            }
        }
#else
        /* TODO(sgi): Test custom LFE routing here */
#endif
    }

    for ( i = 0; i < args.inConfig.numAudioObjects; ++i )
@@ -1265,18 +1238,10 @@ static bool parseOutConfig(
    return true;
}

#ifdef REND_CFG_LFE
static bool parseDiegeticPan(
#else
static int8_t parseDiegeticPan(
#endif
    char *value,
    float *noDiegeticPan )
{
#ifndef REND_CFG_LFE
    int8_t success;
    success = 1;
#endif
    to_upper( value );

    if ( ( strcmp( value, "CENTER" ) == 0 ) || ( strchr( value, 'C' ) != NULL ) )
@@ -1298,32 +1263,16 @@ static int8_t parseDiegeticPan(
        if ( *noDiegeticPan > 1.0f || *noDiegeticPan < -1.0f )
        {
            fprintf( stderr, "Error: Incorrect value for panning option argument specified!\n\n" );
#ifdef REND_CFG_LFE
            return false;
#else
            success = 0;
#endif
        }
    }
#ifdef REND_CFG_LFE
    return false;
#else
    return success ? 0 : -1;
#endif
}

#ifdef REND_CFG_LFE
static bool parseOrientationTracking(
#else
static int8_t parseOrientationTracking(
#endif
    char *value,
    int8_t *tracking_type )
{
#ifndef REND_CFG_LFE
    int8_t success;
    success = 1;
#endif

    to_upper( value );

@@ -1338,18 +1287,10 @@ static int8_t parseOrientationTracking(
    else
    {
        fprintf( stderr, "Error: Invalid orientation tracking type %s \n\n", value );
#ifdef REND_CFG_LFE
        return false;
#else
        success = 0;
#endif
    }

#ifdef REND_CFG_LFE
    return true;
#else
    return success ? 0 : -1;
#endif
}

static IVAS_REND_AudioConfig parseAudioConfig(
@@ -1444,7 +1385,6 @@ static IVAS_REND_AudioConfig parseAudioConfig(
    return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
}

#ifdef REND_CFG_LFE
static bool parseLfePositionConfig(
    const char *value,
    float *lfeGain,
@@ -1490,7 +1430,6 @@ static bool parseLfePositionConfig(
    *lfeElevation = values[2];
    return true;
}
#endif

#ifndef FIX_293_EXT_RENDERER_CLI
static const CmdLnParser_Option *findOptionById(
@@ -1591,7 +1530,6 @@ static CmdlnArgs defaultArgs(
    args.sceneDescriptionInput = false;
    args.inputGainGlobal = 1.0f;

#ifdef REND_CFG_LFE
    args.lfePanningEnabled = false;
    args.lfeConfigGain = 1.0f;
    args.lfeConfigAzimuth = 0;
@@ -1599,7 +1537,6 @@ static CmdlnArgs defaultArgs(

    args.lfeCustomRoutingEnabled = false;
    clearString( args.inLfePanningMatrixFile );
#endif
    return args;
}

@@ -1670,11 +1607,7 @@ static void parseOption(
            break;
        case CmdLnOptionId_noDiegeticPan:
            assert( numOptionValues == 1 );
#ifdef REND_CFG_LFE
            if ( !parseDiegeticPan( optionValues[0], &args->noDiegeticPan ) )
#else
            if ( parseDiegeticPan( optionValues[0], &args->noDiegeticPan ) != 0 )
#endif
            {
                fprintf( stderr, "Unknown option for diegetic panning: %s\n", optionValues[0] );
                exit( -1 );
@@ -1682,17 +1615,12 @@ static void parseOption(
            break;
        case CmdLnOptionId_orientationTracking:
            assert( numOptionValues == 1 );
#ifdef REND_CFG_LFE
            if ( !parseOrientationTracking( optionValues[0], &args->orientationTracking ) )
#else
            if ( parseOrientationTracking( optionValues[0], &args->orientationTracking ) != 0 )
#endif
            {
                fprintf( stderr, "Unknown option for orientation tracking: %s\n", optionValues[0] );
                exit( -1 );
            }
            break;
#ifdef REND_CFG_LFE
        case CmdlnOptionId_lfePosition:
            assert( numOptionValues == 1 );
            if ( !parseLfePositionConfig( optionValues[0], &args->lfeConfigGain, &args->lfeConfigAzimuth, &args->lfeConfigElevation ) )
@@ -1702,18 +1630,12 @@ static void parseOption(
            }
            args->lfePanningEnabled = true;
            break;
#else
        case CmdLnOptionId_customLfeRouting:
            assert( 0 && "Not yet implemented in CLI" );
#endif
            break;
#ifdef REND_CFG_LFE
        case CmdlnOptionId_lfeMatrix:
            assert( numOptionValues == 1 );
            strncpy( args->inLfePanningMatrixFile, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
            args->lfeCustomRoutingEnabled = true;
            break;
#endif
        case CmdLnOptionId_noDelayCmp:
            assert( numOptionValues == 0 );
            args->delayCompensationEnabled = false;
@@ -2496,7 +2418,6 @@ static void printSupportedAudioConfigs()
    return;
}

#ifdef REND_CFG_LFE
static ivas_error parseLfePanMtxFile(
    const char *lfeRoutingMatrixFilePath,
    IVAS_REND_LfePanMtx *lfePanMtx )
@@ -2560,7 +2481,6 @@ static ivas_error parseLfePanMtxFile(
    fclose( mtxFile );
    return IVAS_ERR_OK;
}
#endif

// VE2AT: possibly move these functions to cmdln_parser.c ?
static void convert_backslash(
+0 −1
Original line number Diff line number Diff line
@@ -147,7 +147,6 @@
#endif
#define FIX_I59_DELAY_ROUNDING                          /* Issue 59: rounding in sample domain instead of nanosec for IVAS_ENC_GetDelay() and IVAS_DEC_GetDelay() */
#define FIX_FIX_I59                                     /* Issue 59:  small fix concerning LFE delay rounding */
#define REND_CFG_LFE                                    /* Issue 110: Configurable LFE handling for external renderer */
#define FIX_235                                         /* Issue 235: Deallocation of HR filter memory separately for lib_rend (ROM) and lib_util (from file) */
#define ENV_STAB_FIX                                    /* Contribution 23: HQ envelope stability memory fix */
#define STABILIZE_GIPD                                  /* FhG: Contribution 22: gIPD stabilization */
+0 −2
Original line number Diff line number Diff line
@@ -48,9 +48,7 @@

#define RENDERER_HEAD_POSITIONS_PER_FRAME 4 // todo  (Marc) -> renanr IVAS_RENDERER_HEAD_POSITIONS_PER_FRAME ?

#ifdef REND_CFG_LFE
typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
#endif
typedef struct
{
    int16_t numSamplesPerChannel;
+0 −41
Original line number Diff line number Diff line
@@ -122,7 +122,6 @@ typedef struct
    rotation_matrix rot_mat_prev;
} input_ism;

#ifdef REND_CFG_LFE
typedef struct
{
    int16_t numLfeChannels;
@@ -132,7 +131,6 @@ typedef struct
    float lfeOutputElevation;
    IVAS_REND_LfePanMtx lfePanMtx;
} lfe_routing;
#endif

typedef struct
{
@@ -151,11 +149,7 @@ typedef struct
    CREND_WRAPPER crendWrapper;
#endif
    rotation_gains rot_gains_prev;
#ifdef REND_CFG_LFE
    lfe_routing lfeRouting;
#else
    IVAS_REND_LfeRouting lfeRouting;
#endif
} input_mc;

typedef struct
@@ -1449,7 +1443,6 @@ static bool configsAreEqual(
    return configA == configB;
}

#ifdef REND_CFG_LFE
static ivas_error updateLfePanGainsForMcOut(
    input_mc *inputMc,
    const IVAS_REND_AudioConfig outConfig )
@@ -1538,7 +1531,6 @@ static ivas_error updateLfePanGainsForAmbiOut(

    return error;
}
#endif

static ivas_error updateMcPanGainsForMcOut(
    input_mc *inputMc,
@@ -1581,7 +1573,6 @@ static ivas_error updateMcPanGainsForMcOut(
        error = initMcPanGainsWithConversionMapping( inputMc, outConfig );
    }

#ifdef REND_CFG_LFE
    /* check for errors from above block */
    if ( error != IVAS_ERR_OK )
    {
@@ -1590,7 +1581,6 @@ static ivas_error updateMcPanGainsForMcOut(

    /* update LFE panning */
    error = updateLfePanGainsForMcOut( inputMc, outConfig );
#endif

    return error;
}
@@ -1654,13 +1644,11 @@ static ivas_error updateMcPanGainsForAmbiOut(
        }
    }

#ifdef REND_CFG_LFE
    /* update LFE panning */
    if ( ( error = updateLfePanGainsForAmbiOut( inputMc, outConfig ) ) != IVAS_ERR_OK )
    {
        return error;
    }
#endif

    return IVAS_ERR_OK;
}
@@ -1801,22 +1789,14 @@ static ivas_error initMcBinauralRendering(
    return error;
}

#ifdef REND_CFG_LFE
static lfe_routing defaultLfeRouting(
#else
static IVAS_REND_LfeRouting defaultLfeRouting(
#endif
    IVAS_REND_AudioConfig inConfig,
    LSSETUP_CUSTOM_STRUCT customLsIn,
    IVAS_REND_AudioConfig outConfig,
    LSSETUP_CUSTOM_STRUCT customLsOut )
{
    int32_t i;
#ifdef REND_CFG_LFE
    lfe_routing routing;
#else
    IVAS_REND_LfeRouting routing;
#endif

    /* Set all output gains to zero, then route each input LFE consecutively to the next available output LFE. */

@@ -1825,10 +1805,8 @@ static IVAS_REND_LfeRouting defaultLfeRouting(
        set_zero( routing.lfePanMtx[i], IVAS_MAX_OUTPUT_CHANNELS );
    }

#ifdef REND_CFG_LFE
    routing.pan_lfe = false;
    routing.lfeInputGain = 1.0f;
#endif

    switch ( inConfig )
    {
@@ -3189,7 +3167,6 @@ ivas_error IVAS_REND_SetInputGain(
    return IVAS_ERR_OK;
}

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfeMtx(
    IVAS_REND_HANDLE hIvasRend,
    const IVAS_REND_InputId inputId,
@@ -3232,22 +3209,13 @@ ivas_error IVAS_REND_SetInputLfeMtx(

    return IVAS_ERR_OK;
}
#endif

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfePos(
#else
ivas_error IVAS_REND_SetInputLfeRouting(
#endif
    IVAS_REND_HANDLE hIvasRend,
    const IVAS_REND_InputId inputId,
#ifdef REND_CFG_LFE
    const float inputGain,
    const float outputAzimuth,
    const float outputElevation
#else
    const IVAS_REND_LfeRouting lfeRouting
#endif
)
{
    input_base *pInputBase;
@@ -3273,19 +3241,10 @@ ivas_error IVAS_REND_SetInputLfeRouting(
    }
    pInputMc = (input_mc *) pInputBase;

#ifdef REND_CFG_LFE
    pInputMc->lfeRouting.pan_lfe = true;
    pInputMc->lfeRouting.lfeInputGain = inputGain;
    pInputMc->lfeRouting.lfeOutputAzimuth = outputAzimuth;
    pInputMc->lfeRouting.lfeOutputElevation = outputElevation;
#else
    if ( getNumLfeChannels( pInputMc ) != lfeRouting.numLfeChannels )
    {
        return IVAS_ERR_WRONG_NUM_CHANNELS;
    }

    pInputMc->lfeRouting = lfeRouting;
#endif
    if ( ( error = updateMcPanGains( pInputMc, hIvasRend->outputConfig ) ) != IVAS_ERR_OK )
    {
        return error;
+0 −19
Original line number Diff line number Diff line
@@ -53,9 +53,7 @@

#define RENDERER_HEAD_POSITIONS_PER_FRAME 4

#ifdef REND_CFG_LFE
typedef float IVAS_REND_LfePanMtx[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
#endif

typedef struct
{
@@ -141,13 +139,6 @@ typedef enum

typedef uint16_t IVAS_REND_InputId;

#ifndef REND_CFG_LFE
typedef struct
{
    int16_t numLfeChannels;
    float lfeOutputGains[IVAS_MAX_INPUT_LFE_CHANNELS][IVAS_MAX_OUTPUT_CHANNELS];
} IVAS_REND_LfeRouting;
#endif

#else

@@ -208,28 +199,18 @@ ivas_error IVAS_REND_SetInputGain(
    const float gain                                /* i  : linear gain (not in dB)                             */
);

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfeMtx(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: Renderer handle                                     */
    const IVAS_REND_InputId inputId,                /* i  : ID of the input                                     */
    const IVAS_REND_LfePanMtx *lfePanMtx            /* i  : LFE panning matrix                                  */
);
#endif

#ifdef REND_CFG_LFE
ivas_error IVAS_REND_SetInputLfePos(
#else
ivas_error IVAS_REND_SetInputLfeRouting(
#endif
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: Renderer handle                                     */
    const IVAS_REND_InputId inputId,                /* i  : ID of the input                                     */
#ifdef REND_CFG_LFE
    const float inputGain,                          /* i  : Input gain to be applied to the LFE channel(s)      */
    const float outputAzimuth,                      /* i  : Output azimuth position                             */
    const float outputElevation                     /* i  : Output elevation position                           */
#else
    const IVAS_REND_LfeRouting lfeRouting           /* i  : custom LFE routing struct                           */
#endif
);

ivas_error IVAS_REND_RemoveInput(