Commit 24530a20 authored by vaclav's avatar vaclav
Browse files

improvements within DEBUG_SBA_AUDIO_DUMP:

- get rid of global variables
- unify SPAR debug function names
- formal improvements (add 'const', 'return', ...)
parent 553699bb
Loading
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -58,11 +58,6 @@
#endif
#include "render_config_reader.h"

#ifdef DEBUG_SBA
int16_t numTransportChannels = 1;
int16_t numOutChannels = 1;
int16_t pca_ingest_channels = 1;
#endif

#define WMC_TOOL_MAN

@@ -201,6 +196,9 @@ int main(
#ifdef DEBUGGING
    int32_t noClipping;
    int32_t cnt_frames_limited;
#ifdef DEBUG_SBA_AUDIO_DUMP
    int16_t numOutChannels, numTransportChannels, pca_ingest_channels;
#endif
#endif

#ifdef WMOPS
@@ -395,8 +393,8 @@ int main(
        }
    }

#ifdef DEBUG_SBA
    ivas_open_decoder_debug_files( arg.output_Fs, numOutChannels, numTransportChannels );
#ifdef DEBUG_SBA_AUDIO_DUMP
    ivas_open_sba_decoder_debug_files( arg.output_Fs, 1, 1 );
#endif

    /*-----------------------------------------------------------------*
@@ -552,6 +550,10 @@ int main(

cleanup:

#ifdef DEBUG_SBA_AUDIO_DUMP
    IVAS_DEC_GetSbaDebugParams( hIvasDec, &numOutChannels, &numTransportChannels, &pca_ingest_channels );
#endif

    IVAS_DEC_Close( &hIvasDec );
    CustomLsReader_close( &hLsCustomReader );
    hrtfFileReader_close( &hrtfReader );
@@ -580,8 +582,8 @@ cleanup:
        printf( "\n" );
    }

#ifdef DEBUG_SBA
    ivas_close_decoder_debug_files( arg.output_Fs, numOutChannels, numTransportChannels, pca_ingest_channels );
#ifdef DEBUG_SBA_AUDIO_DUMP
    ivas_close_sba_decoder_debug_files( arg.output_Fs, numOutChannels, numTransportChannels, pca_ingest_channels );
#endif
#ifdef DEBUGGING
    dbgclose();
+10 −6
Original line number Diff line number Diff line
@@ -53,12 +53,8 @@
#include "debug.h"
#endif


#define WMC_TOOL_MAN

#ifdef DEBUG_SBA
int16_t numTransportChannelsEnc = 1;
#endif

/*------------------------------------------------------------------------------------------*
 * Local constants, enums, structures
@@ -218,6 +214,10 @@ int main(
    FILE *f_forcedModeProfile = NULL;
#endif

#ifdef DEBUG_SBA
    int16_t numTransportChannels = 1;
#endif

#ifdef WMOPS
    size_t SRAM_size = 0;
#endif
@@ -440,7 +440,11 @@ int main(
            }
            break;
        case IVAS_ENC_INPUT_SBA:
#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 )
#endif
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
@@ -559,7 +563,7 @@ int main(
#ifdef DEBUG_AGC
    ivas_open_agc_debug_files( (int16_t) arg.agc );
#endif
    ivas_open_encoder_debug_files( arg.inputFs, numTransportChannelsEnc, arg.dbg_file_tag, arg.initBitrate, (int16_t) arg.dtxConfig.enabled );
    ivas_open_sba_encoder_debug_files( arg.inputFs, numTransportChannels, arg.dbg_file_tag, arg.initBitrate, (int16_t) arg.dtxConfig.enabled );
#endif

    if ( !arg.quietModeEnabled )
@@ -825,7 +829,7 @@ cleanup:
#endif

#ifdef DEBUG_SBA
    ivas_close_remove_debug_files();
    ivas_close_sba_encoder_debug_files();
#ifdef DEBUG_AGC
    ivas_close_agc_debug_files();
#endif
+4 −4
Original line number Diff line number Diff line
@@ -114,17 +114,17 @@
/*#define TDREND_HRTF_TABLE_METHODS*/           /* Enable HRTF lookup from tables, for testing & evaluation. Supply file in table format to use. Note that a suitable HR filter lookup method should be written if the filters sample point grids are not in the formats. */
/*#define TDREND_STANDALONE*/                   /* Used when renderer is built in standalone form, without IVAS encoding/decoding (see scripts/object_renderer_standalone). This is just here to ensure this is cleaned out by prepare_instrumentation.sh */

#define DEBUG_SBA                           /* debug DIRAC/SPAR in-out */
/*#define DEBUG_SBA*/                           /* debug DIRAC/SPAR in-out */
#ifdef DEBUG_SBA
#define DEBUG_SBA_AUDIO_DUMP                /* SBA intermediate audio wav file dumping */
#define DEBUG_SBA_MD_DUMP                   /* SBA metadata and variable file dumping */
/*#define DEBUG_SBA_AUDIO_DUMP*/                /* SBA intermediate audio wav file dumping */
/*#define DEBUG_SBA_MD_DUMP*/                   /* SBA metadata and variable file dumping */
/*#define DEBUG_SPAR_MD_TARGET_TUNING*/         /* SPAR MD target bitrate tuning debug code */
/*#define DEBUG_SPAR_BYPASS_EVS_CODEC*/         /* bypass EVS coding in float precision, emulating EVS encoder/decoder delay */
/*#define DEBUG_SPAR_WRITE_OUT_COV*/            /* write covariance per frame into a text file for verification */
/*#define DEBUG_SPAR_DIRAC_WRITE_OUT_PRED_PARS*/
/*#define DEBUG_AGC*/                           /* debug SPAR AGC in-out */
#endif
#define SPAR_HOA_DBG                        /* SPAR HOA debug statements */
/*#define SPAR_HOA_DBG*/                        /* SPAR HOA debug statements */
/*#define DEBUG_BINAURAL_FILTER_DESIGN*/        /* debugging of Crend binaural filter design */

#endif
+78 −71
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ void ivas_close_agc_debug_files( void )
        fclose( agcOut );
        agcOut = NULL;
    }

    return;
}

void ivas_open_agc_debug_files( int16_t agc )
@@ -150,10 +152,16 @@ void ivas_open_agc_debug_files( int16_t agc )
        }
        fprintf( stdout, "Temporary gain control bitstream file %s is opened\n", agcFilename );
    }

    return;
}
#endif

void UpdateWave( const uint32_t sampleRate, const uint32_t numChannels, const uint32_t bps, WAVEFILEOUT *spar_wav )
static void UpdateWave( 
    const uint32_t sampleRate, 
    const uint32_t numChannels, 
    const uint32_t bps, 
    WAVEFILEOUT *spar_wav )
{
    uint32_t blockAlignment = 0;
    uint16_t writeValue16;
@@ -169,9 +177,18 @@ void UpdateWave( const uint32_t sampleRate, const uint32_t numChannels, const ui
    writeValue32 = LittleEndian32( sampleRate * blockAlignment );
    fwrite( &writeValue32, sizeof( writeValue32 ), 1, spar_wav->theFile );
    fwrite( &writeValue16, sizeof( writeValue16 ), 1, spar_wav->theFile );

    return;
}

void ivas_spar_dump_signal_wav( int16_t input_frame, float **ppPcm, float pcm_array[IVAS_MAX_NUM_CH][L_FRAME48k], int16_t no_channel, WAVEFILEOUT *wave_file, char *location )

void ivas_spar_dump_signal_wav( 
    const int16_t input_frame, 
    float **ppPcm, 
    float pcm_array[IVAS_MAX_NUM_CH][L_FRAME48k], 
    const int16_t no_channel, 
    WAVEFILEOUT *wave_file, 
    char *location )
{
    float tmp_value;
    int16_t pcm_value, i, j, k;
@@ -181,6 +198,7 @@ void ivas_spar_dump_signal_wav( int16_t input_frame, float **ppPcm, float pcm_ar
    int16_t Clipping = 0;
    float largest_value = 0;
    float db_value = 0;

    for ( j = 0; j < input_frame; j++ )
    {
        for ( i = 0; i < no_channel; i++, k++ )
@@ -216,18 +234,23 @@ void ivas_spar_dump_signal_wav( int16_t input_frame, float **ppPcm, float pcm_ar
        db_value = 20.f * (float) log( largest_value );
        fprintf( stderr, "%d\t Clipping detected ", Clipping );
    }
    WriteWavShort(
        wave_file,
        debug_tmp,
        ( no_channel * input_frame ) );

    WriteWavShort( wave_file, debug_tmp, ( no_channel * input_frame ) );

    if ( db_value )
    {
        fprintf( stderr, "\t In %s largest clipped sample in dB %f \n", location, db_value );
    }

    return;
}

void ivas_close_decoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transport, int16_t pca_ingest_channels )

void ivas_close_sba_decoder_debug_files( 
    const int32_t fs, 
    const int16_t n_ch, 
    const int16_t n_transport, 
    const int16_t pca_ingest_channels )
{
    if ( spar_foa_dec_wav[0] != NULL )
    {
@@ -249,9 +272,12 @@ void ivas_close_decoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transpo
        UpdateWave( fs, n_ch, 16, spar_foa_dec_wav[3] );
        CloseWav( spar_foa_dec_wav[3] );
    }

    return;
}

void ivas_close_remove_debug_files( void )

void ivas_close_sba_encoder_debug_files( void )
{

    if ( spar_foa_enc_wav[0] != NULL )
@@ -280,48 +306,43 @@ void ivas_close_remove_debug_files( void )
      fprintf(fp, "%s\n", file_names[0]);
      fprintf(fp, "%d\n", iter_max);
      fclose(fp); */

    return;
}

void ivas_open_decoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transport )

void ivas_open_sba_decoder_debug_files( 
    const int32_t fs, 
    const int16_t n_ch, 
    const int16_t n_transport )
{
    int8_t fb_wav_dump_path[4][MAX_PLUG_IN_FILE_LEN] = { "", "", "", "" };
    
    cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), "dec_out.wav" );
    spar_foa_dec_wav[0] = CreateWav(
        (const char *) fb_wav_dump_path[0],
        fs,
        n_ch,
        32
        /* const uint32_t writeWaveExt */
    );
    spar_foa_dec_wav[0] = CreateWav( (const char *) fb_wav_dump_path[0], fs, n_ch, 32 /* const uint32_t writeWaveExt */ );
    
    cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), "agc_dec_out.wav" );
    spar_foa_dec_wav[1] = CreateWav(
        (const char *) fb_wav_dump_path[1],
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
    spar_foa_dec_wav[1] = CreateWav( (const char *) fb_wav_dump_path[1], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
    
    cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), "pca_dec.wav" );
    spar_foa_dec_wav[2] = CreateWav(
        (const char *) fb_wav_dump_path[2],
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
    spar_foa_dec_wav[2] = CreateWav( (const char *) fb_wav_dump_path[2], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );
    
    cstrcat( (char *) fb_wav_dump_path[3], sizeof( fb_wav_dump_path[3] ), "cldfbSynthesis.wav" );
    spar_foa_dec_wav[3] = CreateWav(
        (const char *) fb_wav_dump_path[3],
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
    spar_foa_dec_wav[3] = CreateWav( (const char *) fb_wav_dump_path[3], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );

    return;
}

void ivas_open_encoder_debug_files( int32_t fs, int16_t n_transport, const char *file_tag, int32_t ivas_total_brate, int16_t dtx_on )

void ivas_open_sba_encoder_debug_files( 
    const int32_t fs, 
    const int16_t n_transport, 
    const char *file_tag, 
    const int32_t ivas_total_brate, 
    const int16_t dtx_on )
{
    int8_t fb_wav_dump_path[3][MAX_PLUG_IN_FILE_LEN] = { "spar_foa_enc", "spar_foa_enc", "spar_foa_enc" };
    
    if ( file_tag != NULL )
    {
        cstrcpy( (char *) file_names[0], sizeof( file_names[0] ), (const char *) file_tag );
@@ -330,40 +351,40 @@ void ivas_open_encoder_debug_files( int32_t fs, int16_t n_transport, const char
    /* ivas_total_brate */
    switch ( ivas_total_brate )
    {
        case 24400:
        case IVAS_24k4:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr24k" );
            break;
        case 32000:
        case IVAS_32k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr32k" );
            break;
        case 48000:
        case IVAS_48k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr48k" );
            break;
        case 64000:
        case IVAS_64k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr64k" );
            break;
        case 80000:
        case IVAS_80k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr80k" );
            break;
        case 96000:
        case IVAS_96k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr96k" );
            break;
        case 128000:
        case IVAS_128k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr128k" );
            break;
        case 160000:
        case IVAS_160k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr160k" );
            break;
        case 192000:
        case IVAS_192k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr192k" );
            break;
        case 256000:
        case IVAS_256k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr256k" );
            break;
        case 384000:
        case IVAS_384k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr384k" );
            break;
        case 512000:
        case IVAS_512k:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr512k" );
            break;
    }
@@ -385,31 +406,17 @@ void ivas_open_encoder_debug_files( int32_t fs, int16_t n_transport, const char

    cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), (const char *) file_names[2] );
    cstrcat( (char *) fb_wav_dump_path[0], sizeof( fb_wav_dump_path[0] ), "_pca_enc.wav" );
    spar_foa_enc_wav[0] = CreateWav(
        (const char *) fb_wav_dump_path[0],
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
    spar_foa_enc_wav[0] = CreateWav( (const char *) fb_wav_dump_path[0], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );

    cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), (const char *) file_names[2] );
    cstrcat( (char *) fb_wav_dump_path[1], sizeof( fb_wav_dump_path[1] ), "_fb_mixer_enc.wav" );
    spar_foa_enc_wav[1] = CreateWav(
        (const char *) fb_wav_dump_path[1],
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
    spar_foa_enc_wav[1] = CreateWav( (const char *) fb_wav_dump_path[1], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );

    cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), (const char *) file_names[2] );
    cstrcat( (char *) fb_wav_dump_path[2], sizeof( fb_wav_dump_path[2] ), "_agc_enc.wav" );
    spar_foa_enc_wav[2] = CreateWav(
        (const char *) fb_wav_dump_path[2],
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
    spar_foa_enc_wav[2] = CreateWav( (const char *) fb_wav_dump_path[2], fs, n_transport, 16 /* const uint32_t writeWaveExt */ );

    return;
}

#endif /* DEBUG_SBA */
+8 −6
Original line number Diff line number Diff line
@@ -41,18 +41,20 @@
#include "ivas_cnst.h"
#include "tinywaveout_c.h"

#ifdef DEBUG_SBA_AUDIO_DUMP
extern WAVEFILEOUT *spar_foa_enc_wav[3];
extern WAVEFILEOUT *spar_foa_dec_wav[4];
#endif

#ifdef DEBUG_AGC
void ivas_close_agc_debug_files( void );
void ivas_open_agc_debug_files( int16_t agc );
#endif
void ivas_spar_dump_signal_wav( int16_t input_frame, float **ppPcm, float pcm_array[IVAS_MAX_NUM_CH][L_FRAME48k], int16_t no_channel, WAVEFILEOUT *wave_file, char *location );
void ivas_close_remove_debug_files( void );
void ivas_open_encoder_debug_files( int32_t fs, int16_t n_transport, const char *file_tag, int32_t ivas_total_brate, int16_t dtx_on );
void ivas_close_decoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transport, int16_t pca_ingest_channels );
void ivas_open_decoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transport );
void UpdateWave( const uint32_t sampleRate, const uint32_t numChannels, const uint32_t bps, WAVEFILEOUT *spar_wav );
void ivas_spar_dump_signal_wav( const int16_t input_frame, float **ppPcm, float pcm_array[IVAS_MAX_NUM_CH][L_FRAME48k], const int16_t no_channel, WAVEFILEOUT *wave_file, char *location );
void ivas_close_sba_encoder_debug_files( void );
void ivas_open_sba_encoder_debug_files( const int32_t fs, const int16_t n_transport, const char *file_tag, const int32_t ivas_total_brate, const int16_t dtx_on );
void ivas_close_sba_decoder_debug_files( const int32_t fs, const int16_t n_ch, const int16_t n_transport, const int16_t pca_ingest_channels );
void ivas_open_sba_decoder_debug_files( const int32_t fs, const int16_t n_ch, const int16_t n_transport );
#endif

#endif /* SBA_DEBUG_H */
Loading