diff --git a/apps/encoder.c b/apps/encoder.c index d3e0ced2739d5eae7826b019dfcd80e934ea9221..5443bafe43dc42f2b69f0e3f4cdf96d0a97e2ab3 100644 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -366,32 +366,38 @@ 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; + } } } + /*------------------------------------------------------------------------------------------* + * Handle Channel-aware mode + *------------------------------------------------------------------------------------------*/ + IVAS_ENC_CHANNEL_AWARE_CONFIG caConfig = arg.caConfig; if ( arg.ca_config_file ) @@ -410,6 +416,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 *------------------------------------------------------------------------------------------*/ @@ -468,7 +481,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 28085ae0967758307d8d0784d279fc505e02bd66..bcc0a62047739eb8a19491fe23083ceccb06e70a 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", ACELP_5k90 ); + } + 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 ) @@ -865,11 +872,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." ); - } - #ifdef SBA_CLEANING if ( hEncoderConfig->Opt_AGC_ON && !( hEncoderConfig->ivas_format == SBA_FORMAT && ivas_sba_mode_select( hEncoderConfig->ivas_total_brate ) == SBA_MODE_SPAR ) ) #else @@ -1322,7 +1324,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: @@ -1549,17 +1553,13 @@ 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 ) { 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 ) { @@ -2003,14 +2003,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 0139e0f7abffa6bb0cd5f724a6469e869ae41768..dce4d6a0101938a868459ec949ad68d02d06d8d5 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 */ );