Commit ad9ca4c3 authored by BOHMRR's avatar BOHMRR
Browse files

encoder: simplified _debug_files() calls

parent e3af3a7d
Loading
Loading
Loading
Loading
+8 −25
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@

#define WMC_TOOL_MAN

#ifdef DEBUG_SBA
int16_t numTransportChannelsEnc = 1;
int16_t numInputChannels = 1;
#endif

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

#ifdef DEBUG_SBA
    spar_debug_t dbg_params;
#endif
#ifdef WMOPS
    size_t SRAM_size = 0;
#endif
@@ -555,29 +557,10 @@ int main(
    uint16_t numBits = 0;

#ifdef DEBUG_SBA
    int16_t numInputChannels;
    if ( ( error = IVAS_ENC_GetNumInputChannels( hIvasEnc, &numInputChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nGetNumInputChannels failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
        goto cleanup;
    }
    dbg_params.agc = (int16_t) arg.agc;
    dbg_params.dtx_on = (int16_t) arg.dtxConfig.enabled;
    dbg_params.file_tag = arg.dbg_file_tag;
    dbg_params.ivas_total_brate = arg.initBitrate;
    dbg_params.fs = arg.inputFs;
    dbg_params.n_ch = numInputChannels;
    int16_t numTransportChannels;
    if ( ( error = getTransportChannel( hIvasEnc, &numTransportChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nGetNumInputChannels failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
        goto cleanup;
    }
    dbg_params.n_transport = numTransportChannels;
#ifdef DEBUG_AGC
    ivas_open_agc_debug_files( &dbg_params );
    ivas_open_agc_debug_files( (int16_t) arg.agc );
#endif
    ivas_open_debug_files( &dbg_params );
    ivas_open_encoder_debug_files( arg.inputFs, numInputChannels, numTransportChannelsEnc, arg.dbg_file_tag, arg.initBitrate, (int16_t) arg.dtxConfig.enabled );
#endif

    if ( !arg.quietModeEnabled )
@@ -845,7 +828,7 @@ cleanup:
#ifdef DEBUG_SBA
    ivas_close_remove_debug_files();
#ifdef DEBUG_AGC
    ivas_close_agc_debug_files( &io_params );
    ivas_close_agc_debug_files();
#endif
#endif

+18 −20
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ int8_t file_names[NUM_DEBUG_FILES][MAX_TAG_LEN + MAX_DEBUG_TAG_LEN];


#ifdef DEBUG_AGC
FILE *agcOut; /* temporary AGC bitstream */
FILE *agcOut = NULL; /* temporary AGC bitstream */
#endif

/*-----------------------------------------------------------------------------------------*
@@ -128,21 +128,19 @@ static void cstrcat( char *_Destination, size_t _SizeInBytes, const char *_Sourc


#ifdef DEBUG_AGC
void ivas_close_agc_debug_files( spar_debug_t *pDebug_params )
{
    if ( pDebug_params->agc > 0 ) /* temporary */
void ivas_close_agc_debug_files( void )
{
    if ( agcOut != NULL )
    {
        fclose( agcOut );
        }
        agcOut = NULL;
    }
}

void ivas_open_agc_debug_files( spar_debug_t *pDebug_params )
void ivas_open_agc_debug_files( int16_t agc )
{
    /* Temporary AGC file */
    if ( pDebug_params->agc > 0 )
    if ( agc > 0 )
    {
        char agcFilename[50] = "agcBitstream.bin";
        if ( ( agcOut = fopen( agcFilename, "wb" ) ) == NULL )
@@ -311,16 +309,16 @@ void ivas_open_decoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transpor
    );
}

void ivas_open_debug_files( spar_debug_t *pDebug_params )
void ivas_open_encoder_debug_files( int32_t fs, int16_t n_ch, int16_t n_transport, const char *file_tag, int32_t ivas_total_brate, 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 ( pDebug_params->file_tag != NULL )
    if ( file_tag != NULL )
    {
        cstrcpy( (char *) file_names[0], sizeof( file_names[0] ), (const char *) pDebug_params->file_tag );
        cstrcpy( (char *) file_names[0], sizeof( file_names[0] ), (const char *) file_tag );
    }

    /* ivas_total_brate */
    switch ( pDebug_params->ivas_total_brate )
    switch ( ivas_total_brate )
    {
        case 24400:
            cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_ivasbr24k" );
@@ -361,7 +359,7 @@ void ivas_open_debug_files( spar_debug_t *pDebug_params )
    }

    /* DTX */
    if ( pDebug_params->dtx_on )
    if ( dtx_on )
    {
        cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_DTX1" );
    }
@@ -379,8 +377,8 @@ void ivas_open_debug_files( spar_debug_t *pDebug_params )
    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],
        pDebug_params->fs,
        pDebug_params->n_ch,
        fs,
        n_ch,
        16
        /* const uint32_t writeWaveExt */
    );
@@ -388,8 +386,8 @@ void ivas_open_debug_files( spar_debug_t *pDebug_params )
    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],
        pDebug_params->fs,
        pDebug_params->n_transport,
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
@@ -397,8 +395,8 @@ void ivas_open_debug_files( spar_debug_t *pDebug_params )
    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],
        pDebug_params->fs,
        pDebug_params->n_transport,
        fs,
        n_transport,
        16
        /* const uint32_t writeWaveExt */
    );
+3 −19
Original line number Diff line number Diff line
@@ -40,29 +40,13 @@
#include "cnst.h"
#include "tinywaveout_c.h"

/*------------------------------------------------------------------------------------------*
 * Global variables used for debugging
 *------------------------------------------------------------------------------------------*/

typedef struct spar_debug_t
{
    const char *file_tag;
    int32_t ivas_total_brate;
    int16_t dtx_on;
    int16_t agc;
    int32_t fs;
    int16_t n_ch;
    int16_t n_transport;
    int16_t pca_ingest_channels;
} spar_debug_t;

#ifdef DEBUG_AGC
void ivas_close_agc_debug_files( spar_debug_t *pDebug_params );
void ivas_open_agc_debug_files( spar_debug_t *pDebug_params );
void ivas_close_agc_debug_files( void );
void ivas_open_agc_debug_files( int16_t agc );
#endif
float ivas_spar_dump_signal_wav( int16_t input_frame, float data_f[][L_FRAME48k * 2], int16_t no_channel, WAVEFILEOUT *wave_file );
void ivas_close_remove_debug_files( void );
void ivas_open_debug_files( spar_debug_t *pDebug_params );
void ivas_open_encoder_debug_files( int32_t fs, int16_t n_ch, 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 );
+4 −18
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@
#ifdef DEBUG_AGC
extern FILE *agcOut;

static int16_t ivas_agc_writeBits( FILE *stream, ivas_agc_enc_in_buf_t *in_buf, ivas_agc_enc_state_t *pState );
static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_agc_enc_state_t *pState );
#endif


@@ -472,7 +472,7 @@ void ivas_agc_enc_process(

#ifdef DEBUG_AGC
    /* writing to a temporary bitstream file */
    if ( ivas_agc_writeBits( agcOut, pIn_buf, pState ) )
    if ( ivas_agc_writeBits( agcOut, n_channels, pState ) )
    {
        /* TODO: return error once error codes are harmonized */
        IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "SPAR ENC AGC Failed to open agcOut\n " );
@@ -483,21 +483,7 @@ void ivas_agc_enc_process(
}

#ifdef DEBUG_AGC

/*-----------------------------------------------------------------------------------------*
 * Function description -
 * Get a window function
 *
 * Inputs -
 * float* winFunc
 * unsigned integer frameLen
 *
 * Outputs -
 * returns status
 *
 *
 *-----------------------------------------------------------------------------------------*/
static int16_t ivas_agc_writeBits( FILE *stream, ivas_agc_enc_in_buf_t *pIn_buf, ivas_agc_enc_state_t *pState )
static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_agc_enc_state_t *pState )
{
    if ( stream == NULL )
    {
@@ -505,7 +491,7 @@ static int16_t ivas_agc_writeBits( FILE *stream, ivas_agc_enc_in_buf_t *pIn_buf,
    }

    int16_t num_bits = 0, num_dmx_bits[4] = { 0 };
    for ( int16_t i = 0; i < pIn_buf->n_channels; i++ )
    for ( int16_t i = 0; i < n_channels; i++ )
    {
        if ( pState->gain_data[i].absGainExpCurr < 0 ||
             pState->gain_data[i].absGainExpCurr >= (int16_t) pow( 2, pState->agc_com.betaE ) )
+10 −45
Original line number Diff line number Diff line
@@ -43,6 +43,11 @@
#include "wmops.h"
#endif

#ifdef DEBUG_SBA_AUDIO_DUMP
extern int16_t numTransportChannelsEnc;
extern int16_t numInputChannels;
#endif

/*---------------------------------------------------------------------*
 * Local struct
 *---------------------------------------------------------------------*/
@@ -466,6 +471,11 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics(

    error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() );

#ifdef DEBUG_SBA_AUDIO_DUMP
    numInputChannels = hEncoderConfig->nchan_inp;
    numTransportChannelsEnc = hIvasEnc->st_ivas->nchan_transport;
#endif

    return error;
}

@@ -946,51 +956,6 @@ ivas_error IVAS_ENC_GetDelay(
}


#ifdef DEBUG_SBA
/*---------------------------------------------------------------------*
 * IVAS_ENC_GetNumInputChannels()
 *
 *
 *---------------------------------------------------------------------*/

ivas_error IVAS_ENC_GetNumInputChannels(
    const IVAS_ENC_HANDLE hIvasEnc, /* i  : IVAS encoder handle                   */
    int16_t *numInChannels          /* o  : number of input channels with current */
)
{
    if ( !hIvasEnc->isConfigured )
    {
        return IVAS_ERR_NOT_CONFIGURED;
    }

    if ( numInChannels == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    *numInChannels = hIvasEnc->st_ivas->hEncoderConfig->nchan_inp;

    return IVAS_ERR_OK;
}


/*---------------------------------------------------------------------*
 * getTransportChannel()
 *
 *
 *---------------------------------------------------------------------*/

ivas_error getTransportChannel(
    const IVAS_ENC_HANDLE hIvasEnc, /* i  : IVAS encoder handle */
    int16_t *no_channels_Transport  /* o  : number of transport channels */
)
{
    *no_channels_Transport = hIvasEnc->st_ivas->nchan_transport;
    return IVAS_ERR_OK;
}
#endif


/*---------------------------------------------------------------------*
 * getInputBufferSize()
 *
Loading