From adaca99d138da60d9aed53f92b6d2fda0238d4b9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 31 Jan 2023 15:03:39 +0100 Subject: [PATCH 1/6] - SWITCHING_FORMAT_DEC - issue 326: Bitstream Switching (Decoder side) - SWITCHING_FORMAT_ENC - VA: issue 325: Encoder Input format Switching - SIMULATE_FORMAT_SWITCHING_ENC (deactivated) - debugging: simulate Input format switching --- apps/encoder.c | 241 +++++++++++++++++++++++++++++++++++- lib_com/ivas_prot.h | 11 ++ lib_com/options.h | 5 + lib_dec/ivas_init_dec.c | 178 +++++++++++++++++++------- lib_dec/ivas_mc_param_dec.c | 5 + lib_dec/lib_dec.c | 32 +++++ lib_enc/ivas_enc.c | 1 + lib_enc/ivas_init_enc.c | 3 +- lib_enc/lib_enc.c | 44 +++++++ lib_enc/lib_enc.h | 6 + 10 files changed, 479 insertions(+), 47 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index d789fd5486..205043d19d 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -136,13 +136,24 @@ typedef struct *------------------------------------------------------------------------------------------*/ static void initArgStruct( EncArguments *arg ); -static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg ); +static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg +#ifdef SWITCHING_FORMAT_ENC + , + const bool reconfig_flag +#endif +); static void usage_enc( void ); static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter ); static bool readBitrate( FILE *file, int32_t *bitrate ); +#ifdef SWITCHING_FORMAT_ENC +static ivas_error configureEnc( const EncArguments arg, IVAS_ENC_HANDLE hIvasEnc, const int32_t totalBitrate, const IVAS_ENC_BANDWIDTH bandwidth, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); +#endif #ifdef DEBUGGING static ivas_error readForcedMode( FILE *file, IVAS_ENC_FORCED_MODE *forcedMode, int32_t *forceFrameCounter ); static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ); +#ifdef SIMULATE_FORMAT_SWITCHING_ENC +static void simulate_input_format_switching( int16_t *argc_new, char *p_argv_new[10], bool *reinit_flag ); +#endif #endif @@ -198,7 +209,12 @@ int main( IVAS_ENC_PrintDisclaimer(); - if ( !parseCmdlIVAS_enc( (int16_t) argc, argv, &arg ) ) + if ( !parseCmdlIVAS_enc( (int16_t) argc, argv, &arg +#ifdef SWITCHING_FORMAT_ENC + , + false +#endif + ) ) { /* Error printout done internally in parseCmdlIVAS_enc() */ goto cleanup; @@ -217,7 +233,9 @@ int main( /*------------------------------------------------------------------------------------------* * Open input audio file *------------------------------------------------------------------------------------------*/ + int32_t inFileSampleRate = 0; + if ( AudioFileReader_open( &audioReader, arg.inputWavFilename, &inFileSampleRate ) != IVAS_ERR_OK ) { fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename ); @@ -373,6 +391,12 @@ int main( * Configure and initialize (allocate memory for static variables) the encoder *------------------------------------------------------------------------------------------*/ +#ifdef SWITCHING_FORMAT_ENC + if ( ( error = configureEnc( arg, hIvasEnc, totalBitrate, bandwidth, caConfig ) ) != IVAS_ERR_OK ) + { + goto cleanup; + } +#else switch ( arg.inputFormat ) { case IVAS_ENC_INPUT_MONO: @@ -444,6 +468,7 @@ int main( fprintf( stderr, "\nInvalid input type\n\n" ); goto cleanup; } +#endif if ( ( error = IVAS_ENC_PrintConfig( hIvasEnc, caConfig.channelAwareModeEnabled ) ) != IVAS_ERR_OK ) { @@ -565,8 +590,53 @@ int main( * - Write the parameters into output bitstream file *------------------------------------------------------------------------------------------*/ +#ifdef SWITCHING_FORMAT_ENC + bool reinit_flag = false; + char *p_argv_new[10]; + int16_t argc_new = -1; +#endif + while ( 1 ) { +#ifdef SWITCHING_FORMAT_ENC +#ifdef SIMULATE_FORMAT_SWITCHING_ENC + /* simulate input format switching */ + simulate_input_format_switching( &argc_new, p_argv_new, &reinit_flag ); +#endif + + /* Reinitialization of the encoder in case of application parameter(s) change (e.g. change of IVAS input format) */ + if ( reinit_flag ) + { + IVAS_ENC_Close_Reinit( &hIvasEnc ); + + if ( !parseCmdlIVAS_enc( argc_new, p_argv_new, &arg, true ) ) + { + goto cleanup; + } + + /* Configure and initialize (allocate memory for static variables) the encoder */ + if ( ( error = configureEnc( arg, hIvasEnc, totalBitrate, bandwidth, caConfig ) ) != IVAS_ERR_OK ) + { + goto cleanup; + } + + /* Allocate input data buffer */ + int16_t pcmBufSize_new; + if ( ( error = IVAS_ENC_GetInputBufferSize( hIvasEnc, &pcmBufSize_new ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nGetInputBufferSize failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } + + if ( pcmBufSize_new != pcmBufSize ) + { + free( pcmBuf ); + pcmBuf = malloc( pcmBufSize_new * sizeof( int16_t ) ); + pcmBufSize = pcmBufSize_new; + } + } +#endif + /* Read the input data */ if ( ( error = AudioFileReader_read( audioReader, pcmBuf, pcmBufSize, &numSamplesRead ) ) != IVAS_ERR_OK ) { @@ -864,7 +934,12 @@ static void initArgStruct( EncArguments *arg ) static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], - EncArguments *arg ) + EncArguments *arg +#ifdef SWITCHING_FORMAT_ENC + , + const bool reconfig_flag +#endif +) { int16_t i, j; char argv_to_upper[FILENAME_MAX]; @@ -1457,6 +1532,17 @@ static bool parseCmdlIVAS_enc( } } /* end of while */ +#ifdef SWITCHING_FORMAT_ENC + /*-----------------------------------------------------------------* + * Return in case of reconfiguration + *-----------------------------------------------------------------*/ + + if ( reconfig_flag == true ) + { + return true; + } +#endif + /*-----------------------------------------------------------------* * Mandatory input arguments *-----------------------------------------------------------------*/ @@ -1739,6 +1825,99 @@ static bool readBitrate( } +#ifdef SWITCHING_FORMAT_ENC +/*---------------------------------------------------------------------* + * configureEnc() + * + * Configure and initialize the encoder + *---------------------------------------------------------------------*/ + +static ivas_error configureEnc( + const EncArguments arg, + IVAS_ENC_HANDLE hIvasEnc, + const int32_t totalBitrate, + const IVAS_ENC_BANDWIDTH bandwidth, + const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ) +{ + ivas_error error = IVAS_ERR_UNKNOWN; + + switch ( arg.inputFormat ) + { + case IVAS_ENC_INPUT_MONO: + if ( ( error = IVAS_ENC_ConfigureForMono( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, caConfig, arg.inputFormatConfig.stereoToMonoDownmix ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMono failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + return error; + } + break; + case IVAS_ENC_INPUT_STEREO: +#ifdef DEBUGGING + if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.stereoMode ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_ENC_ConfigureForStereo( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig ) ) != IVAS_ERR_OK ) +#endif + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForStereo failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + return error; + } + break; + case IVAS_ENC_INPUT_ISM: + if ( ( error = IVAS_ENC_ConfigureForObjects( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.ism.numObjects ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForObjects failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + return error; + } + 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 + , + &numTransportChannels +#endif + ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + return error; + } + + break; + case IVAS_ENC_INPUT_MASA: + if ( ( error = IVAS_ENC_ConfigureForMasa( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.masaVariant ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMasa failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + return error; + } + break; + case IVAS_ENC_INPUT_MC: + if ( ( error = IVAS_ENC_ConfigureForMultichannel( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.mcLayout ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_ENC_ConfigureForMultichannel failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + return error; + } + break; + default: + fprintf( stderr, "\nInvalid input type\n\n" ); + return error; + } + + return error; +} +#endif + + #ifdef DEBUGGING /*---------------------------------------------------------------------* * parseForcedMode() @@ -1823,4 +2002,60 @@ static ivas_error readForcedMode( return IVAS_ERR_OK; } + + +#ifdef SIMULATE_FORMAT_SWITCHING_ENC +/*---------------------------------------------------------------------* + * simulate_input_format_switching() + * + * Simulation of IVAS input format switching + *---------------------------------------------------------------------*/ + +#define ENC_FORMAT_VARIANTS 7 + +char input_params[ENC_FORMAT_VARIANTS][6][50] = { + { "1", { "-stereo" } }, + { "4", { "-ism" }, { "2" }, { "NULL" }, { "NULL" } }, + { "2", { "-MC" }, { "5_1" } }, + { "2", { "-sba" }, { "3" } }, + { "3", { "-ism" }, { "1" }, { "NULL" } }, + { "2", { "-sba" }, { "-2" } }, + { "2", { "-MC" }, { "7_1_4" } }, +}; + +static void simulate_input_format_switching( + int16_t *argc_new, + char *p_argv_new[10], + bool *reinit_flag ) +{ + int16_t i; + static int16_t ff = -1; + + *reinit_flag = 0; + *argc_new = -1; + *p_argv_new = NULL; + + if ( frame % 20 == 0 ) + { + ff++; + if ( ff > ENC_FORMAT_VARIANTS - 1 ) + { + ff = 0; + } + *reinit_flag = 1; + } + + if ( *reinit_flag ) + { + *argc_new = (int16_t) atoi( input_params[ff][0] ); + for ( i = 0; i < *argc_new + 1; i++ ) + { + p_argv_new[i] = input_params[ff][i]; + } + *argc_new += 5; /* 4 mandatory parameters + executable name */ + } + + return; +} +#endif #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6f4d27d5e8..847bddabcc 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -410,12 +410,23 @@ void destroy_core_dec( void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifdef SWITCHING_FORMAT_DEC + , + const int16_t flag_all /* i : 1 == destroy external data handles */ +#endif ); void ivas_initialize_handles_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef SWITCHING_FORMAT_DEC +void ivas_decoder_init_highlevel_params( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + ivas_error ivas_core_enc( SCE_ENC_HANDLE hSCE, /* i/o: SCE encoder structure */ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ diff --git a/lib_com/options.h b/lib_com/options.h index 5dddf236ea..e2b82be9df 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,6 +168,11 @@ #define FIX_317 /* FhG: issue 317 - address sanitizer error in MDCT-Stereo PLC */ +#define SWITCHING_FORMAT_DEC /* VA: issue 326: Bitstream Switching (Decoder side) */ +#define SWITCHING_FORMAT_ENC /* VA: issue 325: Encoder Input format Switching */ +/*#define SIMULATE_FORMAT_SWITCHING_ENC*/ /* VA: debugging: simulate Input format switching */ + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 763c83dc39..2aa8db73c7 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -69,6 +69,12 @@ ivas_error ivas_dec_setup( Decoder_State *st; int32_t ivas_total_brate; ivas_error error; +#ifdef SWITCHING_FORMAT_DEC + IVAS_FORMAT ivas_format_old; + + ivas_format_old = st_ivas->ivas_format; +#endif + error = IVAS_ERR_OK; num_bits_read = 0; @@ -82,17 +88,34 @@ ivas_error ivas_dec_setup( ivas_read_format( st_ivas, &num_bits_read ); +#ifdef SWITCHING_FORMAT_DEC + /*-------------------------------------------------------------------* + * Reinitialize the decoder in case of the IVAS format change + *-------------------------------------------------------------------*/ - if ( is_DTXrate( ivas_total_brate ) == 0 ) + if ( ivas_format_old != st_ivas->ivas_format && st_ivas->ini_frame > 0 ) { - /*-------------------------------------------------------------------* - * Read IVAS format related signaling: - * - in ISM : read number of objects - * - in SBA : read SBA planar flag and SBA order - * - in MASA : read number of TC - * - in MC : read LS setup - *-------------------------------------------------------------------*/ + IVAS_FORMAT ivas_format_read = st_ivas->ivas_format; + + /* Destroy the decoder handle */ + st_ivas->ivas_format = ivas_format_old; + ivas_destroy_dec( st_ivas, 0 ); + /* set decoder high level parameters */ + ivas_decoder_init_highlevel_params( ivas_format_read, st_ivas ); + } +#endif + + /*-------------------------------------------------------------------* + * Read IVAS format related signaling: + * - in ISM : read number of objects + * - in SBA : read SBA planar flag and SBA order + * - in MASA : read number of TC + * - in MC : read LS setup + *-------------------------------------------------------------------*/ + + if ( is_DTXrate( ivas_total_brate ) == 0 ) + { if ( st_ivas->ivas_format == STEREO_FORMAT ) { element_mode_flag = 1; @@ -157,6 +180,10 @@ ivas_error ivas_dec_setup( } else { +#ifdef SWITCHING_FORMAT_DEC + st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); +#endif + ivas_sba_config( ivas_total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->element_mode_init ); } } @@ -364,8 +391,9 @@ static ivas_error ivas_read_format( else { st_ivas->ivas_format = SBA_FORMAT; - +#ifndef SWITCHING_FORMAT_DEC st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); +#endif } ( *num_bits_read )++; break; @@ -796,7 +824,6 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -811,6 +838,10 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->ivas_format == SBA_FORMAT ) { +#ifdef SWITCHING_FORMAT_DEC + st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); +#endif + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { if ( ( error = ivas_spar_dec_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -1563,6 +1594,53 @@ void ivas_initialize_handles_dec( } +#ifdef SWITCHING_FORMAT_DEC +/*----------------------------------------------------------------- + * ivas_initialize_handles_dec() + * + * initialize high-level parameters + *-----------------------------------------------------------------*/ + +void ivas_decoder_init_highlevel_params( + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + st_ivas->ivas_format = ivas_format; + + if ( ivas_format == MONO_FORMAT ) + { + st_ivas->codec_mode = 0; /* unknown before first frame */ + st_ivas->element_mode_init = EVS_MONO; + st_ivas->transport_config = AUDIO_CONFIG_INVALID; + st_ivas->intern_config = AUDIO_CONFIG_INVALID; + st_ivas->writeFECoffset = 0; + } + else + { + st_ivas->codec_mode = 0; /* unknown before first frame */ + st_ivas->element_mode_init = -1; + st_ivas->transport_config = AUDIO_CONFIG_INVALID; + st_ivas->intern_config = AUDIO_CONFIG_INVALID; + st_ivas->renderer_type = RENDERER_DISABLE; + st_ivas->ini_frame = 0; + st_ivas->ini_active_frame = 0; + st_ivas->writeFECoffset = 0; + + st_ivas->ism_mode = ISM_MODE_NONE; + st_ivas->sba_mode = SBA_MODE_NONE; + st_ivas->mc_mode = MC_MODE_NONE; + + st_ivas->sba_order = 0; + st_ivas->sba_planar = 0; + st_ivas->sba_analysis_order = 0; + } + + return; +} +#endif + + /*------------------------------------------------------------------------- * ivas_destroy_dec() * @@ -1571,6 +1649,10 @@ void ivas_initialize_handles_dec( void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#ifdef SWITCHING_FORMAT_DEC + , + const int16_t flag_all /* i : 1 == destroy external data handles */ +#endif ) { int16_t i, n; @@ -1736,52 +1818,61 @@ void ivas_destroy_dec( st_ivas->hMonoDmxRenderer = NULL; } - /* Head track data handle */ - if ( st_ivas->hHeadTrackData != NULL ) +#ifdef SWITCHING_FORMAT_DEC + if ( flag_all ) { - free( st_ivas->hHeadTrackData ); - st_ivas->hHeadTrackData = NULL; - } +#endif + /* Head track data handle */ + if ( st_ivas->hHeadTrackData != NULL ) + { + free( st_ivas->hHeadTrackData ); + st_ivas->hHeadTrackData = NULL; + } - /* Time Domain binaural renderer handle */ - if ( st_ivas->hBinRendererTd != NULL ) - { - ivas_td_binaural_close( &st_ivas->hBinRendererTd ); - } - else if ( st_ivas->hHrtfTD != NULL ) - { - BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); + /* Time Domain binaural renderer handle */ + if ( st_ivas->hBinRendererTd != NULL ) + { + ivas_td_binaural_close( &st_ivas->hBinRendererTd ); + } + else if ( st_ivas->hHrtfTD != NULL ) + { + BSplineModelEvalDealloc( &st_ivas->hHrtfTD->ModelParams, &st_ivas->hHrtfTD->ModelEval ); - ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); - } + ivas_HRTF_binary_close( &st_ivas->hHrtfTD ); + } #ifdef HRTF_BINARY_FILE - /* CRend binaural renderer handle */ - if ( st_ivas->hSetOfHRTF != NULL ) - { - destroy_SetOfHRTF( st_ivas->hSetOfHRTF ); - ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); - } + /* CRend binaural renderer handle */ + if ( st_ivas->hSetOfHRTF != NULL ) + { + destroy_SetOfHRTF( st_ivas->hSetOfHRTF ); + ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); + } - /* Fastconv HRTF filters */ - if ( st_ivas->hHrtfFastConv != NULL ) - { - ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); - } + /* Fastconv HRTF filters */ + if ( st_ivas->hHrtfFastConv != NULL ) + { + ivas_HRTF_fastconv_binary_close( &st_ivas->hHrtfFastConv ); + } - /* Parametric binauralizer HRTF filters */ - if ( st_ivas->hHrtfParambin != NULL ) - { - ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); - } + /* Parametric binauralizer HRTF filters */ + if ( st_ivas->hHrtfParambin != NULL ) + { + ivas_HRTF_parambin_binary_close( &st_ivas->hHrtfParambin ); + } #endif - /* Config. Renderer */ - ivas_render_config_close( &( st_ivas->hRenderConfig ) ); + /* Config. Renderer */ + ivas_render_config_close( &( st_ivas->hRenderConfig ) ); + +#ifdef SWITCHING_FORMAT_DEC + } +#endif /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); +#ifndef SWITCHING_FORMAT_DEC if ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); @@ -1790,6 +1881,7 @@ void ivas_destroy_dec( /* main IVAS handle */ free( st_ivas ); +#endif return; } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 41ba3e53c7..89e5e43623 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1060,8 +1060,13 @@ void ivas_param_mc_dec_close( hParamMC->hoa_encoder = NULL; } +#ifdef SWITCHING_FORMAT_DEC + free( *hParamMC_out ); + *hParamMC_out = NULL; +#else free( hParamMC ); hParamMC = NULL; +#endif return; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index c14d3318a6..1c63e3c6de 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -166,6 +166,24 @@ ivas_error IVAS_DEC_Open( /* initialize pointers to handles to NULL */ ivas_initialize_handles_dec( st_ivas ); +#ifdef SWITCHING_FORMAT_DEC + /*-----------------------------------------------------------------* + * Initialize high-level parameters + *-----------------------------------------------------------------*/ + + if ( mode == IVAS_DEC_MODE_EVS ) + { + ivas_decoder_init_highlevel_params( MONO_FORMAT, st_ivas ); + + return IVAS_ERR_OK; + } + else if ( mode == IVAS_DEC_MODE_IVAS ) + { + ivas_decoder_init_highlevel_params( UNDEFINED_FORMAT, st_ivas ); + + return IVAS_ERR_OK; + } +#else /* set high-level parameters */ if ( mode == IVAS_DEC_MODE_EVS ) { @@ -200,6 +218,7 @@ ivas_error IVAS_DEC_Open( return IVAS_ERR_OK; } +#endif return IVAS_ERR_WRONG_PARAMS; } @@ -256,7 +275,20 @@ void IVAS_DEC_Close( if ( ( *phIvasDec )->st_ivas ) { +#ifdef SWITCHING_FORMAT_DEC + ivas_destroy_dec( ( *phIvasDec )->st_ivas, 1 ); + + if ( ( *phIvasDec )->st_ivas->hDecoderConfig != NULL ) + { + free( ( *phIvasDec )->st_ivas->hDecoderConfig ); + ( *phIvasDec )->st_ivas->hDecoderConfig = NULL; + } + + /* main IVAS handle */ + free( ( *phIvasDec )->st_ivas ); +#else ivas_destroy_dec( ( *phIvasDec )->st_ivas ); +#endif ( *phIvasDec )->st_ivas = NULL; } diff --git a/lib_enc/ivas_enc.c b/lib_enc/ivas_enc.c index e5794d756a..44efbe8260 100644 --- a/lib_enc/ivas_enc.c +++ b/lib_enc/ivas_enc.c @@ -385,6 +385,7 @@ ivas_error ivas_enc( hEncoderConfig->last_ivas_total_brate = ivas_total_brate; #ifdef DEBUG_MODE_INFO + dbgwrite( &ivas_format, sizeof( int16_t ), 1, input_frame, "res/ivas_format" ); { float tmpF = ivas_total_brate / 1000.0f; dbgwrite( &tmpF, sizeof( float ), 1, input_frame, "res/ivas_total_brate" ); diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index fd92453980..9c01ee3fad 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -985,6 +985,7 @@ void ivas_destroy_enc( st_ivas->hLFE = NULL; } +#ifndef SWITCHING_FORMAT_ENC /* Encoder configuration handle */ if ( st_ivas->hEncoderConfig != NULL ) { @@ -994,6 +995,6 @@ void ivas_destroy_enc( /* main IVAS handle */ free( st_ivas ); - +#endif return; } diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 8049f5215c..75b0b789c4 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -208,6 +208,7 @@ void IVAS_ENC_Close( { ivas_destroy_enc( ( *phIvasEnc )->st_ivas ); } +#ifndef SWITCHING_FORMAT_ENC else { if ( ( *phIvasEnc )->st_ivas->hEncoderConfig ) @@ -217,7 +218,19 @@ void IVAS_ENC_Close( } free( ( *phIvasEnc )->st_ivas ); } +#endif + +#ifdef SWITCHING_FORMAT_ENC + /* Encoder configuration handle */ + if ( ( *phIvasEnc )->st_ivas->hEncoderConfig ) + { + free( ( *phIvasEnc )->st_ivas->hEncoderConfig ); + ( *phIvasEnc )->st_ivas->hEncoderConfig = NULL; + } + /* main IVAS handle */ + free( ( *phIvasEnc )->st_ivas ); +#endif ( *phIvasEnc )->st_ivas = NULL; #ifdef BITSTREAM_INDICES_MEMORY @@ -235,6 +248,35 @@ void IVAS_ENC_Close( } +#ifdef SWITCHING_FORMAT_ENC +/*---------------------------------------------------------------------* + * IVAS_ENC_Close_Reinit() + * + * + *---------------------------------------------------------------------*/ + +void IVAS_ENC_Close_Reinit( + IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to IVAS encoder handle */ +) +{ + /* Free all memory */ + if ( phIvasEnc == NULL || *phIvasEnc == NULL ) + { + return; + } + + if ( ( *phIvasEnc )->isConfigured ) + { + ivas_destroy_enc( ( *phIvasEnc )->st_ivas ); + } + + ( *phIvasEnc )->isConfigured = false; + + return; +} +#endif + + /*---------------------------------------------------------------------* * IVAS_ENC_ConfigureForMono() * @@ -1800,10 +1842,12 @@ static ivas_error doCommonConfigureChecks( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifndef SWITCHING_FORMAT_ENC if ( hIvasEnc->isConfigured ) { return IVAS_ERR_RECONFIGURE_NOT_SUPPORTED; } +#endif return IVAS_ERR_OK; } diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index be4d673596..98447a042e 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -231,6 +231,12 @@ void IVAS_ENC_Close( IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to IVAS encoder handle */ ); +#ifdef SWITCHING_FORMAT_ENC +void IVAS_ENC_Close_Reinit( + IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to IVAS encoder handle */ +); +#endif + /* Encoding functions - should be called with a configured encoder handle */ /*! r: error code */ -- GitLab From bc4714a1544db735a6c141e3a8845190c5cf4ed2 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 15 May 2023 17:02:26 +0200 Subject: [PATCH 2/6] updates within SWITCHING_FORMAT_DEC --- lib_dec/ivas_init_dec.c | 10 +++++----- lib_dec/ivas_mc_param_dec.c | 4 ++-- lib_dec/lib_dec.c | 4 ---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 5f77e442b4..f1ad9e203f 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -99,7 +99,7 @@ ivas_error ivas_dec_setup( * Reinitialize the decoder in case of the IVAS format change *-------------------------------------------------------------------*/ - if ( ivas_format_old != st_ivas->ivas_format && st_ivas->ini_frame > 0 ) + if ( ivas_format_old != st_ivas->ivas_format && st_ivas->ini_frame > 0 ) // Note: for OMASA/OSBA, this condtion need to be changed!!! { IVAS_FORMAT ivas_format_read = st_ivas->ivas_format; @@ -2015,6 +2015,10 @@ void ivas_destroy_dec( } #endif +#ifdef JBM_TSM_ON_TCS + ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); +#endif + /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); @@ -2025,10 +2029,6 @@ void ivas_destroy_dec( st_ivas->hDecoderConfig = NULL; } -#ifdef JBM_TSM_ON_TCS - ivas_jbm_dec_tc_buffer_close( &st_ivas->hTcBuffer ); -#endif - /* main IVAS handle */ free( st_ivas ); #endif diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 0b4f9a3c74..d19e2d33cc 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -645,8 +645,8 @@ ivas_error ivas_param_mc_dec_reconfig( } /*-----------------------------------------------------------------* - * set input parameters - *-----------------------------------------------------------------*/ + * set input parameters + *-----------------------------------------------------------------*/ #ifndef JBM_TSM_ON_TCS hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 973c8898d0..d49e029dad 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -335,10 +335,6 @@ void IVAS_DEC_Close( ( *phIvasDec )->st_ivas->hDecoderConfig = NULL; } -#ifdef JBM_TSM_ON_TCS - ivas_jbm_dec_tc_buffer_close( &( ( *phIvasDec )->st_ivas->hTcBuffer ) ); -#endif - /* main IVAS handle */ free( ( *phIvasDec )->st_ivas ); #else -- GitLab From 502ba6627f219d56de3c4163978a08d0a31a202c Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 14:24:15 +0200 Subject: [PATCH 3/6] - updates within SWITCHING_FORMAT_DEC - DEBUG_FORMAT_SWITCHING_ENC replaces SWITCHING_FORMAT_ENC and SIMULATE_FORMAT_SWITCHING_ENC --- apps/encoder.c | 88 +++++++++++++++++++++++++++++++++-------- lib_com/options.h | 3 +- lib_dec/ivas_init_dec.c | 5 +++ lib_enc/ivas_init_enc.c | 2 +- lib_enc/ivas_ism_enc.c | 8 ++++ lib_enc/lib_enc.c | 8 ++-- lib_enc/lib_enc.h | 2 +- 7 files changed, 92 insertions(+), 24 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index fe78bb017a..a431af38de 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -140,7 +140,7 @@ typedef struct static void initArgStruct( EncArguments *arg ); static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC , const bool reconfig_flag #endif @@ -148,13 +148,13 @@ static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg static void usage_enc( void ); static bool readBandwidth( FILE *file, IVAS_ENC_BANDWIDTH *bandwidth, int32_t *bandwidthFrameCounter ); static bool readBitrate( FILE *file, int32_t *bitrate ); -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC static ivas_error configureEnc( const EncArguments arg, IVAS_ENC_HANDLE hIvasEnc, const int32_t totalBitrate, const IVAS_ENC_BANDWIDTH bandwidth, const IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig ); #endif #ifdef DEBUGGING static ivas_error readForcedMode( FILE *file, IVAS_ENC_FORCED_MODE *forcedMode, int32_t *forceFrameCounter ); static IVAS_ENC_FORCED_MODE parseForcedMode( char *forcedModeChar ); -#ifdef SIMULATE_FORMAT_SWITCHING_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC static void simulate_input_format_switching( int16_t *argc_new, char *p_argv_new[10], bool *reinit_flag ); #endif #endif @@ -190,6 +190,9 @@ int main( } int16_t *pcmBuf = NULL; #ifdef DEBUGGING +#ifdef DEBUG_FORMAT_SWITCHING_ENC + int16_t pcmBufSize_orig; +#endif FILE *f_forcedModeProfile = NULL; #ifdef DEBUG_SBA int16_t numTransportChannels = 1; @@ -213,7 +216,7 @@ int main( IVAS_ENC_PrintDisclaimer(); if ( !parseCmdlIVAS_enc( (int16_t) argc, argv, &arg -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC , false #endif @@ -376,7 +379,7 @@ int main( * Configure and initialize (allocate memory for static variables) the encoder *------------------------------------------------------------------------------------------*/ -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC if ( ( error = configureEnc( arg, hIvasEnc, totalBitrate, bandwidth, caConfig ) ) != IVAS_ERR_OK ) { goto cleanup; @@ -574,6 +577,9 @@ int main( fprintf( stderr, "\nGetInputBufferSize failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); goto cleanup; } +#ifdef DEBUG_FORMAT_SWITCHING_ENC + pcmBufSize_orig = pcmBufSize; +#endif pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) ); @@ -634,19 +640,18 @@ int main( * - Write the parameters into output bitstream file *------------------------------------------------------------------------------------------*/ -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC bool reinit_flag = false; + int16_t pcmBufSize_new = pcmBufSize; char *p_argv_new[10]; int16_t argc_new = -1; #endif while ( 1 ) { -#ifdef SWITCHING_FORMAT_ENC -#ifdef SIMULATE_FORMAT_SWITCHING_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC /* simulate input format switching */ simulate_input_format_switching( &argc_new, p_argv_new, &reinit_flag ); -#endif /* Reinitialization of the encoder in case of application parameter(s) change (e.g. change of IVAS input format) */ if ( reinit_flag ) @@ -665,7 +670,6 @@ int main( } /* Allocate input data buffer */ - int16_t pcmBufSize_new; if ( ( error = IVAS_ENC_GetInputBufferSize( hIvasEnc, &pcmBufSize_new ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nGetInputBufferSize failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); @@ -675,10 +679,17 @@ int main( if ( pcmBufSize_new != pcmBufSize ) { free( pcmBuf ); - pcmBuf = malloc( pcmBufSize_new * sizeof( int16_t ) ); - pcmBufSize = pcmBufSize_new; + pcmBuf = malloc( max( pcmBufSize_new, pcmBufSize_orig ) * sizeof( int16_t ) ); } } + + if ( pcmBufSize_new < pcmBufSize_orig ) + { + free( pcmBuf ); + pcmBuf = malloc( max( pcmBufSize_new, pcmBufSize_orig ) * sizeof( int16_t ) ); + } + + pcmBufSize = pcmBufSize_orig; #endif /* Read the input data */ @@ -688,6 +699,51 @@ int main( goto cleanup; } +#ifdef DEBUG_FORMAT_SWITCHING_ENC + if ( pcmBufSize_new > pcmBufSize_orig ) + { + /* keep only channels corresponding to input file channels and zero the others */ + int16_t tmp_buf[16 * 960]; + int16_t nchan = pcmBufSize_new / 960; + int16_t nchan_orig = pcmBufSize / 960; + memcpy( tmp_buf, pcmBuf, numSamplesRead * sizeof( int16_t ) ); + memset( pcmBuf, 0, pcmBufSize_new * sizeof( int16_t ) ); + int16_t k = 0; + for ( i = 0; i < 960; i++ ) + { + for ( int16_t j = 0; j < nchan_orig; j++ ) + { + pcmBuf[i * nchan + j] = tmp_buf[k++]; + } + } + + pcmBufSize = pcmBufSize_new; + numSamplesRead = pcmBufSize; + } + else if ( pcmBufSize_new < pcmBufSize_orig ) + { + int16_t tmp_buf[16 * 960]; + + /* skip channels corresponding to non-read input file channels */ + + memcpy( tmp_buf, pcmBuf, pcmBufSize * sizeof( int16_t ) ); + free( pcmBuf ); + pcmBuf = malloc( pcmBufSize_new * sizeof( int16_t ) ); + + int16_t fac = pcmBufSize / pcmBufSize_new; + int16_t k = 0; + for ( i = 0; i < pcmBufSize; i += fac ) + { + for ( int16_t j = 0; j < pcmBufSize / pcmBufSize_orig; j++ ) + { + pcmBuf[k++] = tmp_buf[i + j]; + } + } + + pcmBufSize = pcmBufSize_new; + } +#endif + if ( numSamplesRead == 0 ) { /* end of input data */ @@ -981,7 +1037,7 @@ static bool parseCmdlIVAS_enc( int16_t argc, char *argv[], EncArguments *arg -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC , const bool reconfig_flag #endif @@ -1625,7 +1681,7 @@ static bool parseCmdlIVAS_enc( } } /* end of while */ -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC /*-----------------------------------------------------------------* * Return in case of reconfiguration *-----------------------------------------------------------------*/ @@ -1924,7 +1980,7 @@ static bool readBitrate( } -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC /*---------------------------------------------------------------------* * configureEnc() * @@ -2096,7 +2152,7 @@ static ivas_error readForcedMode( } -#ifdef SIMULATE_FORMAT_SWITCHING_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC /*---------------------------------------------------------------------* * simulate_input_format_switching() * diff --git a/lib_com/options.h b/lib_com/options.h index 6a5d866844..1d8f910a0d 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -228,8 +228,7 @@ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ #define SWITCHING_FORMAT_DEC /* VA: issue 326: Bitstream Switching (Decoder side) */ -#define SWITCHING_FORMAT_ENC /* VA: issue 325: Encoder Input format Switching */ -/*#define SIMULATE_FORMAT_SWITCHING_ENC*/ /* VA: debugging: simulate Input format switching */ +#define DEBUG_FORMAT_SWITCHING_ENC /* VA: debugging: simulate Input format switching */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index f1ad9e203f..ac5adcd9eb 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -109,6 +109,11 @@ ivas_error ivas_dec_setup( /* set decoder high level parameters */ ivas_decoder_init_highlevel_params( ivas_format_read, st_ivas ); + + st_ivas->nSCE = 0; + st_ivas->nCPE = 0; + st_ivas->nchan_transport = -1; + st_ivas->sba_dirac_stereo_flag = 0; } #endif diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index 269e6126ef..3245effcd0 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -1038,7 +1038,7 @@ void ivas_destroy_enc( /* Stereo downmix for EVS encoder handle */ stereo_dmx_evs_close_encoder( &( st_ivas->hStereoDmxEVS ) ); -#ifndef SWITCHING_FORMAT_ENC +#ifndef DEBUG_FORMAT_SWITCHING_ENC /* Encoder configuration handle */ if ( st_ivas->hEncoderConfig != NULL ) { diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 5c310ac30f..4aaac56a8c 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -176,6 +176,14 @@ ivas_error ivas_ism_enc( { vad_flag[sce_id] = st->vad_flag; } + +#ifdef DEBUG_MODE_INFO + if ( sce_id == 0 ) + { + dbgwrite( st->input - NS2SA( st->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, "res/input_DMX" ); + dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) ); + } +#endif } /*------------------------------------------------------------------* diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index a9b07b85cf..e038352671 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -209,7 +209,7 @@ void IVAS_ENC_Close( { ivas_destroy_enc( ( *phIvasEnc )->st_ivas ); } -#ifndef SWITCHING_FORMAT_ENC +#ifndef DEBUG_FORMAT_SWITCHING_ENC else { if ( ( *phIvasEnc )->st_ivas->hEncoderConfig ) @@ -221,7 +221,7 @@ void IVAS_ENC_Close( } #endif -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC /* Encoder configuration handle */ if ( ( *phIvasEnc )->st_ivas->hEncoderConfig ) { @@ -249,7 +249,7 @@ void IVAS_ENC_Close( } -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC /*---------------------------------------------------------------------* * IVAS_ENC_Close_Reinit() * @@ -1876,7 +1876,7 @@ static ivas_error doCommonConfigureChecks( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -#ifndef SWITCHING_FORMAT_ENC +#ifndef DEBUG_FORMAT_SWITCHING_ENC if ( hIvasEnc->isConfigured ) { return IVAS_ERR_RECONFIGURE_NOT_SUPPORTED; diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index d6837e501f..913a917b25 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -239,7 +239,7 @@ void IVAS_ENC_Close( IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to IVAS encoder handle */ ); -#ifdef SWITCHING_FORMAT_ENC +#ifdef DEBUG_FORMAT_SWITCHING_ENC void IVAS_ENC_Close_Reinit( IVAS_ENC_HANDLE *phIvasEnc /* i/o: pointer to IVAS encoder handle */ ); -- GitLab From 87ad0246ba165bab58208e633865f35a7b800941 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 14:27:41 +0200 Subject: [PATCH 4/6] update comment --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 0ee40568eb..3709745d0f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -212,7 +212,7 @@ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ #define SWITCHING_FORMAT_DEC /* VA: issue 326: Bitstream Switching (Decoder side) */ -#define DEBUG_FORMAT_SWITCHING_ENC /* VA: debugging: simulate Input format switching */ +#define DEBUG_FORMAT_SWITCHING_ENC /* simulate Input format switching */ /* ################## End DEVELOPMENT switches ######################### */ -- GitLab From 6b21770ca3f733cc670733e782ee13780416803e Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 14:47:34 +0200 Subject: [PATCH 5/6] fix build error --- apps/encoder.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index a431af38de..670a67d5a7 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -679,14 +679,14 @@ int main( if ( pcmBufSize_new != pcmBufSize ) { free( pcmBuf ); - pcmBuf = malloc( max( pcmBufSize_new, pcmBufSize_orig ) * sizeof( int16_t ) ); + pcmBuf = malloc( ( pcmBufSize_new > pcmBufSize_orig ? pcmBufSize_new : pcmBufSize_orig ) * sizeof( int16_t ) ); } } if ( pcmBufSize_new < pcmBufSize_orig ) { free( pcmBuf ); - pcmBuf = malloc( max( pcmBufSize_new, pcmBufSize_orig ) * sizeof( int16_t ) ); + pcmBuf = malloc( ( pcmBufSize_new > pcmBufSize_orig ? pcmBufSize_new : pcmBufSize_orig ) * sizeof( int16_t ) ); } pcmBufSize = pcmBufSize_orig; @@ -723,9 +723,7 @@ int main( else if ( pcmBufSize_new < pcmBufSize_orig ) { int16_t tmp_buf[16 * 960]; - /* skip channels corresponding to non-read input file channels */ - memcpy( tmp_buf, pcmBuf, pcmBufSize * sizeof( int16_t ) ); free( pcmBuf ); pcmBuf = malloc( pcmBufSize_new * sizeof( int16_t ) ); -- GitLab From 1aeca2e66e402a8f595300c359ccb5ada0edba32 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 16 May 2023 14:57:41 +0200 Subject: [PATCH 6/6] disable DEBUG_FORMAT_SWITCHING_ENC --- lib_com/options.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3709745d0f..649575a213 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -212,7 +212,7 @@ #define FIX_DTX_428 /* FhG: fix for issue 428, crash with DTX and bitrate switching */ #define SWITCHING_FORMAT_DEC /* VA: issue 326: Bitstream Switching (Decoder side) */ -#define DEBUG_FORMAT_SWITCHING_ENC /* simulate Input format switching */ +/*#define DEBUG_FORMAT_SWITCHING_ENC*/ /* simulate Input format switching */ /* ################## End DEVELOPMENT switches ######################### */ -- GitLab