diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index 144ceed2da76407275b45f89b40ec7240b71df16..ed091573fc0f72621a89a53be938267e4d4289c0 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -78,7 +78,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -109,7 +109,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) @@ -147,7 +147,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 58dbb6aab7a0e9da53c0f896fd1122c1b74e2148..d8efa0879d63594f1c3c56f85acf340c61f14e25 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false @@ -97,7 +97,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false @@ -124,7 +124,7 @@ AnySuitable false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true @@ -147,7 +147,7 @@ - + @@ -155,7 +155,7 @@ - + diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index 0e21d3f4a3c11d5a8d20efdca714f2e1dc74474a..40302c56cd09ea3191d637279e5627b487c5afb0 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks @@ -129,7 +129,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) @@ -176,7 +176,7 @@ Neither false false - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) true diff --git a/apps/decoder.c b/apps/decoder.c index 14b0c19f3ba54d1a0c2bb9b62550fb9eef7141b4..cb81edc24be6893e626bedca2d4d8e9e15b4b781 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -57,13 +57,7 @@ #include "debug.h" #endif #include "render_config_reader.h" -#ifdef DEBUG_SBA -#include "ivas_cnst.h" -#include "spar_debug.h" -int16_t numTransportChannels = 1; -int16_t numOutChannels = 1; -int16_t pca_ingest_channels = 1; -#endif + #define WMC_TOOL_MAN @@ -202,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 @@ -396,13 +393,8 @@ int main( } } -#ifdef DEBUG_SBA - spar_debug_t dbg_params; - dbg_params.fs = arg.output_Fs; - dbg_params.n_ch = numOutChannels; - dbg_params.n_transport = numTransportChannels; - dbg_params.pca_ingest_channels = pca_ingest_channels; - ivas_open_decoder_debug_files( &dbg_params ); +#ifdef DEBUG_SBA_AUDIO_DUMP + ivas_open_sba_decoder_debug_files( arg.output_Fs, 1, 1 ); #endif /*-----------------------------------------------------------------* @@ -558,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 ); @@ -586,12 +582,8 @@ cleanup: printf( "\n" ); } -#ifdef DEBUG_SBA - dbg_params.fs = arg.output_Fs; - dbg_params.n_ch = numOutChannels; - dbg_params.n_transport = numTransportChannels; - dbg_params.pca_ingest_channels = pca_ingest_channels; - ivas_close_decoder_debug_files( &dbg_params ); +#ifdef DEBUG_SBA_AUDIO_DUMP + ivas_close_sba_decoder_debug_files( arg.output_Fs, numOutChannels, numTransportChannels, pca_ingest_channels ); #endif #ifdef DEBUGGING dbgclose(); diff --git a/apps/encoder.c b/apps/encoder.c index 8f82f3d0d665f3308321f86fd6569d8cb6493208..e11b4465d3db6f9065bb72e46a1aa1d1b6bad2df 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -51,15 +51,11 @@ #endif #ifdef DEBUGGING #include "debug.h" -#ifdef DEBUG_SBA -#include "ivas_cnst.h" -#include "spar_debug.h" -#endif #endif - #define WMC_TOOL_MAN + /*------------------------------------------------------------------------------------------* * Local constants, enums, structures *------------------------------------------------------------------------------------------*/ @@ -219,8 +215,9 @@ int main( #endif #ifdef DEBUG_SBA - spar_debug_t dbg_params; + int16_t numTransportChannels = 1; #endif + #ifdef WMOPS size_t SRAM_size = 0; #endif @@ -443,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,29 +560,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_sba_encoder_debug_files( arg.inputFs, numTransportChannels, arg.dbg_file_tag, arg.initBitrate, (int16_t) arg.dtxConfig.enabled ); #endif if ( !arg.quietModeEnabled ) @@ -847,9 +829,9 @@ cleanup: #endif #ifdef DEBUG_SBA - ivas_close_remove_debug_files(); + ivas_close_sba_encoder_debug_files(); #ifdef DEBUG_AGC - ivas_close_agc_debug_files( &io_params ); + ivas_close_agc_debug_files(); #endif #endif diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index baf63f6e35ae84a9d6408289b9b8eacc40453048..88f39f713b3c6d0aa82e616166fa7ff3b2c93f44 100644 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -1551,9 +1551,9 @@ void ivas_compute_spar_params( { float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; int16_t b, i, ndm; - ivas_get_pred_coeffs( pppCov_mat_re, pred_coeffs_re, dm_fv_re, num_ch, - start_band, end_band, active_w, dtx_vad, - from_dirac ); + + ivas_get_pred_coeffs( pppCov_mat_re, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, dtx_vad, from_dirac ); + #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n Prediction Coefficients:\n"); @@ -1613,15 +1613,17 @@ void ivas_compute_spar_params( { fprintf( stdout, "\n\nUnquantised C, P coeffs -- band %d:\n", b ); - for ( ii = 0; ii < num_ch; ii++ ) + for ( int16_t ii = 0; ii < num_ch; ii++ ) { fprintf( stdout, "%f |", hSparMd->band_coeffs[b].pred_re[ii] ); if ( ii < num_ch - ndm ) { - for ( jj = 0; jj < ndm - 1; jj++ ) + for ( int16_t jj = 0; jj < ndm - 1; jj++ ) + { fprintf( stdout, "%f,\t", hSparMd->band_coeffs[b].C_re[ii][jj] ); - fprintf( stdout, "| %f", hSparMd->band_coeffs[b].P_re[ii][ii] ); + } + fprintf( stdout, "| %f", hSparMd->band_coeffs[b].P_re[ii] ); } fprintf( stdout, "\n" ); } diff --git a/lib_debug/debug.h b/lib_debug/debug.h index 9b38b16b6622dc674444d79e307fcf2765a7bc52..abf246674ab451196d64a8ac6e7dc987a8897782 100644 --- a/lib_debug/debug.h +++ b/lib_debug/debug.h @@ -36,6 +36,9 @@ #include "options.h" #include #include +#ifdef DEBUG_SBA +#include "sba_debug.h" +#endif /*------------------------------------------------------------------------------------------* * Global variables used for debugging diff --git a/lib_debug/spar_debug.c b/lib_debug/sba_debug.c similarity index 77% rename from lib_debug/spar_debug.c rename to lib_debug/sba_debug.c index 619365735bca50301a0028dd502d8bd967c09e9b..3526478e4dec45cbdec59d86f30ff7ebb5dbb26b 100644 --- a/lib_debug/spar_debug.c +++ b/lib_debug/sba_debug.c @@ -38,7 +38,7 @@ #include "options.h" #include "ivas_cnst.h" #include "prot.h" -#include "spar_debug.h" +#include "sba_debug.h" #include #include "wmops.h" #ifdef DEBUG_SBA @@ -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,21 @@ 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 ) +void ivas_close_agc_debug_files( void ) { - if ( pDebug_params->agc > 0 ) /* temporary */ + if ( agcOut != NULL ) { - if ( agcOut != NULL ) - { - fclose( agcOut ); - } + fclose( agcOut ); + agcOut = NULL; } + + return; } -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 ) @@ -152,10 +152,16 @@ void ivas_open_agc_debug_files( spar_debug_t *pDebug_params ) } 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; @@ -171,23 +177,40 @@ 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; } -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_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; int16_t debug_tmp[IVAS_SPAR_MAX_CH * L_FRAME48k * 2]; - /* Dump audio signal after pca_enc */ + k = 0; 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++ ) { - tmp_value = roundf( data_f[i][j] * PCM16_TO_FLT_FAC ); + if ( ppPcm ) + { + tmp_value = roundf( ppPcm[i][j] * PCM16_TO_FLT_FAC ); + } + else + { + tmp_value = roundf( pcm_array[i][j] * PCM16_TO_FLT_FAC ); + } if ( tmp_value > MAX16B_FLT ) { largest_value = (float) fabs( tmp_value ) > largest_value ? (float) fabs( tmp_value ) : largest_value; @@ -211,39 +234,50 @@ float ivas_spar_dump_signal_wav( int16_t input_frame, float data_f[][L_FRAME48k db_value = 20.f * (float) log( largest_value ); fprintf( stderr, "%d\t Clipping detected ", Clipping ); } - WriteWavShort( - wave_file, - debug_tmp, - ( no_channel * input_frame ) ); - return ( db_value ); + 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( spar_debug_t *pDebug_params ) + +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 ) { - UpdateWave( pDebug_params->fs, pDebug_params->n_transport, 32, spar_foa_dec_wav[0] ); + UpdateWave( fs, n_transport, 32, spar_foa_dec_wav[0] ); CloseWav( spar_foa_dec_wav[0] ); } if ( spar_foa_dec_wav[1] != NULL ) { - UpdateWave( pDebug_params->fs, pDebug_params->n_transport, 16, spar_foa_dec_wav[1] ); + UpdateWave( fs, n_transport, 16, spar_foa_dec_wav[1] ); CloseWav( spar_foa_dec_wav[1] ); } if ( spar_foa_dec_wav[2] != NULL ) { - UpdateWave( pDebug_params->fs, pDebug_params->pca_ingest_channels, 16, spar_foa_dec_wav[2] ); + UpdateWave( fs, pca_ingest_channels, 16, spar_foa_dec_wav[2] ); CloseWav( spar_foa_dec_wav[2] ); } if ( spar_foa_dec_wav[3] != NULL ) { - UpdateWave( pDebug_params->fs, pDebug_params->n_ch, 16, spar_foa_dec_wav[3] ); + 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 ) @@ -272,96 +306,91 @@ 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( spar_debug_t *pDebug_params ) + +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], - pDebug_params->fs, - pDebug_params->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], - pDebug_params->fs, - pDebug_params->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], - pDebug_params->fs, - pDebug_params->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], - pDebug_params->fs, - pDebug_params->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_debug_files( spar_debug_t *pDebug_params ) + +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 ( 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: + 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; } /* DTX */ - if ( pDebug_params->dtx_on ) + if ( dtx_on ) { cstrcat( (char *) file_names[0], sizeof( file_names[0] ), "_DTX1" ); } @@ -377,31 +406,17 @@ void ivas_open_debug_files( spar_debug_t *pDebug_params ) 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], - pDebug_params->fs, - pDebug_params->n_ch, - 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], - pDebug_params->fs, - pDebug_params->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], - pDebug_params->fs, - pDebug_params->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 */ diff --git a/lib_debug/spar_debug.h b/lib_debug/sba_debug.h similarity index 68% rename from lib_debug/spar_debug.h rename to lib_debug/sba_debug.h index 8e8457e16a5076de1ba89bd6b98e8ffa5846cf95..8153929286aa6218177b16d97ea0d9b0b2ed432e 100644 --- a/lib_debug/spar_debug.h +++ b/lib_debug/sba_debug.h @@ -30,41 +30,31 @@ *******************************************************************************************************/ -#ifndef SPAR_DEBUG_H -#define SPAR_DEBUG_H +#ifndef SBA_DEBUG_H +#define SBA_DEBUG_H #include "options.h" #include #include #ifdef DEBUG_SBA +#include "cnst.h" +#include "ivas_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_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( 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_close_decoder_debug_files( spar_debug_t *pDebug_params ); -void ivas_open_decoder_debug_files( spar_debug_t *dbg_params ); -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 /* SPAR_DEBUG_H */ +#endif /* SBA_DEBUG_H */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 9acc451ea0a65dcf6e0df375bee54aeb07a0806a..8e1392cf9d0b831b8c93724f776e01a0cedb4509 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -42,14 +42,7 @@ #include "debug.h" #endif #include "wmops.h" -#ifdef DEBUG_SBA_AUDIO_DUMP -#include "tinywaveout_c.h" -#include "spar_debug.h" -float data_array[IVAS_MAX_NUM_CH][L_FRAME48k * 2]; -extern WAVEFILEOUT *spar_foa_dec_wav[4]; -extern int16_t numTransportChannels; -extern int16_t numOutChannels; -#endif + /*--------------------------------------------------------------------------* * ivas_dec() @@ -285,23 +278,10 @@ ivas_error ivas_dec( return error; } } + #ifdef DEBUG_SBA_AUDIO_DUMP - float largest_value; - int16_t i, j; - numTransportChannels = st_ivas->nchan_transport; /* Dump audio signal after core-decoding */ - for ( i = 0; i < numTransportChannels; i++ ) - { - for ( j = 0; j < output_frame; j++ ) - { - data_array[i][j] = output[i][j]; - } - } - largest_value = ivas_spar_dump_signal_wav( output_frame, data_array, numTransportChannels, spar_foa_dec_wav[0] ); - if ( largest_value ) - { - fprintf( stderr, "\t In core-decoding largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( output_frame, NULL, output, st_ivas->nchan_transport, spar_foa_dec_wav[0], "core-decoding" ); #endif /* TCs remapping */ nchan_remapped = st_ivas->nchan_transport; diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 7dbb54676018e9f0b952cd44086388e0bebdcb51..fe8db4f0fd0dd6766fba013cfac2779f87aa834b 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -44,15 +44,7 @@ #include #include #include "wmops.h" -#ifdef DEBUG_SBA_AUDIO_DUMP -#include "tinywaveout_c.h" -#include "spar_debug.h" -extern WAVEFILEOUT *spar_foa_dec_wav[4]; -float data_array[IVAS_MAX_NUM_CH][L_FRAME48k * 2]; -extern int16_t numTransportChannels; -extern int16_t pca_ingest_channels; -extern int16_t numOutChannels; -#endif + /*-------------------------------------------------------------------* * Local function prototypes @@ -960,22 +952,8 @@ void ivas_spar_dec_upmixer( ivas_agc_dec_process( pState->hAgcDec, output, output, nchan_transport, output_frame ); #ifdef DEBUG_SBA_AUDIO_DUMP - int16_t l; - float largest_value; - numTransportChannels = st_ivas->nchan_transport; /* Dump audio signal after ivas_agc_dec_process */ - for ( i = 0; i < numTransportChannels; i++ ) - { - for ( l = 0; l < output_frame; l++ ) - { - data_array[i][l] = output[i][l]; - } - } - largest_value = ivas_spar_dump_signal_wav( output_frame, data_array, numTransportChannels, spar_foa_dec_wav[1] ); - if ( largest_value ) - { - fprintf( stderr, "\t In ivas_agc_dec_process() largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( output_frame, NULL, output, st_ivas->nchan_transport, spar_foa_dec_wav[1], "ivas_agc_dec_process()" ); #endif /*---------------------------------------------------------------------* @@ -1000,26 +978,18 @@ void ivas_spar_dec_upmixer( * PCA decoder *---------------------------------------------------------------------*/ +#ifdef DEBUG_SBA_AUDIO_DUMP + pState->pca_ingest_channels = num_in_ingest; +#endif + #ifdef SBA_CLEANING if ( pState->hPCA != NULL ) #endif { ivas_pca_dec( pState->hPCA, output_frame, num_in_ingest, hDecoderConfig->ivas_total_brate, hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, output ); #ifdef DEBUG_SBA_AUDIO_DUMP - pca_ingest_channels = num_in_ingest; /* Dump audio signal after ivas_pca_dec */ - for ( i = 0; i < pca_ingest_channels; i++ ) - { - for ( l = 0; l < output_frame; l++ ) - { - data_array[i][l] = output[i][l]; - } - } - largest_value = ivas_spar_dump_signal_wav( output_frame, data_array, pca_ingest_channels, spar_foa_dec_wav[2] ); - if ( largest_value ) - { - fprintf( stderr, "\t In ivas_pca_dec() largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( output_frame, NULL, output, num_in_ingest, spar_foa_dec_wav[2], "ivas_pca_dec()" ); #endif } @@ -1207,7 +1177,7 @@ void ivas_spar_dec_upmixer( } } #ifdef DEBUG_SBA_AUDIO_DUMP - numOutChannels = outchannels; + pState->numOutChannels = outchannels; #endif } else @@ -1228,23 +1198,12 @@ void ivas_spar_dec_upmixer( } } #ifdef DEBUG_SBA_AUDIO_DUMP - numOutChannels = numch_out_dirac; + pState->numOutChannels = numch_out_dirac; #endif } #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after cldfbSynthesis */ - for ( i = 0; i < numOutChannels; i++ ) - { - for ( l = 0; l < output_frame; l++ ) - { - data_array[i][l] = output[i][l]; - } - } - largest_value = ivas_spar_dump_signal_wav( output_frame, data_array, numOutChannels, spar_foa_dec_wav[3] ); - if ( largest_value ) - { - fprintf( stderr, "\t In cldfbSynthesis() largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( output_frame, NULL, output, pState->numOutChannels, spar_foa_dec_wav[3], "cldfbSynthesis()" ); #endif split_band = SPAR_DIRAC_SPLIT_START_BAND; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 412da7d5db88a60c8621955e2e314d8955d1f49d..63fe83dfbe8fba8e43f128fdc63c061d146ed1e3 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -42,9 +42,6 @@ #include #include "wmops.h" #include "ivas_stat_dec.h" -#ifdef DEBUG_SBA_MD_DUMP -extern int32_t frame; -#endif /*#define ENABLE_DITHER */ /* IVAS_fmToDo: development switch */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index b9218ecaaa2ced195a0c553a1769668a0e8558cb..18fc4b47415f1d38da2dc0fedc2c1b5932251b69 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -879,6 +879,11 @@ typedef struct ivas_spar_dec_lib_t int32_t core_nominal_brate; /* Nominal bitrate for core coding */ int32_t i_subframe; +#ifdef DEBUG_SBA_AUDIO_DUMP + int16_t numOutChannels; + int16_t pca_ingest_channels; +#endif + } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8f963664fb2e19519c483cd6a3fab7c4ff1aa8d4..87f754d4d33978269388174bec15c07aba66d1dd 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1847,6 +1847,13 @@ void IVAS_DEC_PrintConfigWithBitstream( } #endif + +/*---------------------------------------------------------------------* + * IVAS_DEC_PrintDisclaimer( ) + * + * Print IVAS disclaimer to console + *---------------------------------------------------------------------*/ + void IVAS_DEC_PrintDisclaimer( void ) { print_disclaimer( stderr ); @@ -2047,6 +2054,42 @@ ivas_error IVAS_DEC_SetForcedRendMode( return IVAS_ERR_OK; } + +#ifdef DEBUG_SBA_AUDIO_DUMP +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSbaDebugParams( ) + * + * Returns SBA debug parameters + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetSbaDebugParams( + const IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *numOutputChannels, + int16_t *numTransportChannels, + int16_t *pca_ingest_channels ) +{ + if ( hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + if ( hIvasDec->st_ivas->ivas_format != SBA_FORMAT || hIvasDec->st_ivas->hSpar == NULL ) + { + *numOutputChannels = 1; + *numTransportChannels = 1; + *pca_ingest_channels = 1; + } + else + { + *numOutputChannels = hIvasDec->st_ivas->hSpar->numOutChannels; + *numTransportChannels = hIvasDec->st_ivas->nchan_transport; + *pca_ingest_channels = hIvasDec->st_ivas->hSpar->pca_ingest_channels; + } + + return IVAS_ERR_OK; +} +#endif /* DEBUG_SBA_AUDIO_DUMP */ + #endif /* DEBUGGING */ static ivas_error input_format_API_to_internal( diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index b4221c142cbc2d02ec776a6ff6a76566c1e56152..f43034c885ad422fe62e26bc78302ebef5a47c54 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -235,6 +235,15 @@ ivas_error IVAS_DEC_SetForcedRendMode( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const IVAS_DEC_FORCED_REND_MODE forcedRendMode /* i : forced renderer mode */ ); + +#ifdef DEBUG_SBA_AUDIO_DUMP +ivas_error IVAS_DEC_GetSbaDebugParams( + const IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + int16_t *numOutputChannels, + int16_t *numTransportChannels, + int16_t *pca_ingest_channels +); +#endif #endif /* Getter functions - retrieve information from a decoder through a handle */ diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 45326ce8a713c003a1a947fdae0806dd9d003c09..493d1ac07118e67371f3d44eb9dc654166cfd257 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -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 ) ) diff --git a/lib_enc/ivas_dirac_enc.c b/lib_enc/ivas_dirac_enc.c index 05a8f83e7f0ee4f99671f672ce1f3f944d0605d5..73789414d41d93b2f6dddd3a2028ebbea2b3ff54 100644 --- a/lib_enc/ivas_dirac_enc.c +++ b/lib_enc/ivas_dirac_enc.c @@ -43,9 +43,6 @@ #include "debug.h" #endif #include "wmops.h" -#ifdef DEBUG_SBA_MD_DUMP -extern int32_t frame; -#endif /*------------------------------------------------------------------------- * Local function prototypes diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index ae95d02d247b6cfc7bb68225274edd4ef5336f3e..a7a72735e9560a2a0ca10d0db4815179c59209ec 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -43,12 +43,6 @@ #include #include "wmops.h" -#ifdef DEBUG_SBA_AUDIO_DUMP -#include "tinywaveout_c.h" -#include "spar_debug.h" -float data_array[IVAS_MAX_NUM_CH][L_FRAME48k * 2]; -extern WAVEFILEOUT *spar_foa_enc_wav[3]; -#endif /*-------------------------------------------------------------------* * Local function prototypes @@ -779,19 +773,7 @@ static ivas_error ivas_spar_enc_process( ivas_fb_mixer_process( pState->hFbMixer, pState->hMdEnc->mixer_mat, p_pcm_tmp, input_frame, in_out_mixer_map ); #ifdef DEBUG_SBA_AUDIO_DUMP - float largest_value; - for ( i = 0; i < nchan_transport; i++ ) - { - for ( j = 0; j < input_frame; j++ ) - { - data_array[i][j] = p_pcm_tmp[i][j]; - } - } - largest_value = ivas_spar_dump_signal_wav( input_frame, data_array, nchan_transport, spar_foa_enc_wav[1] ); - if ( largest_value ) - { - fprintf( stderr, "\t In ivas_fb_mixer_process() largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( input_frame, p_pcm_tmp, NULL, nchan_transport, spar_foa_enc_wav[1], "ivas_fb_mixer_process()" ); #endif /* move delayed W into output buffer unless activeW operation*/ @@ -817,22 +799,11 @@ static ivas_error ivas_spar_enc_process( push_next_indice( hMetaData, PCA_MODE_INACTIVE, 1 ); } } + #ifdef DEBUG_SBA_AUDIO_DUMP - for ( i = 0; i < nchan_inp; i++ ) - { - for ( j = 0; j < input_frame; j++ ) - { - data_array[i][j] = data_f[i][j]; - } - } - largest_value = ivas_spar_dump_signal_wav( input_frame, data_array, nchan_inp, spar_foa_enc_wav[0] ); - if ( largest_value ) - { - fprintf( stderr, "\t In ivas_pca_enc() largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( input_frame, p_pcm_tmp, NULL, nchan_transport, spar_foa_enc_wav[0], "ivas_pca_enc()" ); #endif - #ifdef SPAR_HOA_DBG /*FILE *fp = fopen("int_enc_dmx.raw", "ab"); for (int16_t t = 0; t < 960; t++) @@ -864,18 +835,7 @@ static ivas_error ivas_spar_enc_process( } #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after ivas_agc_enc_process */ - for ( i = 0; i < nchan_transport; i++ ) - { - for ( j = 0; j < input_frame; j++ ) - { - data_array[i][j] = p_pcm_tmp[i][j]; - } - } - largest_value = ivas_spar_dump_signal_wav( input_frame, data_array, nchan_transport, spar_foa_enc_wav[2] ); - if ( largest_value ) - { - fprintf( stderr, "\t In ivas_agc_enc_process() largest clipped sample in dB %f \n", largest_value ); - } + ivas_spar_dump_signal_wav( input_frame, p_pcm_tmp, NULL, nchan_transport, spar_foa_enc_wav[2], "ivas_agc_enc_process()" ); #endif #ifdef DEBUG_SPAR_BYPASS_EVS_CODEC diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index f8fdc96edb6ce3aecee54e0868e99da0ba94eb75..39f8746004cdb3df06670e64638ff3417483ccdc 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -41,9 +41,6 @@ #include "ivas_rom_com.h" #include #include "wmops.h" -#ifdef DEBUG_SBA_MD_DUMP -extern int32_t frame; -#endif /*------------------------------------------------------------------------------------------* @@ -636,6 +633,9 @@ ivas_error ivas_spar_md_enc_process( planarCP = 0; code_strat = 0; +#ifdef DEBUG_SBA_MD_DUMP + ndec = -1; +#endif #ifdef DEBUG_SPAR_MD_TARGET_TUNING for ( qsi = 0; qsi < 1; qsi++ ) #else @@ -956,7 +956,7 @@ ivas_error ivas_spar_md_enc_process( fprintf( stdout, "|\t" ); for ( j = 0; j < num_ch - ndm; j++ ) { - fprintf( stdout, "%.2f\t", pState->spar_md.band_coeffs[b].P_quant_re[i][j] ); + fprintf( stdout, "%.2f\t", pState->spar_md.band_coeffs[b].P_quant_re[j] ); } } fprintf( stdout, "\n" ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 369670e47cbaa60060546725925aad6e2fa97245..21b1bf5765eff27cccc0b01de09b7e4c8c066fbc 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -43,6 +43,7 @@ #include "wmops.h" #endif + /*---------------------------------------------------------------------* * Local struct *---------------------------------------------------------------------*/ @@ -439,6 +440,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_AGC_ON, /* i : AGC on/off flag */ const bool Opt_PCA_ON /* i : PCA option flag */ +#ifdef DEBUG_SBA_AUDIO_DUMP + , + int16_t *numTransportChannels +#endif ) { ENCODER_CONFIG_HANDLE hEncoderConfig; @@ -466,6 +471,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( error = configureEncoder( hIvasEnc, inputFs, bitrate, maxBandwidth, dtxConfig, IVAS_ENC_GetDefaultChannelAwareConfig() ); +#ifdef DEBUG_SBA_AUDIO_DUMP + *numTransportChannels = hIvasEnc->st_ivas->nchan_transport; +#endif + return error; } @@ -946,51 +955,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() * diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index f6f32d9baa6d4e6b5e89b2e6b1e8ebc692fbfef5..325c854f732438caf709015844d7c8638dc036ef 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -191,6 +191,10 @@ ivas_error IVAS_ENC_ConfigureForAmbisonics( const bool isPlanar, /* i : if true, input is treated as planar Ambisonics */ const bool Opt_AGC_ON, /* i : AGC on/off flag */ const bool Opt_PCA_ON /* i : PCA option flag */ +#ifdef DEBUG_SBA_AUDIO_DUMP + , + int16_t *numTransportChannels +#endif ); /*! r: error code */ @@ -288,20 +292,6 @@ ivas_error IVAS_ENC_GetDelay( int16_t *delay /* o : encoder delay */ ); -#ifdef DEBUG_SBA -/*! r: encoder error code */ -ivas_error IVAS_ENC_GetNumInputChannels( - const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ - int16_t *numInChannels /* o : number of input channels with current configuration */ -); - -/*! r: encoder error code */ -ivas_error getTransportChannel( - const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ - int16_t *no_channels_Transport /* o : number of transport channels */ -); -#endif - /*! r: encoder error code */ ivas_error IVAS_ENC_GetInputBufferSize( const IVAS_ENC_HANDLE hIvasEnc, /* i/o: IVAS encoder handle */ diff --git a/lib_util/tinywaveout_c.h b/lib_util/tinywaveout_c.h index bfa69199a8122d0e1e26d2d9ba5dc0a8016540c2..39cde0d3383801c81b75139324d5dfab2ddb2555 100644 --- a/lib_util/tinywaveout_c.h +++ b/lib_util/tinywaveout_c.h @@ -241,13 +241,8 @@ static WAVEFILEOUT *CreateWav( return CreateBWF( fileName, sampleRate, numChannels, bps ); } -#ifdef DEBUG_SBA -#define MAX_PCM16 ( 32767 ) -#define MIN_PCM16 ( -32768 ) -#else -const int16_t MAX_PCM16 = 32767; -const int16_t MIN_PCM16 = -32768; -#endif +static const int16_t MAX_PCM16 = 32767; +static const int16_t MIN_PCM16 = -32768; static __inline int32_t CLIP_PCM16( int32_t sample, uint32_t *clipcount ) @@ -271,13 +266,8 @@ static __inline int32_t CLIP_PCM16( return tmp; } -#ifdef DEBUG_SBA -#define MAX_PCM24 ( 8388607 ) -#define MIN_PCM24 ( -8388608 ) -#else -const int32_t MAX_PCM24 = 8388607; -const int32_t MIN_PCM24 = -8388608; -#endif +static const int32_t MAX_PCM24 = 8388607; +static const int32_t MIN_PCM24 = -8388608; static __inline int32_t CLIP_PCM24( int32_t sample, uint32_t *clipcount )