Commit 12d08876 authored by premathasara's avatar premathasara
Browse files

Wrapping AGC command line option in a debugging macro

Macro is named `DEBUG_AGC_ENCODER_CMD_OPTION`
parent 529db2bb
Loading
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -120,11 +120,13 @@ typedef struct
    const char *ca_config_file;
    bool mimeOutput;

#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#ifdef AGC_ENABLE_FOR_LBR
    IVAS_ENC_AGC agc;
#else
    bool agc;
#endif
#endif /* AGC_ENABLE_FOR_LBR */
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */
    bool pca;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
@@ -444,11 +446,25 @@ int main(
            }
            break;
        case IVAS_ENC_INPUT_SBA:
            if ( ( error =
                       IVAS_ENC_ConfigureForAmbisonics(
                           hIvasEnc,
                           arg.inputFs,
                           totalBitrate,
                           arg.max_bwidth_user,
                           bandwidth,
                           arg.dtxConfig,
                           arg.inputFormatConfig.sba.order,
                           arg.inputFormatConfig.sba.isPlanar,
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
                           arg.agc,
#endif
                           arg.pca
#ifdef DEBUG_SBA_AUDIO_DUMP
            if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, arg.agc, arg.pca, &numTransportChannels ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, arg.agc, arg.pca ) ) != IVAS_ERR_OK )
                           ,
                           &numTransportChannels
#endif
                           ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
@@ -874,11 +890,13 @@ static void initArgStruct( EncArguments *arg )
    arg->ca_config_file = NULL;
    arg->mimeOutput = false;

#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#ifdef AGC_ENABLE_FOR_LBR
    arg->agc = IVAS_ENC_AGC_UNDEFINED;
#else
    arg->agc = IVAS_DEFAULT_AGC;
#endif
#endif /* AGC_ENABLE_FOR_LBR */
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */
    arg->pca = false;
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
@@ -1384,6 +1402,7 @@ static bool parseCmdlIVAS_enc(
            arg->inputFormatConfig.stereoToMonoDownmix = true;
            i++;
        }
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
        else if ( strcmp( argv_to_upper, "-AGC" ) == 0 )
        {
            i++;
@@ -1409,6 +1428,7 @@ static bool parseCmdlIVAS_enc(
                return false;
            }
        }
#endif
        else if ( strcmp( argv_to_upper, "-BYPASS" ) == 0 ) // VE: should be renamed to "-pca"
        {
            i++;
@@ -1648,13 +1668,15 @@ static void usage_enc( void )
#ifdef DEBUG_SBA
    fprintf( stdout, "-tag                : Tag name for intermediate debug files\n" );
#endif
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#ifdef AGC_ENABLE_FOR_LBR
    fprintf( stdout, "-agc op             : SBA Adaptive gain control, op = (0, 1).  \n" );
    fprintf( stdout, "                      By default op is 1 (activated) for bitrates between 24400 and 32000,\n" );
    fprintf( stdout, "                      otherwise it is 0 (deactivated) for all other bitrates\n" );
#else
    fprintf( stdout, "-agc op             : SBA Adaptive gain control, op = (0, 1), by default op is 0 or deactivated\n" );
#endif
#endif /* AGC_ENABLE_FOR_LBR */
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */

    fprintf( stdout, "-bypass mode        : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" );
#ifdef DEBUGGING
+5 −1
Original line number Diff line number Diff line
@@ -45,8 +45,10 @@
#include "ivas_stat_com.h"
#include "ivas_error_utils.h"
#ifdef AGC_ENABLE_FOR_LBR
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#include "lib_enc.h"
#endif
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */
#endif /* AGC_ENABLE_FOR_LBR */

/* clang-format off */

@@ -3774,7 +3776,9 @@ void ivas_sba_prototype_renderer(
/* AGC */
#ifdef AGC_ENABLE_FOR_LBR
int16_t ivas_agc_enc_get_enablement_flag(
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    IVAS_ENC_AGC agc_configuration,                             /* i  : configuration used when encoder was initialised from cmd line */
#endif
    int16_t nchan_transport                                     /* i  : number of transport channels                                  */
);
#endif
+1 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@
#endif
/*#define SPAR_HOA_DBG*/                        /* SPAR HOA debug statements */
/*#define DEBUG_BINAURAL_FILTER_DESIGN*/        /* debugging of Crend binaural filter design */
#define DEBUG_AGC_ENCODER_CMD_OPTION            /* Ability to force enable or disable AGC behaviour in DIRAC/SPAR via command line option */

#endif
/* #################### End DEBUGGING switches ############################ */
+19 −3
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_
#endif

#ifdef AGC_ENABLE_FOR_LBR
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
/*-----------------------------------------------------------------------------------------*
 * Function ivas_agc_enc_get_enablement_flag()
 *
@@ -68,16 +69,31 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_
 * enablement, otherwise AGC is enabled only if there is one transport channel.
 *
 *-----------------------------------------------------------------------------------------*/
#else
/*-----------------------------------------------------------------------------------------*
 * Function ivas_agc_enc_get_enablement_flag()
 *
 * This function determines if AGC should be enabled or disabled.
 * AGC is enabled only if there is one transport channel.
 *
 *-----------------------------------------------------------------------------------------*/
#endif

int16_t ivas_agc_enc_get_enablement_flag(
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    IVAS_ENC_AGC agc_configuration,
#endif
    int16_t nchan_transport )
{
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    return (int16_t) ( ( agc_configuration == IVAS_ENC_AGC_UNDEFINED )
                           ? ( nchan_transport == 1 )
                           : agc_configuration );
}
#else
    return (int16_t) ( nchan_transport == 1 );
#endif
}
#endif /* AGC_ENABLE_FOR_LBR */

/*-----------------------------------------------------------------------------------------*
 * Function ivas_agc_enc_init()
+4 −0
Original line number Diff line number Diff line
@@ -121,7 +121,11 @@ ivas_error ivas_spar_enc_open(

    /* AGC handle */
#ifdef AGC_ENABLE_FOR_LBR
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    hSpar->AGC_Enable = ivas_agc_enc_get_enablement_flag( hEncoderConfig->Opt_AGC_ON, nchan_transport );
#else
    hSpar->AGC_Enable = ivas_agc_enc_get_enablement_flag( nchan_transport );
#endif
#endif
    if ( ( error = ivas_spar_agc_enc_open( &hSpar->hAgcEnc, input_Fs, nchan_inp ) ) != IVAS_ERR_OK )
    {
Loading