Loading apps/decoder.c +98 −15 Original line number Diff line number Diff line Loading @@ -129,6 +129,9 @@ static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #ifdef SIMULATE_SWITCHING_OUTPUT_CONFIG static void simulate_output_configuration_switching( IVAS_DEC_AUDIO_CONFIG *outputConfig, bool *reinit_flag ); #endif #endif Loading Loading @@ -1301,6 +1304,9 @@ static ivas_error decodeG192( ivas_error error = IVAS_ERR_UNKNOWN; uint16_t numObj = 0; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; #ifdef SWITCHING_OUTPUT_CONFIG bool reinit_flag; #endif IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) Loading Loading @@ -1332,6 +1338,10 @@ static ivas_error decodeG192( while ( 1 ) { #ifdef SWITCHING_OUTPUT_CONFIG reinit_flag = false; #endif /* Read next frame */ if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK ) { Loading Loading @@ -1359,6 +1369,23 @@ static ivas_error decodeG192( } #endif #ifdef SWITCHING_OUTPUT_CONFIG #ifdef SIMULATE_SWITCHING_OUTPUT_CONFIG /* Simulation of output configuration switching */ simulate_output_configuration_switching( &( arg.outputFormat ), &reinit_flag ); #endif /* Reinitialization of the decoder in case of application parameter(s) change (e.g. change of output config) */ if ( reinit_flag ) { if ( ( error = IVAS_DEC_Reinit_Dec( hIvasDec, arg.outputFormat ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_Reinit_Dec: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } #endif /* Feed into decoder */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK ) { Loading Loading @@ -1403,22 +1430,9 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, &delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ); if ( error != IVAS_ERR_OK ) if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, &delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in initOnFirstGoodFrame, code: %d\n", error ); goto cleanup; } } Loading Loading @@ -2046,4 +2060,73 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( return IVAS_DEC_FORCE_REND_UNDEFINED; } #ifdef SIMULATE_SWITCHING_OUTPUT_CONFIG /*---------------------------------------------------------------------* * simulate_input_format_switching() * * Simulation of IVAS input format switching *---------------------------------------------------------------------*/ #if 1 #define MAX_OUT_CONFIGS_SIMULATE 3 IVAS_DEC_AUDIO_CONFIG output_config_options[MAX_OUT_CONFIGS_SIMULATE] = { IVAS_DEC_OUTPUT_STEREO, IVAS_DEC_OUTPUT_BINAURAL, IVAS_DEC_OUTPUT_BINAURAL_ROOM, }; #else #define MAX_OUT_CONFIGS_SIMULATE 12 IVAS_DEC_AUDIO_CONFIG output_config_options[MAX_OUT_CONFIGS_SIMULATE] = { IVAS_DEC_OUTPUT_MONO, IVAS_DEC_OUTPUT_STEREO, IVAS_DEC_OUTPUT_5_1, IVAS_DEC_OUTPUT_7_1, IVAS_DEC_OUTPUT_5_1_2, IVAS_DEC_OUTPUT_5_1_4, IVAS_DEC_OUTPUT_7_1_4, /*IVAS_DEC_OUTPUT_LS_CUSTOM,*/ IVAS_DEC_OUTPUT_FOA, IVAS_DEC_OUTPUT_HOA2, IVAS_DEC_OUTPUT_HOA3, IVAS_DEC_OUTPUT_BINAURAL, IVAS_DEC_OUTPUT_BINAURAL_ROOM, /*IVAS_DEC_OUTPUT_EXT,*/ /*IVAS_DEC_OUTPUT_UNKNOWN*/ }; #endif static void simulate_output_configuration_switching( IVAS_DEC_AUDIO_CONFIG *outputConfig, bool *reinit_flag ) { static int16_t ff = -1; IVAS_DEC_AUDIO_CONFIG outputConfig_new; *reinit_flag = false; outputConfig_new = *outputConfig; if ( frame % 20 == 0 ) { ff++; if ( ff > MAX_OUT_CONFIGS_SIMULATE - 1 ) { ff = 0; } outputConfig_new = output_config_options[ff]; } if ( *outputConfig != outputConfig_new ) { *reinit_flag = true; *outputConfig = outputConfig_new; } return; } #endif #endif lib_com/ivas_prot.h +4 −0 Original line number Diff line number Diff line Loading @@ -410,6 +410,10 @@ void destroy_core_dec( void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ #ifdef SWITCHING_OUTPUT_CONFIG , const int16_t flag_all /* i : 1 == destroy external data handles */ #endif ); void ivas_initialize_handles_dec( Loading lib_com/options.h +4 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,10 @@ #define FIX_317 /* FhG: issue 317 - address sanitizer error in MDCT-Stereo PLC */ #define SWITCHING_OUTPUT_CONFIG /* VA: Issue 323 - Decoder Output Format Switching */ /*#define SIMULATE_SWITCHING_OUTPUT_CONFIG*/ /* VA: debugging - simulate Decoder Output Format Switching */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif lib_dec/ivas_dec.c +2 −0 Original line number Diff line number Diff line Loading @@ -610,6 +610,8 @@ ivas_error ivas_dec( } #ifdef DEBUG_MODE_INFO dbgwrite( &st_ivas->ivas_format, sizeof( int16_t ), 1, output_frame, "res/ivas_format.dec" ); dbgwrite( &st_ivas->hDecoderConfig->output_config, sizeof( int16_t ), 1, output_frame, "res/output_config" ); dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" ); { Loading lib_dec/ivas_init_dec.c +67 −36 Original line number Diff line number Diff line Loading @@ -553,7 +553,11 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Custom loudspeaker layout handle *--------------------------------------------------------------------*/ #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig->Opt_LsCustom && st_ivas->hLsSetupCustom == NULL ) #else if ( st_ivas->hDecoderConfig->Opt_LsCustom ) #endif { if ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) { Loading @@ -565,7 +569,11 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Head-Tracking handle *--------------------------------------------------------------------*/ #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData == NULL ) #else if ( st_ivas->hDecoderConfig->Opt_Headrotation ) #endif { if ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) { Loading @@ -577,7 +585,11 @@ ivas_error ivas_init_decoder_front( * Allocate HRTF binary handle *--------------------------------------------------------------------*/ #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && st_ivas->hHrtfTD == NULL ) #else if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) #endif { if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { Loading Loading @@ -607,10 +619,16 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) { #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hRenderConfig == NULL ) #endif { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { return error; } } if ( ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) != IVAS_ERR_OK ) { Loading Loading @@ -1571,6 +1589,10 @@ void ivas_initialize_handles_dec( void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ #ifdef SWITCHING_OUTPUT_CONFIG , const int16_t flag_all /* i : 1 == destroy external data handles */ #endif ) { int16_t i, n; Loading Loading @@ -1736,6 +1758,11 @@ void ivas_destroy_dec( st_ivas->hMonoDmxRenderer = NULL; } #ifdef SWITCHING_OUTPUT_CONFIG if ( flag_all ) { #endif /* Head track data handle */ if ( st_ivas->hHeadTrackData != NULL ) { Loading Loading @@ -1778,10 +1805,14 @@ void ivas_destroy_dec( /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); #ifdef SWITCHING_OUTPUT_CONFIG } #endif /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); #ifndef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); Loading @@ -1790,7 +1821,7 @@ void ivas_destroy_dec( /* main IVAS handle */ free( st_ivas ); #endif return; } Loading Loading
apps/decoder.c +98 −15 Original line number Diff line number Diff line Loading @@ -129,6 +129,9 @@ static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #ifdef SIMULATE_SWITCHING_OUTPUT_CONFIG static void simulate_output_configuration_switching( IVAS_DEC_AUDIO_CONFIG *outputConfig, bool *reinit_flag ); #endif #endif Loading Loading @@ -1301,6 +1304,9 @@ static ivas_error decodeG192( ivas_error error = IVAS_ERR_UNKNOWN; uint16_t numObj = 0; IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN; #ifdef SWITCHING_OUTPUT_CONFIG bool reinit_flag; #endif IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS]; for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i ) Loading Loading @@ -1332,6 +1338,10 @@ static ivas_error decodeG192( while ( 1 ) { #ifdef SWITCHING_OUTPUT_CONFIG reinit_flag = false; #endif /* Read next frame */ if ( ( error = BS_Reader_ReadFrame_short( hBsReader, bit_stream, &num_bits, &bfi ) ) != IVAS_ERR_OK ) { Loading Loading @@ -1359,6 +1369,23 @@ static ivas_error decodeG192( } #endif #ifdef SWITCHING_OUTPUT_CONFIG #ifdef SIMULATE_SWITCHING_OUTPUT_CONFIG /* Simulation of output configuration switching */ simulate_output_configuration_switching( &( arg.outputFormat ), &reinit_flag ); #endif /* Reinitialization of the decoder in case of application parameter(s) change (e.g. change of output config) */ if ( reinit_flag ) { if ( ( error = IVAS_DEC_Reinit_Dec( hIvasDec, arg.outputFormat ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_Reinit_Dec: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } #endif /* Feed into decoder */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK ) { Loading Loading @@ -1403,22 +1430,9 @@ static ivas_error decodeG192( /* Once good frame decoded, catch up */ if ( decodedGoodFrame ) { error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, &delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ); if ( error != IVAS_ERR_OK ) if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, &delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in initOnFirstGoodFrame, code: %d\n", error ); goto cleanup; } } Loading Loading @@ -2046,4 +2060,73 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( return IVAS_DEC_FORCE_REND_UNDEFINED; } #ifdef SIMULATE_SWITCHING_OUTPUT_CONFIG /*---------------------------------------------------------------------* * simulate_input_format_switching() * * Simulation of IVAS input format switching *---------------------------------------------------------------------*/ #if 1 #define MAX_OUT_CONFIGS_SIMULATE 3 IVAS_DEC_AUDIO_CONFIG output_config_options[MAX_OUT_CONFIGS_SIMULATE] = { IVAS_DEC_OUTPUT_STEREO, IVAS_DEC_OUTPUT_BINAURAL, IVAS_DEC_OUTPUT_BINAURAL_ROOM, }; #else #define MAX_OUT_CONFIGS_SIMULATE 12 IVAS_DEC_AUDIO_CONFIG output_config_options[MAX_OUT_CONFIGS_SIMULATE] = { IVAS_DEC_OUTPUT_MONO, IVAS_DEC_OUTPUT_STEREO, IVAS_DEC_OUTPUT_5_1, IVAS_DEC_OUTPUT_7_1, IVAS_DEC_OUTPUT_5_1_2, IVAS_DEC_OUTPUT_5_1_4, IVAS_DEC_OUTPUT_7_1_4, /*IVAS_DEC_OUTPUT_LS_CUSTOM,*/ IVAS_DEC_OUTPUT_FOA, IVAS_DEC_OUTPUT_HOA2, IVAS_DEC_OUTPUT_HOA3, IVAS_DEC_OUTPUT_BINAURAL, IVAS_DEC_OUTPUT_BINAURAL_ROOM, /*IVAS_DEC_OUTPUT_EXT,*/ /*IVAS_DEC_OUTPUT_UNKNOWN*/ }; #endif static void simulate_output_configuration_switching( IVAS_DEC_AUDIO_CONFIG *outputConfig, bool *reinit_flag ) { static int16_t ff = -1; IVAS_DEC_AUDIO_CONFIG outputConfig_new; *reinit_flag = false; outputConfig_new = *outputConfig; if ( frame % 20 == 0 ) { ff++; if ( ff > MAX_OUT_CONFIGS_SIMULATE - 1 ) { ff = 0; } outputConfig_new = output_config_options[ff]; } if ( *outputConfig != outputConfig_new ) { *reinit_flag = true; *outputConfig = outputConfig_new; } return; } #endif #endif
lib_com/ivas_prot.h +4 −0 Original line number Diff line number Diff line Loading @@ -410,6 +410,10 @@ void destroy_core_dec( void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ #ifdef SWITCHING_OUTPUT_CONFIG , const int16_t flag_all /* i : 1 == destroy external data handles */ #endif ); void ivas_initialize_handles_dec( Loading
lib_com/options.h +4 −0 Original line number Diff line number Diff line Loading @@ -168,6 +168,10 @@ #define FIX_317 /* FhG: issue 317 - address sanitizer error in MDCT-Stereo PLC */ #define SWITCHING_OUTPUT_CONFIG /* VA: Issue 323 - Decoder Output Format Switching */ /*#define SIMULATE_SWITCHING_OUTPUT_CONFIG*/ /* VA: debugging - simulate Decoder Output Format Switching */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif
lib_dec/ivas_dec.c +2 −0 Original line number Diff line number Diff line Loading @@ -610,6 +610,8 @@ ivas_error ivas_dec( } #ifdef DEBUG_MODE_INFO dbgwrite( &st_ivas->ivas_format, sizeof( int16_t ), 1, output_frame, "res/ivas_format.dec" ); dbgwrite( &st_ivas->hDecoderConfig->output_config, sizeof( int16_t ), 1, output_frame, "res/output_config" ); dbgwrite( &st_ivas->bfi, sizeof( int16_t ), 1, output_frame, "res/bfi" ); dbgwrite( &st_ivas->BER_detect, sizeof( int16_t ), 1, output_frame, "res/BER_detect" ); { Loading
lib_dec/ivas_init_dec.c +67 −36 Original line number Diff line number Diff line Loading @@ -553,7 +553,11 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Custom loudspeaker layout handle *--------------------------------------------------------------------*/ #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig->Opt_LsCustom && st_ivas->hLsSetupCustom == NULL ) #else if ( st_ivas->hDecoderConfig->Opt_LsCustom ) #endif { if ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) { Loading @@ -565,7 +569,11 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Head-Tracking handle *--------------------------------------------------------------------*/ #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig->Opt_Headrotation && st_ivas->hHeadTrackData == NULL ) #else if ( st_ivas->hDecoderConfig->Opt_Headrotation ) #endif { if ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) { Loading @@ -577,7 +585,11 @@ ivas_error ivas_init_decoder_front( * Allocate HRTF binary handle *--------------------------------------------------------------------*/ #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig->Opt_HRTF_binary && st_ivas->hHrtfTD == NULL ) #else if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) #endif { if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { Loading Loading @@ -607,10 +619,16 @@ ivas_error ivas_init_decoder_front( if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) { #ifdef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hRenderConfig == NULL ) #endif { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { return error; } } if ( ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) != IVAS_ERR_OK ) { Loading Loading @@ -1571,6 +1589,10 @@ void ivas_initialize_handles_dec( void ivas_destroy_dec( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ #ifdef SWITCHING_OUTPUT_CONFIG , const int16_t flag_all /* i : 1 == destroy external data handles */ #endif ) { int16_t i, n; Loading Loading @@ -1736,6 +1758,11 @@ void ivas_destroy_dec( st_ivas->hMonoDmxRenderer = NULL; } #ifdef SWITCHING_OUTPUT_CONFIG if ( flag_all ) { #endif /* Head track data handle */ if ( st_ivas->hHeadTrackData != NULL ) { Loading Loading @@ -1778,10 +1805,14 @@ void ivas_destroy_dec( /* Config. Renderer */ ivas_render_config_close( &( st_ivas->hRenderConfig ) ); #ifdef SWITCHING_OUTPUT_CONFIG } #endif /* Limiter struct */ ivas_limiter_close( &( st_ivas->hLimiter ) ); #ifndef SWITCHING_OUTPUT_CONFIG if ( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); Loading @@ -1790,7 +1821,7 @@ void ivas_destroy_dec( /* main IVAS handle */ free( st_ivas ); #endif return; } Loading