diff --git a/apps/decoder.c b/apps/decoder.c index 4e59e521cf00b3ea98fd26f01c665763c04bfd3b..595ca6a71445eca7568db6ed776d6d84c45c7b38 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "options.h" #include "lib_dec.h" #include "cmdl_tools.h" @@ -103,7 +102,7 @@ typedef struct char *outputWavFilename; IVAS_DEC_MODE decMode; int32_t output_Fs; - IVAS_DEC_AUDIO_CONFIG outputFormat; + IVAS_DEC_AUDIO_CONFIG outputConfig; bool quietModeEnabled; bool delayCompensationEnabled; bool voipMode; @@ -119,12 +118,10 @@ typedef struct char *jbmTraceFilename; #endif char *jbmOffsetFilename; - char *FEPatterFileName; + char *FEPatternFileName; float FER; bool hrtfReaderEnabled; char *hrtfFileName; - bool hrtfCRendReaderEnabled; - char *hrtfCRendFileName; IVAS_DEC_INPUT_FORMAT inputFormat; bool customLsOutputEnabled; char *customLsSetupFilename; @@ -145,6 +142,7 @@ typedef struct #endif #ifdef DEBUG_JBM_CMD_OPTION bool noBadFrameDelay; + uint16_t frontendFetchSizeMs; #endif #ifdef VARIABLE_SPEED_DECODING bool variableSpeedMode; @@ -152,11 +150,7 @@ typedef struct char *tsmScaleFileName; uint16_t tsmScale; #endif -#ifdef DEBUG_JBM_CMD_OPTION - uint16_t frontendFetchSizeMs; -#endif #endif - #ifdef CONTROL_METADATA_REVERB uint16_t acousticEnvironmentId; #ifdef CONTROL_METADATA_DIRECTIVITY @@ -172,6 +166,7 @@ typedef struct *------------------------------------------------------------------------------------------*/ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg ); + static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, @@ -180,6 +175,7 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotF #endif IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); + static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec ); #ifdef DEBUGGING #ifdef VARIABLE_SPEED_DECODING @@ -288,7 +284,7 @@ int main( if ( arg.hrtfReaderEnabled ) { /* sanity check */ - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) { arg.hrtfReaderEnabled = false; fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" ); @@ -310,9 +306,9 @@ int main( if ( arg.enableHeadRotation ) { /* sanity check */ - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB + if ( arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM + && arg.outputConfig != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED && arg.outputConfig != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM #endif ) { @@ -334,7 +330,7 @@ int main( if ( arg.enableReferenceRotation ) { /* sanity check */ - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) { fprintf( stderr, "\nError: Reference rotation file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -361,7 +357,7 @@ int main( if ( arg.enableReferenceVectorTracking ) { /* sanity check */ - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) { fprintf( stderr, "\nError: Reference vector trajectory file cannot be used in this output configuration.\n\n" ); goto cleanup; @@ -414,9 +410,9 @@ int main( if ( arg.renderConfigEnabled ) { /* sanity check */ - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB + if ( arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB #ifdef SPLIT_REND_WITH_HEAD_ROT - && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED && arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM + && arg.outputConfig != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED && arg.outputConfig != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM #endif ) { @@ -434,13 +430,15 @@ int main( /*------------------------------------------------------------------------------------------* * Configure the decoder *------------------------------------------------------------------------------------------*/ + #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED || arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED || arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) { arg.enableHeadRotation = true; } #endif - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputFormat, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) + + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.Opt_non_diegetic_pan, arg.non_diegetic_pan_gain, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -545,9 +543,9 @@ int main( * Open Error pattern file for simulation *-----------------------------------------------------------------*/ - if ( arg.FEPatterFileName != NULL ) + if ( arg.FEPatternFileName != NULL ) { - if ( ( FEC_pattern = fopen( arg.FEPatterFileName, "rb" ) ) == NULL ) + if ( ( FEC_pattern = fopen( arg.FEPatternFileName, "rb" ) ) == NULL ) { fprintf( stderr, "Error: Missing or incorrect FEC filename specification\n\n" ); usage_dec(); @@ -563,11 +561,11 @@ int main( * Print information about FEC *-----------------------------------------------------------------*/ - if ( !arg.voipMode && ( arg.FEPatterFileName != NULL || arg.FER > 0 ) ) + if ( !arg.voipMode && ( arg.FEPatternFileName != NULL || arg.FER > 0 ) ) { - if ( arg.FEPatterFileName != NULL ) + if ( arg.FEPatternFileName != NULL ) { - fprintf( stdout, "FEC: %s\n", arg.FEPatterFileName ); + fprintf( stdout, "FEC: %s\n", arg.FEPatternFileName ); } else { @@ -588,9 +586,9 @@ int main( /* sanity check */ #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB && - arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED && - arg.outputFormat != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) + if ( arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB && + arg.outputConfig != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED && + arg.outputConfig != IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) { fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" ); exit( -1 ); @@ -627,7 +625,7 @@ int main( #endif #ifdef CONTROL_METADATA_REVERB - if ( arg.outputFormat == IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) { if ( ( error = RenderConfigReader_getAcousticEnvironment( renderConfigReader, arg.acousticEnvironmentId, &renderConfig.room_acoustics ) ) == IVAS_ERR_OK ) { @@ -645,6 +643,7 @@ int main( renderConfig.room_acoustics.override = true; } #endif + if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -690,29 +689,44 @@ int main( goto cleanup; } - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF = NULL; - IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ); + if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } if ( ( error = create_SetOfHRTF_from_binary( hSetOfHRTF, hrtfReader, arg.output_Fs ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfCRendFileName ); + fprintf( stderr, "\nError in loading HRTF binary file %s for CRend \n\n", arg.hrtfFileName ); goto cleanup; } + IVAS_DEC_HRTF_FASTCONV_HANDLE hHrtfFastConv = NULL; - IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv ); + if ( ( error = IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetHrtfFastConvHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } if ( ( error = load_fastconv_HRTF_from_binary( hHrtfFastConv, hrtfReader ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s for FastConv \n\n", arg.hrtfCRendFileName ); + fprintf( stderr, "\nError in loading HRTF binary file %s for FastConv \n\n", arg.hrtfFileName ); + goto cleanup; goto cleanup; } + IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin = NULL; - IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ); + if ( ( error = IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } if ( ( error = load_parambin_HRTF_from_binary( hHrtfParambin, hrtfReader ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfCRendFileName ); + fprintf( stderr, "\nError in loading HRTF binary file %s for parametric binauralizer \n\n", arg.hrtfFileName ); + goto cleanup; goto cleanup; } } @@ -944,7 +958,7 @@ static bool parseCmdlIVAS_dec( #endif #endif arg->output_Fs = 48000; - arg->outputFormat = IVAS_DEC_OUTPUT_MONO; + arg->outputConfig = IVAS_DEC_OUTPUT_MONO; arg->decMode = IVAS_DEC_MODE_IVAS; arg->quietModeEnabled = false; arg->delayCompensationEnabled = true; @@ -967,14 +981,11 @@ static bool parseCmdlIVAS_dec( arg->jbmOffsetFilename = NULL; arg->FER = 0.f; - arg->FEPatterFileName = NULL; + arg->FEPatternFileName = NULL; arg->hrtfReaderEnabled = false; arg->hrtfFileName = NULL; - arg->hrtfCRendReaderEnabled = false; - arg->hrtfCRendFileName = NULL; - arg->customLsOutputEnabled = false; arg->customLsSetupFilename = NULL; @@ -1107,7 +1118,7 @@ static bool parseCmdlIVAS_dec( ftmp = 0.0f; if ( sscanf( argv[i + 1], "%f", &ftmp ) != 1 ) { - arg->FEPatterFileName = argv[i + 1]; + arg->FEPatternFileName = argv[i + 1]; } else { @@ -1414,14 +1425,14 @@ static bool parseCmdlIVAS_dec( if ( i < argc - 3 ) { - arg->outputFormat = cmdline2config( argv[i] ); - if ( arg->outputFormat == IVAS_DEC_OUTPUT_LS_CUSTOM ) + arg->outputConfig = cmdline2config( argv[i] ); + if ( arg->outputConfig == IVAS_DEC_OUTPUT_LS_CUSTOM ) { arg->customLsOutputEnabled = true; arg->customLsSetupFilename = argv[i]; } i++; - if ( ( arg->Opt_non_diegetic_pan ) && ( arg->outputFormat != IVAS_DEC_OUTPUT_STEREO ) ) + if ( ( arg->Opt_non_diegetic_pan ) && ( arg->outputConfig != IVAS_DEC_OUTPUT_STEREO ) ) { fprintf( stderr, "Error: non-diegetic panning is supported in stereo only\n\n" ); usage_dec(); @@ -1430,11 +1441,11 @@ static bool parseCmdlIVAS_dec( } else { - arg->outputFormat = IVAS_DEC_OUTPUT_MONO; + arg->outputConfig = IVAS_DEC_OUTPUT_MONO; arg->decMode = IVAS_DEC_MODE_EVS; if ( ( arg->Opt_non_diegetic_pan ) ) { - arg->outputFormat = IVAS_DEC_OUTPUT_STEREO; + arg->outputConfig = IVAS_DEC_OUTPUT_STEREO; } } @@ -1638,8 +1649,8 @@ static ivas_error initOnFirstGoodFrame( return error; } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) || - ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) ) + if ( ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) || + ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) ) { pFullDelayNumSamples[0] = 0; } @@ -1666,32 +1677,42 @@ static ivas_error initOnFirstGoodFrame( } #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) { int16_t delayNumSamples_temp[3]; int32_t delayTimeScale_temp; - IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ); - error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp ); - if ( error != IVAS_ERR_OK ) + + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + return error; + } + + if ( ( error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputWavFilename, delayNumSamples_temp[0], delayTimeScale_temp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", arg.outputWavFilename ); - exit( -1 ); + return error; } + *ppAfWriter = NULL; } else { - if ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) { int16_t delayNumSamples_temp[3]; int32_t delayTimeScale_temp; - IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ); - assert( arg.outputMdFilename != NULL ); - error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp ); - if ( error != IVAS_ERR_OK ) + + if ( ( error = IVAS_DEC_GetDelay( hIvasDec, delayNumSamples_temp, &delayTimeScale_temp ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) ); + return error; + } + + if ( ( error = split_rend_writer_open( hSplitRendFileReadWrite, arg.outputMdFilename, delayNumSamples_temp[0], delayTimeScale_temp ) ) != IVAS_ERR_OK ) { fprintf( stderr, "Could not open split rend metadata file %s\n", arg.outputWavFilename ); - exit( -1 ); + return error; } } #endif @@ -1749,7 +1770,7 @@ static ivas_error initOnFirstGoodFrame( free( zeroBuf ); /* Open other output files if EXT output config - now details about ISM or MASA are known */ - if ( arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { if ( ( error = IVAS_DEC_GetFormat( hIvasDec, pBsFormat ) ) != IVAS_ERR_OK ) { @@ -2128,7 +2149,7 @@ static ivas_error decodeG192( if ( decodedGoodFrame ) { #ifdef SPLIT_REND_WITH_HEAD_ROT - if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) ) + if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, splitRendBits.codec, splitRendBits.pose_correction ) != IVAS_ERR_OK ) @@ -2139,7 +2160,7 @@ static ivas_error decodeG192( } else { - if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) ) + if ( ( hSplitRendFileReadWrite != NULL ) && ( arg.outputConfig == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) ) { if ( split_rend_write_bitstream_to_file( hSplitRendFileReadWrite, splitRendBits.bits_buf, &splitRendBits.bits_read, &splitRendBits.bits_written, splitRendBits.codec, splitRendBits.pose_correction ) != IVAS_ERR_OK ) @@ -2168,7 +2189,7 @@ static ivas_error decodeG192( } /* Write MASA/ISM metadata to external file(s) */ - if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( decodedGoodFrame && arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { #ifdef MASA_AND_OBJECTS if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM ) @@ -2277,7 +2298,7 @@ static ivas_error decodeG192( } /* Print output metadata file name(s) */ - if ( arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { if ( bsFormat == IVAS_DEC_BS_OBJ ) { @@ -2762,7 +2783,7 @@ static ivas_error decodeVoIP( } /* Write ISM metadata to external file(s) */ - if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( decodedGoodFrame && arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { int16_t i; @@ -3202,7 +3223,7 @@ static ivas_error decodeVariableSpeed( } /* Write ISm metadata to external file(s) */ - if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( decodedGoodFrame && arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { #ifdef MASA_AND_OBJECTS if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM ) @@ -3390,7 +3411,7 @@ static ivas_error decodeVariableSpeed( } /* Write ISm metadata to external file(s) */ - if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( decodedGoodFrame && arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { #ifdef MASA_AND_OBJECTS if ( bsFormat == IVAS_DEC_BS_OBJ || bsFormat == IVAS_DEC_BS_MASA_ISM ) @@ -3476,7 +3497,7 @@ static ivas_error decodeVariableSpeed( } /* Print output metadata file name(s) */ - if ( arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) + if ( arg.outputConfig == IVAS_DEC_OUTPUT_EXT ) { if ( bsFormat == IVAS_DEC_BS_OBJ ) { diff --git a/apps/renderer.c b/apps/renderer.c index 6255e87e44a90e478c4bc2b650ee9da170b75443..40a2132411b598e3633067a72247d6b1069ca930 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -3726,8 +3726,10 @@ static void convertInputBuffer( { int16_t slotIdx, numCldfbBands, numFloatPcmSamples; float fIn[MAX_OUTPUT_CHANNELS][L_FRAME48k]; + numFloatPcmSamples = numFloatSamplesPerChannel >> 1; numCldfbBands = numFloatPcmSamples / CLDFB_NO_COL_MAX; + /* CLDFB Analysis*/ assert( numIntSamplesPerChannel <= MAX_OUTPUT_CHANNELS * L_FRAME48k ); for ( smpl = 0; smpl < numFloatPcmSamples; ++smpl ) @@ -3746,6 +3748,7 @@ static void convertInputBuffer( ++i; } } + for ( chnl = 0; chnl < numChannels; ++chnl ) { for ( slotIdx = 0; slotIdx < CLDFB_NO_COL_MAX; slotIdx++ ) @@ -3815,8 +3818,10 @@ static void convertOutputBuffer( float fIn[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float re[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; float im[MAX_OUTPUT_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; + numPcmSamples = numSamplesPerChannel >> 1; numCldfbBands = numPcmSamples / CLDFB_NO_COL_MAX; + /* CLDFB Synthesis*/ for ( chnl = 0; chnl < numChannels; ++chnl ) { diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 7211274eea069aea398d0188d3d431ba0ecb3d31..dc17fae8f22337092087071ac91f76dcd97e9368 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -40,7 +40,12 @@ #include "wmc_auto.h" #include "prot.h" +/*-----------------------------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------------------------*/ + #define BAND_SMOOTH_REST_START_IDX ( 2 ) + #ifndef CODE_CLEAN_UP_DIRAC /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() @@ -147,24 +152,36 @@ static void ivas_set_up_cov_smoothing( * To calculate the update factor *-----------------------------------------------------------------------------------------*/ -static float ivas_calculate_update_factor( float *p_bin_to_band, int16_t active_bins ) +static float ivas_calculate_update_factor( + float *p_bin_to_band, + int16_t active_bins ) { float update_factor_temp = 0.0f; int16_t k; + for ( k = 0; k < active_bins; k++ ) { update_factor_temp += p_bin_to_band[k]; } + return update_factor_temp; } + /*-----------------------------------------------------------------------------------------* * Function ivas_calculate_smoothning_factor() * * To calculate the Smoothning factor *-----------------------------------------------------------------------------------------*/ -static void ivas_calculate_smoothning_factor( float *Smoothing_factor, float update_factor, const int16_t min_pool_size, const float max_update_rate, const COV_SMOOTHING_TYPE smooth_mode, const int32_t ivas_total_brate, int16_t j ) +static void ivas_calculate_smoothning_factor( + float *Smoothing_factor, + float update_factor, + const int16_t min_pool_size, + const float max_update_rate, + const COV_SMOOTHING_TYPE smooth_mode, + const int32_t ivas_total_brate, + int16_t j ) { float smooth_fact; *Smoothing_factor = update_factor / min_pool_size; @@ -180,12 +197,16 @@ static void ivas_calculate_smoothning_factor( float *Smoothing_factor, float upd } *Smoothing_factor *= ( j + 1 ) * smooth_fact; } + if ( *Smoothing_factor > max_update_rate ) { *Smoothing_factor = max_update_rate; } + + return; } + /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() * @@ -223,6 +244,8 @@ static void ivas_set_up_cov_smoothing( } hCovState->prior_bank_idx = -1; + + return; } #endif diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 070a0ff5faf42c23c46d09360719d546789afc35..6482584b31a7f90e982c59208d92f6a06df1d545 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -611,8 +611,8 @@ static if ( hFbMixer->first_frame[ch] == 0 ) { - fade_start_offset = (int16_t) hFbMixer->cross_fade_start_offset; - fade_end_offset = (int16_t) hFbMixer->cross_fade_end_offset; + fade_start_offset = hFbMixer->cross_fade_start_offset; + fade_end_offset = hFbMixer->cross_fade_end_offset; for ( k = 0; k < fade_start_offset; k++ ) { diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 98229a668d8e11f1b576e22ad1a41182f48d932c..b45811366bc4395fc9508508754544e820a24403 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2676,7 +2676,7 @@ void sns_avq_dec( void sns_avq_dec_stereo( int16_t *indexl, /* i : Quantization indices (left channel) */ int16_t *indexr, /* i : Quantization indices (right channe) */ - const int16_t L_frame, + const int16_t L_frame, /* i : frame length */ float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ float *SNS_Qr /* o : Quantized SNS vectors (right channe) */ ); @@ -3546,6 +3546,7 @@ void ivas_sba_getTCs( const int16_t input_frame /* i : frame length */ ); +/*! r: SBA DirAC stereo flag */ int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index a131509ea1ec18c18630518f7a4835e4fd276685..57f1cc53475d6e522bc02a636011632cebf06864 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -5666,11 +5666,17 @@ const int16_t ivas_num_active_bands[FB - WB + 1] = IVAS_16K_12BANDS_ACTIVE_BANDS, IVAS_FB_BANDS_12, IVAS_FB_BANDS_12 }; +/*------------------------------------------------------------------------------------------* + * SNS MSVQ codebooks and means + *------------------------------------------------------------------------------------------*/ + const int16_t ivas_sns_cdbks_tcx20_levels[SNS_MSVQ_NSTAGES_TCX20] = { 128, 64, 32, 32 }; + const int16_t ivas_sns_cdbks_tcx20_bits[SNS_MSVQ_NSTAGES_TCX20] = { 7, 6, 5, 5 }; /* pre-rounded codebook vectors for singed Q4.12 represantation */ -const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { +const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = +{ -1.8305664f, -2.0878906f, -0.9638672f, 2.8059082f, 2.668213f, 1.1638184f, 1.390625f, 1.217041f, 1.3850098f, 0.44555664f, -0.47045898f, -0.5307617f, -0.810791f, -1.1647949f, -1.4560547f, -1.7612305f, -2.5979004f, -3.3308105f, -1.8554688f, -0.3605957f, 1.6828613f, 2.5871582f, 0.98168945f, 0.22436523f, -0.13110352f, 0.16699219f, 1.5004883f, 0.3293457f, 0.33569336f, 1.1591797f, 0.1796875f, -0.8718262f, 1.982666f, 2.2011719f, 1.1525879f, 0.8093262f, 0.86499023f, 1.1618652f, 1.2888184f, 1.3618164f, 1.0827637f, 0.83251953f, 0.12011719f, -0.7182617f, -2.1948242f, -3.0500488f, -3.3571777f, -3.53833f, @@ -5800,7 +5806,9 @@ const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { 1.7553711f, 2.8996582f, 1.9260254f, 0.40551758f, -0.0234375f, 0.44506836f, 0.31152344f, 0.1809082f, -0.47607422f, -0.4807129f, -1.204834f, -1.3293457f, -1.2412109f, -1.0134277f, -0.89501953f, -1.2602539f, 0.2253418f, 2.2539062f, 2.265625f, 0.57128906f, -0.7661133f, -0.6245117f, 0.21313477f, 1.2248535f, 0.8737793f, -0.12524414f, -0.9609375f, -2.416504f, -1.1223145f, -0.70532227f, -0.31469727f, -0.592041f, }; -const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = +{ -1.1569824f, -0.4765625f, 0.008056641f, 0.47802734f, 0.38330078f, -0.075683594f, -0.3737793f, -0.29516602f, -0.1352539f, 0.012939453f, 0.22241211f, 0.375f, 0.31689453f, 0.20874023f, 0.2541504f, 0.25439453f, -0.40600586f, -0.22070312f, -0.04272461f, 0.15893555f, -0.25195312f, -0.6623535f, -0.27172852f, 0.28735352f, 0.35742188f, 0.20166016f, 0.052246094f, -0.3647461f, -0.4506836f, 0.1862793f, 0.66796875f, 0.7585449f, 0.02734375f, -0.2097168f, -0.39819336f, -0.54296875f, -0.46850586f, -0.25146484f, -0.26953125f, -0.07495117f, 0.375f, 0.9343262f, 0.91625977f, 0.4267578f, 0.026123047f, -0.15576172f, -0.11425781f, -0.22021484f, @@ -5866,7 +5874,9 @@ const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { 0.3227539f, -1.0678711f, -1.1435547f, 0.068603516f, 0.7546387f, 0.38745117f, 0.09008789f, -0.0007324219f, -0.12792969f, 0.076416016f, 0.24853516f, 0.28735352f, 0.076660156f, -0.041748047f, -0.01977539f, 0.08911133f, 0.6101074f, -0.22070312f, -0.5324707f, -0.119384766f, 0.10473633f, 0.16333008f, -0.15112305f, -0.34472656f, -0.39746094f, -0.43652344f, -0.23876953f, 0.0017089844f, 0.056152344f, 0.22973633f, 0.50024414f, 0.7751465f, }; -const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = +{ -0.12109375f, -0.32348633f, -0.25976562f, 0.21435547f, 0.4814453f, 0.14819336f, -0.22363281f, -0.31030273f, -0.13256836f, 0.10107422f, 0.33276367f, 0.32495117f, 0.16577148f, -0.079833984f, -0.16210938f, -0.15527344f, 0.088378906f, -0.0146484375f, -0.13378906f, -0.29003906f, 0.873291f, -0.3125f, -0.19384766f, 0.19311523f, -0.09863281f, 0.052734375f, -0.13110352f, -0.021972656f, -0.07861328f, -0.01977539f, -0.07373047f, 0.1616211f, -0.115722656f, 0.28100586f, 0.2697754f, -0.10522461f, -0.107910156f, -0.2866211f, -0.36694336f, -0.33862305f, -0.15844727f, 0.01928711f, 0.17382812f, 0.21118164f, 0.2697754f, 0.17260742f, 0.07299805f, 0.009033203f, @@ -5900,7 +5910,9 @@ const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = { 0.17895508f, -0.31396484f, -0.033203125f, -0.02734375f, -0.0637207f, -0.11791992f, -0.03466797f, 0.0061035156f, 0.07324219f, 0.072753906f, 0.14916992f, 0.13671875f, 0.12524414f, 0.017333984f, -0.08178711f, -0.08618164f, 0.13330078f, -0.15893555f, -0.22045898f, -0.032226562f, -0.07739258f, -0.25463867f, -0.32299805f, -0.2614746f, 0.039794922f, 0.18554688f, 0.1262207f, -0.04321289f, -0.010498047f, 0.13330078f, 0.31860352f, 0.44506836f, }; -const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = +{ -0.0056152344f, -0.03955078f, 0.071777344f, 0.26879883f, 0.44140625f, -0.08203125f, -0.20092773f, -0.009277344f, 0.05810547f, -0.06347656f, -0.07910156f, -0.05126953f, -0.07006836f, -0.068847656f, -0.07885742f, -0.09082031f, -0.011962891f, -0.060302734f, 0.011962891f, 0.049804688f, -0.044677734f, 0.037841797f, 0.099121094f, 0.06274414f, 0.022216797f, -0.09057617f, 0.00390625f, 0.38452148f, 0.1027832f, -0.5292969f, -0.3269043f, 0.28881836f, -0.3557129f, 0.3815918f, 0.10839844f, 0.08203125f, 0.03149414f, -0.0024414062f, -0.0036621094f, -0.02758789f, -0.03125f, -0.096191406f, -0.09326172f, -0.103515625f, -0.07006836f, 0.008056641f, 0.06616211f, 0.10644531f, @@ -5938,9 +5950,11 @@ const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { const float *const ivas_sns_cdbks_tcx20[SNS_MSVQ_NSTAGES_TCX20] = { ivas_sns_cdbk_tcx20_stage1, ivas_sns_cdbk_tcx20_stage2, ivas_sns_cdbk_tcx20_stage3, ivas_sns_cdbk_tcx20_stage4 }; const int16_t ivas_sns_cdbks_tcx10_levels[SNS_MSVQ_NSTAGES_TCX10] = { 128, 32, 8 }; + const int16_t ivas_sns_cdbks_tcx10_bits[SNS_MSVQ_NSTAGES_TCX10] = { 7, 5, 3 }; -const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { +const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = +{ 1.0144043f, 1.1826172f, 0.3269043f, -0.6411133f, -1.2163086f, -1.1411133f, -1.1525879f, -0.8898926f, -0.19604492f, 0.7402344f, 1.1782227f, 1.0830078f, 0.78222656f, 0.26953125f, -0.33203125f, -1.0080566f, -0.38916016f, -0.31347656f, -1.1826172f, -2.036621f, -2.086914f, -1.8569336f, -1.637207f, -1.3156738f, -0.4182129f, 0.50634766f, 1.2770996f, 1.3771973f, 1.8566895f, 2.3503418f, 2.3015137f, 1.5678711f, 0.43652344f, 1.8859863f, 2.8059082f, 2.2385254f, 1.5480957f, 0.14331055f, 0.07299805f, -1.1218262f, -1.1103516f, -0.7336426f, -0.4194336f, -0.89624023f, -1.0429688f, -0.79785156f, -1.204834f, -1.8046875f, @@ -6070,7 +6084,9 @@ const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 3.256836f, 3.5593262f, 2.2746582f, 1.1318359f, 0.3149414f, -0.02368164f, 0.27172852f, -0.19335938f, -0.48779297f, -0.9663086f, -0.9187012f, -1.0222168f, -1.512207f, -1.6816406f, -1.8964844f, -2.1069336f, -0.057617188f, -0.45092773f, -0.9638672f, -0.72143555f, 0.20703125f, 1.4692383f, 1.921875f, 1.6833496f, 1.3933105f, 0.6699219f, 0.17333984f, -0.43798828f, -0.9772949f, -1.1477051f, -1.3552246f, -1.4057617f, }; -const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = +{ 0.30615234f, 0.48828125f, -0.02709961f, -0.47680664f, -0.5300293f, -0.25463867f, -0.13305664f, -0.14941406f, -0.14819336f, 0.08666992f, 0.28833008f, 0.27514648f, 0.099365234f, -0.017578125f, 0.033203125f, 0.15893555f, 0.40942383f, -0.044189453f, -0.088378906f, 0.38720703f, 0.5151367f, 0.42236328f, 0.34960938f, 0.2680664f, 0.037597656f, -0.19970703f, -0.31054688f, -0.32617188f, -0.38452148f, -0.38085938f, -0.38598633f, -0.2692871f, -0.16040039f, -0.37548828f, -0.41479492f, -0.1237793f, 0.25708008f, 0.29589844f, 0.045410156f, -0.04345703f, -0.11450195f, -0.2019043f, 0.032470703f, 0.5847168f, 1.074707f, 0.3178711f, -0.43847656f, -0.73535156f, @@ -6104,7 +6120,9 @@ const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { -0.78149414f, 0.05517578f, 0.09863281f, -0.35083008f, -0.29174805f, 0.1352539f, 0.10620117f, -0.3515625f, -0.27514648f, 0.15917969f, 0.34326172f, 0.2626953f, 0.39916992f, 0.42089844f, 0.20947266f, -0.1394043f, -0.20361328f, -0.21557617f, -0.16308594f, -0.041748047f, -0.111083984f, -0.057617188f, 0.0390625f, 0.013183594f, 0.17358398f, 0.74902344f, 0.9448242f, 0.4477539f, -0.09423828f, -0.32739258f, -0.50634766f, -0.6467285f, }; -const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { + +const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = +{ 0.15209961f, -0.12768555f, 0.09375f, -0.083496094f, -0.25390625f, 0.12524414f, 0.2993164f, -0.09863281f, -0.34814453f, -0.2434082f, -0.11254883f, -0.060058594f, 0.032470703f, 0.15527344f, 0.23413086f, 0.2355957f, -0.16235352f, -0.111083984f, -0.3173828f, -0.25634766f, 0.13842773f, 0.29858398f, 0.10498047f, 0.11743164f, 0.26611328f, 0.05444336f, -0.1459961f, -0.19238281f, 0.041748047f, 0.2097168f, 0.07421875f, -0.12011719f, -0.05078125f, 0.14770508f, -0.1003418f, -0.32104492f, -0.17504883f, -0.18652344f, -0.27148438f, -0.07788086f, 0.0036621094f, -0.04296875f, 0.10131836f, 0.34985352f, 0.3083496f, 0.10107422f, 0.0769043f, 0.13696289f, @@ -6122,7 +6140,8 @@ const int16_t ivas_sns_cdbks_side_tcx20_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 5 }; const int16_t ivas_sns_cdbks_side_tcx10_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 8 }; const int16_t ivas_sns_cdbks_side_tcx10_bits[SNS_MSVQ_NSTAGES_SIDE] = { 5, 3 }; -const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = +{ -0.11376953f, -0.06591797f, 0.041992188f, 0.044677734f, 0.17871094f, -0.02758789f, -0.32592773f, -0.21069336f, -0.049072266f, 0.0126953125f, 0.012939453f, 0.015136719f, 0.08203125f, 0.12670898f, 0.12695312f, 0.15112305f, -0.017089844f, 0.09326172f, 0.2355957f, 0.2241211f, 0.107421875f, 0.05029297f, 0.039794922f, -0.0073242188f, -0.048339844f, -0.0871582f, -0.08520508f, -0.12060547f, -0.111572266f, -0.10620117f, -0.08911133f, -0.078125f, -0.26635742f, 0.27368164f, 0.4543457f, 0.1821289f, 0.6513672f, 0.18066406f, 0.14575195f, -0.008056641f, 0.2631836f, -0.045898438f, -0.52001953f, -0.1628418f, 0.038330078f, -0.31811523f, -0.4321289f, -0.43603516f, @@ -6157,7 +6176,8 @@ const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = { -0.19580078f, -0.14624023f, -0.11303711f, -0.055908203f, -0.052001953f, -0.009033203f, 0.022949219f, -0.0068359375f, -0.032470703f, 0.0017089844f, 0.045410156f, 0.025146484f, 0.039794922f, 0.07543945f, 0.1574707f, 0.24267578f, }; -const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = +{ -0.013916016f, 0.0007324219f, 0.017089844f, 0.005859375f, 0.056152344f, -0.08178711f, -0.2927246f, 0.00390625f, 0.140625f, 0.03881836f, 0.010498047f, 0.038330078f, 0.042236328f, 0.020751953f, 0.005859375f, 0.0075683594f, -0.07104492f, -0.10253906f, 0.038085938f, 0.091552734f, 0.118896484f, 0.13476562f, 0.05078125f, -0.111328125f, -0.13842773f, -0.20727539f, -0.25732422f, -0.15063477f, 0.032470703f, 0.08129883f, 0.17578125f, 0.31469727f, 0.0715332f, 0.029052734f, 0.01953125f, 0.008056641f, 0.0234375f, 0.020751953f, 0.032226562f, 0.021972656f, 0.03466797f, 0.017822266f, -0.037841797f, -0.14038086f, -0.21679688f, -0.11035156f, 0.057617188f, 0.16845703f, @@ -6194,7 +6214,8 @@ const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = { const float *const ivas_sns_cdbks_side_tcx20[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx20_stage1, ivas_sns_cdbks_side_tcx20_stage2 }; -const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = +{ -0.23950195f, -0.203125f, -0.17822266f, -0.1315918f, -0.123291016f, -0.095947266f, -0.106933594f, -0.16552734f, -0.14941406f, -0.075683594f, 0.026367188f, 0.1015625f, 0.17041016f, 0.2770996f, 0.37890625f, 0.5148926f, 0.12890625f, 0.20825195f, 0.22924805f, 0.2998047f, 0.24267578f, 0.14477539f, 0.07861328f, 0.024658203f, -0.076171875f, -0.18432617f, -0.26660156f, -0.33251953f, -0.2758789f, -0.13964844f, -0.030517578f, -0.05126953f, -0.14160156f, -0.13305664f, -0.111816406f, -0.037353516f, -0.038085938f, 0.051513672f, 0.07348633f, 0.0073242188f, 0.044921875f, -0.0234375f, -0.123291016f, -0.01171875f, 0.28100586f, 0.24194336f, 0.0703125f, -0.1496582f, @@ -6227,9 +6248,11 @@ const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = { 0.06982422f, 0.072265625f, 0.18261719f, 0.025390625f, -0.2475586f, -0.2861328f, -0.111572266f, -0.037109375f, 0.0036621094f, 0.031982422f, 0.043945312f, 0.057373047f, 0.078125f, 0.072021484f, 0.028564453f, 0.016357422f, 0.07836914f, 0.13549805f, 0.1743164f, 0.15478516f, 0.12573242f, -0.009521484f, -0.1508789f, -0.1965332f, -0.19604492f, -0.103027344f, -0.045898438f, -0.026123047f, 0.020263672f, 0.023925781f, 0.013183594f, 0.0014648438f, 0.25341797f, 0.22558594f, 0.2241211f, 0.17114258f, 0.18164062f, 0.16894531f, 0.16503906f, 0.20239258f, 0.17041016f, 0.025878906f, -0.16625977f, -0.24121094f, -0.31982422f, -0.4008789f, -0.38256836f, -0.27783203f, -}; +} +; -const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = { +const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = +{ -0.13989258f, -0.024658203f, 0.12670898f, 0.027832031f, 0.06689453f, 0.12817383f, 0.07495117f, -0.01977539f, -0.05834961f, -0.07543945f, -0.06542969f, -0.0546875f, -0.04345703f, -0.0063476562f, 0.034179688f, 0.029541016f, -0.06713867f, -0.11450195f, -0.09790039f, -0.091308594f, -0.12182617f, -0.010009766f, 0.10986328f, 0.115478516f, 0.060058594f, 0.038085938f, 0.020507812f, 0.017333984f, 0.024169922f, 0.028320312f, 0.038330078f, 0.05053711f, 0.05517578f, 0.030517578f, 0.0390625f, 0.05810547f, 0.021484375f, 0.032470703f, 0.040039062f, -0.0087890625f, -0.055908203f, -0.023925781f, 0.037109375f, 0.06347656f, 0.02709961f, -0.07373047f, -0.1274414f, -0.115234375f, @@ -6242,7 +6265,8 @@ const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = { const float *const ivas_sns_cdbks_side_tcx10[SNS_MSVQ_NSTAGES_SIDE] = { ivas_sns_cdbks_side_tcx10_stage1, ivas_sns_cdbks_side_tcx10_stage2 }; -const int16_t sns_1st_cdbk[2][2][8 * 32] = { +const int16_t sns_1st_cdbk[2][2][8 * 32] = +{ { /* split 1 */ { /* TCX 20 */ -10900, -11064, -10637, -10471, -9051, -6381, -4688, -2438, @@ -6384,7 +6408,9 @@ const int16_t sns_1st_cdbk[2][2][8 * 32] = { } } }; -const int16_t sns_1st_means_16k[2][16] = { + +const int16_t sns_1st_means_16k[2][16] = +{ { /* TCX 20 */ 14210, 19017, 14362, 9309, 5385, 2674, 1055, -211, -1407, -3059, -4393, -8597, -11180, -11756, -12131, -13281, }, @@ -6392,7 +6418,9 @@ const int16_t sns_1st_means_16k[2][16] = { 12018, 15915, 11089, 6015, 847, -705, -539, -1548, -893, -2163, -1806, -4189, -7017, -8670, -8874, -9480, } }; -const int16_t sns_1st_means_25k6[2][16] = { + +const int16_t sns_1st_means_25k6[2][16] = +{ { /* TCX 20 */ 14973, 20323, 16461, 9554, 4017, 3103, 1602, 1694, -221, -1401, -6817, -10071, -11503, -11805, -13158, -16749, }, @@ -6400,7 +6428,9 @@ const int16_t sns_1st_means_25k6[2][16] = { 15560, 19489, 14623, 5595, 2084, 1699, 775, -1312, -2195, -6101, -9078, -9465, -7825, -6603, -7281, -9960, } }; -const int16_t sns_1st_means_32k[2][16] = { + +const int16_t sns_1st_means_32k[2][16] = +{ { /* TCX 20 */ 15041, 20603, 16969, 10289, 4973, 4283, 3003, 3316, 1684, -259, -6614, -9535, -10363, -11834, -16625, -24930, }, @@ -6409,100 +6439,105 @@ const int16_t sns_1st_means_32k[2][16] = { } }; -ACPL_QUANT_TABLE alpha_quant_table[] = -{ - { /* Alfa Fine */ - 33, /* nquant */ - 16, /* offset */ - { -2.000000e+000f, -1.809375e+000f, -1.637500e+000f, -1.484375e+000f, -1.350000e+000f, -1.234375e+000f, -1.137500e+000f, -1.059375e+000f, -1.000000e+000f, -9.406250e-001f, - -8.625000e-001f, -7.656250e-001f, -6.500000e-001f, -5.156250e-001f, -3.625000e-001f, -1.906250e-001f, +0.000000e+000f, +1.906250e-001f, +3.625000e-001f, +5.156250e-001f, - +6.500000e-001f, +7.656250e-001f, +8.625000e-001f, +9.406250e-001f, +1.000000e+000f, +1.059375e+000f, +1.137500e+000f, +1.234375e+000f, +1.350000e+000f, +1.484375e+000f, - +1.637500e+000f, +1.809375e+000f, +2.000000e+000f } /* data */ - }, /* End Alfa Fine */ - { /* Alfa Coarse */ - 17, /* nquant */ - 8, /* offset */ - { -2.000000e+000f, -1.637500e+000f, -1.350000e+000f, -1.137500e+000f, -1.000000e+000f, -8.625000e-001f, -6.500000e-001f, -3.625000e-001f, +0.000000e+000f, +3.625000e-001f, - +6.500000e-001f, +8.625000e-001f, +1.000000e+000f, +1.137500e+000f, +1.350000e+000f, +1.637500e+000f, +2.000000e+000f } /* data */ - } /* End Alfa Coarse */ -}; - -ACPL_QUANT_TABLE beta_quant_table[2][9] = -{ - { - { /* Beta Fine #1 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +2.375000e-001f, +5.500000e-001f, +9.375000e-001f, +1.400000e+000f, +1.937500e+000f, +2.550000e+000f, +3.237500e+000f, +4.000000e+000f } /* data */ - }, /* End Beta Fine #1 */ - { /* Beta Fine #2 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +2.035449e-001f, +4.713672e-001f, +8.034668e-001f, +1.199844e+000f, +1.660498e+000f, +2.185430e+000f, +2.774639e+000f, +3.428125e+000f } /* data */ - }, /* End Beta Fine #2 */ - { /* Beta Fine #3 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +1.729297e-001f, +4.004688e-001f, +6.826172e-001f, +1.019375e+000f, +1.410742e+000f, +1.856719e+000f, +2.357305e+000f, +2.912500e+000f } /* data */ - }, /* End Beta Fine #3 */ - { /* Beta Fine #4 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +1.456543e-001f, +3.373047e-001f, +5.749512e-001f, +8.585938e-001f, +1.188232e+000f, +1.563867e+000f, +1.985498e+000f, +2.453125e+000f } /* data */ - }, /* End Beta Fine #4 */ - { /* Beta Fine #5 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +1.217188e-001f, +2.818750e-001f, +4.804688e-001f, +7.175000e-001f, +9.929688e-001f, +1.306875e+000f, +1.659219e+000f, +2.050000e+000f } /* data */ - }, /* End Beta Fine #5 */ - { /* Beta Fine #6 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +1.011230e-001f, +2.341797e-001f, +3.991699e-001f, +5.960938e-001f, +8.249512e-001f, +1.085742e+000f, +1.378467e+000f, +1.703125e+000f } /* data */ - }, /* End Beta Fine #6 */ - { /* Beta Fine #7 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +8.386719e-002f, +1.942188e-001f, +3.310547e-001f, +4.943750e-001f, +6.841797e-001f, +9.004688e-001f, +1.143242e+000f, +1.412500e+000f } /* data */ - }, /* End Beta Fine #7 */ - { /* Beta Fine #8 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +6.995117e-002f, +1.619922e-001f, +2.761230e-001f, +4.123438e-001f, +5.706543e-001f, +7.510547e-001f, +9.535449e-001f, +1.178125e+000f } /* data */ - }, /* End Beta Fine #8 */ - { /* Beta Fine #9 */ - 9, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +5.937500e-002f, +1.375000e-001f, +2.343750e-001f, +3.500000e-001f, +4.843750e-001f, +6.375000e-001f, +8.093750e-001f, +1.000000e+000f } /* data */ - } /* End Beta Fine #9 */ - }, - { - { /* Beta Coarse #1 */ - 5, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +5.500000e-001f, +1.400000e+000f, +2.550000e+000f, +4.000000e+000f } /* data */ - }, /* End Beta Coarse #1 */ - { /* Beta Coarse #2 */ - 5, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +4.004688e-001f, +1.019375e+000f, +1.856719e+000f, +2.912500e+000f } /* data */ - }, /* End Beta Coarse #2 */ - { /* Beta Coarse #3 */ - 5, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +2.818750e-001f, +7.175000e-001f, +1.306875e+000f, +2.050000e+000f } /* data */ - }, /* End Beta Coarse #3 */ - { /* Beta Coarse #4 */ - 5, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +1.942188e-001f, +4.943750e-001f, +9.004688e-001f, +1.412500e+000f } /* data */ - }, /* End Beta Coarse #4 */ - { /* Beta Coarse #5 */ - 5, /* nquant */ - 0, /* offset */ - { +0.000000e+000f, +1.375000e-001f, +3.500000e-001f, +6.375000e-001f, +1.000000e+000f } /* data */ - } /* End Beta Coarse #5 */ - } + +/*------------------------------------------------------------------------------------------* + * MC ParamUpMix tables + *------------------------------------------------------------------------------------------*/ + +const ACPL_QUANT_TABLE ivas_param_upmx_alpha_quant_table[] = +{ + { /* Alfa Fine */ + 33, /* nquant */ + 16, /* offset */ + { -2.000000e+000f, -1.809375e+000f, -1.637500e+000f, -1.484375e+000f, -1.350000e+000f, -1.234375e+000f, -1.137500e+000f, -1.059375e+000f, -1.000000e+000f, -9.406250e-001f, + -8.625000e-001f, -7.656250e-001f, -6.500000e-001f, -5.156250e-001f, -3.625000e-001f, -1.906250e-001f, +0.000000e+000f, +1.906250e-001f, +3.625000e-001f, +5.156250e-001f, + +6.500000e-001f, +7.656250e-001f, +8.625000e-001f, +9.406250e-001f, +1.000000e+000f, +1.059375e+000f, +1.137500e+000f, +1.234375e+000f, +1.350000e+000f, +1.484375e+000f, + +1.637500e+000f, +1.809375e+000f, +2.000000e+000f } /* data */ + }, + { /* Alfa Coarse */ + 17, /* nquant */ + 8, /* offset */ + { -2.000000e+000f, -1.637500e+000f, -1.350000e+000f, -1.137500e+000f, -1.000000e+000f, -8.625000e-001f, -6.500000e-001f, -3.625000e-001f, +0.000000e+000f, +3.625000e-001f, + +6.500000e-001f, +8.625000e-001f, +1.000000e+000f, +1.137500e+000f, +1.350000e+000f, +1.637500e+000f, +2.000000e+000f } /* data */ + } +}; + +const ACPL_QUANT_TABLE ivas_param_upmx_beta_quant_table[2][9] = +{ + { + { /* Beta Fine #1 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +2.375000e-001f, +5.500000e-001f, +9.375000e-001f, +1.400000e+000f, +1.937500e+000f, +2.550000e+000f, +3.237500e+000f, +4.000000e+000f } /* data */ + }, + { /* Beta Fine #2 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +2.035449e-001f, +4.713672e-001f, +8.034668e-001f, +1.199844e+000f, +1.660498e+000f, +2.185430e+000f, +2.774639e+000f, +3.428125e+000f } /* data */ + }, + { /* Beta Fine #3 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.729297e-001f, +4.004688e-001f, +6.826172e-001f, +1.019375e+000f, +1.410742e+000f, +1.856719e+000f, +2.357305e+000f, +2.912500e+000f } /* data */ + }, + { /* Beta Fine #4 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.456543e-001f, +3.373047e-001f, +5.749512e-001f, +8.585938e-001f, +1.188232e+000f, +1.563867e+000f, +1.985498e+000f, +2.453125e+000f } /* data */ + }, + { /* Beta Fine #5 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.217188e-001f, +2.818750e-001f, +4.804688e-001f, +7.175000e-001f, +9.929688e-001f, +1.306875e+000f, +1.659219e+000f, +2.050000e+000f } /* data */ + }, + { /* Beta Fine #6 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.011230e-001f, +2.341797e-001f, +3.991699e-001f, +5.960938e-001f, +8.249512e-001f, +1.085742e+000f, +1.378467e+000f, +1.703125e+000f } /* data */ + }, + { /* Beta Fine #7 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +8.386719e-002f, +1.942188e-001f, +3.310547e-001f, +4.943750e-001f, +6.841797e-001f, +9.004688e-001f, +1.143242e+000f, +1.412500e+000f } /* data */ + }, + { /* Beta Fine #8 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +6.995117e-002f, +1.619922e-001f, +2.761230e-001f, +4.123438e-001f, +5.706543e-001f, +7.510547e-001f, +9.535449e-001f, +1.178125e+000f } /* data */ + }, + { /* Beta Fine #9 */ + 9, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +5.937500e-002f, +1.375000e-001f, +2.343750e-001f, +3.500000e-001f, +4.843750e-001f, +6.375000e-001f, +8.093750e-001f, +1.000000e+000f } /* data */ + } + }, + { + { /* Beta Coarse #1 */ + 5, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +5.500000e-001f, +1.400000e+000f, +2.550000e+000f, +4.000000e+000f } /* data */ + }, + { /* Beta Coarse #2 */ + 5, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +4.004688e-001f, +1.019375e+000f, +1.856719e+000f, +2.912500e+000f } /* data */ + }, + { /* Beta Coarse #3 */ + 5, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +2.818750e-001f, +7.175000e-001f, +1.306875e+000f, +2.050000e+000f } /* data */ + }, + { /* Beta Coarse #4 */ + 5, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.942188e-001f, +4.943750e-001f, +9.004688e-001f, +1.412500e+000f } /* data */ + }, + { /* Beta Coarse #5 */ + 5, /* nquant */ + 0, /* offset */ + { +0.000000e+000f, +1.375000e-001f, +3.500000e-001f, +6.375000e-001f, +1.000000e+000f } /* data */ + } + } }; /* clang-format on */ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 15fbd2048d8219f892126733b72b603a2e16418c..d234ed8662708f4690121d05f112eb253760244c 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -428,6 +428,7 @@ extern const int16_t ivas_num_active_bands[FB - WB + 1]; /*------------------------------------------------------------------------------------------* * SNS MSVQ codebooks and means *------------------------------------------------------------------------------------------*/ + extern const int16_t ivas_sns_cdbks_tcx20_levels[]; extern const int16_t ivas_sns_cdbks_tcx20_bits[]; @@ -445,13 +446,18 @@ extern const int16_t ivas_sns_cdbks_side_tcx10_bits[]; extern const float *const ivas_sns_cdbks_side_tcx20[]; extern const float *const ivas_sns_cdbks_side_tcx10[]; -extern ACPL_QUANT_TABLE alpha_quant_table[]; -extern ACPL_QUANT_TABLE beta_quant_table[2][9]; - /* means and codebooks for the split VQ in the 2-stage SNS VQ */ extern const int16_t sns_1st_cdbk[2][2][8 * 32]; extern const int16_t sns_1st_means_16k[2][16]; extern const int16_t sns_1st_means_25k6[2][16]; extern const int16_t sns_1st_means_32k[2][16]; + +/*------------------------------------------------------------------------------------------* + * SNS MSVQ codebooks and means + *------------------------------------------------------------------------------------------*/ + +extern const ACPL_QUANT_TABLE ivas_param_upmx_alpha_quant_table[]; +extern const ACPL_QUANT_TABLE ivas_param_upmx_beta_quant_table[2][9]; + /* IVAS_ROM_COM_H */ #endif diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 42688ee145fb0e695bf6150c7c5f1811e90b78ac..4f4f6319dc5ff1e2ce0dbfd707b3f8d9fba80362 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2448,7 +2448,7 @@ void dctT2_N_apply_matrix( const float *input, /* i : input in fdcng or DCT(fdcng) domain */ float *output, /* o : output in DCT(fdcng) or fdcng ordomain */ const int16_t dct_dim, /* i : dct processing dim possibly truncated */ - int16_t fdcngvq_dim, /* i : fdcng domain length */ + const int16_t fdcngvq_dim, /* i : fdcng domain length */ const float *matrix, /* i : IDCT matrix */ const int16_t matrix_row_dim, /* i : */ const DCTTYPE dcttype /* i : matrix operation type */ diff --git a/lib_com/prot.h b/lib_com/prot.h index bf9446939d98abc010f6bd8711263d62b3414247..2459ba90af5272fb69a1699b0ad3a7416b4f7c31 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3984,7 +3984,7 @@ void set_impulse( float exc[], /* o : adaptive codebook excitation */ float y1[], /* o : filtered adaptive codebook excitation */ int16_t *imp_shape, /* o : adaptive codebook index */ - int16_t *imp_pos, /* o : position of the glotal impulse center index */ + int16_t *imp_pos, /* o : position of the glottal impulse center index */ float *gain_trans /* o : transition gain */ ); @@ -4943,7 +4943,7 @@ void FEC_encode( int16_t FEC_pos_dec( Decoder_State *st, /* i/o: decoder state structure */ - int16_t *last_pulse_pos, /* o : Last glotal pulse position in the lost ACB */ + int16_t *last_pulse_pos, /* o : Last glottal pulse position in the lost ACB */ float *enr_q, /* o : Decoded energy */ const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */ ); @@ -8149,7 +8149,7 @@ void dctT2_N_apply_matrix( const float *input, /* i : input in fdcng or DCT(fdcng) domain */ float *output, /* o : output in DCT(fdcng) or fdcng ordomain */ const int16_t dct_dim, /* i : dct processing dim possibly truncated */ - int16_t fdcngvq_dim, /* i : fdcng domain length */ + const int16_t fdcngvq_dim, /* i : fdcng domain length */ const float *matrix, /* i : IDCT matrix */ const int16_t matrix_row_dim, /* i : */ const DCTTYPE dcttype /* i : matrix operation type */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 79976efa88ab63a6d3eb8948712e899a1e5e1f12..b36e31253f7726399ef393cbf8857b770b0f1edf 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -461,7 +461,7 @@ typedef int16_t ( *TDecodeValue )( struct Decoder_State *st, int16_t index, int1 */ typedef float ( *TLinearPredictionFilter )( const int16_t order, const float parCoeff[], float *state, float x ); -/** Structure that defines mapping between a parameter and a bistream. */ +/** Structure that defines mapping between a parameter and a bitstream. */ typedef struct ParamBitMap { /** Number of bits in a bitstream required for the parameter. @@ -516,7 +516,7 @@ typedef struct ParamBitMap struct ParamsBitMap const *pSubParamBitMap; } ParamBitMap; -/** Structure that defines mapping between parameters and a bistream. */ +/** Structure that defines mapping between parameters and a bitstream. */ typedef struct ParamsBitMap { /** Number of parameters in params. */ diff --git a/lib_dec/FEC_clas_estim.c b/lib_dec/FEC_clas_estim.c index 4acd3dab9cef32fa47fafd57184f9edc2e52877a..8d54129a7c2d5945f07951153d958c86c21f1cb5 100644 --- a/lib_dec/FEC_clas_estim.c +++ b/lib_dec/FEC_clas_estim.c @@ -735,7 +735,7 @@ static void FEC_classificationMusic( int16_t FEC_pos_dec( Decoder_State *st, /* i/o: decoder state structure */ - int16_t *last_pulse_pos, /* o : last glotal pulse position in the lost ACB */ + int16_t *last_pulse_pos, /* o : last glottal pulse position in the lost ACB */ float *enr_q, /* o : decoded energy */ const int16_t nBits_es_Pred /* i : number of bits for Es_pred Q */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 353eaddc6009679793223144e767407eada76519..94de946cf9dfc594cd6eee214fe3ab60130b3760 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1869,9 +1869,9 @@ ivas_error ivas_init_decoder( * Allocate and initialize limiter struct *-----------------------------------------------------------------*/ - if ( ( st_ivas->hLimiter = ivas_limiter_open( hDecoderConfig->nchan_out, output_Fs ) ) == NULL ) + if ( ( error = ivas_limiter_open( &st_ivas->hLimiter, hDecoderConfig->nchan_out, output_Fs ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to open limiter handle" ); + return error; } /*-----------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 50d1a91de68132d752ee68ad0be52595dd8e496b..88f5644393233a592d24a9d1e73ba7ceecddd033 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -41,12 +41,12 @@ #include "wmc_auto.h" /*-------------------------------------------------------------------------* - * ivas_ism_bitrate_switching() + * ivas_ism_bitrate_switching_dec() * * *-------------------------------------------------------------------------*/ -static ivas_error ivas_ism_bitrate_switching( +static ivas_error ivas_ism_bitrate_switching_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nchan_transport_old, /* i : last number of transport channels */ const ISM_MODE last_ism_mode, /* i : last ISM mode */ @@ -438,7 +438,7 @@ ivas_error ivas_ism_dec_config( { if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) { - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } @@ -461,7 +461,7 @@ ivas_error ivas_ism_dec_config( /* ISM mode switching */ if ( st_ivas->ism_mode != last_ism_mode ) { - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index 56a52f2be9944bc27587624bb71ad92cd52734d0..9bdfef9eb7399e5750bf661ca37f64bd8e0e8055 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -725,7 +725,7 @@ ivas_error ivas_ism_metadata_dec_create( /*------------------------------------------------------------------------- * decode_angle_indices() * - * Decoding of an angle + * Decoding of a position/orientation angle *-------------------------------------------------------------------------*/ static void decode_angle_indices( diff --git a/lib_dec/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 217d67d69358794394375112e9901dfefc54255a..f7b569923463dd87a29677ec507573bd3edae0b0 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -1356,10 +1356,10 @@ static void huffman_decode( switch ( parType ) { case ALPHA: - nquant = alpha_quant_table[quant_type].nquant; + nquant = ivas_param_upmx_alpha_quant_table[quant_type].nquant; break; case BETA: - nquant = beta_quant_table[quant_type][0].nquant; + nquant = ivas_param_upmx_beta_quant_table[quant_type][0].nquant; break; default: assert( 0 ); @@ -1442,7 +1442,7 @@ static void dequant_alpha( float *v ) { int16_t iv; - ACPL_QUANT_TABLE *quant_table = &alpha_quant_table[quant_type]; + const ACPL_QUANT_TABLE *quant_table = &ivas_param_upmx_alpha_quant_table[quant_type]; for ( iv = 0; iv < ivStart; iv++ ) { @@ -1467,7 +1467,7 @@ static void dequant_beta( float *beta ) { int16_t iv; - ACPL_QUANT_TABLE *quant_table; + const ACPL_QUANT_TABLE *quant_table; for ( iv = 0; iv < ivStart; iv++ ) { @@ -1476,7 +1476,7 @@ static void dequant_beta( for ( iv = ivStart; iv < nv; iv++ ) { - quant_table = &beta_quant_table[quant_type][ivas_param_upmx_mx_qmap[quant_type][aq[iv]]]; + quant_table = &ivas_param_upmx_beta_quant_table[quant_type][ivas_param_upmx_mx_qmap[quant_type][aq[iv]]]; beta[iv] = quant_table->data[bq[iv]]; } diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 7b465ed3bffb9638bb7a99e1b34ee9be79a8657e..e4012a429c95c8c4cbcf2f76106b5f8181cc0daa 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -3739,7 +3739,7 @@ static int16_t decode_fixed_rate_composed_index_coherence( /*-------------------------------------------------------------------* * read_coherence_data_hr_512() * - * + * Read coherence data at HR *-------------------------------------------------------------------*/ /*! r: number of bits read */ diff --git a/lib_dec/ivas_range_uni_dec.c b/lib_dec/ivas_range_uni_dec.c index db0fbddeabd1d3f83ef2df5908f290383289bac9..6fbbaa5636d4a0c6f38be7afcf589afff04f2640 100644 --- a/lib_dec/ivas_range_uni_dec.c +++ b/lib_dec/ivas_range_uni_dec.c @@ -138,7 +138,7 @@ uint16_t rc_uni_dec_read_symbol_fastS( { rc_st_dec->bit_error_detected = 1; - /* for valid bistreams, always low < range, therefore setting low = range */ + /* for valid bitstreams, always low < range, therefore setting low = range */ /* will always reach the bitstream error condition branch on the next call */ rc_st_dec->rc_range = 0xFFFFFFFF; rc_st_dec->rc_low = rc_st_dec->rc_range; @@ -248,7 +248,7 @@ uint16_t rc_uni_dec_read_bit( { rc_st_dec->bit_error_detected = 1; - /* for valid bistreams, always low < range, therefore setting low = range */ + /* for valid bitstreams, always low < range, therefore setting low = range */ /* will always reach the bitstream error condition branch on the next call */ rc_st_dec->rc_range = 0xFFFFFFFF; rc_st_dec->rc_low = rc_st_dec->rc_range; @@ -303,7 +303,7 @@ uint16_t rc_uni_dec_read_bit_prob_fast( { rc_st_dec->bit_error_detected = 1; - /* for valid bistreams, always low < range, therefore setting low = range */ + /* for valid bitstreams, always low < range, therefore setting low = range */ /* will always reach the bitstream error condition branch on the next call */ rc_st_dec->rc_range = 0xFFFFFFFF; rc_st_dec->rc_low = rc_st_dec->rc_range; @@ -376,7 +376,7 @@ uint16_t rc_uni_dec_read_bits( { rc_st_dec->bit_error_detected = 1; - /* for valid bistreams, always low < range, therefore setting low = range */ + /* for valid bitstreams, always low < range, therefore setting low = range */ /* will always reach the bitstream error condition branch on the next call */ rc_st_dec->rc_range = 0xFFFFFFFF; rc_st_dec->rc_low = rc_st_dec->rc_range; @@ -482,7 +482,7 @@ static int16_t rc_uni_dec_read( { rc_st_dec->bit_error_detected = 1; - /* for valid bistreams, always low < range, therefore setting low = range */ + /* for valid bitstreams, always low < range, therefore setting low = range */ /* will always reach the bitstream error condition branch on the next call */ rc_st_dec->rc_range = 0xFFFFFFFF; rc_st_dec->rc_low = rc_st_dec->rc_range; diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 643c7b5a6c2146f49bcab96c21cf047bec9e4b1d..978d3152e26c545fdc224f0be24673f492519cd5 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -219,6 +219,7 @@ void ivas_mc2sba( * Get TCs from Ambisonics signal in ACN *-------------------------------------------------------------------*/ +/*! r: SBA DirAC stereo flag */ int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index adcfe88186018454da9fe8c88a3117905d8a02f4..dec6d85252cdacabd5d36d3b447f039b84c41c11 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -182,11 +182,11 @@ void sns_avq_dec( *-------------------------------------------------------------------*/ void sns_avq_dec_stereo( - int16_t *indexl, /* i : Quantization indices (left channel) */ - int16_t *indexr, /* i : Quantization indices (right channe) */ - const int16_t L_frame, - float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ - float *SNS_Qr /* o : Quantized SNS vectors (right channe) */ + int16_t *indexl, /* i : Quantization indices (left channel) */ + int16_t *indexr, /* i : Quantization indices (right channe) */ + const int16_t L_frame, /* i : frame length */ + float *SNS_Ql, /* o : Quantized SNS vectors (left channel) */ + float *SNS_Qr /* o : Quantized SNS vectors (right channe) */ ) { int16_t i, stereo_mode; @@ -232,6 +232,13 @@ void sns_avq_dec_stereo( return; } + +/*------------------------------------------------------------------- + * dequantize_sns() + * + * Dequantize SNS + *-------------------------------------------------------------------*/ + void dequantize_sns( int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW], float snsQ_out[CPE_CHANNELS][NB_DIV][M], @@ -293,4 +300,6 @@ void dequantize_sns( } } } + + return; } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index a4de639cb976cfebe0b3cf9442f71e9a79b26c46..91d547b4a5db14511bcc6fee62de3d5b36a27893 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -97,7 +97,7 @@ struct IVAS_DEC /*---------------------------------------------------------------------* - * Local functions + * Local function declarations *---------------------------------------------------------------------*/ static void IVAS_DEC_Close_VoIP( IVAS_DEC_VOIP *hVoIP ); @@ -107,14 +107,8 @@ static void store_JbmData( IVAS_DEC_VOIP *hVoIP, JB4_DATAUNIT_HANDLE dataUnit, c static ivas_error evs_dec_main( Decoder_Struct *st_ivas, const int16_t nOutSamples, float *floatBuf, int16_t *pcmBuf ); static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, int16_t *sdp_hf_only, const bool is_voip_enabled ); static void init_decoder_config( DECODER_CONFIG_HANDLE hDecoderConfig ); -static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ); -static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasDec ); static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ); -static ivas_error IVAS_DEC_Setup( IVAS_DEC_HANDLE hIvasDec, uint16_t *nTcBufferGranularity, uint8_t *nTransportChannels, uint8_t *nOutChannels, uint16_t *nSamplesRendered, int16_t *data ); -static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, float *pcmBuf, int16_t *nOutSamples ); -static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *pcmBuf ); -static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, const uint16_t nSamplesForRendering, uint16_t *nSamplesRendered, uint16_t *nSamplesAvailableNext, int16_t *pcmBuf ); -static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, int16_t *nSamplesBuffered ); + /*---------------------------------------------------------------------* * IVAS_DEC_Open() @@ -180,6 +174,7 @@ ivas_error IVAS_DEC_Open( /* initialize Decoder Config. handle */ init_decoder_config( hIvasDec->st_ivas->hDecoderConfig ); + /* initialize pointers to handles to NULL */ ivas_initialize_handles_dec( st_ivas ); @@ -387,82 +382,82 @@ static IVAS_DEC_AUDIO_CONFIG mapAudioConfig2DecAudioConfig( #endif /*---------------------------------------------------------------------* - * mapOutputFormat() + * mapOutputConfig() * * *---------------------------------------------------------------------*/ -static AUDIO_CONFIG mapOutputFormat( - const IVAS_DEC_AUDIO_CONFIG outputFormat ) +static AUDIO_CONFIG mapOutputConfig( + const IVAS_DEC_AUDIO_CONFIG outputConfig_api ) { AUDIO_CONFIG output_config; - if ( outputFormat == IVAS_DEC_OUTPUT_EXT ) /* external renderer */ + if ( outputConfig_api == IVAS_DEC_OUTPUT_EXT ) /* external renderer */ { output_config = AUDIO_CONFIG_EXTERNAL; } - else if ( outputFormat == IVAS_DEC_OUTPUT_MONO ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_MONO ) { output_config = AUDIO_CONFIG_MONO; } - else if ( outputFormat == IVAS_DEC_OUTPUT_STEREO ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_STEREO ) { output_config = AUDIO_CONFIG_STEREO; } - else if ( outputFormat == IVAS_DEC_OUTPUT_5_1 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_5_1 ) { output_config = AUDIO_CONFIG_5_1; } - else if ( outputFormat == IVAS_DEC_OUTPUT_7_1 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_7_1 ) { output_config = AUDIO_CONFIG_7_1; } - else if ( outputFormat == IVAS_DEC_OUTPUT_5_1_2 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_5_1_2 ) { output_config = AUDIO_CONFIG_5_1_2; } - else if ( outputFormat == IVAS_DEC_OUTPUT_5_1_4 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_5_1_4 ) { output_config = AUDIO_CONFIG_5_1_4; } - else if ( outputFormat == IVAS_DEC_OUTPUT_7_1_4 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_7_1_4 ) { output_config = AUDIO_CONFIG_7_1_4; } - else if ( outputFormat == IVAS_DEC_OUTPUT_LS_CUSTOM ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_LS_CUSTOM ) { output_config = AUDIO_CONFIG_LS_CUSTOM; } - else if ( outputFormat == IVAS_DEC_OUTPUT_FOA ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_FOA ) { output_config = AUDIO_CONFIG_FOA; } - else if ( outputFormat == IVAS_DEC_OUTPUT_HOA2 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_HOA2 ) { output_config = AUDIO_CONFIG_HOA2; } - else if ( outputFormat == IVAS_DEC_OUTPUT_HOA3 ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_HOA3 ) { output_config = AUDIO_CONFIG_HOA3; } - else if ( outputFormat == IVAS_DEC_OUTPUT_BINAURAL ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_BINAURAL ) { output_config = AUDIO_CONFIG_BINAURAL; } - else if ( outputFormat == IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_BINAURAL_ROOM_IR ) { output_config = AUDIO_CONFIG_BINAURAL_ROOM_IR; } - else if ( outputFormat == IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_BINAURAL_ROOM_REVERB ) { output_config = AUDIO_CONFIG_BINAURAL_ROOM_REVERB; } #ifdef SPLIT_REND_WITH_HEAD_ROT - else if ( outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_CODED ) { output_config = AUDIO_CONFIG_BINAURAL_SPLIT_CODED; } - else if ( outputFormat == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) + else if ( outputConfig_api == IVAS_DEC_OUTPUT_SPLIT_BINAURAL_PCM ) { output_config = AUDIO_CONFIG_BINAURAL_SPLIT_PCM; } @@ -521,7 +516,7 @@ static IVAS_DEC_BS_FORMAT mapIvasFormat( ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ - const IVAS_DEC_AUDIO_CONFIG outputFormat, /* i : output format */ + const IVAS_DEC_AUDIO_CONFIG outputConfig, /* i : output configuration */ const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ @@ -548,8 +543,8 @@ ivas_error IVAS_DEC_Configure( return IVAS_ERR_WRONG_PARAMS; } - if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && !( ( outputFormat == IVAS_DEC_OUTPUT_MONO && Opt_non_diegetic_pan == 0 ) || - ( outputFormat == IVAS_DEC_OUTPUT_STEREO && Opt_non_diegetic_pan == 1 ) ) ) + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS && !( ( outputConfig == IVAS_DEC_OUTPUT_MONO && Opt_non_diegetic_pan == 0 ) || + ( outputConfig == IVAS_DEC_OUTPUT_STEREO && Opt_non_diegetic_pan == 1 ) ) ) { return IVAS_ERR_WRONG_MODE; } @@ -558,7 +553,7 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig = st_ivas->hDecoderConfig; - hDecoderConfig->output_config = mapOutputFormat( outputFormat ); + hDecoderConfig->output_config = mapOutputConfig( outputConfig ); if ( hDecoderConfig->output_config == AUDIO_CONFIG_INVALID ) { return IVAS_ERR_WRONG_PARAMS; @@ -572,7 +567,7 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->nchan_out = 1; } - if ( outputFormat != IVAS_DEC_OUTPUT_EXT && outputFormat != IVAS_DEC_OUTPUT_LS_CUSTOM ) + if ( outputConfig != IVAS_DEC_OUTPUT_EXT && outputConfig != IVAS_DEC_OUTPUT_LS_CUSTOM ) { hDecoderConfig->nchan_out = audioCfg2channels( hDecoderConfig->output_config ); } @@ -874,7 +869,7 @@ ivas_error IVAS_DEC_GetSamples( /*---------------------------------------------------------------------* * IVAS_DEC_Setup( ) * - * Main function to decode to PCM data of the transport channels + * *---------------------------------------------------------------------*/ static ivas_error IVAS_DEC_Setup( @@ -942,7 +937,7 @@ static ivas_error IVAS_DEC_Setup( * Main function to decode to PCM data of the transport channels *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetTcSamples( +static ivas_error IVAS_DEC_GetTcSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ float *pcmBuf, /* i/o: buffer for decoded PCM output. The memory must already be allocated and be able to hold the expected number of output samples, based on frame size and number of output channels */ int16_t *nOutSamples /* o : number of samples per channel written to output buffer */ @@ -994,7 +989,7 @@ ivas_error IVAS_DEC_GetTcSamples( * Main function to decode to PCM data of the transport channels *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_RendererFeedTcSamples( +static ivas_error IVAS_DEC_RendererFeedTcSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call */ @@ -1026,10 +1021,10 @@ ivas_error IVAS_DEC_RendererFeedTcSamples( /*---------------------------------------------------------------------* * IVAS_DEC_GetRenderedSamples( ) * - * Main function to decode to PCM data of the transport channels + * Main function to render the transport channels to PCM output datat *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_GetRenderedSamples( +static ivas_error IVAS_DEC_GetRenderedSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint16_t nSamplesForRendering, /* i : number of TC samples wanted from the renderer */ uint16_t *nSamplesRendered, /* o : number of samples rendered */ @@ -1059,7 +1054,14 @@ ivas_error IVAS_DEC_GetRenderedSamples( return error; } -ivas_error IVAS_DEC_GetBufferedNumberOfSamples( + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetBufferedNumberOfSamples( ) + * + * Returns the number of objects available in the decoded bitstream + *---------------------------------------------------------------------*/ + +static ivas_error IVAS_DEC_GetBufferedNumberOfSamples( IVAS_DEC_HANDLE hIvasDec, /* i/o : IVAS decoder handle */ int16_t *nSamplesBuffered /* o : number of samples still buffered */ ) @@ -1281,6 +1283,7 @@ ivas_error IVAS_DEC_GetMasaMetadata( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_FeedHeadTrackData( ) * @@ -1343,6 +1346,7 @@ ivas_error IVAS_DEC_FeedHeadTrackData( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_FeedRefRotData( ) * @@ -1371,6 +1375,7 @@ ivas_error IVAS_DEC_FeedRefRotData( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_FeedRefVectorData( ) * @@ -1381,8 +1386,8 @@ ivas_error IVAS_DEC_FeedRefRotData( ivas_error IVAS_DEC_FeedRefVectorData( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const IVAS_VECTOR3 listenerPos, /* i : Listener position */ - const IVAS_VECTOR3 refPos /* i : Reference position */ + const IVAS_VECTOR3 listenerPos, /* i : Listener position */ + const IVAS_VECTOR3 refPos /* i : Reference position */ ) { ivas_orient_trk_state_t *pOtr; @@ -1393,9 +1398,11 @@ ivas_error IVAS_DEC_FeedRefVectorData( } pOtr = hIvasDec->st_ivas->hHeadTrackData->OrientationTracker; + return ivas_orient_trk_SetReferenceVector( pOtr, listenerPos, refPos ); } + /*---------------------------------------------------------------------* * IVAS_DEC_FeedExternalOrientationData( ) * @@ -1440,6 +1447,7 @@ ivas_error IVAS_DEC_FeedExternalOrientationData( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_FeedCustomLsData( ) * @@ -3199,6 +3207,13 @@ ivas_error IVAS_DEC_GetSbaDebugParams( #endif /* DEBUGGING */ + +/*---------------------------------------------------------------------* + * input_format_API_to_internal() + * + * + *---------------------------------------------------------------------*/ + static ivas_error input_format_API_to_internal( IVAS_DEC_INPUT_FORMAT input_format, int16_t *bitstream_format_internal, @@ -3279,7 +3294,7 @@ static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( * *---------------------------------------------------------------------*/ -ivas_error IVAS_DEC_VoIP_reconfigure( +static ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index ba6432bd303ba1f521407316824f3e78e4626a41..3be0729a541db3521320afba6f2f6ce90f54605d 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -147,7 +147,7 @@ ivas_error IVAS_DEC_Open( ivas_error IVAS_DEC_Configure( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const uint32_t sampleRate, /* i : output sampling frequency */ - const IVAS_DEC_AUDIO_CONFIG outputFormat, /* i : output format */ + const IVAS_DEC_AUDIO_CONFIG outputConfig, /* i : output configuration */ const int16_t customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const int16_t hrtfReaderEnabled, /* i : enable HRTF binary file input */ const int16_t enableHeadRotation, /* i : enable head rotation for binaural output */ diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 3154eb56a7b39de30d5305d94f7b9ccb2ad940b7..c4495d6121b8ca4f4fbaa37be48f93aca90cf52c 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -574,7 +574,7 @@ ivas_error ivas_ism_metadata_enc( /* But send the flag with 1 bit */ push_next_indice( hBstr, hParamIsm->flag_noisy_speech, 1 ); - /* Loop over multiwave to write the object indices into bistream */ + /* Loop over multiwave to write the object indices into bitstream */ for ( ch = 0; ch < MAX_PARAM_ISM_WAVE; ch++ ) { for ( nbands = 0; nbands < hParamIsm->nbands; nbands++ ) @@ -586,7 +586,7 @@ ivas_error ivas_ism_metadata_enc( } } - /* Loop over bands to write the power ratio's indices into bistream */ + /* Loop over bands to write the power ratio's indices into bitstream */ for ( nbands = 0; nbands < hParamIsm->nbands; nbands++ ) { for ( nblocks = 0; nblocks < hParamIsm->nblocks[nbands]; nblocks++ ) diff --git a/lib_enc/ivas_mc_paramupmix_enc.c b/lib_enc/ivas_mc_paramupmix_enc.c index 8c442a51c6d357c9d6dc597992901dc90da299aa..7fe52de3098d85101a9db1f01af63ae818ac674b 100644 --- a/lib_enc/ivas_mc_paramupmix_enc.c +++ b/lib_enc/ivas_mc_paramupmix_enc.c @@ -546,8 +546,8 @@ static void quantize_alpha( int16_t nq; const float *data; - nq = alpha_quant_table[quant_type].nquant; - data = alpha_quant_table[quant_type].data; + nq = ivas_param_upmx_alpha_quant_table[quant_type].nquant; + data = ivas_param_upmx_alpha_quant_table[quant_type].data; quantize_pars( nv, alpha, nq, data, aq, adeq ); @@ -567,7 +567,7 @@ static void quantize_beta( float *bdeq ) { int16_t iv, iq, iq0, iq1; - ACPL_QUANT_TABLE *tables = beta_quant_table[quant_type]; + const ACPL_QUANT_TABLE *tables = ivas_param_upmx_beta_quant_table[quant_type]; ACPL_QUANT_TABLE quant_table; for ( iv = 0; iv < nv; iv++ ) @@ -602,7 +602,7 @@ static void quantize_beta( } } - *pnq = beta_quant_table[quant_type][0].nquant; + *pnq = ivas_param_upmx_beta_quant_table[quant_type][0].nquant; return; } diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 1d80309090970df62d0b0887a19d8ff3cd62a58d..f531101cf92e6684e08198f5db86c940c34f8c05 100644 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -76,7 +76,7 @@ static int16_t getInputBufferSize( const Encoder_Struct *st_ivas ); static ivas_error doCommonConfigureChecks( IVAS_ENC_HANDLE hIvasEnc ); static ivas_error doCommonSetterChecks( IVAS_ENC_HANDLE hIvasEnc ); static ivas_error sanitizeBandwidth( const IVAS_ENC_HANDLE hIvasEnc ); -static ivas_error sanitizeBitrateISM( const ENCODER_CONFIG_HANDLE hEncoderConfig, const IVAS_ENC_HANDLE hIvasEnc ); +static ivas_error sanitizeBitrateISM( const ENCODER_CONFIG_HANDLE hEncoderConfig, const bool extMetadataApi ); static void init_encoder_config( ENCODER_CONFIG_HANDLE hEncoderConfig ); static void resetIsmMetadataProvidedFlags( IVAS_ENC_HANDLE hIvasEnc ); static ivas_error bandwidthApiToInternal( const IVAS_ENC_BANDWIDTH maxBandwidth, int16_t *internalMaxBandwidth ); @@ -825,7 +825,7 @@ static ivas_error configureEncoder( } else if ( hEncoderConfig->ivas_format == ISM_FORMAT ) { - if ( ( error = sanitizeBitrateISM( hEncoderConfig, hIvasEnc ) ) != IVAS_ERR_OK ) + if ( ( error = sanitizeBitrateISM( hEncoderConfig, hIvasEnc->extMetadataApi ) ) != IVAS_ERR_OK ) { return error; } @@ -1832,7 +1832,7 @@ static ivas_error setBitrate( if ( hEncoderConfig->ivas_format == ISM_FORMAT ) { - if ( ( error = sanitizeBitrateISM( hEncoderConfig, hIvasEnc ) ) != IVAS_ERR_OK ) + if ( ( error = sanitizeBitrateISM( hEncoderConfig, hIvasEnc->extMetadataApi ) ) != IVAS_ERR_OK ) { return error; } @@ -2073,7 +2073,7 @@ static ivas_error sanitizeBandwidth( static ivas_error sanitizeBitrateISM( const ENCODER_CONFIG_HANDLE hEncoderConfig, - const IVAS_ENC_HANDLE hIvasEnc ) + const bool extMetadataApi ) { if ( hEncoderConfig->ivas_total_brate > IVAS_128k && hEncoderConfig->nchan_inp == 1 ) { @@ -2105,7 +2105,7 @@ static ivas_error sanitizeBitrateISM( return IVAS_ERROR( IVAS_ERR_INVALID_BITRATE, "Too low bitrate for 4 ISM specified in IVAS: %d", hEncoderConfig->ivas_total_brate ); } - if ( hIvasEnc->extMetadataApi ) + if ( extMetadataApi ) { hEncoderConfig->ism_extended_metadata_flag = ( hEncoderConfig->ivas_total_brate >= ISM_EXTENDED_METADATA_BRATE ); } diff --git a/lib_enc/pre_proc.c b/lib_enc/pre_proc.c index 4a11f1b61f1d60360db9540f603d63b03c5b9b97..c035ef5ac4e1948a6cd385e5f4d3fd21cc49b985 100644 --- a/lib_enc/pre_proc.c +++ b/lib_enc/pre_proc.c @@ -381,7 +381,7 @@ void pre_proc( } else if ( st->rf_mode && st->core_brate != FRAME_NO_DATA && st->core_brate != SID_2k40 ) { - /* the RF config is for (n- fec_offset)th frame that will be packed along with the n-th frame bistream */ + /* the RF config is for (n- fec_offset)th frame that will be packed along with the n-th frame bitstream */ st->rf_mode = 1; st->codec_mode = MODE2; diff --git a/lib_enc/set_impulse.c b/lib_enc/set_impulse.c index 4cafeea9e8a253a5b53ee88df65a4e91b0e5796d..2c8a7fdd080353a7880fb30d7ffd018b2f5f70dc 100644 --- a/lib_enc/set_impulse.c +++ b/lib_enc/set_impulse.c @@ -61,10 +61,10 @@ static void convolve_tc2( const float g[], const float h[], float y[], const int /*---------------------------------------------------------------------------------------* * Function set_impulse() for TC * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * - * Builds glottal codebook contribution based on glotal impulses positions finding. * + * Builds glottal codebook contribution based on glottal impulses positions finding. * * * - * Returns a position of the glotal impulse center and * - * a number of the glotal impulse shape. * + * Returns a position of the glottal impulse center and * + * a number of the glottal impulse shape. * * * * |----| |----| xn * * imp_pos-> || | imp_shape-> | g1 | | * @@ -89,7 +89,7 @@ void set_impulse( float exc[], /* o : adaptive codebook excitation */ float y1[], /* o : filtered adaptive codebook excitation */ int16_t *imp_shape, /* o : adaptive codebook index */ - int16_t *imp_pos, /* o : position of the glotal impulse center index */ + int16_t *imp_pos, /* o : position of the glottal impulse center index */ float *gain_trans /* o : transition gain */ ) { diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 33ca0ed1899a10b6919489ce8bb672b582ff1019..638287c9a19845b21111c2704e4b22ff512339ff 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -53,7 +53,7 @@ * Initialize hHrtf handle *------------------------------------------------------------------------*/ -static ivas_error ivas_hrtf_init( +ivas_error ivas_hrtf_init( HRTFS_DATA *hHrtf /* i/o: HRTF handle */ ) { diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana.c index 6d2b8861bb66a3054d4afed3d2b452e318236a20..dc41207be464ad3710542edf632eb6474d4a6dba 100644 --- a/lib_rend/ivas_dirac_ana.c +++ b/lib_rend/ivas_dirac_ana.c @@ -109,11 +109,17 @@ ivas_error ivas_dirac_ana_open( /* intensity 3-dim */ for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { - hDirAC->direction_vector_m[i] = (float **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float * ) ); + if ( ( hDirAC->direction_vector_m[i] = (float **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); + } for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { - hDirAC->direction_vector_m[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ); + if ( ( hDirAC->direction_vector_m[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); + } set_zero( hDirAC->direction_vector_m[i][j], MASA_FREQUENCY_BANDS ); } } @@ -122,7 +128,10 @@ ivas_error ivas_dirac_ana_open( { for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { - hDirAC->buffer_intensity_real[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ); + if ( ( hDirAC->buffer_intensity_real[i][j] = (float *) malloc( MASA_FREQUENCY_BANDS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MASA decoder\n" ) ); + } set_zero( hDirAC->buffer_intensity_real[i][j], MASA_FREQUENCY_BANDS ); } } diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 106c4330341b0e42e8b30ab1db2470cd31d62740..0953e8a825dc3aecfe8a51b004da4a2400884199 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -101,9 +101,10 @@ static int16_t detect_strong_saturations( *-------------------------------------------------------------------*/ /*! r : limiter struct handle */ -IVAS_LIMITER_HANDLE ivas_limiter_open( - const int16_t max_num_channels, /* i : maximum number of I/O channels to be processed */ - const int32_t sampling_rate /* i : sampling rate for processing */ +ivas_error ivas_limiter_open( + IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ + const int16_t max_num_channels, /* i : maximum number of I/O channels to be processed */ + const int32_t sampling_rate /* i : sampling rate for processing */ ) { int16_t i; @@ -111,17 +112,21 @@ IVAS_LIMITER_HANDLE ivas_limiter_open( if ( max_num_channels <= 0 || sampling_rate <= 0 ) { - return NULL; + return ( IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Wrong parameters for Limiter\n" ) ); } if ( ( hLimiter = malloc( sizeof( IVAS_LIMITER ) ) ) == NULL ) { - return NULL; + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Limiter handle\n" ) ); } hLimiter->max_num_channels = max_num_channels; hLimiter->num_channels = max_num_channels; - hLimiter->channel_ptrs = malloc( max_num_channels * sizeof( float * ) ); + + if ( ( hLimiter->channel_ptrs = malloc( max_num_channels * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Limiter handle\n" ) ); + } hLimiter->sampling_rate = sampling_rate; hLimiter->gain = 1.f; hLimiter->release_heuristic = 0.f; @@ -136,7 +141,9 @@ IVAS_LIMITER_HANDLE ivas_limiter_open( hLimiter->channel_ptrs[i] = NULL; } - return hLimiter; + *hLimiter_out = hLimiter; + + return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 2ae5be6759580733454a932db3f87a7a4342c167..b06ee0d5f4f488e00f63682bccae48ac5cecc2ff 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -80,8 +80,9 @@ void ivas_output_init( * Limiter prototypes *----------------------------------------------------------------------------------*/ -/*! r: limiter struct handle */ -IVAS_LIMITER_HANDLE ivas_limiter_open( + +ivas_error ivas_limiter_open( + IVAS_LIMITER_HANDLE *hLimiter_out, /* o : limiter struct handle */ const int16_t num_channels, /* i : number of I/O channels */ const int32_t sampling_rate /* i : sampling rate for processing */ ); @@ -846,6 +847,10 @@ void ivas_rend_closeCrend( #endif ); +ivas_error ivas_hrtf_init( + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ +); + ivas_error ivas_rend_initCrendWrapper( CREND_WRAPPER_HANDLE *pCrend #ifdef SPLIT_REND_WITH_HEAD_ROT diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 253c1d84b6b5caa3c53f5093cd570fa91f2ed122..78e5352f3956a5496b4a288a4debba5c9b9a3ea1 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -790,10 +790,10 @@ static ivas_error initLimiter( const int16_t numChannels, const int32_t sampleRate ) { + ivas_error error; + /* If re-initializing with unchanged values, return early */ - if ( *phLimiter != NULL && - ( *phLimiter )->num_channels == numChannels && - ( *phLimiter )->sampling_rate == sampleRate ) + if ( *phLimiter != NULL && ( *phLimiter )->num_channels == numChannels && ( *phLimiter )->sampling_rate == sampleRate ) { return IVAS_ERR_OK; } @@ -804,9 +804,9 @@ static ivas_error initLimiter( ivas_limiter_close( phLimiter ); } - if ( ( *phLimiter = ivas_limiter_open( numChannels, sampleRate ) ) == NULL ) + if ( ( error = ivas_limiter_open( phLimiter, numChannels, sampleRate ) ) != IVAS_ERR_OK ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to open limiter handle" ); + return error; } return IVAS_ERR_OK; diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 7eb3359238a874e2a1382d12b06764ad130d19ae..56da4df2245917791d1750d138d4412e42bbc1cd 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -678,51 +678,6 @@ ivas_error dealloc_HRTF_binary( } -/*------------------------------------------------------------------------- - * ivas_hrtf_init() - * - * Initialize hHRTF handle - *------------------------------------------------------------------------*/ - -static ivas_error ivas_hrtf_init( - HRTFS_DATA *hHRTF /* i/o: HRTF handle */ -) -{ - int16_t i, j; - - if ( hHRTF == NULL ) - { - return IVAS_ERR_WRONG_PARAMS; - } - - hHRTF->latency_s = 0; - hHRTF->max_num_ir = 0; - hHRTF->max_num_iterations = 0; - hHRTF->index_frequency_max_diffuse = 0; - - for ( i = 0; i < MAX_INTERN_CHANNELS; i++ ) - { - hHRTF->inv_diffuse_weight[i] = 0; - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHRTF->num_iterations[i][j] = 0; - hHRTF->pIndex_frequency_max[i][j] = NULL; - hHRTF->pOut_to_bin_re[i][j] = NULL; - hHRTF->pOut_to_bin_im[i][j] = NULL; - } - } - for ( j = 0; j < BINAURAL_CHANNELS; j++ ) - { - hHRTF->num_iterations_diffuse[j] = 0; - hHRTF->pIndex_frequency_max_diffuse[j] = NULL; - hHRTF->pOut_to_bin_diffuse_re[j] = NULL; - hHRTF->pOut_to_bin_diffuse_im[j] = NULL; - } - - return IVAS_ERR_OK; -} - - /*---------------------------------------------------------------------* * create_HRTF_from_rawdata() * diff --git a/lib_util/split_render_file_read_write.c b/lib_util/split_render_file_read_write.c index 9c69b3de1dc60d7da5f6e698e52b2fef5de57b9a..5a7929e28c04f231389c3baedca053e5b50bffd5 100644 --- a/lib_util/split_render_file_read_write.c +++ b/lib_util/split_render_file_read_write.c @@ -110,6 +110,11 @@ ivas_error split_rend_writer_open( SplitFileReadWrite **hhSplitRendFileReadWrite size_t header_len, h; char header[SPLIT_RENDERER_FRAME_HEADER_LEN] = "MAIN_SPLITH"; + if ( filename == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hSplitRendFileReadWrite = (SplitFileReadWrite *) malloc( sizeof( SplitFileReadWrite ) ); hSplitRendFileReadWrite->file = fopen( filename, "wb" ); if ( hSplitRendFileReadWrite->file == NULL )