Commit d1eceed9 authored by vaclav's avatar vaclav
Browse files

group debugging parameters/options/code

parent 5e5e2ec5
Loading
Loading
Loading
Loading
Loading
+31 −34
Original line number Diff line number Diff line
@@ -105,20 +105,22 @@ typedef struct
    bool hrtfReaderEnabled;
    char *hrtfFileName;
    IVAS_DEC_INPUT_FORMAT inputFormat;
#ifdef DEBUGGING
    bool forceSubframeBinauralization;
    IVAS_DEC_FORCED_REND_MODE forcedRendMode;
#endif
    bool customLsOutputEnabled;
    char *customLsSetupFilename;
    int16_t orientation_tracking;
    float no_diegetic_pan;
    bool renderConfigEnabled;
    char *renderConfigFilename;

#ifdef DEBUGGING
    bool forceSubframeBinauralization;
    IVAS_DEC_FORCED_REND_MODE forcedRendMode;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
#endif

#endif

} DecArguments;


@@ -128,12 +130,10 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef DEBUGGING
static int16_t app_own_random( int16_t *seed );
#endif
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
#ifdef DEBUGGING
static int16_t app_own_random( int16_t *seed );
static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar );
#endif

@@ -582,11 +582,12 @@ cleanup:
        printf( "\n" );
    }

#ifdef DEBUGGING
    dbgclose();

#ifdef DEBUG_SBA_AUDIO_DUMP
    ivas_close_sba_decoder_debug_files( arg.output_Fs, numOutChannels, numTransportChannels, pca_ingest_channels );
#endif
#ifdef DEBUGGING
    dbgclose();
#endif

    return mainFailed ? -1 : 0;
@@ -689,6 +690,9 @@ static bool parseCmdlIVAS_dec(

    arg->forcedRendMode = IVAS_DEC_FORCE_REND_UNFORCED;
    arg->forceSubframeBinauralization = false;
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
#endif
#endif
    arg->output_Fs = 48000;
    arg->outputFormat = IVAS_DEC_OUTPUT_MONO;
@@ -720,9 +724,6 @@ static bool parseCmdlIVAS_dec(

    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
    arg->no_diegetic_pan = 0.f;
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
#endif

    /*-----------------------------------------------------------------*
     * Initialization
@@ -791,21 +792,6 @@ static bool parseCmdlIVAS_dec(
            arg->jbmOffsetFilename = argv[i];
            i++;
        }
#ifdef DEBUGGING
        else if ( strcmp( argv_to_upper, "-FEC" ) == 0 )
        {
            ftmp = 0.0f;
            if ( sscanf( argv[i + 1], "%f", &ftmp ) != 1 )
            {
                arg->FEPatterFileName = argv[i + 1];
            }
            else
            {
                arg->FER = ftmp;
            }
            i += 2;
        }
#endif
        else if ( strcmp( argv_to_upper, "-Q" ) == 0 )
        {
            arg->quietModeEnabled = true;
@@ -827,6 +813,19 @@ static bool parseCmdlIVAS_dec(
            }
        }
#ifdef DEBUGGING
        else if ( strcmp( argv_to_upper, "-FEC" ) == 0 )
        {
            ftmp = 0.0f;
            if ( sscanf( argv[i + 1], "%f", &ftmp ) != 1 )
            {
                arg->FEPatterFileName = argv[i + 1];
            }
            else
            {
                arg->FER = ftmp;
            }
            i += 2;
        }
        else if ( strcmp( argv_to_upper, "-FORCE" ) == 0 )
        {
            i++;
@@ -837,6 +836,11 @@ static bool parseCmdlIVAS_dec(
                i++;
            }
        }
        else if ( strcmp( argv_to_upper, "-FORCE_SUBFRAME_BIN" ) == 0 ) /* Force binauralization to subframe (5 ms) resolution */
        {
            arg->forceSubframeBinauralization = true;
            i++;
        }
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
        /*-----------------------------------------------------------------*
@@ -948,13 +952,6 @@ static bool parseCmdlIVAS_dec(
            }
            i++;
        }
#ifdef DEBUGGING
        else if ( strcmp( argv_to_upper, "-FORCE_SUBFRAME_BIN" ) == 0 ) /* Force binauralization to subframe (5 ms) resolution */
        {
            arg->forceSubframeBinauralization = true;
            i++;
        }
#endif

        /*-----------------------------------------------------------------*
         * Option not recognized
+74 −71
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ typedef union _EncInputFormatConfig
{
    /* MONO details */
    bool stereoToMonoDownmix;

#ifdef DEBUGGING
    /* STEREO details */
    IVAS_ENC_STEREO_MODE stereoMode;
@@ -83,16 +84,20 @@ typedef union _EncInputFormatConfig
        int16_t numObjects;
        const char *metadataFiles[IVAS_MAX_NUM_OBJECTS];
    } ism;

    /* SBA details */
    struct EncSbaConfig
    {
        IVAS_ENC_SBA_ORDER order;
        bool isPlanar;
    } sba;

    /* MASA details */
    IVAS_ENC_MASA_VARIANT masaVariant;

    /* MC details */
    IVAS_ENC_MC_LAYOUT mcLayout;

} EncInputFormatConfig;

/* Struct for storing cmdln arguments */
@@ -112,24 +117,24 @@ typedef struct
    bool quietModeEnabled;
    bool delayCompensationEnabled;
    const char *masaMetadataFile;
#ifdef DEBUGGING
    IVAS_ENC_FORCED_MODE forcedMode;
    const char *forcedModeFile;
#endif
    IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig;
    const char *ca_config_file;
    bool mimeOutput;

#ifdef DEBUGGING
    IVAS_ENC_FORCED_MODE forcedMode;
    const char *forcedModeFile;
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    IVAS_ENC_AGC agc;
#endif
    bool pca;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
#endif
#ifdef DEBUG_SBA
    const char *dbg_file_tag;
#endif
#endif
    bool pca;

} EncArguments;

@@ -214,17 +219,13 @@ int main(
    int16_t *pcmBuf = NULL;
#ifdef DEBUGGING
    FILE *f_forcedModeProfile = NULL;
#endif

#ifdef DEBUG_SBA
    int16_t numTransportChannels = 1;
#endif

#ifdef WMOPS
    size_t SRAM_size = 0;
#endif

#ifdef WMOPS
    size_t SRAM_size = 0;
    reset_wmops();
    reset_stack();
#endif
@@ -820,13 +821,6 @@ cleanup:
        fclose( f_bitrateProfile );
    }

#ifdef DEBUGGING
    if ( f_forcedModeProfile )
    {
        fclose( f_forcedModeProfile );
    }
#endif

    IVAS_ENC_Close( &hIvasEnc );

#ifdef RAM_COUNTING_TOOL
@@ -842,13 +836,18 @@ cleanup:

#ifdef DEBUGGING
    dbgclose();
#endif

    if ( f_forcedModeProfile )
    {
        fclose( f_forcedModeProfile );
    }

#ifdef DEBUG_SBA
    ivas_close_sba_encoder_debug_files();
#ifdef DEBUG_AGC
    ivas_close_agc_debug_files();
#endif
#endif
#endif

    return mainFailed ? -1 : 0;
@@ -878,24 +877,24 @@ static void initArgStruct( EncArguments *arg )
    arg->quietModeEnabled = false;
    arg->delayCompensationEnabled = true;
    arg->masaMetadataFile = NULL;
#ifdef DEBUGGING
    arg->forcedMode = IVAS_ENC_FORCE_UNFORCED;
    arg->forcedModeFile = NULL;
#endif
    arg->caConfig = IVAS_ENC_GetDefaultChannelAwareConfig();
    arg->ca_config_file = NULL;
    arg->mimeOutput = false;

#ifdef DEBUGGING
    arg->forcedMode = IVAS_ENC_FORCE_UNFORCED;
    arg->forcedModeFile = NULL;
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    arg->agc = IVAS_ENC_AGC_UNDEFINED;
#endif
    arg->pca = false;
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
#endif
#ifdef DEBUG_SBA
    arg->dbg_file_tag = NULL;
#endif
#endif
    arg->pca = false;

    return;
}
@@ -1057,6 +1056,54 @@ static bool parseCmdlIVAS_enc(
        }
#endif /* #ifdef DEBUG_MODE_INFO_TWEAK */
#endif /* #ifdef DEBUG_MODE_INFO */

#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
        /*-----------------------------------------------------------------*
         * IVAS SPAR AGC option
         *-----------------------------------------------------------------*/
        else if ( strcmp( argv_to_upper, "-AGC" ) == 0 )
        {
            i++;
            if ( i < argc - 4 )
            {
                arg->agc = ( atoi( argv[i] ) ) ? IVAS_ENC_AGC_ENABLED : IVAS_ENC_AGC_DISABLED;
                if ( argv[i] == NULL || atoi( argv[i] ) < 0 || atoi( argv[i] ) > 1 )
                {
                    fprintf( stderr, "Error: wrong adaptive gain control option specified (%d), expected 0 or 1\n\n", (int32_t) atoi( argv[i] ) );
                    usage_enc();
                    return false;
                }
                i++;
            }
            else
            {
                fprintf( stderr, "Error: unspecified adaptive gain control option\n\n" );
                usage_enc();
                return false;
            }
        }
#endif

#ifdef DEBUG_SBA
        /*-----------------------------------------------------------------*
         * IVAS SPAR debug files tag
         *-----------------------------------------------------------------*/
        else if ( strcmp( argv_to_upper, "-TAG" ) == 0 )
        {
            i++;
            if ( i < argc - 4 )
            {
                arg->dbg_file_tag = argv[i];
                ++i;
            }
            else
            {
                fprintf( stderr, "Error: [IVAS SPAR Encoder] unspecified tag value \n\n" );
                usage_enc();
                return false;
            }
        }
#endif
#endif /* #ifdef DEBUGGING */

        /*-----------------------------------------------------------------*
@@ -1394,29 +1441,6 @@ static bool parseCmdlIVAS_enc(
            arg->inputFormatConfig.stereoToMonoDownmix = true;
            i++;
        }
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
        else if ( strcmp( argv_to_upper, "-AGC" ) == 0 )
        {
            i++;
            if ( i < argc - 4 )
            {
                arg->agc = ( atoi( argv[i] ) ) ? IVAS_ENC_AGC_ENABLED : IVAS_ENC_AGC_DISABLED;
                if ( argv[i] == NULL || atoi( argv[i] ) < 0 || atoi( argv[i] ) > 1 )
                {
                    fprintf( stderr, "Error: wrong adaptive gain control option specified (%d), expected 0 or 1\n\n", (int32_t) atoi( argv[i] ) );
                    usage_enc();
                    return false;
                }
                i++;
            }
            else
            {
                fprintf( stderr, "Error: unspecified adaptive gain control option\n\n" );
                usage_enc();
                return false;
            }
        }
#endif
        else if ( strcmp( argv_to_upper, "-BYPASS" ) == 0 ) // VE: should be renamed to "-pca"
        {
            i++;
@@ -1450,26 +1474,6 @@ static bool parseCmdlIVAS_enc(
                return false;
            }
        }
#ifdef DEBUG_SBA
        /*-----------------------------------------------------------------*
         * IVAS SPAR debug files tag
         *-----------------------------------------------------------------*/
        else if ( strcmp( argv_to_upper, "-TAG" ) == 0 )
        {
            i++;
            if ( i < argc - 4 )
            {
                arg->dbg_file_tag = argv[i];
                ++i;
            }
            else
            {
                fprintf( stderr, "Error: [IVAS SPAR Encoder] unspecified tag value \n\n" );
                usage_enc();
                return false;
            }
        }
#endif

        /*-----------------------------------------------------------------*
         * Option not recognized
@@ -1653,6 +1657,10 @@ static void usage_enc( void )
    fprintf( stdout, "                      The encoder produces TS26.445 Annex.2.6 Mime Storage Format, (not RFC4867 Mime Format).\n" );
    fprintf( stdout, "                      default output bitstream file format is G.192\n" );

    fprintf( stdout, "-bypass mode        : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" );
#ifdef DEBUGGING
    fprintf( stdout, "-force T            : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" );
    fprintf( stdout, "                      alternatively, T can be a text file where each line contains \"nb_frames T\"\n" );
#ifdef DEBUG_SBA
    fprintf( stdout, "-tag                : Tag name for intermediate debug files\n" );
#endif
@@ -1661,11 +1669,6 @@ static void usage_enc( void )
    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" );
#endif

    fprintf( stdout, "-bypass mode        : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" );
#ifdef DEBUGGING
    fprintf( stdout, "-force T            : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" );
    fprintf( stdout, "                      alternatively, T can be a text file where each line contains \"nb_frames T\"\n" );
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
    fprintf( stdout, "-info <folder>      : specify subfolder name for debug output\n" );
+3 −3
Original line number Diff line number Diff line
@@ -80,14 +80,14 @@ typedef enum
    IVAS_ERR_INVALID_INDEX,
    IVAS_ERR_NOT_SUPPORTED_OPTION,
    IVAS_ERR_NOT_IMPLEMENTED,
#ifdef DEBUGGING
    IVAS_ERR_INVALID_FORCE_MODE,
#endif
    IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH,
    IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT,
    IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE,
#ifdef DEBUGGING
    IVAS_ERR_INVALID_FORCE_MODE,
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    IVAS_ERR_INVALID_AGC,
#endif
#endif

    /*----------------------------------------*
+12 −10
Original line number Diff line number Diff line
@@ -68,6 +68,16 @@ 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.
 *
 *-----------------------------------------------------------------------------------------*/

/*! r: AGC enable flag */
int16_t ivas_agc_enc_get_flag(
    int16_t agc_configuration, /* i  : AGC configuration from command-line     */
    int16_t nchan_transport    /* i  : number of transport channels            */
)
{
    return (int16_t) ( ( agc_configuration == SBA_AGC_DEFAULT ) ? ( nchan_transport == 1 ) : agc_configuration );
}

#else
/*-----------------------------------------------------------------------------------------*
 * Function ivas_agc_enc_get_flag()
@@ -76,25 +86,17 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_
 * AGC is enabled only if there is one transport channel.
 *
 *-----------------------------------------------------------------------------------------*/
#endif

/*! r: AGC enable flag */
int16_t ivas_agc_enc_get_flag(
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    int16_t agc_configuration, /* i  : AGC configuration from command-line     */
#endif
    int16_t nchan_transport /* i  : number of transport channels            */
)
{
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    return (int16_t) ( ( agc_configuration == SBA_AGC_DEFAULT )
                           ? ( nchan_transport == 1 )
                           : agc_configuration );
#else
    return (int16_t) ( nchan_transport == 1 );
#endif
}

#endif

/*-----------------------------------------------------------------------------------------*
 * Function ivas_agc_enc_init()
 *
+3 −3
Original line number Diff line number Diff line
@@ -999,9 +999,6 @@ typedef struct encoder_config_structure
    int16_t last_Opt_SC_VBR;                        /* flag indicating prev frame's SC-VBR mode */

    /* temp. development parameters */
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    int16_t Opt_AGC_ON;                             /* flag indicating AGC operation in SBA */
#endif
    int16_t Opt_PCA_ON;                             /* flag indicating PCA operation in SBA */

#ifdef DEBUGGING
@@ -1009,6 +1006,9 @@ typedef struct encoder_config_structure
    int16_t stereo_mode_cmdl;                       /* stereo mode forced from the command-line  */
    int16_t force;                                  /* parameter to force specific "core" of the Core-Coder*/
    int16_t mdct_stereo_mode_cmdl;                  /* mdct stereo mode forced from command-line, employed only when DEBUG_FORCE_MDCT_STEREO_MODE is activated */
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    int16_t Opt_AGC_ON;                             /* flag indicating AGC operation in SBA */
#endif
#endif


Loading