From 5625bf037d788839ddece045ccfef1ef46cc168a Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 11 Jul 2022 10:34:05 +0200 Subject: [PATCH 1/6] fix WMC build with unremoved defines --- lib_dec/ivas_spar_foa_dec.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_spar_foa_dec.c b/lib_dec/ivas_spar_foa_dec.c index 55460493c6..3773329584 100644 --- a/lib_dec/ivas_spar_foa_dec.c +++ b/lib_dec/ivas_spar_foa_dec.c @@ -590,11 +590,13 @@ void ivas_spar_dec_MD( DECODER_CONFIG_HANDLE hDecoderConfig = st_ivas->hDecoderConfig; #ifndef FIX_SBA_CLEAN_UP_OPT ivas_spar_foa_dec_state_t *pState = st_ivas->hSpar->hSparFoa; - - wmops_sub_start( "ivas_spar_foa_dec_MD" ); #else SPAR_DEC_HANDLE pState = st_ivas->hSpar; +#endif +#ifndef FIX_SBA_CLEAN_UP_OPT + wmops_sub_start( "ivas_spar_foa_dec_MD" ); +#else wmops_sub_start( "ivas_spar_dec_MD" ); #endif @@ -814,7 +816,7 @@ void ivas_spar_get_parameters( float par_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS] ) #endif { - int16_t spar_band, out_ch, in_ch; + int16_t spar_band, out_ch, in_ch, prev_idx; float weight, weight_20ms; int16_t ts0, ts1, split_band; @@ -869,11 +871,11 @@ void ivas_spar_get_parameters( { #ifndef FIX_SBA_CLEAN_UP_OPT /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ - int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ + prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSparFoa->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSparFoa->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; #else /* 20ms Transport channel reconstruction with matching encoder/decoder processing */ - int16_t prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ + prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */ par_mat[out_ch][in_ch][spar_band] = ( 1.0f - weight_20ms ) * hSpar->hMdDec->mixer_mat_prev[prev_idx][out_ch][in_ch][spar_band] + weight_20ms * hSpar->hMdDec->mixer_mat[out_ch][in_ch][spar_band]; #endif } -- GitLab From c4a82e252faf59e152c75d7402303913efb354ec Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Jul 2022 17:37:04 +0200 Subject: [PATCH 2/6] - print out a message code and exit the encoder when channel-aware mode is requested in IVAS --- apps/encoder.c | 11 +++++++++++ lib_enc/lib_enc.c | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 607e377e3b..d69afc1b68 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -392,6 +392,10 @@ int main( } } + /*------------------------------------------------------------------------------------------* + * Handle Channel-aware mode + *------------------------------------------------------------------------------------------*/ + IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig = arg.caConfig; if ( arg.ca_config_file ) @@ -410,6 +414,13 @@ int main( fprintf( stdout, "Channel-aware mode: ON, FEC indicator : %s FEC offset: %d \n\n", ( caConfig.fec_indicator == IVAS_ENC_FEC_LO ) ? "LO" : "HI", caConfig.fec_offset ); } + if ( arg.inputFormat != IVAS_ENC_INPUT_MONO && ( caConfig.channelAwareModeEnabled || arg.ca_config_file ) ) + { + fprintf( stderr, "Channel-aware mode is not supported in IVAS.\n\n" ); + usage_enc(); + goto cleanup; + } + /*------------------------------------------------------------------------------------------* * Configure and initialize (allocate memory for static variables) the encoder *------------------------------------------------------------------------------------------*/ diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 81f13d40d2..370c043e7d 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -869,11 +869,6 @@ static ivas_error configureEncoder( return IVAS_ERROR( IVAS_ERR_DTX_NOT_SUPPORTED, "DTX is not supported in this IVAS format and element mode." ); } - if ( hEncoderConfig->ivas_format != MONO_FORMAT && hEncoderConfig->Opt_RF_ON ) - { - return IVAS_ERROR( IVAS_ERR_NOT_IMPLEMENTED, "Channel-aware mode is not supported in IVAS yet." ); - } - if ( hEncoderConfig->Opt_AGC_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR ) ) { return IVAS_ERROR( IVAS_ERR_NOT_SUPPORTED_OPTION, "AGC supported in SBA format at bitrates >= 24.4 kbps only." ); -- GitLab From 0d25834c4792b9b621857bd06d768dbfb56f8580 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Jul 2022 17:49:13 +0200 Subject: [PATCH 3/6] fix VBR option exit + properly return an error for IVAS_ENC_PrintConfig() --- apps/encoder.c | 6 +++++- lib_enc/lib_enc.c | 12 ++++++------ lib_enc/lib_enc.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index d69afc1b68..6a34cdff81 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -479,7 +479,11 @@ int main( goto cleanup; } - IVAS_ENC_PrintConfig( hIvasEnc, caConfig.channelAwareModeEnabled ); + if( ( error = IVAS_ENC_PrintConfig( hIvasEnc, caConfig.channelAwareModeEnabled ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\n IVAS_ENC_PrintConfig failed %s\n\n", IVAS_ENC_GetErrorMessage( error ) ); + goto cleanup; + } /*------------------------------------------------------------------------------------------* * Open input metadata files diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 370c043e7d..378163b02f 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1317,7 +1317,9 @@ const char *IVAS_ENC_GetErrorMessage( case IVAS_ERR_OK: return "no error"; case IVAS_ERR_FAILED_ALLOC: - return "memory error"; + return "Failed allocation error"; + case IVAS_ERR_WRONG_PARAMS: + return "wrong parameters"; case IVAS_ERR_INVALID_BANDWIDTH: return "invalid bandwidth"; case IVAS_ERR_INVALID_DTX_UPDATE_RATE: @@ -1544,7 +1546,7 @@ static ivas_error printConfigInfo_enc( if ( st_ivas->hEncoderConfig->Opt_SC_VBR && !hEncoderConfig->Opt_DTX_ON ) { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: SC-VBR 5900 bps not supported without DTX\n\n" ); + return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "\nError: SC-VBR 5900 bps not supported without DTX\n\n" ); } if ( hIvasEnc->maxBandwidthUser ) @@ -1998,14 +2000,12 @@ static ivas_error forcedModeApiToInternal( * *---------------------------------------------------------------------*/ -void IVAS_ENC_PrintConfig( +ivas_error IVAS_ENC_PrintConfig( const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ const int16_t channelAwareModeEnabled /* i : channel-aware mode enabled flag */ ) { - printConfigInfo_enc( hIvasEnc, channelAwareModeEnabled ); - - return; + return printConfigInfo_enc( hIvasEnc, channelAwareModeEnabled ); } diff --git a/lib_enc/lib_enc.h b/lib_enc/lib_enc.h index 0139e0f7ab..dce4d6a010 100644 --- a/lib_enc/lib_enc.h +++ b/lib_enc/lib_enc.h @@ -316,7 +316,7 @@ const char *IVAS_ENC_GetErrorMessage( ); -void IVAS_ENC_PrintConfig( +ivas_error IVAS_ENC_PrintConfig( const IVAS_ENC_HANDLE hIvasEnc, /* i : IVAS encoder handle */ const int16_t channelAwareModeEnabled /* i : channel-aware mode enabled flag */ ); -- GitLab From 7c886f3a7d88a7052eb88660f95da76686911191 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Jul 2022 17:55:09 +0200 Subject: [PATCH 4/6] fix printout for audio bandwidth limitation --- apps/encoder.c | 44 +++++++++++++++++++++++--------------------- lib_enc/lib_enc.c | 4 ---- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 6a34cdff81..bd78103cc6 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -366,29 +366,31 @@ int main( { if ( bandwidth == IVAS_ENC_BANDWIDTH_NB && arg.inputFormat != IVAS_ENC_INPUT_MONO ) { - fprintf( stdout, "\nNB coding not supported in IVAS. Switching to WB.\n" ); + fprintf( stdout, "\nNB coding not supported in IVAS. Switching to WB.\n\n" ); } - - switch ( bandwidth ) + else { - case IVAS_ENC_BANDWIDTH_UNDEFINED: - break; - case IVAS_ENC_BANDWIDTH_NB: - fprintf( stdout, "Max. encoded bandwidth: NB\n" ); - break; - case IVAS_ENC_BANDWIDTH_WB: - fprintf( stdout, "Max. encoded bandwidth: WB\n" ); - break; - case IVAS_ENC_BANDWIDTH_SWB: - fprintf( stdout, "Max. encoded bandwidth: SWB\n" ); - break; - case IVAS_ENC_BANDWIDTH_FB: - fprintf( stdout, "Max. encoded bandwidth: FB\n" ); - break; - default: - fprintf( stderr, "Error: Invalid bandwidth value\n" ); - usage_enc(); - goto cleanup; + switch ( bandwidth ) + { + case IVAS_ENC_BANDWIDTH_UNDEFINED: + break; + case IVAS_ENC_BANDWIDTH_NB: + fprintf( stdout, "Max. encoded bandwidth: NB\n" ); + break; + case IVAS_ENC_BANDWIDTH_WB: + fprintf( stdout, "Max. encoded bandwidth: WB\n" ); + break; + case IVAS_ENC_BANDWIDTH_SWB: + fprintf( stdout, "Max. encoded bandwidth: SWB\n" ); + break; + case IVAS_ENC_BANDWIDTH_FB: + fprintf( stdout, "Max. encoded bandwidth: FB\n" ); + break; + default: + fprintf( stderr, "Error: Invalid bandwidth value\n" ); + usage_enc(); + goto cleanup; + } } } diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 378163b02f..900d24e81f 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -1553,10 +1553,6 @@ static ivas_error printConfigInfo_enc( { fprintf( stdout, "\nBandwidth limited to %s.\n", max_bwidth_string ); } - if ( hIvasEnc->maxBandwidthUser && hEncoderConfig->max_bwidth < FB && hEncoderConfig->input_Fs == 48000 ) - { - fprintf( stdout, "\nBandwidth limited to %s. To enable FB coding, please use -max_band FB.\n", max_bwidth_string ); - } if ( hEncoderConfig->ivas_format == MONO_FORMAT ) { -- GitLab From 49823deb7545e78241ba9087462d128f4c24f9e3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Jul 2022 17:58:59 +0200 Subject: [PATCH 5/6] fix error bitrate printout in VBR mode in IVAS --- lib_enc/lib_enc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 900d24e81f..2756b40d94 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -698,7 +698,14 @@ static ivas_error configureEncoder( { if ( !is_IVAS_bitrate( hEncoderConfig->ivas_total_brate ) ) { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS: %d", hEncoderConfig->ivas_total_brate ); + if( hEncoderConfig->Opt_SC_VBR ) + { + return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", 5900 ); + } + else + { + return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", hEncoderConfig->ivas_total_brate ); + } } if ( hEncoderConfig->ivas_format == STEREO_FORMAT ) -- GitLab From cd67663384a9ec528c8e5e76cdc12243d1fa0689 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 18 Jul 2022 19:13:08 +0200 Subject: [PATCH 6/6] magic number -> macro define --- lib_enc/lib_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 2756b40d94..f3c423627c 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -700,7 +700,7 @@ static ivas_error configureEncoder( { if( hEncoderConfig->Opt_SC_VBR ) { - return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", 5900 ); + return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Incorrect bitrate specification in IVAS [bps]: %d", ACELP_5k90 ); } else { -- GitLab