diff --git a/Workspace_msvc/lib_com.vcxproj b/Workspace_msvc/lib_com.vcxproj index bfe36b1f4812b8e44a7cb32fca8793c1b443c962..23aa2ae3f0b6722871f7f9d2c37b27e41f46862f 100644 --- a/Workspace_msvc/lib_com.vcxproj +++ b/Workspace_msvc/lib_com.vcxproj @@ -78,7 +78,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 9b7b5806615c336f40e3f5850ded7b2c2d4103ec..3b648fae048920ae06aa709785d4b49d2e58d710 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -73,7 +73,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);%(PreprocessorDefinitions) false diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index 760621d7a40ce2113110aed02262c1d0f8f40ff9..80910aa5e713bfca913d57aa453a16cac1744f1d 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;..\lib_rend;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_enc.vcxproj b/Workspace_msvc/lib_enc.vcxproj index d9f8e974f0a9fbb885386ff137db1a0b8ef49c0c..3378ac10f0ccb8b95616f87f6d225f38af30bb3d 100644 --- a/Workspace_msvc/lib_enc.vcxproj +++ b/Workspace_msvc/lib_enc.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_rend;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/Workspace_msvc/lib_rend.vcxproj b/Workspace_msvc/lib_rend.vcxproj index 4bd0ca9a93af1b4580271f339f0670bdc1a26bac..865652649a8a320ff0769bd83170528445da8ab3 100644 --- a/Workspace_msvc/lib_rend.vcxproj +++ b/Workspace_msvc/lib_rend.vcxproj @@ -89,7 +89,7 @@ Disabled - ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;..\lib_util;%(AdditionalIncludeDirectories) + ..\lib_com;..\lib_debug;..\lib_dec;..\lib_enc;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;$(Macros);WIN32;%(PreprocessorDefinitions) EnableFastChecks diff --git a/apps/decoder.c b/apps/decoder.c index 9b6b85676508d94c60b728bf651da78c8332a555..a2f4adcf10c278dbc6fc8e6e780bfeda83d17c32 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -84,7 +84,6 @@ static #endif #ifdef JBM_TSM_ON_TCS #define JBM_FRONTEND_FETCH_FRAMESIZE_MS 20 -#define FRAME_SIZE_NS 20000000L #endif typedef struct @@ -107,12 +106,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; @@ -463,9 +460,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(); @@ -481,11 +478,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 { @@ -574,7 +571,7 @@ int main( 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; @@ -582,14 +579,14 @@ int main( 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 ); } IVAS_DEC_HRTF_PARAMBIN_HANDLE hHrtfParambin; IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ); 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 ); } } @@ -837,14 +834,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; @@ -967,7 +961,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 { @@ -1010,7 +1004,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VS" ) == 0 ) { i++; - int tmp = 100; + int32_t tmp = 100; arg->variableSpeedMode = true; if ( i < argc - 3 ) { @@ -1037,7 +1031,7 @@ static bool parseCmdlIVAS_dec( else if ( strcmp( argv_to_upper, "-VOIP_FRAMESIZE" ) == 0 ) { i++; - int tmp; + int32_t tmp; if ( i < argc - 3 ) { if ( !is_digits_only( argv[i] ) ) @@ -2574,6 +2568,7 @@ static ivas_error decodeVariableSpeed( #endif nSamplesAvailableNext = 0; nOutSamples = (int16_t) ( arg.output_Fs / 1000 * VARIABLE_SPEED_FETCH_FRAMESIZE_MS ); + /*------------------------------------------------------------------------------------------* * Loop for every packet (frame) of bitstream data * - Read the bitstream packet @@ -2641,13 +2636,10 @@ static ivas_error decodeVariableSpeed( /* decode and get samples */ do { - error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, - pcmBuf, 0, - &nSamplesAvailableNext + error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, 0, &nSamplesAvailableNext #ifdef SUPPORT_JBM_TRACEFILE , - writeJbmTraceFileFrameWrapper, - jbmTraceWriter + writeJbmTraceFileFrameWrapper, jbmTraceWriter #endif ); if ( error != IVAS_ERR_OK && error != IVAS_ERR_VS_FRAME_NEEDED ) @@ -2746,7 +2738,6 @@ static ivas_error decodeVariableSpeed( } } - /* Write current frame */ if ( decodedGoodFrame ) { @@ -2833,6 +2824,7 @@ static ivas_error decodeVariableSpeed( /*------------------------------------------------------------------------------------------* * Flush what is still left in the VoIP Buffers.... *------------------------------------------------------------------------------------------*/ + while ( nSamplesAvailableNext > 0 ) { int16_t nSamplesFlushed; @@ -2893,25 +2885,19 @@ static ivas_error decodeVariableSpeed( } /* decode and get samples */ - if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, - pcmBuf, - &nSamplesAvailableNext, - &nSamplesFlushed ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesAvailableNext, &nSamplesFlushed ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } - /* Write current frame */ - if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, nSamplesFlushed * nOutChannels ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nOutput audio file writer error\n" ); goto cleanup; } - /* Write ISm metadata to external file(s) */ if ( decodedGoodFrame && arg.outputFormat == IVAS_DEC_OUTPUT_EXT ) { @@ -2969,6 +2955,7 @@ static ivas_error decodeVariableSpeed( #endif } } + /*------------------------------------------------------------------------------------------* * Printouts after decoding has finished *------------------------------------------------------------------------------------------*/ diff --git a/apps/renderer.c b/apps/renderer.c index 533472b428c854c7a0deba8804e75de4d1c562a4..0f4d65accc1d346b4bc7379b5279aeeba47962e8 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -989,7 +989,7 @@ int main( else { error = IVAS_REND_SetHeadRotation( hIvasRend, NULL, NULL ); - if ( ( error != IVAS_ERR_OK ) && ( error != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) // VE: TBC + if ( ( error != IVAS_ERR_OK ) && ( error != IVAS_ERR_INVALID_OUTPUT_FORMAT ) ) { fprintf( stderr, "Error setting Head Rotation: %s\n", ivas_error_to_string( error ) ); exit( -1 ); diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 886509b5ac96d65923b4f13872021fd74414c2f2..1aae7c97edd922ff7f52daf0a80346ad13734da1 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -1839,9 +1839,6 @@ ivas_error preview_indices( break; case SID_ISM: st_ivas->ivas_format = ISM_FORMAT; - /* temporary hack to make mode signaling work with the current 1-object ISM DTX: read padding bits */ - /* Todo: how to apply this here? maybe pt_stream += ... would work? */ - /* st->bit_stream += ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; */ break; case SID_MULTICHANNEL: st_ivas->ivas_format = MC_FORMAT; diff --git a/lib_com/fd_cng_com.c b/lib_com/fd_cng_com.c index 99ae9894f44a26c5b29d70b3cb5e8bc4497f39ce..e31ce67d138a96f1610faeaf30f22dfce3fd551b 100644 --- a/lib_com/fd_cng_com.c +++ b/lib_com/fd_cng_com.c @@ -966,7 +966,6 @@ void SynthesisSTFT_dirac( mvr2r( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize ); set_f( olapBuffer + hFdCngCom->frameSize, 0.0f, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/ - for ( i = hFdCngCom->frameSize / 4; i < 3 * hFdCngCom->frameSize / 4; i++ ) { olapBuffer[i] += fftBuffer[i] * olapWin[i - hFdCngCom->frameSize / 4]; @@ -1009,6 +1008,7 @@ void SynthesisSTFT_dirac( } #endif + /*------------------------------------------------------------------- * mhvals() * diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index f6369235a60c48b21f0f0647ed3a707740e5aae2..c67eb1a426d76b3dd96d519aa7351831237b0dd5 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -219,6 +219,7 @@ typedef enum #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH #define MAX_CLDFB_DIGEST_CHANNELS 4 + typedef enum { TC_BUFFER_MODE_NONE = 0, @@ -1014,9 +1015,9 @@ typedef enum typedef enum { DIRAC_OPEN, /* initialize to default value */ - DIRAC_RECONFIGURE /* HOA3 */ - , + DIRAC_RECONFIGURE, /* HOA3 */ DIRAC_RECONFIGURE_MODE + } DIRAC_CONFIG_FLAG; @@ -1086,7 +1087,7 @@ typedef enum #define IVAS_SPAR_BR_TABLE_LEN 20 -/* TD decorr */ // VE: not all 16CH are currently supported -> t be revisited later +/* TD decorr */ // VE: not all 16CH are currently supported -> to be revisited later enum { IVAS_TD_DECORR_OUT_1CH = 1, @@ -1653,11 +1654,11 @@ typedef enum typedef enum { OTR_TRACKING_NONE = IVAS_ORIENT_TRK_NONE, - OTR_TRACKING_REF_ORIENT = IVAS_ORIENT_TRK_REF, /* track orientation relative to external reference orientation (default: no rotation) */ - OTR_TRACKING_AVG_ORIENT = IVAS_ORIENT_TRK_AVG /* track orientation relative to average orientation */ - , - OTR_TRACKING_REF_VEC = IVAS_ORIENT_TRK_REF_VEC, /* track orientation relative to external reference vector */ + OTR_TRACKING_REF_ORIENT = IVAS_ORIENT_TRK_REF, /* track orientation relative to external reference orientation (default: no rotation) */ + OTR_TRACKING_AVG_ORIENT = IVAS_ORIENT_TRK_AVG, /* track orientation relative to average orientation */ + OTR_TRACKING_REF_VEC = IVAS_ORIENT_TRK_REF_VEC, /* track orientation relative to external reference vector */ OTR_TRACKING_REF_VEC_LEV = IVAS_ORIENT_TRK_REF_VEC_LEV /* track orientation relative to level component of external reference vector */ + } OTR_TRACKING_T; diff --git a/lib_com/ivas_cov_smooth.c b/lib_com/ivas_cov_smooth.c index 7a2439660671bbdf529b1a62cc38dd159809f7ab..9d2d1ca23d6f5a96e6750b04d38cd9af99ee5320 100644 --- a/lib_com/ivas_cov_smooth.c +++ b/lib_com/ivas_cov_smooth.c @@ -39,7 +39,14 @@ #include "wmc_auto.h" #include "prot.h" + +/*-----------------------------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------------------------*/ + #define BAND_SMOOTH_REST_START_IDX ( 2 ) + + /*-----------------------------------------------------------------------------------------* * Function ivas_set_up_cov_smoothing() * @@ -59,15 +66,15 @@ static void ivas_set_up_cov_smoothing( const int32_t ivas_total_brate ) { int16_t j, k; + float update_factor, smooth_fact, *p_bin_to_band; + int16_t active_bins; + if ( ivas_total_brate < IVAS_24k4 ) { for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - float update_factor; - float *p_bin_to_band; update_factor = 0.0f; p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; - int16_t active_bins; active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; for ( k = 0; k < active_bins; k++ ) @@ -76,7 +83,7 @@ static void ivas_set_up_cov_smoothing( } hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; - float smooth_fact; + if ( ivas_total_brate < IVAS_24k4 ) { smooth_fact = 0.5f; @@ -99,7 +106,6 @@ static void ivas_set_up_cov_smoothing( { for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - float update_factor; update_factor = 0.0f; for ( k = 0; k < pFb->fb_bin_to_band.pFb_active_bins_per_band[j]; k++ ) @@ -120,18 +126,18 @@ static void ivas_set_up_cov_smoothing( #endif for ( j = 0; j < pFb->filterbank_num_bands; j++ ) { - float update_factor; - float *p_bin_to_band; - int16_t active_bins; update_factor = 0.0f; p_bin_to_band = pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j]; active_bins = pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j]; + for ( k = 0; k < active_bins; k++ ) { update_factor += p_bin_to_band[k]; } + hCovState->pSmoothing_factor[j] = update_factor / min_pool_size; hCovState->pSmoothing_factor[j] *= ( j + 1 ) * 0.75f; + if ( hCovState->pSmoothing_factor[j] > max_update_rate ) { hCovState->pSmoothing_factor[j] = max_update_rate; @@ -156,9 +162,8 @@ ivas_error ivas_spar_covar_smooth_enc_open( ivas_cov_smooth_state_t **hCovState_out, /* i/o: SPAR Covar. smoothing handle */ const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { ivas_cov_smooth_state_t *hCovState; @@ -259,6 +264,7 @@ static void ivas_compute_smooth_cov( float factor = 0; int16_t sm_b; int16_t non_sm_b_idx; + sm_b = BAND_SMOOTH_REST_START_IDX; assert( end_band <= pFb->filterbank_num_bands ); diff --git a/lib_com/ivas_dirac_com.c b/lib_com/ivas_dirac_com.c index d0b4c5a4db1b3a37719ab466836e24645f3c1e2e..72eacb6809c1947feeb695b94d3ac8906409f919 100644 --- a/lib_com/ivas_dirac_com.c +++ b/lib_com/ivas_dirac_com.c @@ -176,6 +176,7 @@ ivas_error ivas_dirac_config( #ifdef FIX_391_SBA hConfig->dec_param_estim_old = hConfig->dec_param_estim; #endif + if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */ { if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK ) @@ -192,7 +193,6 @@ ivas_error ivas_dirac_config( hConfig->enc_param_start_band = hQMetaData->q_direction[0].cfg.start_band + spar_dirac_split_band; } - if ( sba_mode == SBA_MODE_SPAR ) { hConfig->dec_param_estim = TRUE; @@ -843,12 +843,12 @@ float deindex_azimuth( /*---------------------------------------------------------------- - * deindex_spherical_component() + * ivas_qmetadata_deindex_spherical_component() * * decoding the spherical index for one tile *-----------------------------------------------------------------*/ -void deindex_spherical_component( +void ivas_qmetadata_deindex_spherical_component( const uint16_t sph_idx, /* i : spherical index */ float *az, /* o : decoded azimuth value */ float *el, /* o : decoded elevation value */ diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 2598a43d3001e02c7cdcca3c011fa74bf2f47bb2..bbe02da04610f625c500baa31c36854f5e29e918 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -62,7 +62,7 @@ static ivas_error ivas_fb_mixer_get_window( const int16_t fade_len, const int32_ * Get number of bands from BW index *-----------------------------------------------------------------------------------------*/ -/* !r: number of spectral bands */ +/*! r: number of spectral bands */ int16_t ivas_get_num_bands_from_bw_idx( const int16_t bwidth /* i : audio bandwidth */ ) diff --git a/lib_com/ivas_ism_com.c b/lib_com/ivas_ism_com.c index d14b252fd87b163b23d6e27062b53bed5cf948fc..a668489215cb4c9263175fcf67c41b8fcfeb0dab 100644 --- a/lib_com/ivas_ism_com.c +++ b/lib_com/ivas_ism_com.c @@ -470,8 +470,8 @@ float ism_dequant_meta( * ---------------------------------------------------------------*/ void ivas_param_ism_config( - PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ - const int16_t nchan_obj /* i : number of ISM channels */ + PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ + const int16_t nchan_obj /* i : number of ISM channels */ ) { int16_t i; @@ -502,7 +502,7 @@ void ivas_param_ism_config( * selects the ISM mode base on bitrate and number of objects * ---------------------------------------------------------------*/ -/*! r : ISM format mode */ +/*! r: ISM format mode */ ISM_MODE ivas_ism_mode_select( const int16_t nchan_inp, /* i : number of input objects */ const int32_t ivas_total_brate /* i : IVAS total bitrate */ diff --git a/lib_com/ivas_masa_com.c b/lib_com/ivas_masa_com.c index 7c0955436d02a2fbcadaaa565dd5c5bfd2d967d8..29c5a617b1ada115690b13a0915b2d28d63f93c5 100644 --- a/lib_com/ivas_masa_com.c +++ b/lib_com/ivas_masa_com.c @@ -52,6 +52,18 @@ #define MASA_SMALL_INC_META_BITS 10 +#ifdef HR_METADATA +/*--------------------------------------------------------------- + * Local prototypes + *---------------------------------------------------------------*/ + +static int16_t quantize_theta( float x, const int16_t no_cb, float *xhat ); + +static int16_t quantize_phi_masa( float phi, const int16_t flag_delta, float *phi_hat, const int16_t n ); + +#endif + + /*--------------------------------------------------------------- * ivas_masa_setup() * @@ -310,12 +322,11 @@ void ivas_masa_set_coding_config( *---------------------------------------------------------------*/ void masa_sample_rate_band_correction( - MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ - int16_t *band_mapping, /* i/o: Band mapping used and modified */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ - const int32_t sampling_rate /* i : Sampling rate */ - , - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_CODEC_CONFIG *config, /* i/o: MASA codec config */ + int16_t *band_mapping, /* i/o: Band mapping used and modified */ + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ + const int32_t sampling_rate, /* i : Sampling rate */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ) { uint8_t band, sf; @@ -388,6 +399,7 @@ void masa_sample_rate_band_correction( hQMetaData->twoDirBands[band] = 0; } } + if ( hExtOutMeta != NULL ) { /* in decoder, zero the EXT out MASA meta buffer */ @@ -414,17 +426,17 @@ void masa_sample_rate_band_correction( #ifdef HR_METADATA -/*------------------------------------------------------------------------- - * index_theta_phi_16() +/*--------------------------------------------------------------- + * ivas_qmetadata_index_theta_phi_16() * * - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------*/ /*! r: output index for direction */ -uint16_t index_theta_phi_16( - float *p_theta, /* i/o: input elevation to be indexed */ - float *p_phi, /* i/o: input azimuth to be indexed */ - const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ +uint16_t ivas_qmetadata_index_theta_phi_16( + float *p_theta, /* i/o: input elevation to be indexed */ + float *p_phi, /* i/o: input azimuth to be indexed */ + const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ ) { float abs_theta; @@ -512,14 +524,14 @@ uint16_t index_theta_phi_16( } -/*------------------------------------------------------------------------- - * quantize_phi_masa() +/*--------------------------------------------------------------- + * quantize_theta() * * - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------*/ -/*! r: output index */ -int16_t quantize_theta( +/*! r: index of quantized value */ +static int16_t quantize_theta( float x, /* i : theta value to be quantized */ const int16_t no_cb, /* i : number of codewords */ float *xhat /* o : quantized value */ @@ -561,7 +573,7 @@ int16_t quantize_theta( *------------------------------------------------------------------------*/ /*! r: index azimuth */ -int16_t quantize_phi_masa( +static int16_t quantize_phi_masa( float phi, /* i : azimuth value */ const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ float *phi_hat, /* o : quantized azimuth */ @@ -609,12 +621,12 @@ int16_t quantize_phi_masa( /*------------------------------------------------------------------------- - * deindex_sph_idx() + * ivas_qmetadata_deindex_sph_idx() * * deindex the MASA metadata from the input metadata file *------------------------------------------------------------------------*/ -void deindex_sph_idx( +void ivas_qmetadata_deindex_sph_idx( const uint16_t sphIndex, /* i : Spherical index */ const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ float *theta, /* o : Elevation */ diff --git a/lib_com/ivas_mc_com.c b/lib_com/ivas_mc_com.c index 9bda9d49a4d27edd80a390f1a702c332acf801a0..6e4a632ecadcc53506f5405dc89cee6cf06a4080 100644 --- a/lib_com/ivas_mc_com.c +++ b/lib_com/ivas_mc_com.c @@ -48,7 +48,7 @@ * selects the multichannel mode base on bitrate and LS setup * ---------------------------------------------------------------*/ -/*! r : MC format mode */ +/*! r: MC format mode */ MC_MODE ivas_mc_mode_select( const MC_LS_SETUP mc_ls_setup, /* i : MC loudspeaker setup */ const int32_t total_brate /* i : IVAS total bitrate */ @@ -133,7 +133,7 @@ MC_MODE ivas_mc_mode_select( * returns the number of channels (including the LFE) for a MC LS setup * ---------------------------------------------------------------*/ -/*! r : number of loudspeaker channels */ +/*! r: number of loudspeaker channels */ int16_t ivas_mc_ls_setup_get_num_channels( const MC_LS_SETUP mc_ls_setup /* i : multi channel loudspeaker setup */ ) @@ -173,7 +173,7 @@ int16_t ivas_mc_ls_setup_get_num_channels( * maps output configuration multi channel loudspeaker setup * ---------------------------------------------------------------*/ -/*! r : multi channel loudspeaker setup */ +/*! r: multi channel loudspeaker setup */ MC_LS_SETUP ivas_mc_map_output_config_to_mc_ls_setup( const AUDIO_CONFIG output_config /* i : output audio configuration */ ) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 672b5a7441735223fbdc3befbf75c92c674bcefe..81b7e3f8d7a5b08e3a0fce6cfc591ed71e1ec3ad 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -252,9 +252,9 @@ ivas_error ivas_compute_core_buffers( /*! r: number of clipped samples */ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS - float *synth[], /* i/o: float synthesis signal */ + float *synth[], /* i/o: float synthesis signal */ #else - float synth[][L_FRAME48k], /* i/o: float synthesis signal */ + float synth[][L_FRAME48k], /* i/o: float synthesis signal */ #endif const int16_t output_frame, /* i : output frame length (one channel) */ const int16_t n_channels, /* i : number of output channels */ @@ -263,11 +263,11 @@ uint32_t ivas_syn_output( #ifdef JBM_TSM_ON_TCS void ivas_syn_output_f( - float *synth[], /* i/o: float synthesis signal */ - const int16_t output_frame, /* i : output frame length (one channel) */ - const int16_t n_channels, /* i : number of output channels */ - float *synth_out /* o : integer 16 bits synthesis signal */ - ); + float *synth[], /* i/o: float synthesis signal */ + const int16_t output_frame, /* i : output frame length (one channel) */ + const int16_t n_channels, /* i : number of output channels */ + float *synth_out /* o : integer 16 bits synthesis signal */ +); #endif void ivas_initialize_handles_enc( @@ -312,10 +312,10 @@ ivas_error ivas_dec( ivas_error ivas_dec_setup( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - #ifdef JBM_TSM_ON_TCS +#ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -759,102 +759,107 @@ void dtx_read_padding_bits( const int16_t num_bits ); + #ifdef JBM_TSM_ON_TCS /*----------------------------------------------------------------------------------* * JBM prototypes *----------------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : output synthesis signals */ ); ivas_error ivas_jbm_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const uint16_t nSamplesAsked, /* i : number of samples wanted */ - uint16_t *nSamplesRendered, /* o : number of samples rendered */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - int16_t *data /* o : output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const uint16_t nSamplesAsked, /* i : number of samples wanted */ + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ + int16_t *data /* o : output synthesis signal */ ); ivas_error ivas_jbm_dec_flush_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - uint16_t *nSamplesRendered, /* o : number of samples flushed */ - int16_t *data /* o : rendered samples */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t tc_granularity_new, /* i : new renderer granularity */ + const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ + const AUDIO_CONFIG intern_config_old, /* i : old internal config */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ + const MC_MODE mc_mode_old, /* i : old MC mode */ + const ISM_MODE ism_mode_old, /* i : old ISM mode */ + uint16_t *nSamplesRendered, /* o : number of samples flushed */ + int16_t *data /* o : rendered samples */ ); ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i/o: transport channels/output synthesis signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i/o: transport channels/output synthesis signal */ ); ivas_error ivas_jbm_dec_set_discard_samples( - Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ + Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); void ivas_jbm_dec_get_adapted_linear_interpolator( - const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ - const int16_t interp_length, /* i : length of the interpolator to be created */ - float *interpolator /* o : the interpolator */ + const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */ + const int16_t interp_length, /* i : length of the interpolator to be created */ + float *interpolator /* o : the interpolator */ ); void ivas_jbm_dec_get_adapted_subframes( - const int16_t nCldfbTs, /* i : number of time slots in the current frame */ - int16_t *subframe_nbslots, /* i/o: subframe grid */ - int16_t *nb_subframes /* i/o: number of subframes in the frame */ + const int16_t nCldfbTs, /* i : number of time slots in the current frame */ + int16_t *subframe_nbslots, /* i/o: subframe grid */ + int16_t *nb_subframes /* i/o: number of subframes in the frame */ ); void ivas_jbm_dec_get_md_map( - const int16_t default_len, /* i : default frame length in metadata slots */ - const int16_t len, /* i : length of the modfied frames in metadata slots */ - const int16_t subframe_len, /* i : default length of a subframe */ - const int16_t offset, /* i : current read offset into the md buffer */ - const int16_t buf_len, /* i : length of the metadata buffer */ - int16_t *map /* o : metadata index map */ + const int16_t default_len, /* i : default frame length in metadata slots */ + const int16_t len, /* i : length of the modfied frames in metadata slots */ + const int16_t subframe_len, /* i : default length of a subframe */ + const int16_t offset, /* i : current read offset into the md buffer */ + const int16_t buf_len, /* i : length of the metadata buffer */ + int16_t *map /* o : metadata index map */ ); -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ); /* i : IVAS decoder handle */ +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); -int16_t ivas_jbm_dec_get_render_granularity( /* o : render granularity */ - const RENDERER_TYPE rendererType, /* i : renderer type */ - const int32_t output_Fs /* i : sampling rate */ +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ ); ivas_error ivas_jbm_dec_tc_buffer_open( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const int16_t nchan_transport_jbm, /* i : number of real transport channels */ - const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ - const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ + const int16_t nchan_transport_jbm, /* i : number of real transport channels */ + const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ + const int16_t nchan_full, /* i : number of channels to fully store */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); ivas_error ivas_jbm_dec_tc_buffer_reconfigure( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ - const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ - const int16_t nchan_full, /* i : new number of channels to fully store */ - const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const int16_t nchan_transport_jbm, /* i : new number of real transport channels */ + const int16_t nchan_transport_internal, /* i : new number of totally buffered channels */ + const int16_t nchan_full, /* i : new number of channels to fully store */ + const int16_t n_samples_granularity /* i : new granularity of the renderer/buffer */ ); void ivas_jbm_dec_tc_buffer_close( - DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ + DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif @@ -963,7 +968,7 @@ ivas_error ivas_ism_metadata_dec( ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ int16_t *ism_extended_metadata_flag, /* i/o: Extended metadata active in renderer */ - int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ + int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ ); @@ -1003,8 +1008,7 @@ void ivas_param_ism_stereo_dmx( ); void ivas_param_ism_config( - PARAM_ISM_CONFIG_HANDLE hParamIsm /* i/o: IVAS Param ISM Config Structure */ - , + PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i/o: IVAS Param ISM Config Structure */ const int16_t nchan_ism /* i : number of ISM channels */ ); @@ -1013,13 +1017,12 @@ ivas_error ivas_ism_enc_config( ); ivas_error ivas_ism_dec_config( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - , + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const ISM_MODE last_ism_mode /* i/o: last ISM mode */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change */ - int16_t *data /* o : flushed PCM samples */ + uint16_t *nSamplesRendered, /* o : number of samples flushed on renderer change*/ + int16_t *data /* o : flushed PCM samples */ #endif ); @@ -1039,21 +1042,21 @@ void ivas_param_ism_dec( #ifdef JBM_TSM_ON_TCS void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -1197,8 +1200,8 @@ float stereo_dft_enc_synthesize( void stereo_dft_enc_process( CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ const int16_t input_frame /* i : input frame length */ ); @@ -2117,8 +2120,8 @@ void deindex_lvq_SHB( void stereo_td_itd_mdct_stereo( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ const int16_t input_frame /* i : frame length */ ); @@ -3114,34 +3117,27 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( const int16_t bits_sp_coh ); -void deindex_sph_idx( +int16_t ivas_qmetadata_dec_decode_hr_384_512( + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ + uint16_t *bitstream, /* i : bitstream */ + int16_t *index, /* i/o: bitstream position */ + const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ + const int16_t bits_sph_idx, + const int16_t bits_sp_coh +); + +void ivas_qmetadata_deindex_sph_idx( const uint16_t sphIndex, /* i : Spherical index */ const SPHERICAL_GRID_DATA *gridData, /* i : Prepared spherical grid */ float *theta, /* o : Elevation */ float *phi /* o : Azimuth */ ); -/*! r: output index for direction */ -uint16_t index_theta_phi_16( +uint16_t ivas_qmetadata_index_theta_phi_16( float * p_theta, /* i/o: input elevation to be indexed */ float * p_phi, /* i/o: input azimuth to be indexed */ const SPHERICAL_GRID_DATA *gridData /* i : generated grid data */ ); - -/*! r: output index */ -int16_t quantize_theta( - float x, /* i : theta value to be quantized */ - const int16_t no_cb, /* i : number of codewords */ - float *xhat /* o : quantized value */ -); - -/*! r: index azimuth */ -int16_t quantize_phi_masa( - float phi, /* i : azimuth value */ - const int16_t flag_delta, /* i : flag indicating if the azimuth codebook is translated or not */ - float *phi_hat, /* o : quantized azimuth */ - const int16_t n /* i : azimuth codebook size */ -); #endif void reset_metadata_spatial( @@ -3174,18 +3170,6 @@ int16_t ivas_qmetadata_dec_decode( #endif ); -#ifdef HR_METADATA -/*! r: number of bits read */ -int16_t ivas_qmetadata_dec_decode_hr_384_512( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index, /* i/o: bitstream position */ - const SPHERICAL_GRID_DATA *sph_grid16, /* i : spherical grid for deindexing */ - const int16_t bits_sph_idx, - const int16_t bits_sp_coh -); -#endif - /*! r: number of bits read */ int16_t ivas_qmetadata_dec_sid_decode( IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */ @@ -3351,7 +3335,7 @@ float deindex_azimuth( const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ); -void deindex_spherical_component( +void ivas_qmetadata_deindex_spherical_component( const uint16_t sph_idx, /* i : spherical index */ float *az, /* o : decoded azimuth value */ float *el, /* o : decoded elevation value */ @@ -3444,12 +3428,12 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS ivas_error ivas_sba_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering, /* i : number of samples provided */ - float *data[] /* i : transport channel samples */ - ); + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering, /* i : number of samples provided */ + float *data[] /* i : transport channel samples */ +); #endif void ivas_init_dec_get_num_cldfb_instances( @@ -3494,15 +3478,15 @@ int16_t ivas_sba_get_nchan_metadata( #ifdef HODIRAC void ivas_sba_get_spar_hoa_ch_ind( - const int16_t num_md_chs, /* i : number of MD channels */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t num_md_chs, /* i : number of MD channels */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ int16_t HOA_md_ind[IVAS_SPAR_MAX_CH] ); /*! r: flag indicating to code SPAR HOA MD for all bands */ void ivas_sba_get_spar_hoa_md_flag( - const int16_t sba_order, /* i : Ambisonic (SBA) order */ - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ int16_t *spar_hoa_md_flag, int16_t *spar_hoa_dirac2spar_md_flag ); @@ -3527,6 +3511,7 @@ void ivas_sba_getTCs( const int16_t input_frame /* i : frame length */ ); +/*! r: number of remapped SBA TCs */ int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ @@ -3552,8 +3537,9 @@ int16_t ivas_get_hodirac_flag( ); #endif +/*! r: SBA DirAC stereo flag */ int16_t ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ); void ivas_sba_dirac_stereo_smooth_parameters( @@ -3673,31 +3659,32 @@ void ivas_dirac_dec_read_BS( #ifdef JBM_TSM_ON_TCS void generate_masking_noise_lb_dirac( - HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ - const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ - const int16_t cna_flag /* i : CNA flag for LB and HB */ + HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ + float *tdBuffer, /* i/o: time-domain signal, if NULL no LB-CNA */ + const int16_t nCldfbTs, /* i : number of CLDFB slots that will be rendered */ + const int16_t cna_flag /* i : CNA flag for LB and HB */ ); void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ); + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +); void ivas_dirac_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ - const int16_t nchan_transport /* i : number of transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + const int16_t nchan_transport /* i : number of transport channels */ ); #endif #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -3708,9 +3695,9 @@ void ivas_dirac_dec_render_sf( #endif Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + float *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ #else - float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ + float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ #endif const int16_t nchan_transport, /* i : number of transport channels */ float *pppQMfFrame_ts_re[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX], @@ -3823,7 +3810,7 @@ ivas_error ivas_dirac_dec_output_synthesis_open( const int16_t nchan_transport, /* i : number of transport channels */ const int32_t output_Fs /* i : output sampling rate */ #ifdef HODIRAC - , + , const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ #endif ); @@ -3856,7 +3843,7 @@ void ivas_dirac_dec_output_synthesis_process_slot( const float *p_Rmat, /* i : rotation matrix */ const VBAP_HANDLE hVBAPdata, /* i : VBAP structure */ const IVAS_OUTPUT_SETUP hOutSetup, /* i : output setup structure */ - const int16_t nchan_transport /* i : number of transport channels */ + const int16_t nchan_transport /* i : number of transport channels */ #if !defined( HODIRAC ) || defined( JBM_TSM_ON_TCS ) , const int16_t index_slot @@ -3968,24 +3955,24 @@ void calculate_hodirac_sector_parameters( #ifdef MC_PARAMUPMIX_MODE void ivas_mc_paramupmix_enc( - Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ - BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ - float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ - const int16_t input_frame /* i : input frame length */ + Encoder_Struct *st_ivas, /* i/o: IVAS Encoder handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: IVAS Metadata bitstream handle */ + float data_f[][L_FRAME48k], /* i/o: input: CICP6, CICP12, CICP14, CICP16 or CICP19 MC data */ + const int16_t input_frame /* i : input frame length */ ); ivas_error ivas_mc_paramupmix_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ + Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ ); void ivas_mc_paramupmix_enc_close( - MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ + MC_PARAMUPMIX_ENC_HANDLE *hMCParamUpmix, /* i/o: MC Param-Upmix encoder handle */ const int32_t sampling_rate ); void ivas_mc_paramupmix_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output_f[][L_FRAME48k] /* i/o: synthesized core-coder transport channels/DirAC output */ ); int16_t ivas_mc_paramupmix_getNumTransportChannels( @@ -3993,19 +3980,19 @@ int16_t ivas_mc_paramupmix_getNumTransportChannels( ); ivas_error ivas_mc_paramupmix_dec_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); void ivas_mc_paramupmix_dec_close( - MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ + MC_PARAMUPMIX_DEC_HANDLE *hMCParamUpmix_out /* i/o: Parametric MC decoder handle */ ); void ivas_mc_paramupmix_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ - int16_t *nb_bits /* o : number of bits written */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + Decoder_State *st, /* i/o: decoder state structure */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix, /* i/o: decoder MC Param-Upmix handle */ + int16_t *nb_bits /* o : number of bits written */ ); #endif @@ -4319,8 +4306,8 @@ void FdCngDecodeDiracMDCTStereoSID( *----------------------------------------------------------------------------------*/ ivas_error ivas_spar_enc_open( - Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */ - ,const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ + Encoder_Struct *st_ivas, /* i/o: IVAS encoder handle */ + const int16_t spar_reconfig_flag /* i : SPAR reconfiguration flag */ ); void ivas_spar_enc_close( @@ -4495,7 +4482,7 @@ int16_t ivas_get_sba_num_TCs( void ivas_spar_set_bitrate_config( ivas_spar_md_com_cfg *pSpar_md_cfg, /* i/o: SPAR MD config. handle */ const int16_t table_idx, /* i : config. table index */ - const int16_t num_bands /* i : number of bands */ + const int16_t num_bands /* i : number of bands */ ); void ivas_spar_bitrate_dist( @@ -4557,46 +4544,46 @@ int16_t ivas_is_res_channel( #ifdef JBM_TSM_ON_TCS void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int16_t output_frame /* i : output frame length */ ); void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ ); void ivas_spar_dec_set_render_params( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t n_cldfb_slots /* i : number of cldfb slots in this frame */ ); void ivas_spar_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); ivas_error ivas_sba_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nCldfbSlots, /* i : number of CLDFB slots */ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nCldfbSlots, /* i : number of CLDFB slots */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ); void ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ); void ivas_spar_dec_upmixer_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float *output[], /* o : output audio channels */ - const int16_t nchan_internal /* i : number of internal channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float *output[], /* o : output audio channels */ + const int16_t nchan_internal /* i : number of internal channels */ ); #endif @@ -4626,9 +4613,8 @@ ivas_error ivas_spar_md_enc_process( BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const int16_t dtx_vad, const int16_t nchan_inp, - const int16_t sba_order /* i : Ambisonic (SBA) order */ - , - float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i : prior mixer_matrix */ + const int16_t sba_order, /* i : Ambisonic (SBA) order */ + float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i : prior mixer_matrix */ ); void ivas_compute_spar_params( @@ -4685,8 +4671,7 @@ void ivas_get_spar_md_from_dirac( const int16_t end_band, const int16_t order, const int16_t dtx_vad, - float Wscale_d[IVAS_MAX_NUM_BANDS] - , + float Wscale_d[IVAS_MAX_NUM_BANDS], const uint8_t useLowerRes, const int16_t active_w_vlbr ); @@ -4701,7 +4686,7 @@ ivas_error ivas_spar_md_dec_open( ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */ const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */ const int16_t num_channels, /* i : number of internal channels */ - const int16_t sba_order, /* i : SBA order */ + const int16_t sba_order, /* i : SBA order */ const int16_t sid_format /* i : SID format */ ); @@ -4737,9 +4722,8 @@ void ivas_spar_to_dirac( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out /* i : number of output bands */ - , - const int16_t bw /* i : band joining factor */ + const int16_t num_bands_out, /* i : number of output bands */ + const int16_t bw /* i : band joining factor */ ); void ivas_spar_update_md_hist( @@ -4780,9 +4764,8 @@ ivas_error ivas_spar_covar_enc_open( ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); void ivas_spar_covar_enc_close( @@ -4812,9 +4795,8 @@ ivas_error ivas_spar_covar_smooth_enc_open( ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */ const ivas_cov_smooth_cfg_t *cov_smooth_cfg, /* i : SPAR config. handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); void ivas_spar_covar_smooth_enc_close( @@ -5207,7 +5189,7 @@ void masa_sample_rate_band_correction( int16_t *band_mapping, /* i/o: Band mapping used and modified */ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: QMetadata structure for modification */ const int32_t sampling_rate, /* i : sampling rate */ - MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ + MASA_DECODER_EXT_OUT_META_HANDLE hExtOutMeta /* i/o: MASA decoder metadata ext out buffer */ ); void invdct4_transform( @@ -5286,9 +5268,10 @@ void ivas_binaural_cldfb( #ifdef JBM_TSM_ON_TCS void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + ); #endif @@ -5328,7 +5311,7 @@ ivas_error ivas_ism_renderer_open( void ivas_ism_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output_f[], /* i/o: core-coder transport channels/object output */ + float *output_f[], /* i/o: core-coder transport channels/object output */ #else float output_f[][L_FRAME48k], /* i/o: core-coder transport channels/object output */ #endif @@ -5337,9 +5320,9 @@ void ivas_ism_render( #ifdef JBM_TSM_ON_TCS void ivas_ism_render_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t n_samples_to_render /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: core-coder transport channels/object output */ + const int16_t n_samples_to_render /* i : output frame length per channel */ ); #endif @@ -5365,9 +5348,9 @@ void ivas_mc2sba( void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS - float *buffer_td[], /* i/o: TD signal buffers */ + float *buffer_td[], /* i/o: TD signal buffers */ #else - float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ + float buffer_td[][L_FRAME48k], /* i/o: TD signal buffers */ #endif ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ const ISM_METADATA_HANDLE hIsmMetaData[], /* i : object metadata */ @@ -5378,15 +5361,17 @@ void ivas_ism2sba( #ifdef JBM_TSM_ON_TCS void ivas_ism2sba_sf( - float *buffer_in[], /* i : TC buffer */ - float *buffer_out[], /* o : TD signal buffers */ - ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ - const int16_t num_objects, /* i : number of objects */ - const int16_t n_samples_to_render, /* i : output frame length per channel */ - const int16_t offset, /* i : offset for the interpolatr */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + float *buffer_in[], /* i : TC buffer */ + float *buffer_out[], /* o : TD signal buffers */ + ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ + const int16_t num_objects, /* i : number of objects */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int16_t offset, /* i : offset for the interpolatr */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ); #endif + + /*----------------------------------------------------------------------------------* * Amplitude Panning VBAP prototypes *----------------------------------------------------------------------------------*/ @@ -5422,6 +5407,7 @@ void v_sort_ind( const int16_t len /* i : vector length */ ); + /*----------------------------------------------------------------------------------* * LS Renderer prototypes *----------------------------------------------------------------------------------*/ @@ -5442,10 +5428,10 @@ void ivas_ls_setup_conversion( #endif const int16_t output_frame, /* i : frame length */ #ifdef JBM_TSM_ON_TCS - float *input[], /* i : LS input/output synthesis signal */ - float *output[] /* i/o: LS input/output synthesis signal */ + float *input[], /* i : LS input/output synthesis signal */ + float *output[] /* i/o: LS input/output synthesis signal */ #else - float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ + float output[][L_FRAME48k] /* i/o: LS input/output synthesis signal */ #endif ); @@ -5462,7 +5448,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, /* i : number of time slots to process */ + const int16_t num_timeslots, /* i : number of time slots to process */ #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ @@ -5695,18 +5681,18 @@ ivas_error ivas_td_binaural_open( ivas_error ivas_td_binaural_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else - float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif const int16_t output_frame /* i : output frame length */ ); #ifdef JBM_TSM_ON_TCS -void ObjRenderIVASSubframe( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t output_frame /* i : output frame length */ +ivas_error ivas_td_binaural_renderer_sf( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ); #endif diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index e0ccc3005b93e08c2c645fc2feebd632b82bb416..2212841f9593babfd270201e95a9a88e7fbaeef3 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -890,13 +890,12 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = /* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */ /* preferred tuning (3.2/4.9kbps) with/out TDD */ - { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, - { { 10000, 8300, 13150 } }, + { 13200, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 10000, 8300, 13150 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, - { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, - { { 13200, 11500, 16350 } }, - { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, + { 16400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0, { { 13200, 11500, 16350 } }, + { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, + { 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } }, { { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 }, @@ -5622,7 +5621,12 @@ const int16_t ivas_num_active_bands[FB - WB + 1] = IVAS_16K_12BANDS_ACTIVE_BANDS, IVAS_FB_BANDS_12, IVAS_FB_BANDS_12 }; + #ifdef SNS_MSVQ +/*------------------------------------------------------------------------------------------* + * 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 }; @@ -6201,7 +6205,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 }; #else /* codebooks trained for no adaptive tilt */ -const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { +const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = +{ -3.24881770f, -1.99497051f, -0.04725080f, 1.02318508f, 1.51589220f, 1.44649178f, 1.27858728f, 1.15137095f, 0.98029724f, 0.69167126f, 0.33414576f, 0.11759238f, -0.27510520f, -0.63610342f, -1.05394049f, -1.28304590f, -3.24340413f, -4.15075396f, -2.86242117f, -1.11561919f, 1.12899983f, 1.98341478f, 0.56638511f, -0.05841474f, -0.14875192f, 0.31098029f, 1.87121037f, 0.91347082f, 1.02548459f, 1.98227488f, 1.30278860f, 0.49435585f, 1.23065598f, 0.87793778f, 0.28294330f, 0.02972172f, 0.42574775f, 0.83386805f, 0.95758438f, 1.21299710f, 1.15042593f, 1.00234403f, 0.60083169f, -0.06520030f, -1.53941239f, -2.26801783f, -2.42116011f, -2.31126766f, @@ -6331,7 +6336,9 @@ const float ivas_sns_cdbk_tcx20_stage1[ 128 * 16 ] = { 2.58466208f, 2.01534437f, 1.28252767f, 0.44865967f, -0.33100837f, -0.81011259f, -1.06701187f, -1.12743988f, -1.21505758f, -0.99337144f, -0.66853937f, -0.46093443f, -0.22132067f, 0.00996599f, 0.24481197f, 0.30882455f, -0.62864502f, 1.04984327f, 1.56877053f, 0.77975000f, 0.01037804f, 0.92352492f, 1.12297462f, 0.76284403f, -0.16106015f, -0.21398417f, -0.62673537f, -1.68917053f, -1.60748063f, -0.79116243f, -0.06290217f, -0.43694470f }; -const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = +{ -0.14487037f, 0.32346300f, 0.29798679f, -0.52393127f, -0.25671033f, 0.85717754f, -0.09030235f, -0.41110330f, -0.32938564f, -0.36580017f, -0.13142117f, -0.06404494f, 0.10671000f, 0.18731030f, 0.26606878f, 0.27885301f, 0.52707061f, 0.35016312f, 0.54090507f, 0.82023896f, 0.46675870f, -0.60012182f, -0.76783382f, -0.39198749f, -0.17916696f, -0.17307722f, -0.10507731f, -0.09327542f, -0.12176361f, -0.12715624f, -0.11980175f, -0.02587481f, -0.71420988f, -0.65927011f, -0.35007906f, -0.01478187f, 0.15375095f, 0.11149616f, 0.08819131f, 0.11537168f, 0.18041243f, 0.28846009f, 0.61920238f, 0.78709602f, 0.49945852f, -0.03863360f, -0.42339912f, -0.64306599f, @@ -6397,7 +6404,9 @@ const float ivas_sns_cdbk_tcx20_stage2[ 64 * 16 ] = { -0.42321919f, 0.85086362f, 0.60159420f, 0.08633772f, -0.28445894f, -0.22512885f, 0.23909004f, 0.20046697f, 0.01484137f, -0.11652413f, -0.12017169f, -0.26922922f, -0.26311675f, -0.18921524f, -0.06712212f, -0.03500777f, 0.58209071f, -0.26533411f, -0.20240535f, 0.27577532f, 0.65478295f, 0.66491349f, 0.41026256f, 0.22123940f, 0.15813271f, 0.07048989f, -0.03133192f, -0.19389440f, -0.34519672f, -0.53017394f, -0.73238212f, -0.73696843f }; -const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = +{ -0.08443224f, -0.18703635f, -0.02297765f, 0.35108322f, -0.47365404f, 0.60080101f, -0.14560352f, 0.01413276f, 0.01222370f, 0.01369841f, 0.05509108f, 0.03233707f, 0.01187713f, -0.08225931f, -0.08910713f, -0.00617424f, -0.45134081f, -0.18205893f, -0.21886586f, -0.27082278f, -0.18872267f, -0.08438255f, 0.11808124f, 0.11472340f, 0.08049694f, 0.05868671f, 0.08856118f, 0.10686811f, 0.14792971f, 0.16522330f, 0.21823435f, 0.29738868f, -0.11328915f, 0.10130429f, -0.14943437f, 0.15645630f, 0.63935450f, 0.37821704f, -0.21310801f, -0.24867988f, -0.01659672f, 0.03328198f, -0.08180066f, -0.05657044f, 0.10906149f, 0.03196869f, -0.22137928f, -0.34878580f, @@ -6431,7 +6440,9 @@ const float ivas_sns_cdbk_tcx20_stage3[ 32 * 16 ] = { 0.19660049f, -0.03582845f, -0.21224511f, -0.09633821f, 0.02140122f, 0.06690902f, 0.14753796f, 0.23491232f, 0.40075372f, 0.33318442f, -0.21453422f, -0.44835823f, -0.31995723f, -0.14770359f, -0.02720588f, 0.10087175f, 0.22313452f, 0.23174662f, 0.13588360f, -0.01979092f, -0.17483898f, -0.36387601f, -0.35104947f, -0.34545228f, -0.17072761f, 0.01654692f, 0.12560464f, 0.14070090f, 0.18025650f, 0.13082045f, 0.10588357f, 0.13515746f }; -const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx20_stage4[ 32 * 16 ] = +{ -0.01178932f, -0.08216325f, 0.00009975f, 0.07861932f, 0.10639093f, 0.10607783f, -0.11972309f, 0.01910820f, -0.05635505f, 0.02765448f, -0.08840101f, -0.09623400f, 0.34917350f, -0.19835894f, -0.46938213f, 0.43528268f, -0.08636054f, 0.13923351f, -0.15932705f, -0.10849641f, -0.02303533f, -0.23968519f, -0.02192257f, 0.50128910f, 0.27139459f, -0.07262939f, -0.06622134f, -0.01073419f, -0.04308095f, -0.05629457f, -0.03175020f, 0.00762044f, 0.24815560f, 0.14657944f, 0.07172491f, 0.02302382f, 0.01991109f, -0.10204469f, -0.24960876f, -0.07085594f, 0.12223419f, 0.06999865f, 0.10986748f, 0.13492392f, 0.05865008f, -0.10366906f, -0.23987720f, -0.23901358f, @@ -6468,7 +6479,8 @@ 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 float ivas_sns_means_tcx20[M] = { +const float ivas_sns_means_tcx20[M] = +{ 0.9155f , 1.2408f , 1.0050f , 0.5846f, 0.2472f , 0.1902f , 0.0984f , 0.1039f, -0.0139f , -0.0856f , -0.4157f , -0.6148f, @@ -6478,7 +6490,8 @@ const float ivas_sns_means_tcx20[M] = { 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 ] = +{ 0.06343891f, -0.00651786f, -0.56994713f, -0.98772396f, -1.35099293f, -1.24848646f, -1.20301995f, -0.81089507f, -0.06563095f, 1.11147581f, 1.73933309f, 1.65859611f, 1.26237806f, 0.68028141f, 0.12449909f, -0.39678907f, -1.34007175f, -1.50272189f, -2.07958791f, -2.38322761f, -2.22156614f, -1.96435669f, -1.68760863f, -1.23664935f, -0.28772180f, 0.87765579f, 1.83822720f, 1.95281398f, 2.33671266f, 2.76119687f, 2.75790597f, 2.17899850f, -0.51450332f, 0.69692757f, 1.90898730f, 1.89179379f, 1.41350404f, 0.03604267f, 0.02251128f, -1.04270018f, -0.97981089f, -0.36225564f, 0.14171617f, -0.32050715f, -0.56272675f, -0.38710633f, -0.74842203f, -1.19345103f, @@ -6608,7 +6621,9 @@ const float ivas_sns_cdbk_tcx10_stage1[ 128 * 16 ] = { 2.30575156f, 2.37005513f, 1.37776397f, 0.78509487f, 0.18022242f, -0.13093354f, 0.22126477f, -0.11444642f, -0.35716968f, -0.59492665f, -0.35765935f, -0.44655201f, -1.03213345f, -1.27074059f, -1.44000075f, -1.49558947f, -1.00874079f, -1.64011865f, -1.86084729f, -1.06805908f, 0.07222945f, 1.36179475f, 1.87160360f, 1.76248472f, 1.52374330f, 1.04119855f, 0.73448166f, 0.13768018f, -0.49711929f, -0.73696841f, -0.89885406f, -0.79450886f }; -const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { + +const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = +{ 0.30627323f, 0.48836579f, -0.02716944f, -0.47680077f, -0.52992614f, -0.25467720f, -0.13298242f, -0.14929291f, -0.14808149f, 0.08665801f, 0.28830653f, 0.27526330f, 0.09942358f, -0.01755061f, 0.03315580f, 0.15903469f, 0.40931263f, -0.04412117f, -0.08826419f, 0.38716891f, 0.51515595f, 0.42227845f, 0.34963425f, 0.26800736f, 0.03770000f, -0.19967080f, -0.31044249f, -0.32623294f, -0.38445978f, -0.38085950f, -0.38590829f, -0.26929836f, -0.16037262f, -0.37557223f, -0.41481262f, -0.12384627f, 0.25702942f, 0.29593484f, 0.04534352f, -0.04349856f, -0.11439445f, -0.20184919f, 0.03250628f, 0.58473249f, 1.07468564f, 0.31789485f, -0.43837532f, -0.73540590f, @@ -6642,7 +6657,9 @@ const float ivas_sns_cdbk_tcx10_stage2[ 32 * 16 ] = { -0.78143464f, 0.05520810f, 0.09851993f, -0.35088396f, -0.29183273f, 0.13535467f, 0.10630173f, -0.35151176f, -0.27502696f, 0.15923208f, 0.34325564f, 0.26263384f, 0.39924614f, 0.42088604f, 0.20935571f, -0.13930422f, -0.20363163f, -0.21557857f, -0.16300691f, -0.04183005f, -0.11100316f, -0.05771045f, 0.03898740f, 0.01316220f, 0.17362802f, 0.74914331f, 0.94477958f, 0.44778038f, -0.09421183f, -0.32736334f, -0.50631884f, -0.64682642f }; -const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { + +const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = +{ 0.15213764f, -0.12778955f, 0.09362990f, -0.08343056f, -0.25379718f, 0.12518895f, 0.29943288f, -0.09857322f, -0.34816031f, -0.24349585f, -0.11266650f, -0.05996015f, 0.03254247f, 0.15532134f, 0.23410563f, 0.23551447f, -0.16242282f, -0.11097776f, -0.31747514f, -0.25628076f, 0.13836003f, 0.29861681f, 0.10506779f, 0.11734717f, 0.26608658f, 0.05454060f, -0.14603348f, -0.19239843f, 0.04173306f, 0.20966631f, 0.07432020f, -0.12015035f, -0.05086737f, 0.14763099f, -0.10027459f, -0.32093478f, -0.17515530f, -0.18641303f, -0.27141947f, -0.07787662f, 0.00378069f, -0.04285463f, 0.10140687f, 0.34974771f, 0.30832793f, 0.10107726f, 0.07691200f, 0.13691240f, @@ -6655,11 +6672,12 @@ const float ivas_sns_cdbk_tcx10_stage3[ 8 * 16 ] = { const float *const ivas_sns_cdbks_tcx10[SNS_MSVQ_NSTAGES_TCX10] = { ivas_sns_cdbk_tcx10_stage1, ivas_sns_cdbk_tcx10_stage2, ivas_sns_cdbk_tcx10_stage3}; -const float ivas_sns_means_tcx10[M] = { - 0.9510f , 1.1892f , 0.8969f , 0.3467f, - 0.1347f , 0.1074f , 0.0504f , -0.0790f, - -0.1305f , -0.3713f , -0.5611f , -0.5757f, - -0.4801f , -0.4108f , -0.4564f , -0.6112f +const float ivas_sns_means_tcx10[M] = +{ + 0.9510f, 1.1892f, 0.8969f, 0.3467f, + 0.1347f, 0.1074f, 0.0504f, -0.0790f, + -0.1305f, -0.3713f, -0.5611f, -0.5757f, + -0.4801f, -0.4108f, -0.4564f, -0.6112f }; const int16_t ivas_sns_cdbks_side_tcx20_levels[SNS_MSVQ_NSTAGES_SIDE] = { 32, 32 }; @@ -6667,14 +6685,16 @@ 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_means_side_tcx20[M] = { - -0.0181f , 0.0044f , 0.0133f , 0.0096f, - 0.0073f , 0.0038f , 0.0058f , 0.0015f, - -0.0046f , -0.0096f , -0.0099f , -0.0173f, - -0.0075f , 0.0049f , 0.0023f , 0.0141f +const float ivas_sns_means_side_tcx20[M] = +{ + -0.0181f, 0.0044f, 0.0133f, 0.0096f, + 0.0073f, 0.0038f, 0.0058f, 0.0015f, + -0.0046f, -0.0096f, -0.0099f, -0.0173f, + -0.0075f, 0.0049f, 0.0023f, 0.0141f }; -const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = +{ -0.09561560f, -0.07036320f, 0.02878750f, 0.03511974f, 0.17132389f, -0.03138941f, -0.33178799f, -0.21216198f, -0.04445341f, 0.02221417f, 0.02283919f, 0.03233147f, 0.08941267f, 0.12190493f, 0.12476806f, 0.13706984f, 0.00109929f, 0.08875231f, 0.22238215f, 0.21457590f, 0.10015343f, 0.04638508f, 0.03393346f, -0.00874452f, -0.04376851f, -0.07742100f, -0.07534945f, -0.10337673f, -0.10407952f, -0.11112585f, -0.09133646f, -0.09207950f, -0.24818594f, 0.26921203f, 0.44107852f, 0.17248048f, 0.64417785f, 0.17680036f, 0.13990282f, -0.00956079f, 0.26766161f, -0.03617849f, -0.51006953f, -0.14559280f, 0.04585566f, -0.32296828f, -0.43440915f, -0.45020472f, @@ -6709,7 +6729,8 @@ const float ivas_sns_cdbks_side_tcx20_stage1[ 32 * 16 ] = { -0.17764482f, -0.15058551f, -0.12627503f, -0.06547272f, -0.05935809f, -0.01277874f, 0.01723090f, -0.00829920f, -0.02788840f, 0.01142219f, 0.05531784f, 0.04254613f, 0.04730144f, 0.07050022f, 0.15526930f, 0.22871460f }; -const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx20_stage2[ 32 * 16 ] = +{ -0.01387178f, 0.00066194f, 0.01705500f, 0.00585076f, 0.05625865f, -0.08189174f, -0.29272907f, 0.00394582f, 0.14068978f, 0.03888049f, 0.01046905f, 0.03828706f, 0.04214951f, 0.02083198f, 0.00583650f, 0.00757601f, -0.07101791f, -0.10250166f, 0.03818920f, 0.09162373f, 0.11895681f, 0.13465195f, 0.05088923f, -0.11144198f, -0.13846971f, -0.20720284f, -0.25737659f, -0.15071919f, 0.03249921f, 0.08124332f, 0.17587328f, 0.31480317f, 0.07163217f, 0.02904662f, 0.01959293f, 0.00805967f, 0.02343380f, 0.02069451f, 0.03232257f, 0.02206815f, 0.03462995f, 0.01790113f, -0.03778174f, -0.14048245f, -0.21681559f, -0.11035045f, 0.05755451f, 0.16849432f, @@ -6746,14 +6767,16 @@ 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_means_side_tcx10[M] = { - -0.0085f , 0.0070f , 0.0074f , 0.0045f, - -0.0038f , 0.0071f , 0.0040f , -0.0068f, - -0.0104f , -0.0095f , -0.0259f , -0.0163f, - 0.0127f , 0.0087f , 0.0036f , 0.0262f +const float ivas_sns_means_side_tcx10[M] = +{ + -0.0085f, 0.0070f, 0.0074f, 0.0045f, + -0.0038f, 0.0071f, 0.0040f, -0.0068f, + -0.0104f, -0.0095f, -0.0259f, -0.0163f, + 0.0127f, 0.0087f, 0.0036f, 0.0262f }; -const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = { +const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = +{ -0.23085418f, -0.21005449f, -0.18570241f, -0.13606880f, -0.11948469f, -0.10308038f, -0.11104958f, -0.15882089f, -0.13896854f, -0.06621316f, 0.05217852f, 0.11795393f, 0.15762859f, 0.26837024f, 0.37542593f, 0.48873907f, 0.13745600f, 0.20131847f, 0.22182278f, 0.29526068f, 0.24656821f, 0.13757111f, 0.07460669f, 0.03134436f, -0.06561883f, -0.17480962f, -0.24070771f, -0.31627147f, -0.28865063f, -0.14849001f, -0.03399112f, -0.07740884f, -0.13299250f, -0.14002491f, -0.11936499f, -0.04179630f, -0.03438902f, 0.04431344f, 0.06951552f, 0.01403797f, 0.05531963f, -0.01394528f, -0.09745552f, 0.00448586f, 0.26823524f, 0.23321159f, 0.06675539f, -0.17590634f, @@ -6788,7 +6811,8 @@ const float ivas_sns_cdbks_side_tcx10_stage1[ 32 * 16 ] = { 0.26197082f, 0.21849905f, 0.21673972f, 0.16654799f, 0.18547759f, 0.16177425f, 0.16111117f, 0.20927596f, 0.18073438f, 0.03535012f, -0.14032550f, -0.22486416f, -0.33259461f, -0.40957544f, -0.38613800f, -0.30398287f }; -const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = { +const float ivas_sns_cdbks_side_tcx10_stage2[ 8 * 16 ] = +{ -0.13993218f, -0.02453874f, 0.12672628f, 0.02785695f, 0.06681568f, 0.12811808f, 0.07492973f, -0.01977524f, -0.05822869f, -0.07547464f, -0.06553072f, -0.05473233f, -0.04357434f, -0.00634272f, 0.03406826f, 0.02961442f, -0.06711216f, -0.11444162f, -0.09789788f, -0.09123304f, -0.12190348f, -0.00995424f, 0.10989921f, 0.11555575f, 0.06002452f, 0.03801973f, 0.02047622f, 0.01721280f, 0.02414692f, 0.02829613f, 0.03827912f, 0.05063187f, 0.05523005f, 0.03052467f, 0.03910551f, 0.05802321f, 0.02158461f, 0.03249705f, 0.04015871f, -0.00878163f, -0.05597684f, -0.02391125f, 0.03722223f, 0.06349026f, 0.02718346f, -0.07380323f, -0.12743287f, -0.11511406f, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index fd8bd41a3034cbf94686cf6f51c0896dbef503a2..4a4de150ca00cb52537cf2bf2fb295e8e7b81b2c 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -435,6 +435,7 @@ extern const int16_t ivas_num_active_bands[FB - WB + 1]; /*------------------------------------------------------------------------------------------* * SNS MSVQ codebooks and means *------------------------------------------------------------------------------------------*/ + #ifdef FIX_445_SNS_BUGFIXES extern const int16_t ivas_sns_cdbks_tcx20_levels[]; extern const int16_t ivas_sns_cdbks_tcx20_bits[]; diff --git a/lib_com/ivas_td_decorr.c b/lib_com/ivas_td_decorr.c index 9a08c06f6a3fd08d11edc45bdc83253e07324bef..7714915177a5415f266a34d9abd993834bbe745b 100644 --- a/lib_com/ivas_td_decorr.c +++ b/lib_com/ivas_td_decorr.c @@ -480,7 +480,7 @@ static void ivas_td_decorr_APD_sections( void ivas_td_decorr_process( ivas_td_decorr_state_t *hTdDecorr, /* i/o: SPAR Covar. decoder handle */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], + float *pcm_in[], /* i : input audio channels */ #else float pcm_in[][L_FRAME48k], /* i : input audio channels */ #endif diff --git a/lib_com/ivas_transient_det.c b/lib_com/ivas_transient_det.c index 1e8f53c7ca5a1d17b7d49501169deaf7634914a6..2962a91f9fb15638b4fe9156d9f7d9469ef30b39 100644 --- a/lib_com/ivas_transient_det.c +++ b/lib_com/ivas_transient_det.c @@ -211,11 +211,12 @@ void ivas_transient_det_close( * * Transient detection process call *-----------------------------------------------------------------------------------------*/ + void ivas_transient_det_process( ivas_trans_det_state_t *hTranDet, /* i/o: SPAR TD handle */ float *pIn_pcm, /* i : input audio channels */ const int16_t frame_len, /* i : frame length in samples */ - int16_t transient_det[2] /* o: transient det outputs */ + int16_t transient_det[2] /* o : transient det outputs */ ) { float in_duck_gain[L_FRAME48k]; diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 02a735e80c0baf8914c90526bd7fde29581f5dd8..40280a43c9365e82ab92c6ca0bbc6697fa00c9ac 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -2027,13 +2027,20 @@ int16_t tcxlpc_get_cdk( return cdk; } + +/*--------------------------------------------------------------------------* + * dec_FDCNG_MSVQ_stage1() + * + * + *--------------------------------------------------------------------------*/ + void dec_FDCNG_MSVQ_stage1( - int16_t j_full, /* i: index full range */ - int16_t n, /* i: dimension to generate */ - const float *invTrfMatrix, /* i: IDCT matrix for synthesis */ - const DCTTYPE idcttype, /* i: specify which IDCT */ - float *uq, /* o: synthesized stage1 vector */ - Word16 *uq_ind /* o: synthesized stage1 vector in BASOP */ + const int16_t j_full, /* i : index full range */ + const int16_t n, /* i : dimension to generate */ + const float *invTrfMatrix, /* i : IDCT matrix for synthesis */ + const DCTTYPE idcttype, /* i : IDCT type */ + float *uq, /* o : synthesized stage1 vector */ + Word16 *uq_ind /* o : synthesized stage1 vector in BASOP */ ) { int16_t col, segm_ind, j; @@ -2067,9 +2074,9 @@ void dec_FDCNG_MSVQ_stage1( { dct_vec[col] = (float) ( ( (Word16) cbpW8[col] ) << dct_col_shift_tab[col] ); /* LOGIC( 1 ); SHIFT( 1 ); ADD( 1 ); - in BASOP: s_and(for W8->W16), shl(), sub() - */ + in BASOP: s_and(for W8->W16), shl(), sub() */ } + dctT2_N_apply_matrix( (const float *) dct_vec, idct_vec, cdk1_ivas_cols_per_segment[segm_ind], n, invTrfMatrix, FDCNG_VQ_DCT_MAXTRUNC, idcttype ); /*scale down to original fdcngvq domain and move to Q0 */ @@ -2080,6 +2087,8 @@ void dec_FDCNG_MSVQ_stage1( /*add common mid fdcng vector, in fdcng bands domain */ v_add( idct_vec, cdk1r_tr_midQ_truncQ, uq, n ); assert( uq_ind == NULL ); + + return; } @@ -2089,7 +2098,6 @@ void dec_FDCNG_MSVQ_stage1( * *--------------------------------------------------------------------------*/ - void msvq_dec( const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ @@ -2425,19 +2433,21 @@ void a2isf( return; } + /*-------------------------------------------------------------------* * dctT2_N_apply_matrix() * * dct/idct truncated matrix appl. for DCT basis vector lengths of N *-------------------------------------------------------------------*/ + void dctT2_N_apply_matrix( const float *input, float *output, const int16_t dct_dim, - int16_t fdcngvq_dim, + const int16_t fdcngvq_dim, const float *matrix, const int16_t matrix_row_dim, - DCTTYPE dcttype ) + const DCTTYPE dcttype ) { int16_t i, j, dim_in, dim_out; int16_t mat_step_col, mat_step_row, mat_step_col_flag; @@ -2448,7 +2458,6 @@ void dctT2_N_apply_matrix( /* non-square DCT_N and IDCT_N matrix application, using a stored format of an IDCT_Nx(FDCNG_VQ_DCT_MAXTRUNC) matrix */ /* efficiently parallelized in SIMD */ - assert( dct_dim <= FDCNG_VQ_DCT_MAXTRUNC ); assert( fdcngvq_dim <= FDCNG_VQ_MAX_LEN ); @@ -2494,9 +2503,13 @@ void dctT2_N_apply_matrix( } pt_y++; } + mvr2r( tmp_y, output, dim_out ); + + return; } + /*-------------------------------------------------------------------* * extend_dctN_input() * @@ -2505,14 +2518,15 @@ void dctT2_N_apply_matrix( *-------------------------------------------------------------------*/ void extend_dctN_input( - const float *input, /* i: input in fdcng domain */ - const float *dct_input, /* i: input in dctN(fdcng) domain */ - const int16_t in_dim, /* i: in_dim == N */ - float *ext_sig, /* o: extended output in fdcng domain */ - const int16_t out_dim, /* i: output total dim */ - float *matrix, /* i: idct synthesis matrix N rows, n_cols columns */ - const int16_t n_cols, /* i: number of columns == DCT truncation length */ - DCTTYPE dcttype ) /* i: matrix operation type */ + const float *input, /* i : input in fdcng domain */ + const float *dct_input, /* i : input in dctN(fdcng) domain */ + const int16_t in_dim, /* i : in_dim == N */ + float *ext_sig, /* o : extended output in fdcng domain */ + const int16_t out_dim, /* i : output total dim */ + float *matrix, /* i : idct synthesis matrix N rows, n_cols columns */ + const int16_t n_cols, /* i : number of columns == DCT truncation length */ + const DCTTYPE dcttype /* i : matrix operation type */ +) { int16_t i, j, i_rev; const float( *ptr )[FDCNG_VQ_DCT_MAXTRUNC] = (void *) matrix; @@ -2545,11 +2559,23 @@ void extend_dctN_input( #undef WMC_TOOL_SKIP } } + + return; } -/* inititate idct24 FDCNG_VQ_DCT_MAXTRUNCx N matrix in RAM from a quantized compressed ROM format */ -void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16_t n_cols, const int16_t alloc_size ) +/*-------------------------------------------------------------------* + * create_IDCT_N_Matrix() + * + * inititate idct24 FDCNG_VQ_DCT_MAXTRUNCx N matrix in RAM from a quantized compressed ROM format + *-------------------------------------------------------------------*/ + +void create_IDCT_N_Matrix( + float *inv_matrixFloatQ, /* i/o: RAM buffer */ + const int16_t N, /* i : DCT length , number of time samples */ + const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */ + const int16_t alloc_size /* i : RAM buffer size in elements */ +) { int16_t c, c1, r, r_flip, W16_val; int16_t len; @@ -2576,7 +2602,8 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 mat_cpy_size = ( n_cols ) * ( len >> 1 ); /* NB integer division of "len" */ if ( ( len & 1 ) != 0 ) - { /* odd sized DCT with a non-reflected center row */ + { + /* odd sized DCT with a non-reflected center row */ mat_cpy_size += n_cols; } @@ -2589,6 +2616,7 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 { W16_val = -( W16_val ); } + inv_matrixFloatQ[c] = ( +1.52587890625e-05f ) * ( (float) W16_val ); /* 1.0/2.^16 scaling to a float-"Q0" , a scaling that is not done in BASOP */ } @@ -2613,4 +2641,6 @@ void create_IDCT_N_Matrix( float *inv_matrixFloatQ, const int16_t N, const int16 #undef WMC_TOOL_SKIP } } + + return; } diff --git a/lib_com/prot.h b/lib_com/prot.h index 8c6fdd674f7cc674b1059abde2f0205c9f949bce..a6dd99e5e111854df942265122ed517ffaf7240a 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3024,9 +3024,8 @@ void lsf_enc( float *lsp_mid, /* i : mid-frame LSP vector */ float *Aq, /* o : quantized A(z) for 4 subframes */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); void isf_enc_amr_wb( @@ -3823,9 +3822,8 @@ void bw_detect( Encoder_State *st, /* i/o: Encoder State */ const float signal_in[], /* i : input signal */ float *spectrum, /* i : MDCT spectrum */ - const float *enerBuffer /* i : energy buffer */ - , - const int16_t mct_on /* i : flag MCT mode */ + const float *enerBuffer, /* i : energy buffer */ + const int16_t mct_on /* i : flag MCT mode */ ); @@ -3931,7 +3929,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 */ ); @@ -4577,16 +4575,15 @@ void swb_CNG_dec( ); void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ - const int16_t tdm_low_rate_mode /* i : secondary channel low rate mode flag */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + Decoder_State *st, /* i/o: State structure */ + const int16_t tc_subfr, /* i : TC subframe index */ + float *Aq, /* o : quantized A(z) for 4 subframes */ + int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ + float *lsf_new, /* o : de-quantized LSF vector */ + float *lsp_new, /* o : de-quantized LSP vector */ + float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ + const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); void isf_dec_amr_wb( @@ -4894,7 +4891,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 */ ); @@ -8050,20 +8047,20 @@ int16_t enc_lsf_tcxlpc( ); void msvq_enc( - const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ - const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ - const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ - const float u[], /* i : Vector to be encoded (prediction and mean removed) */ - const int16_t *levels, /* i : Number of levels in each stage */ - const int16_t maxC, /* i : Tree search size (number of candidates kept from */ + const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ + const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ + const int16_t offs[], /* i : Starting dimension of each codebook stage (NULL: 0) */ + const float u[], /* i : Vector to be encoded (prediction and mean removed) */ + const int16_t *levels, /* i : Number of levels in each stage */ + const int16_t maxC, /* i : Tree search size (number of candidates kept from */ /* one stage to the next == M-best) */ - const int16_t stages, /* i : Number of stages */ - const float w[], /* i : Weights */ - const int16_t N, /* i : Vector dimension */ - const int16_t maxN, /* i : Codebook dimension */ - const int16_t applyDCT_flag, /* i : applyDCT flag */ - float *invTrfMatrix, /* i:/o expanded synthesis matrix */ - int16_t Idx[] /* o : Indices */ + const int16_t stages, /* i : Number of stages */ + const float w[], /* i : Weights */ + const int16_t N, /* i : Vector dimension */ + const int16_t maxN, /* i : Codebook dimension */ + const int16_t applyDCT_flag, /* i : applyDCT flag */ + float *invTrfMatrix, /* i/o: expanded synthesis matrix */ + int16_t Idx[] /* o : Indices */ ); void msvq_dec( @@ -8074,78 +8071,80 @@ void msvq_dec( const int16_t N, /* i : Vector dimension */ const int16_t maxN, /* i : Codebook dimension */ const int16_t Idx[], /* i : Indices */ - const int16_t applyIDCT_flag, /* i : applyIDCT flag */ - const float *invTrfMatrix, /* i: synthesis matrix */ + const int16_t applyIDCT_flag, /* i : applyIDCT flag */ + const float *invTrfMatrix, /* i : synthesis matrix */ float *uq, /* o : quantized vector */ Word16 *uq_ind /* o : quantized vector (fixed point) */ ); - void dec_FDCNG_MSVQ_stage1( - int16_t j_full, /* i: index full range */ - int16_t n, /* i: dimension to generate */ - const float *invTrfMatrix, /* i: synthesis matrix */ - DCTTYPE idcttype, /* i: idct type */ - float *uq, /* o: synthesized stage1 vector */ - Word16 *uq_ind /* o: synthesized stage1 vector in BASOP */ + const int16_t j_full, /* i : index full range */ + const int16_t n, /* i : dimension to generate */ + const float *invTrfMatrix, /* i : synthesis matrix */ + const DCTTYPE idcttype, /* i : IDCT type */ + float *uq, /* o : synthesized stage1 vector */ + Word16 *uq_ind /* o : ynthesized stage1 vector in BASOP */ ); void create_IDCT_N_Matrix( - float *inv_matrixFloatQ, /* i/o: RAM buffer */ - const int16_t N, /* i: DCT length , number of time samples */ - const int16_t n_cols, /* i: number of dct coeffs (as DCT may be truncated) */ - const int16_t alloc_size /* i: RAM buffer size in elements*/ + float *inv_matrixFloatQ, /* i/o: RAM buffer */ + const int16_t N, /* i : DCT length , number of time samples */ + const int16_t n_cols, /* i : number of dct coeffs (as DCT may be truncated) */ + const int16_t alloc_size /* i : RAM buffer size in elements */ ); 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 float *idctT2_N_16matrixQ16, /* i: IDCT matrix */ - const int16_t matrix_1st_dim, /* i: */ - DCTTYPE dcttype ); /* i: matrix operation type */ + 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 */ + const int16_t fdcngvq_dim, /* i : FDCNG domain length */ + const float *idctT2_N_16matrixQ16, /* i : IDCT matrix */ + const int16_t matrix_1st_dim, /* i : */ + const DCTTYPE dcttype /* i : matrix operation type */ +); void extend_dctN_input( - const float *input, /* i: input in fdcng domain */ - const float *dct_input, /* i: input in dctN(fdcng) domain */ - const int16_t in_dim, /* i: in_dim==N */ - float *ext_sig, /* o: extended output in fdcng domain */ - const int16_t out_dim, /* i: output total dim */ - float *matrix, /* i: idct matrix of size N rows , n_cols columns*/ - const int16_t n_cols, /* i: number of columns == truncation length */ - DCTTYPE dcttype ); /* i: matrix type */ - -#ifdef ERI_MSVQ_CLEANUP -int16_t msvq_stage1_dct_search( /* o : (p_max , best candidate sofar ) */ - const float *u, /* i : target */ - const int16_t N, /* i : target length and IDCT synthesis length */ - const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ - const int16_t max_dct_trunc, /* i: maximum of truncation lenghts */ - float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ - const float *midQ_truncQ, /* i: midQ vector */ - const float *dct_invScaleF, /* i: global inv scale factors*/ - const float *dct_scaleF, /* i: global scale factors*/ - const Word16 n_segm, /* i: number of segments */ - const Word16 *cols_per_segment, /* i: remaining length per segment */ - const Word16 *trunc_dct_cols_per_segment, /* i: trunc length per segment */ - const Word16 *entries_per_segment, /* i: number of rows per segment */ - const Word16 *cum_entries_per_segment, /* i: number of cumulative entries */ - const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ - const Word16 npost_check, /*i: number of neigbours to check , should be even */ - float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ - int16_t *indices_st1_local, /*o: selected cand indices */ - float *st1_syn_vec_ptr, /*i/o: buffer for IDCT24 synthesis */ - float *dist1_ptr /*o: resulting stage 1 MSEs in DCT-N domain */ + const float *input, /* i : input in fdcng domain */ + const float *dct_input, /* i : input in dctN(fdcng) domain */ + const int16_t in_dim, /* i : in_dim==N */ + float *ext_sig, /* o : extended output in fdcng domain */ + const int16_t out_dim, /* i : output total dim */ + float *matrix, /* i : IDCT matrix of size N rows , n_cols columns */ + const int16_t n_cols, /* i : number of columns == truncation length */ + const DCTTYPE dcttype /* i : matrix type */ ); +#ifdef ERI_MSVQ_CLEANUP +/*! r: (p_max , best candidate sofar ) */ +int16_t msvq_stage1_dct_search( + const float *u, /* i : target */ + const int16_t N, /* i : target length and IDCT synthesis length */ + const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* i : DFT type: e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const int16_t max_dct_trunc, /* i : maximum of truncation lenghts */ + float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + const float *midQ_truncQ, /* i : midQ vector */ + const float *dct_invScaleF, /* i : global inv scale factors */ + const float *dct_scaleF, /* i : global scale factors */ + const Word16 n_segm, /* i : number of segments */ + const Word16 *cols_per_segment, /* i : remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ + const Word16 *entries_per_segment, /* i : number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ + const Word16 npost_check, /* i : number of neigbours to check , should be even */ + float *st1_mse_ptr, /* i : dynRAM buffer for MSEs */ + int16_t *indices_st1_local, /* o : selected cand indices */ + float *st1_syn_vec_ptr, /* i/o: buffer for IDCT24 synthesis */ + float *dist1_ptr /* o : resulting stage 1 MSEs in DCT-N domain */ +); + +/*! r: updated p_max */ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( - /* o : (updated p_max) */ const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ const float *u, /* i : target signal */ const int16_t maxC_st1, /* i : number of candidates in stage1 */ @@ -8163,16 +8162,16 @@ void PulseResynchronization( ); void con_acelp( - float A[], /* i : coefficients NxAz[M+1] */ - const int16_t coder_type, /* i : ACELP coder type */ - float synth[], /* i/o: synthesis */ - int16_t *pT, /* o : pitch for all subframe */ - float *pgainT, /* o : pitch gain for all subfr */ - float stab_fac, /* i : stability of isf */ - Decoder_State *st, /* i/o: coder memory state */ - float pitch_buffer[], /* i/o: floating pitch values for each subframe */ - float *voice_factors, /* o : voicing factors */ - float *bwe_exc /* o : excitation for SWB TBE */ + float A[], /* i : coefficients NxAz[M+1] */ + const int16_t coder_type, /* i : ACELP coder type */ + float synth[], /* i/o: synthesis */ + int16_t *pT, /* o : pitch for all subframe */ + float *pgainT, /* o : pitch gain for all subfr */ + float stab_fac, /* i : stability of isf */ + Decoder_State *st, /* i/o: coder memory state */ + float pitch_buffer[], /* i/o: floating pitch values for each subframe */ + float *voice_factors, /* o : voicing factors */ + float *bwe_exc /* o : excitation for SWB TBE */ ); void con_tcx( @@ -8294,9 +8293,8 @@ void lsf_end_dec( float *qlsf, /* o : quantized LSFs in the cosine domain */ int16_t *lpc_param, /* i : LPC parameters */ int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - int16_t *nb_indices /* o : number of indices */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + int16_t *nb_indices, /* o : number of indices */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ); ivas_error find_pred_mode( 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..81175471d6196d4f8807698d46996c0b26faa0d1 100644 --- a/lib_dec/FEC_clas_estim.c +++ b/lib_dec/FEC_clas_estim.c @@ -735,10 +735,9 @@ 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 */ - ) { int16_t pitch_index, T0, T0_frac, T0_min, T0_max; diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 9896d1d8c024016b4b074c4b25a73a8e5dbe503f..74c0437d538ebc337faf4571a0771d613a334019 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -337,7 +337,7 @@ void IMDCT( } if ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && - ( st->tcxonly ) ) + st->tcxonly ) { /* Mode decision in PLC @@ -555,7 +555,7 @@ void IMDCT( if ( ( frame_cnt != 0 ) || ( st->last_core_bfi > ACELP_CORE ) ) { if ( ( ( L_frameTCX == hTcxDec->L_frameTCX >> 1 ) && - ( st->tcxonly ) ) || + st->tcxonly ) || ( hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ) { if ( !bfi && ( frame_cnt > 0 ) && ( index == 0 ) && ( hTcxCfg->tcx_curr_overlap_mode == FULL_OVERLAP ) && ( st->last_core != ACELP_CORE ) ) diff --git a/lib_dec/fd_cng_dec.c b/lib_dec/fd_cng_dec.c index 7f8eba27c0e5a7f9dd7ff5f953e1818e7e3b5de0..4d832de52ea6eef5e2f86cd481412f0123525e45 100644 --- a/lib_dec/fd_cng_dec.c +++ b/lib_dec/fd_cng_dec.c @@ -858,12 +858,14 @@ static void perform_noise_estimation_dec( hFdCngDec->ms_cnt_bw_up = FIRST_CNA_NOISE_UPD_FRAMES; } hFdCngDec->ms_last_inactive_bwidth = bwidth; + /* update background noise during inactive frames */ ptr_per = msNoiseEst; for ( p = 0; p < npart; p++ ) { enr = msPeriodog[p]; alpha = 0.95f; + /* bandwidth increased -> do fast re-initilization */ if ( hFdCngDec->ms_cnt_bw_up > 0 && p > 55 ) { @@ -943,8 +945,7 @@ static void perform_noise_estimation_dec( compress_range( msPeriodog, msLogPeriodog, npart ); /* Call the minimum statistics routine for noise estimation */ - minimum_statistics( npart, nFFTpart, psize, msLogPeriodog, hFdCngDec->msNoiseFloor, msLogNoiseEst, hFdCngDec->msAlpha, hFdCngDec->msPsd, hFdCngDec->msPsdFirstMoment, hFdCngDec->msPsdSecondMoment, hFdCngDec->msMinBuf, hFdCngDec->msBminWin, hFdCngDec->msBminSubWin, hFdCngDec->msCurrentMin, hFdCngDec->msCurrentMinOut, hFdCngDec->msCurrentMinSubWindow, hFdCngDec->msLocalMinFlag, hFdCngDec->msNewMinFlag, hFdCngDec->msPeriodogBuf, &( hFdCngDec->msPeriodogBufPtr ), hFdCngDec->hFdCngCom, - DEC, element_mode ); + minimum_statistics( npart, nFFTpart, psize, msLogPeriodog, hFdCngDec->msNoiseFloor, msLogNoiseEst, hFdCngDec->msAlpha, hFdCngDec->msPsd, hFdCngDec->msPsdFirstMoment, hFdCngDec->msPsdSecondMoment, hFdCngDec->msMinBuf, hFdCngDec->msBminWin, hFdCngDec->msBminSubWin, hFdCngDec->msCurrentMin, hFdCngDec->msCurrentMinOut, hFdCngDec->msCurrentMinSubWindow, hFdCngDec->msLocalMinFlag, hFdCngDec->msNewMinFlag, hFdCngDec->msPeriodogBuf, &( hFdCngDec->msPeriodogBufPtr ), hFdCngDec->hFdCngCom, DEC, element_mode ); /* Expand MS outputs */ expand_range( msLogNoiseEst, msNoiseEst, npart ); @@ -995,18 +996,17 @@ void FdCng_decodeSID( index = get_next_indice( st, 7 ); /* MSVQ decoder */ - if ( st->element_mode != EVS_MONO ) { create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); msvq_dec( cdk_37bits_ivas, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 1, invTrfMatrix, v, NULL ); } else - { /* Legacy EVS_MONO MSVQ tables */ + { + /* Legacy EVS_MONO MSVQ tables */ msvq_dec( cdk_37bits, NULL, NULL, FD_CNG_stages_37bits, N, FD_CNG_maxN_37bits, indices, 0, NULL, v, NULL ); } - /* Decode gain */ gain = ( (float) index - gain_q_offset ) / 1.5f; @@ -1419,15 +1419,15 @@ void generate_comfort_noise_dec_hf( *-------------------------------------------------------------------*/ void generate_masking_noise( - float *timeDomainBuffer, /* i/o: time-domain signal */ + float *timeDomainBuffer, /* i/o: time-domain signal */ HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */ - const int16_t length, /* i : frame size */ - const int16_t core, /* i : core */ - const int16_t return_noise, /* i : noise is returned instead of added */ - const int16_t secondary, /* i : flag to indicate secondary noise generation */ - const int16_t element_mode, /* i : element mode */ - STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ - const int16_t nchan_out /* i : number of output channels */ + const int16_t length, /* i : frame size */ + const int16_t core, /* i : core */ + const int16_t return_noise, /* i : noise is returned instead of added */ + const int16_t secondary, /* i : flag to indicate secondary noise generation */ + const int16_t element_mode, /* i : element mode */ + STEREO_CNG_DEC_HANDLE hStereoCng, /* i : stereo CNG handle */ + const int16_t nchan_out /* i : number of output channels */ ) { float *cngNoiseLevel = hFdCngCom->cngNoiseLevel; @@ -1829,7 +1829,6 @@ void generate_masking_noise_lb_dirac( n_samples_out = hFdCngCom->frameSize / DEFAULT_JBM_CLDFB_TIMESLOTS * nCldfbTs; n_samples_start = 0; - /*LB CLDFB - CNA from STFT*/ #ifdef DEBUG_MODE_DIRAC { @@ -1951,7 +1950,6 @@ void generate_masking_noise_lb_dirac( return; } - #endif @@ -2172,7 +2170,6 @@ void FdCngDecodeMDCTStereoSID( float *invTrfMatrix; float tmpRAM[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - invTrfMatrix = (float *) tmpRAM; create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); @@ -2280,7 +2277,6 @@ void FdCngDecodeDiracMDCTStereoSID( float *invTrfMatrix; float tmpRAM[FDCNG_VQ_MAX_LEN][FDCNG_VQ_DCT_MAXTRUNC]; - invTrfMatrix = (float *) tmpRAM; /* dynamically filled */ create_IDCT_N_Matrix( invTrfMatrix, FDCNG_VQ_MAX_LEN, FDCNG_VQ_DCT_MAXTRUNC, sizeof( tmpRAM ) / ( sizeof( float ) ) ); diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index bfe0a4bb533681ebb76b93d73f03380014b20f97..5de5f881fa5446d6cb2be527ec899ce46dbb3da3 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -997,17 +997,19 @@ void ivas_binaural_cldfb( return; } + + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------------* - * ivas_binaural_cldfb() + * ivas_binaural_cldfb_sf() * * Perform CLDFB analysis, fastconv binaural rendering and CLDFB synthesis *-------------------------------------------------------------------------*/ void ivas_binaural_cldfb_sf( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t n_samples_to_render, - float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { float Cldfb_RealBuffer[MAX_INTERN_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX]; @@ -1021,6 +1023,7 @@ void ivas_binaural_cldfb_sf( /* Implement a 5 msec loops */ maxBand = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * st_ivas->hDecoderConfig->output_Fs ) / 48000 ); slot_size = st_ivas->hTcBuffer->nb_subframes; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; @@ -1028,6 +1031,7 @@ void ivas_binaural_cldfb_sf( slot_index_start = st_ivas->hTcBuffer->slots_rendered; slot_index_start_cldfb = 0; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -1086,7 +1090,9 @@ void ivas_binaural_cldfb_sf( slot_index_start += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; slot_index_start_cldfb += st_ivas->hTcBuffer->subframe_nbslots[subframeIdx]; } + st_ivas->hTcBuffer->subframes_rendered = last_sf; + return; } #endif diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index 516e027f90db764e863ccec371bbb212e532b0c2..325d5d985ba51b9cdb1270721b4015a5c0399ed4 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -96,12 +96,13 @@ ivas_error ivas_core_dec( int16_t last_element_mode; int16_t nchan_out; float *save_hb_synth; + IVAS_FORMAT ivas_format; ivas_error error; - error = IVAS_ERR_OK; - push_wmops( "ivas_core_dec" ); + error = IVAS_ERR_OK; + /*------------------------------------------------------------------* * General initialization *-----------------------------------------------------------------*/ @@ -112,6 +113,12 @@ ivas_error ivas_core_dec( read_sid_info = 1; /* read SID by default */ #endif + ivas_format = UNDEFINED_FORMAT; + if ( st_ivas != NULL ) + { + ivas_format = st_ivas->ivas_format; + } + if ( hSCE != NULL ) { sts = hSCE->hCoreCoder; @@ -233,7 +240,7 @@ ivas_error ivas_core_dec( } /* n_channels loop */ /* MDCT stereo -> DFT stereo switching */ - if ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_MDCT && hCPE->element_mode == IVAS_CPE_DFT ) + if ( last_element_mode == IVAS_CPE_MDCT && sts[0]->element_mode == IVAS_CPE_DFT ) { int16_t ovl, fade_len; if ( sts[0]->L_frame != sts[0]->last_L_frame ) @@ -331,7 +338,6 @@ ivas_error ivas_core_dec( return error; } - flag_sec_CNA = -1; if ( hCPE != NULL ) { @@ -360,7 +366,7 @@ ivas_error ivas_core_dec( if ( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE ) && st->element_mode != IVAS_CPE_MDCT ) { /* TCX decoder */ - stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, st_ivas == NULL ? 0 : st_ivas->ivas_format ); + stereo_tcx_core_dec( st, frameMode[n], output[n], synth[n], pitch_buf[n], sba_dirac_stereo_flag, hStereoTD, last_element_mode, flag_sec_CNA, hCPE == NULL ? NULL : hCPE->hStereoCng, nchan_out, ivas_format ); } if ( st->core == HQ_CORE ) @@ -465,12 +471,11 @@ ivas_error ivas_core_dec( mvr2r( synth[n], hSCE->save_synth, output_frame ); } - if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE ) ) != IVAS_ERR_OK ) + if ( ( error = core_switching_post_dec( st, synth[n], output[n], p_output_mem, ivas_format, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, last_element_mode ) ) != IVAS_ERR_OK ) { return error; } - /* for FD-CNG we need the delay compensation in the synth, so do this afterwards */ if ( sba_dirac_stereo_flag && hSCE && st->core_brate == SID_2k40 && st->cng_type == FD_CNG ) { @@ -478,7 +483,7 @@ ivas_error ivas_core_dec( } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ - if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || ( hCPE != NULL && hCPE->last_element_mode == IVAS_CPE_DFT ) ) ) + if ( n == 0 && st->element_mode == IVAS_CPE_MDCT && st->last_core == ACELP_CORE && st->core != ACELP_CORE && ( nchan_out == 1 || last_element_mode == IVAS_CPE_DFT ) ) { mvr2r( sts[0]->previoussynth, sts[1]->previoussynth, st->hTcxDec->L_frameTCX ); } @@ -608,7 +613,7 @@ ivas_error ivas_core_dec( /* Smooth transitions when switching between different technologies */ if ( !( ( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE ) && st->last_core == ACELP_CORE ) && - ( st->extl != st->last_extl || ( st->extl == st->last_extl && ( st->core ^ st->last_core ) == HQ_CORE ) ) && !( st->extl == SWB_CNG && st->last_extl == SWB_TBE ) && ( st->element_mode != IVAS_CPE_TD || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) ) + ( st->extl != st->last_extl || ( st->extl == st->last_extl && ( st->core ^ st->last_core ) == HQ_CORE ) ) && !( st->extl == SWB_CNG && st->last_extl == SWB_TBE ) && ( st->element_mode != IVAS_CPE_TD || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) ) { /* switching between BWE and TBE technologies */ incr = (int16_t) ( L_FRAME / ( tmps + 0.5f ) ); @@ -654,7 +659,7 @@ ivas_error ivas_core_dec( } if ( ( st->element_mode != IVAS_CPE_TD && !use_cldfb_for_dft ) /* IVAS-19: the logic seems to be not consistent between TD and DFT stereo and SCE -> verification needed also whether 1) it is correct here and 2) the DFT->(LR)TD transition is correct */ - || ( hCPE->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) + || ( st->element_mode == IVAS_CPE_TD && tdm_LRTD_flag ) ) { /* Delay hb_synth */ delay_signal( hb_synth[n], output_frame, st->hb_prev_synth_buffer, tmps ); @@ -707,7 +712,7 @@ ivas_error ivas_core_dec( } else /* IVAS_CPE_DFT */ { - if ( hCPE->last_element_mode == IVAS_CPE_MDCT ) + if ( last_element_mode == IVAS_CPE_MDCT ) { stereo_mdct2dft_update( hCPE, output[0], synth[0] ); } diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 0af1699564180f2878a152d52d20f2829c56c816..2be13754edac43db79767676089fe0569c7f845b 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -178,7 +178,6 @@ ivas_error ivas_dec( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_dec() with 'st_ivas' - TBD if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_dirac_dec.c b/lib_dec/ivas_dirac_dec.c index c5485119ba67ad4b86a52602b732b5b63119e1fa..255af21666e2a8e97329c666360db8cb2aa5e4c8 100644 --- a/lib_dec/ivas_dirac_dec.c +++ b/lib_dec/ivas_dirac_dec.c @@ -1126,6 +1126,7 @@ ivas_error ivas_dirac_dec_config( #ifdef FIX_391_SBA hDirAC->hConfig->dec_param_estim_old = hDirAC->hConfig->dec_param_estim; #endif + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { hDirAC->dirac_md_buffer_length = MAX_PARAM_SPATIAL_SUBFRAMES; @@ -1342,9 +1343,10 @@ ivas_error ivas_dirac_dec_config( { int16_t num_slots_in_subfr; num_slots_in_subfr = hDirAC->hConfig->dec_param_estim ? CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES : 1; + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { - if ( ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) ) + if ( hDirAC->hConfig->dec_param_estim_old != hDirAC->hConfig->dec_param_estim ) { #ifdef DIRAC_ALLOC_HARM ivas_dirac_deallocate_parameters( hDirAC, 1 ); @@ -1414,6 +1416,7 @@ ivas_error ivas_dirac_dec_config( } #endif } + hDirAC->dirac_md_buffer_length = ( MAX_PARAM_SPATIAL_SUBFRAMES + DELAY_DIRAC_PARAM_DEC_SFR ) * num_slots_in_subfr; hDirAC->dirac_bs_md_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; hDirAC->spar_to_dirac_write_idx = DELAY_DIRAC_PARAM_DEC_SFR * num_slots_in_subfr; @@ -2252,16 +2255,16 @@ static void ivas_dirac_free_mem( *------------------------------------------------------------------------*/ void ivas_dirac_dec_read_BS( - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - Decoder_State *st, /* i/o: decoder state structure */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ - int16_t *nb_bits, /* o : number of bits read */ - const SBA_MODE sba_mode, /* i : SBA mode */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + Decoder_State *st, /* i/o: decoder state structure */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata */ + int16_t *nb_bits, /* o : number of bits read */ + const SBA_MODE sba_mode, /* i : SBA mode */ #ifdef HODIRAC const int16_t hodirac_flag, /* i : flag to indicate HO-DirAC mode */ #endif - int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ + int16_t *dirac_to_spar_md_bands /* o : DirAC->SPAR MD bands */ ) { int16_t i, j, b, dir, orig_dirac_bands; @@ -2894,9 +2897,11 @@ void ivas_qmetadata_to_dirac( * * Set metadata index mapping for DirAC *------------------------------------------------------------------------*/ + void ivas_dirac_dec_set_md_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { int16_t num_slots_in_subfr; DIRAC_DEC_HANDLE hDirAC; @@ -2938,6 +2943,7 @@ void ivas_dirac_dec_set_md_map( { float tmp; int16_t sf_idx, slot_idx, slot_idx_abs; + slot_idx_abs = 0; for ( sf_idx = 0; sf_idx < hDirAC->nb_subframes; sf_idx++ ) { @@ -2949,17 +2955,20 @@ void ivas_dirac_dec_set_md_map( } hDirAC->render_to_md_map[sf_idx] = ( (int16_t) roundf( tmp / (float) hDirAC->subframe_nbslots[sf_idx] ) + hDirAC->dirac_read_idx ) % hDirAC->dirac_md_buffer_length; } + set_s( &hDirAC->render_to_md_map[hDirAC->nb_subframes], 0, MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME - hDirAC->nb_subframes ); } return; } + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + void ivas_dirac_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output_f[][L_FRAME48k], /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -2978,17 +2987,21 @@ void ivas_dirac_dec( { output_f_local[n] = &output_f[n][0]; } + for ( n = 0; n < nchan_transport; n++ ) { st_ivas->hTcBuffer->tc[n] = output_f[n]; } + if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; st_ivas->hTcBuffer->tc[nchan_transport] = &cng_td_buffer[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], DEFAULT_JBM_CLDFB_TIMESLOTS, st->cna_dirac_flag && st->flag_cna ); } + ivas_dirac_dec_set_md_map( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { ivas_dirac_dec_render_sf( st_ivas, output_f_local, nchan_transport, NULL, NULL ); @@ -2997,6 +3010,7 @@ void ivas_dirac_dec( output_f_local[n] += n_samples_sf; } } + if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_CLDFB_TIMESLOTS ) % st_ivas->hDirAC->dirac_md_buffer_length; @@ -3017,13 +3031,20 @@ void ivas_dirac_dec( return; } + +/*------------------------------------------------------------------------- + * ivas_dirac_dec_render() + * + * DirAC decoding renderer process + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const int16_t nchan_transport, /* i : number of transport channels */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const int16_t nchan_transport, /* i : number of transport channels */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -3042,16 +3063,19 @@ void ivas_dirac_dec_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -3075,16 +3099,20 @@ void ivas_dirac_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec() * * DirAC decoding process *------------------------------------------------------------------------*/ + #ifndef JBM_TSM_ON_TCS void ivas_dirac_dec( #else diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 892cfe4acbd1120a7f3d2f4b90eae08a2fa2ad76..44a9d7e597883b90364076f95931c49179b0f325 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -104,8 +104,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( set_zero( h_dirac_output_synthesis_state->cx_old[idx], nchan_in * nchan_in ); set_zero( h_dirac_output_synthesis_state->cy_old[idx], nchan_out * nchan_out ); set_zero( h_dirac_output_synthesis_state->mixing_matrix_old[idx], nchan_out * nchan_in ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix[idx] = (float *) malloc( nchan_out * nchan_in * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix[idx], nchan_out * nchan_in ); #endif } @@ -118,6 +122,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( h_dirac_output_synthesis_state->mixing_matrix[idx] = NULL; #endif } + for ( idx = 0; idx < num_param_bands_residual; idx++ ) { if ( ( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) @@ -125,8 +130,12 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis covariance\n" ) ); } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx], nchan_out * nchan_out ); + #ifdef JBM_TSM_ON_TCS - h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ); + if ( ( h_dirac_output_synthesis_state->mixing_matrix_res[idx] = (float *) malloc( nchan_out * nchan_out * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n" ) ); + } set_zero( h_dirac_output_synthesis_state->mixing_matrix_res[idx], nchan_out * nchan_out ); #endif } @@ -158,6 +167,7 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS /*-------------------------------------------------------------------* * ivas_dirac_dec_output_synthesis_cov_open() @@ -285,6 +295,7 @@ void ivas_dirac_dec_output_synthesis_cov_close( free( h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] ); h_dirac_output_synthesis_state->mixing_matrix_res_old[idx] = NULL; } + #ifdef JBM_TSM_ON_TCS if ( h_dirac_output_synthesis_state->mixing_matrix[idx] != NULL ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index ef9cbdf54bf9fe4e1237807f4f65175111bac9e3..a80af1c547b8207022944550439d255470d4e7ca 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -680,6 +680,9 @@ ivas_error ivas_init_decoder( int16_t i, k, n; int16_t sce_id, cpe_id; int16_t numCldfbAnalyses, numCldfbSyntheses; +#ifdef JBM_TSM_ON_TCS + int16_t granularity, n_channels_transport_jbm; +#endif int32_t output_Fs, ivas_total_brate; int32_t binauralization_delay_ns; AUDIO_CONFIG output_config; @@ -904,7 +907,6 @@ ivas_error ivas_init_decoder( } else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { - if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { return error; @@ -1334,13 +1336,13 @@ ivas_error ivas_init_decoder( return error; } } + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1379,13 +1381,13 @@ ivas_error ivas_init_decoder( } st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { - int16_t granularity; - int16_t n_channels_transport_jbm; granularity = NS2SA( st_ivas->hDecoderConfig->output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ); n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, TC_BUFFER_MODE_RENDERER, n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, granularity ) ) != IVAS_ERR_OK ) { return error; @@ -1414,6 +1416,7 @@ ivas_error ivas_init_decoder( /*-----------------------------------------------------------------* * LFE handles for rendering after rendering to adjust LFE delay to binaural filter delay *-----------------------------------------------------------------*/ + #ifdef MC_PARAMUPMIX_MODE if ( st_ivas->mc_mode == MC_MODE_MCT || st_ivas->mc_mode == MC_MODE_PARAMUPMIX ) #else @@ -1489,15 +1492,21 @@ ivas_error ivas_init_decoder( } #ifdef JBM_TSM_ON_TCS + /*-----------------------------------------------------------------* + * Allocate and initialize JBM struct + buffer + *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active && st_ivas->hTcBuffer == NULL ) { /* no module has yet open the TC buffer, open a default one */ - int16_t n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + n_channels_transport_jbm = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, ivas_jbm_dec_get_tc_buffer_mode( st_ivas ), n_channels_transport_jbm, n_channels_transport_jbm, n_channels_transport_jbm, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { return error; } } + if ( st_ivas->hTcBuffer == NULL ) { /* we need the handle anyway, but without the buffer*/ @@ -1511,9 +1520,6 @@ ivas_error ivas_init_decoder( return error; } -#ifdef JBM_TSM_ON_TCS - -#endif /*------------------------------------------------------------------------- * destroy_core_dec() diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 5706261093a102b3ffe66ee887b8fc8fd0bea19f..37265e5e6a55ef400859754bc6a91c7f5552e55d 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -44,19 +44,19 @@ /*-------------------------------------------------------------------------* - * ivas_ism_bitrate_switching() - * + * ivas_ism_bitrate_switching_dec() * + * Reconfiguration of ISM decoder in case of bitrate switching *-------------------------------------------------------------------------*/ -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 */ #ifdef JBM_TSM_ON_TCS , - uint16_t *nSamplesRendered, - int16_t *data + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + int16_t *data /* o : rendered samples */ #endif ) { @@ -66,7 +66,6 @@ static ivas_error ivas_ism_bitrate_switching( #ifdef FIX_416_ISM_BR_SWITCHING int16_t numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode; #endif - #ifdef JBM_TSM_ON_TCS TC_BUFFER_MODE tc_buffer_mode_new; int16_t tc_nchan_tc_new; @@ -151,9 +150,11 @@ static ivas_error ivas_ism_bitrate_switching( st_ivas->hTcBuffer->slots_rendered = st_ivas->hDirAC->slots_rendered; mvs2s( st_ivas->hDirAC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } + /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv render what still fits in the new granularity */ tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->hDecoderConfig->output_Fs ); + if ( tc_granularity_new < st_ivas->hTcBuffer->n_samples_granularity ) { if ( ( error = ivas_jbm_dec_flush_renderer( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ) != IVAS_ERR_OK ) @@ -223,12 +224,8 @@ static ivas_error ivas_ism_bitrate_switching( ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); /* Open Crend Binaural renderer */ - if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hRenderConfig, - st_ivas->hSetOfHRTF, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.output_config, + st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -316,6 +313,7 @@ static ivas_error ivas_ism_bitrate_switching( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -326,15 +324,18 @@ static ivas_error ivas_ism_bitrate_switching( tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels( st_ivas ); tc_nchan_allocate_new = tc_nchan_tc_new; tc_nchan_full_new = tc_nchan_tc_new; + if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; tc_nchan_full_new = tc_nchan_allocate_new; } + if ( st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type != RENDERER_MONO_DOWNMIX && st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new ) @@ -344,6 +345,7 @@ static ivas_error ivas_ism_bitrate_switching( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -351,6 +353,7 @@ static ivas_error ivas_ism_bitrate_switching( st_ivas->hDirAC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; st_ivas->hDirAC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hDirAC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); } } @@ -368,9 +371,8 @@ static ivas_error ivas_ism_bitrate_switching( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_dec_config( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ - , - const ISM_MODE last_ism_mode /* i/o: last ISM mode */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode /* i/o: last ISM mode */ #ifdef JBM_TSM_ON_TCS , uint16_t *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */ @@ -386,7 +388,6 @@ ivas_error ivas_ism_dec_config( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; - /* Assumes that num of input objects are constant */ nchan_transport_old = st_ivas->nchan_ism; @@ -413,17 +414,15 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ini_active_frame != 0 ) { /* ISM bit-rate switching */ + if ( st_ivas->ism_mode != last_ism_mode || ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) { - if ( ( st_ivas->ism_mode != last_ism_mode ) || ( st_ivas->hDecoderConfig->ivas_total_brate != st_ivas->hDecoderConfig->last_ivas_total_brate ) ) - { #ifdef JBM_TSM_ON_TCS - 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 ) #else - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) #endif - { - return error; - } + { + return error; } } } @@ -444,9 +443,9 @@ ivas_error ivas_ism_dec_config( if ( st_ivas->ism_mode != last_ism_mode ) { #ifdef JBM_TSM_ON_TCS - 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 ) #else - if ( ( error = ivas_ism_bitrate_switching( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_ism_bitrate_switching_dec( st_ivas, nchan_transport_old, last_ism_mode ) ) != IVAS_ERR_OK ) #endif { return error; diff --git a/lib_dec/ivas_ism_dtx_dec.c b/lib_dec/ivas_ism_dtx_dec.c index b2bc737fa20367b0ce9f3271f4c82a7567d8c2d7..daf4b4b3ed318faa4ed6b85631f37436eba5ffdd 100644 --- a/lib_dec/ivas_ism_dtx_dec.c +++ b/lib_dec/ivas_ism_dtx_dec.c @@ -133,6 +133,7 @@ ivas_error ivas_ism_dtx_dec( ism_mode_bstr = (ISM_MODE) ( idx + 1 ); st_ivas->ism_mode = ism_mode_bstr; } + #ifdef JBM_TSM_ON_TCS if ( ( error = ivas_ism_dec_config( st_ivas, last_ism_mode, NULL, NULL ) ) != IVAS_ERR_OK ) #else diff --git a/lib_dec/ivas_ism_metadata_dec.c b/lib_dec/ivas_ism_metadata_dec.c index b7bf89e026c874793b942f96e2e0b8f798cc0591..40e366becedaceb53e779361ac3b356b345975f3 100644 --- a/lib_dec/ivas_ism_metadata_dec.c +++ b/lib_dec/ivas_ism_metadata_dec.c @@ -142,18 +142,18 @@ static void ism_metadata_smooth( *-------------------------------------------------------------------------*/ ivas_error ivas_ism_metadata_dec( - const int32_t ism_total_brate, /* i : ISM total bitrate */ - const int16_t nchan_ism, /* i : number of ISM channels */ - int16_t *nchan_transport, /* o : number of transport channels */ - ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ - SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ - const int16_t bfi, /* i : bfi flag */ - int16_t nb_bits_metadata[], /* o : number of metadata bits */ - ISM_MODE ism_mode, /* i : ISM mode */ - ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ - const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ - int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer*/ - int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed*/ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + const int16_t nchan_ism, /* i : number of ISM channels */ + int16_t *nchan_transport, /* o : number of transport channels */ + ISM_METADATA_HANDLE hIsmMeta[], /* i/o: ISM metadata handles */ + SCE_DEC_HANDLE hSCE[], /* i/o: SCE decoder handles */ + const int16_t bfi, /* i : bfi flag */ + int16_t nb_bits_metadata[], /* o : number of metadata bits */ + ISM_MODE ism_mode, /* i : ISM mode */ + ISM_DTX_DATA_DEC hISMDTX, /* i/o: ISM DTX structure */ + const PARAM_ISM_CONFIG_HANDLE hParamIsm, /* i : Param ISM Config Handle */ + int16_t *ism_extmeta_active, /* i/o: Extended metadata active in renderer */ + int16_t *ism_extmeta_cnt /* i/o: Number of change frames observed */ ) { int16_t ch, nb_bits_start = 0, last_bit_pos; @@ -182,7 +182,6 @@ ivas_error ivas_ism_metadata_dec( push_wmops( "ism_meta_dec" ); - /* initialization */ st0 = hSCE[0]->hCoreCoder[0]; ism_metadata_flag_global = 0; @@ -323,6 +322,10 @@ ivas_error ivas_ism_metadata_dec( if ( hIsmMeta[ch]->ism_metadata_flag ) { + /*----------------------------------------------------------------* + * Azimuth/Elevation decoding and dequantization + *----------------------------------------------------------------*/ + #ifdef ISM_NON_DIEGETIC_PAN if ( non_diegetic_flag_global ) { @@ -369,7 +372,10 @@ ivas_error ivas_ism_metadata_dec( hIsmMetaData->azimuth = ism_dequant_meta( idx_angle1, ism_azimuth_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_AZIMUTH_NBITS ); hIsmMetaData->elevation = ism_dequant_meta( idx_angle2, ism_elevation_borders, ISM_Q_STEP, ISM_Q_STEP_BORDER, 1 << ISM_ELEVATION_NBITS ); - /* radius/raw/pitch dequantization */ + /*----------------------------------------------------------------* + * radius/raw/pitch decoding + dequantization + *----------------------------------------------------------------*/ + if ( ism_extmeta_bitstream ) { #ifdef ISM_NON_DIEGETIC_PAN @@ -401,6 +407,7 @@ ivas_error ivas_ism_metadata_dec( } } } + /* save for smoothing metadata evolution */ hIsmMetaData->last_true_azimuth = hIsmMetaData->azimuth; hIsmMetaData->last_true_elevation = hIsmMetaData->elevation; @@ -545,7 +552,7 @@ ivas_error ivas_ism_metadata_dec( } /*----------------------------------------------------------------* - * Set bitsream pointers + * Set bitstream pointers *----------------------------------------------------------------*/ /* set the bitstream pointer to its original position */ @@ -631,7 +638,7 @@ ivas_error ivas_ism_metadata_dec_create( /*------------------------------------------------------------------------- * decode_angle_indices() * - * Decoding of an angle + * Decoding of a position/orientation angle indices *-------------------------------------------------------------------------*/ static void decode_angle_indices( @@ -689,6 +696,7 @@ static void decode_angle_indices( nbits_diff_angle1++; } } + idx_angle1 = angle->last_angle1_idx + sgn * diff; } diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index 7e0f65a66332762e561897da24c43a907acd446a..1644c2de06be2dc6b823fecad85c35b259c21af4 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -50,9 +50,8 @@ *-----------------------------------------------------------------------*/ static void ivas_param_ism_dec_dequant_DOA( - DIRAC_DEC_HANDLE hDirAC /* i/o: decoder DirAC handle */ - , - const int16_t nchan_ism /* i : number of ISM channels */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ + const int16_t nchan_ism /* i : number of ISM channels */ ) { int16_t i; @@ -157,6 +156,7 @@ static void ivas_ism_get_proto_matrix( return; } + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_collect_slot( DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -185,9 +185,11 @@ static void ivas_param_ism_collect_slot( ref_power[bin_idx] += tmp; } } + return; } + static void ivas_param_ism_compute_mixing_matrix( const int16_t nchan_ism, /* i : number of ISM channels */ DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ @@ -285,9 +287,9 @@ static void ivas_param_ism_compute_mixing_matrix( #else static void ivas_param_ism_compute_mixing_matrix( - const int16_t nchan_ism, /* i : number of ISM channels */ - DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ - ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ + const int16_t nchan_ism, /* i : number of ISM channels */ + DIRAC_DEC_HANDLE hDirAC, /* i/o: decoder DirAC handle */ + ISM_DTX_DATA_DEC hISMDTX, /* i : ISM DTX handle */ float Cldfb_RealBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer_in[PARAM_ISM_MAX_DMX][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN], @@ -404,6 +406,7 @@ static void ivas_param_ism_compute_mixing_matrix( } #endif + #ifdef JBM_TSM_ON_TCS static void ivas_param_ism_render_slot( DIRAC_DEC_HANDLE hDirAC, @@ -822,9 +825,16 @@ ivas_error ivas_param_ism_dec_open( } else { - hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + if ( ( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_RealBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); - hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ); + + if ( ( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc = (float *) malloc( MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Param ISM JBM Rendering handle\n" ) ); + } set_zero( hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc, MAX_JBM_CLDFB_TIMESLOTS * nchan_transport * hDirAC->num_freq_bands ); } if ( st_ivas->hTcBuffer == NULL ) @@ -1097,7 +1107,6 @@ void ivas_param_ism_dec( float mixing_matrix[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX]; DIRAC_DEC_HANDLE hDirAC; - IVAS_OUTPUT_SETUP hSetup; /* Initialization */ @@ -1287,6 +1296,7 @@ void ivas_param_ism_dec( RealBuffer[i] = Cldfb_RealBuffer[idx_in][i]; ImagBuffer[i] = Cldfb_ImagBuffer[idx_in][i]; } + #ifdef JBM_TSM_ON_TCS cldfbSynthesis( RealBuffer, ImagBuffer, &( output_f[ch][slot_idx_start * hDirAC->num_freq_bands] ), hDirAC->num_freq_bands * hDirAC->subframe_nbslots[subframe_idx], st_ivas->cldfbSynDec[ch] ); @@ -1325,21 +1335,29 @@ void ivas_param_ism_dec( } #ifdef JBM_TSM_ON_TCS + +/*-------------------------------------------------------------------------* + * ivas_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_ism_dec_digest_tc( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); - if ( - st_ivas->renderer_type == RENDERER_TD_PANNING || - st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || - st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || - ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) + if ( st_ivas->renderer_type == RENDERER_TD_PANNING || + st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || + st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || + ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) ) { int16_t i, num_objects; int16_t azimuth, elevation; + /* we have a full frame interpolator, adapt it */ /* for BE testing */ if ( ( st_ivas->hDecoderConfig->output_Fs / (int32_t) FRAMES_PER_SECOND ) == st_ivas->hTcBuffer->n_samples_available ) @@ -1372,6 +1390,7 @@ void ivas_ism_dec_digest_tc( for ( i = 0; i < num_objects; i++ ) { mvr2r( st_ivas->hIsmRendererData->gains[i], st_ivas->hIsmRendererData->prev_gains[i], MAX_OUTPUT_CHANNELS ); + if ( st_ivas->intern_config == AUDIO_CONFIG_STEREO ) { ivas_ism_get_stereo_gains( st_ivas->hIsmMetaData[i]->azimuth, @@ -1384,15 +1403,15 @@ void ivas_ism_dec_digest_tc( // TODO tmu review when #215 is resolved azimuth = (int16_t) floorf( st_ivas->hIsmMetaData[i]->azimuth + 0.5f ); elevation = (int16_t) floorf( st_ivas->hIsmMetaData[i]->elevation + 0.5f ); + if ( ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hHeadTrackData == NULL ) { - - if ( st_ivas->hIntSetup.is_planar_setup ) { /* If no elevation support in output format, then rendering should be done with zero elevation */ elevation = 0; } + if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); @@ -1406,13 +1425,21 @@ void ivas_ism_dec_digest_tc( } } } + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_digest_tc() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; @@ -1422,7 +1449,6 @@ void ivas_param_ism_dec_digest_tc( float cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; /* Direct Response/EFAP Gains */ float direct_response[MAX_NUM_OBJECTS][PARAM_ISM_MAX_CHAN]; - DIRAC_DEC_HANDLE hDirAC; /* Initialization */ @@ -1541,21 +1567,27 @@ void ivas_param_ism_dec_digest_tc( /* Compute mixing matrix */ ivas_param_ism_compute_mixing_matrix( st_ivas->nchan_ism, hDirAC, st_ivas->hISMDTX, direct_response, nchan_transport, nchan_out_woLFE, cx_diag, ref_power, hDirAC->hParamIsmRendering->mixing_matrix_lin ); - pop_wmops(); return; } -static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, - IVAS_OUTPUT_SETUP hSetup, - const int16_t nchan_transport, - const int16_t nchan_out, - const int16_t nchan_out_woLFE, - float *output_f[] /* o : rendered time signal */ + +/*-------------------------------------------------------------------------* + * ivas_ism_param_dec_render_sf() + * + * + *-------------------------------------------------------------------------*/ + +static void ivas_ism_param_dec_render_sf( + Decoder_Struct *st_ivas, + IVAS_OUTPUT_SETUP hSetup, + const int16_t nchan_transport, + const int16_t nchan_out, + const int16_t nchan_out_woLFE, + float *output_f[] /* o : rendered time signal */ ) { - int16_t ch, slot_idx, i, index_slot; /* CLDFB Output Buffers */ float Cldfb_RealBuffer[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -1593,7 +1625,6 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, Cldfb_ImagBuffer_in[ch] = &hDirAC->hParamIsmRendering->Cldfb_ImagBuffer_tc[index_slot * hDirAC->num_freq_bands * nchan_transport + ch * hDirAC->num_freq_bands]; } - /* Compute bandwise rendering to target LS using covariance rendering */ ivas_param_ism_render_slot( hDirAC, Cldfb_RealBuffer_in, Cldfb_ImagBuffer_in, Cldfb_RealBuffer, Cldfb_ImagBuffer, hDirAC->hParamIsmRendering->mixing_matrix_lin, index_slot, slot_idx, @@ -1630,16 +1661,26 @@ static void ivas_ism_param_dec_render_sf( Decoder_Struct *st_ivas, idx_in++; } } + hDirAC->slots_rendered += hDirAC->subframe_nbslots[subframe_idx]; hDirAC->subframes_rendered++; + + return; } + +/*-------------------------------------------------------------------------* + * ivas_param_ism_dec_render() + * + * + *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t ch, slots_to_render, first_sf, last_sf, subframe_idx; @@ -1667,11 +1708,13 @@ void ivas_param_ism_dec_render( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; @@ -1680,10 +1723,12 @@ void ivas_param_ism_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( ch = 0; ch < nchan_out; ch++ ) { output_f_local[ch] = &output_f[ch][0]; } + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { ivas_ism_param_dec_render_sf( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_f_local ); @@ -1693,6 +1738,7 @@ void ivas_param_ism_dec_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { /* copy the memories */ @@ -1714,10 +1760,11 @@ void ivas_param_ism_dec_render( st_ivas->hIsmMetaData[ch]->elevation = st_ivas->hDirAC->elevation_values[ch]; } } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; + return; } - #endif @@ -1766,6 +1813,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1809,6 +1857,7 @@ void ivas_param_ism_params_to_masa_param_mapping( } } } + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) @@ -1825,6 +1874,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hDirAC->numSimultaneousDirections = 1; azimuth[0] = (int16_t) roundf( hDirAC->azimuth_values[0] ); elevation[0] = (int16_t) roundf( hDirAC->elevation_values[0] ); + for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ ) { for ( bin_idx = 0; bin_idx < nBins; bin_idx++ ) diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index 95c153fc807fd19d529eecd4aa4de64a2d4c8ed6..f9461f894ba94fb9ec74a24ae7920f17e08ec022 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -109,6 +109,7 @@ ivas_error ivas_ism_renderer_open( st_ivas->hIsmRendererData->interpolator[i] = (float) i / ( (float) interpolator_length - 1 ); } #endif + return error; } @@ -233,6 +234,12 @@ void ivas_ism_render( } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------------* + * ivas_ism_render_sf() + * + * Object rendering process + *-------------------------------------------------------------------------*/ + void ivas_ism_render_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: core-coder transport channels/object output */ @@ -263,6 +270,7 @@ void ivas_ism_render_sf( { /* Calculate rotation matrix from the quaternion */ QuatToRotMat( st_ivas->hHeadTrackData->Quaternions[st_ivas->hHeadTrackData->num_quaternions++], Rmat ); + ivas_jbm_dec_get_adapted_linear_interpolator( n_samples_to_render, n_samples_to_render, st_ivas->hIsmRendererData->interpolator ); @@ -271,7 +279,6 @@ void ivas_ism_render_sf( for ( i = 0; i < num_objects; i++ ) { - /* Head rotation: rotate the object positions depending the head's orientation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -302,6 +309,7 @@ void ivas_ism_render_sf( output_f[j2][k] += ( *( g1++ ) * gain + g2 * prev_gain ) * *( tc++ ); } } + /* update here only in case of head rotation */ if ( st_ivas->hHeadTrackData != NULL && st_ivas->hHeadTrackData->num_quaternions >= 0 ) { @@ -309,6 +317,7 @@ void ivas_ism_render_sf( } } } + return; } #endif diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index f33a5e01e6cf6a459ddd4b88f9df85127c80a776..443e61e262c52057c1bd86686db1ac43426c3b01 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -51,18 +51,21 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const int16_t nSamplesForRendering, int16_t *nSamplesResidual, float *data, float *tc_digest_f[] ); + static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] ); /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc() * - * Principal IVAS decoder routine, decoding of metadata and transport channels + * Principal IVAS JBM decoder routine, decoding of metadata and transport channels *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *data /* o : transport channel signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *data /* o : transport channel signals */ ) { int16_t n, output_frame, nchan_out; @@ -150,7 +153,6 @@ ivas_error ivas_jbm_dec_tc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_dec() with 'st_ivas' - TBD if ( ( error = ivas_ism_metadata_dec( ivas_total_brate, st_ivas->nchan_ism, &( st_ivas->nchan_transport ), st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, st_ivas->hDirAC->hParamIsm, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt ) ) != IVAS_ERR_OK ) { return error; @@ -209,17 +211,11 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->hQMetaData != NULL ) { st = ( st_ivas->nSCE > 0 ) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - ivas_dirac_dec_read_BS( - ivas_total_brate, - st, - st_ivas->hDirAC, - st_ivas->hQMetaData, - &nb_bits_metadata[0], - st_ivas->sba_mode, + ivas_dirac_dec_read_BS( ivas_total_brate, st, st_ivas->hDirAC, st_ivas->hQMetaData, &nb_bits_metadata[0], st_ivas->sba_mode, #ifdef HODIRAC - st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, + st_ivas->sba_analysis_order > 1 && ivas_total_brate > IVAS_256k, #endif - st_ivas->hSpar->dirac_to_spar_md_bands ); + st_ivas->hSpar->dirac_to_spar_md_bands ); } if ( ( error = ivas_spar_dec( st_ivas, nb_bits_metadata ) ) != IVAS_ERR_OK ) @@ -535,17 +531,18 @@ ivas_error ivas_jbm_dec_tc( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_feed_tc_to_renderer() * - * Feed decoded transport channels and metadata to the IVAS renderer routine + * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ ivas_error ivas_jbm_dec_feed_tc_to_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int16_t nSamplesForRendering, /* i: : number of TC samples available for rendering */ - int16_t *nSamplesResidual, /* o: : number of samples not fitting into the renderer grid and buffer for the next call*/ - float *data /* i : transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */ + int16_t *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + float *data /* i : transport channels */ ) { @@ -623,8 +620,9 @@ ivas_error ivas_jbm_dec_feed_tc_to_renderer( /*--------------------------------------------------------------------------* * ivas_dec_render() * - * Principal IVAS rendering routine + * Principal IVAS JBM rendering routine *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_render( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const uint16_t nSamplesAsked, /* i : number of samples wanted */ @@ -633,7 +631,6 @@ ivas_error ivas_jbm_dec_render( int16_t *data /* o : output synthesis signal */ ) { - int16_t n, nchan_out; int16_t nchan_transport; float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; /* 'float' buffer for output synthesis, MAX_OUTPUT_CHANNELS channels */ /* IVAS_fmToDo: buffer can be allocated dynamically based on the actual number of output channels */ @@ -658,6 +655,7 @@ ivas_error ivas_jbm_dec_render( nchan_transport = st_ivas->hTcBuffer->nchan_transport_jbm; output_config = st_ivas->hDecoderConfig->output_config; nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard; + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { p_output[n] = &output[n][0]; @@ -716,6 +714,7 @@ ivas_error ivas_jbm_dec_render( else /* ISM_MODE_DISC */ { *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal ); + /* Loudspeaker or Ambisonics rendering */ if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { @@ -731,22 +730,15 @@ ivas_error ivas_jbm_dec_render( /* Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - st_ivas->hDecoderConfig, - NULL, - NULL, - NULL, - st_ivas->hTcBuffer, - p_output, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } @@ -763,6 +755,7 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { nchan_remapped = nchan_transport; + /* Loudspeakers, Ambisonics or Binaural rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { @@ -802,21 +795,12 @@ ivas_error ivas_jbm_dec_render( /* Rendering */ if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - st_ivas->intern_config, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - &st_ivas->hIntSetup, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - p_tc, - p_output, - *nSamplesRendered, - output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, + &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_MC ) @@ -834,7 +818,11 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, *nSamplesRendered ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK ) + { + return error; + } + ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, st_ivas->hTcBuffer->tc, p_output ); } } @@ -844,8 +832,6 @@ ivas_error ivas_jbm_dec_render( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { - - /* Rendering */ int16_t offset = st_ivas->hDirAC->slots_rendered * st_ivas->hDirAC->slot_size; nchan_remapped = st_ivas->nchan_transport; @@ -857,7 +843,6 @@ ivas_error ivas_jbm_dec_render( { ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ); - if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* we still need to copy the separate channel if available */ @@ -899,8 +884,10 @@ ivas_error ivas_jbm_dec_render( * - compensation for saturation * - float to integer conversion *----------------------------------------------------------------*/ + st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered; st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered; + if ( st_ivas->hTcBuffer->n_samples_discard > 0 ) { for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) @@ -930,6 +917,7 @@ ivas_error ivas_jbm_dec_render( * * Flush samples if renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_flush_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t tc_granularity_new, /* i : new renderer granularity */ @@ -954,6 +942,7 @@ ivas_error ivas_jbm_dec_flush_renderer( *nSamplesRendered = 0; hTcBuffer = st_ivas->hTcBuffer; + /* get number of possible slots in new granularity */ n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; n_slots_still_available = n_samples_still_available / tc_granularity_new; @@ -961,9 +950,11 @@ ivas_error ivas_jbm_dec_flush_renderer( n_samples_to_render = *nSamplesRendered; n_samples_still_available -= n_samples_to_render; assert( n_samples_still_available < tc_granularity_new ); + if ( n_slots_still_available ) { - int ch_idx; + int16_t ch_idx; + /* render what is still there with zero padding */ for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -972,6 +963,7 @@ ivas_error ivas_jbm_dec_flush_renderer( set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render ); mvr2r( hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_rendered + n_samples_to_render, hTcBuffer->tc[ch_idx] + hTcBuffer->n_samples_granularity, n_samples_still_available ); } + /* simple change of the slot info */ hTcBuffer->num_slots = 1; hTcBuffer->nb_subframes = 1; @@ -995,28 +987,24 @@ ivas_error ivas_jbm_dec_flush_renderer( /* Binaural rendering */ if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } } else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */ set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, hTcBuffer->n_samples_granularity ); + ivas_ism_render_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ); - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - AUDIO_CONFIG_7_1_4, - AUDIO_CONFIG_BINAURAL_ROOM, - st_ivas->hDecoderConfig, - NULL, - NULL, - NULL, - st_ivas->hTcBuffer, - p_output, - p_output, - hTcBuffer->n_samples_granularity, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, st_ivas->hDecoderConfig, NULL, NULL, + NULL, st_ivas->hTcBuffer, p_output, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, p_output, p_output ); } } @@ -1031,26 +1019,21 @@ ivas_error ivas_jbm_dec_flush_renderer( { if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM ) { - if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, - intern_config_old, - st_ivas->hOutSetup.output_config, - st_ivas->hDecoderConfig, - st_ivas->hHeadTrackData, - hIntSetupOld, - st_ivas->hEFAPdata, - st_ivas->hTcBuffer, - hTcBuffer->tc, - p_output, - hTcBuffer->n_samples_granularity, - st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hHeadTrackData, hIntSetupOld, + st_ivas->hEFAPdata, st_ivas->hTcBuffer, hTcBuffer->tc, p_output, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) { return error; } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD ) { - ObjRenderIVASSubframe( st_ivas, p_output, hTcBuffer->n_samples_granularity ); + if ( ( ivas_td_binaural_renderer_sf( st_ivas, p_output, hTcBuffer->n_samples_granularity ) ) != IVAS_ERR_OK ) + { + return error; + } + ivas_binaural_add_LFE( st_ivas, hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->tc, p_output ); } } @@ -1077,11 +1060,13 @@ ivas_error ivas_jbm_dec_flush_renderer( return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_set_discard_samples() * * Set number of samples to discard in the first subframe if the renderer granularity changes on a bitrate change *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_set_discard_samples( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ) @@ -1100,9 +1085,11 @@ ivas_error ivas_jbm_dec_set_discard_samples( /* set last subframes number to max to ensure correct continuation */ st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe; } + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * @@ -1129,6 +1116,7 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec ); } + if ( interpolator[idx + 1] > 0.0f ) { dec = interpolator[idx + 1] / ( jbm_segment_len + 1 ); @@ -1141,13 +1129,17 @@ void ivas_jbm_dec_get_adapted_linear_interpolator( { set_f( interpolator, 0.0f, idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_subframes() * * Get an interpolator that is adapted to time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_adapted_subframes( const int16_t nCldfbTs, /* i : number of time slots in the current frame */ int16_t *subframe_nbslots, /* i/o: subframe grid */ @@ -1156,6 +1148,7 @@ void ivas_jbm_dec_get_adapted_subframes( { uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; uint16_t nCldfbSlotsLocal = nCldfbTs; + /* get last subframe size from previous frame, determine how many slots have to be processed in the first subframe (i.e. potential leftover of a 5ms subframe) */ nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] ); @@ -1165,26 +1158,33 @@ void ivas_jbm_dec_get_adapted_subframes( *nb_subframes = 1; nCldfbSlotsLocal -= nSlotsInFirstSubframe; } + *nb_subframes += (int16_t) ceilf( (float) nCldfbSlotsLocal / (float) PARAM_MC_MAX_NSLOTS_IN_SUBFRAME ); nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME; + set_s( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe; } + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_adapted_linear_interpolator() * * Get an meta data map adapted to a time scale modified IVAS frame *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_get_md_map( const int16_t default_len, /* i : default frame length in metadata slots */ const int16_t len, /* i : length of the modfied frames in metadata slots */ @@ -1196,19 +1196,19 @@ void ivas_jbm_dec_get_md_map( { int16_t jbm_segment_len, map_idx, src_idx, src_idx_map; float dec, src_idx_f; + #ifdef DEBUGGING assert( default_len % 2 == 0 ); #endif - jbm_segment_len = ( default_len >> 1 ); dec = 1.0f / default_len; - for ( map_idx = len - 1, src_idx = default_len - 1; map_idx >= jbm_segment_len; map_idx--, src_idx-- ) { src_idx_map = max( 0, src_idx / subframe_len ); map[map_idx] = ( offset + src_idx_map ) % buf_len; } + /* changed part (first segment), interpolate index to parameters (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */ if ( src_idx >= 0 ) @@ -1226,14 +1226,20 @@ void ivas_jbm_dec_get_md_map( { set_s( map, offset, map_idx + 1 ); } + + return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_num_tc_channels() * * Get the number of transport channels provided by the JBM transport channel decode function *--------------------------------------------------------------------------*/ -int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS decoder handle */ + +int16_t ivas_jbm_dec_get_num_tc_channels( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +) { int16_t num_tc; int32_t ivas_total_brate; @@ -1329,18 +1335,20 @@ int16_t ivas_jbm_dec_get_num_tc_channels( Decoder_Struct *st_ivas ) /* i : IVAS return num_tc; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_tc() * * Copy interleaved transport chnannels to the correct buffers, update the TC * buffer handle *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_copy_tc( + +static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t nSamplesForRendering, /* i : number of samples to digest */ int16_t *nSamplesResidual, /* o : number of samples that will be left for the next frame */ float *data, /* i : (interleaved) transport channel samples */ - float *tc_digest_f[] /* o : samples that will be directly digestest (eg. by CLDFB) */ + float *tc_digest_f[] /* o : samples that will be directly digested (e.g. by CLDFB) */ ) { int16_t ch; @@ -1349,7 +1357,6 @@ void ivas_jbm_dec_copy_tc( int16_t n_ch_full_copy; int16_t n_ch_res_copy; - hTcBuffer = st_ivas->hTcBuffer; n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered; hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard; @@ -1367,6 +1374,7 @@ void ivas_jbm_dec_copy_tc( hTcBuffer->tc[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * st_ivas->hTcBuffer->nchan_transport_jbm + ch]; } } + if ( n_ch_res_copy > 0 ) { for ( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) @@ -1379,13 +1387,24 @@ void ivas_jbm_dec_copy_tc( mvr2r( tc_digest_f[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc[ch], *nSamplesResidual ); } } + hTcBuffer->n_samples_rendered = 0; + return; } -int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, - const int32_t output_Fs ) +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_render_granularity() + * + * + *--------------------------------------------------------------------------*/ + +/*! r: render granularity */ +int16_t ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const int32_t output_Fs /* i : sampling rate */ +) { int16_t render_granularity; @@ -1401,17 +1420,19 @@ int16_t ivas_jbm_dec_get_render_granularity( const RENDERER_TYPE rendererType, return render_granularity; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_open() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_open( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ const int16_t nchan_transport_jbm, /* i : number of real transport channels */ const int16_t nchan_transport_internal, /* i : number of totally buffered channels */ - const int16_t nchan_full, /* i : nubmer of channels to fully store */ + const int16_t nchan_full, /* i : number of channels to fully store */ const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ ) { @@ -1430,8 +1451,9 @@ ivas_error ivas_jbm_dec_tc_buffer_open( if ( ( hTcBuffer = (DECODER_TC_BUFFER_HANDLE) malloc( sizeof( DECODER_TC_BUFFER ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TC Buffer\n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); } + hTcBuffer->tc_buffer_mode = tc_buffer_mode; hTcBuffer->nchan_transport_jbm = nchan_transport_jbm; hTcBuffer->nchan_transport_internal = nchan_transport_internal; @@ -1465,10 +1487,16 @@ ivas_error ivas_jbm_dec_tc_buffer_open( int16_t n_samp_full = ( NS2SA( st_ivas->hDecoderConfig->output_Fs, MAX_JBM_L_FRAME_NS ) + hTcBuffer->n_samples_granularity - 1 ); int16_t n_samp_residual = hTcBuffer->n_samples_granularity - 1; int32_t offset; + nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1487,14 +1515,17 @@ ivas_error ivas_jbm_dec_tc_buffer_open( } st_ivas->hTcBuffer = hTcBuffer; + return error; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_tc_buffer_reconfigure() * - * open and initialize the transport channel buffer + * open and initialize JBM transport channel buffer *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_tc_buffer_reconfigure( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ @@ -1552,8 +1583,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( hTcBuffer->nchan_buffer_full = nchan_full; nchan_residual = nchan_transport_internal - nchan_full; hTcBuffer->n_samples_granularity = n_samples_granularity; +#ifdef DEBUGGING /* what is remaining from last frames needs always be smaller than n_samples_granularity */ assert( ( hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered ) < n_samples_granularity ); +#endif /* realloc buffers */ free( hTcBuffer->tc_buffer ); @@ -1561,8 +1594,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( n_samp_residual = hTcBuffer->n_samples_granularity - 1; nsamp_to_allocate = hTcBuffer->nchan_buffer_full * n_samp_full; nsamp_to_allocate += nchan_residual * n_samp_residual; - hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ); + + if ( ( hTcBuffer->tc_buffer = (float *) malloc( nsamp_to_allocate * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM TC Buffer\n" ) ); + } set_zero( hTcBuffer->tc_buffer, nsamp_to_allocate ); + offset = 0; for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_buffer_full; ch_idx++ ) { @@ -1582,7 +1620,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure( return error; } -void ivas_jbm_dec_tc_buffer_playout( + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_playout() + * + * + *--------------------------------------------------------------------------*/ + +static void ivas_jbm_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, @@ -1592,25 +1637,37 @@ void ivas_jbm_dec_tc_buffer_playout( int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf; slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, nSamplesAsked / slot_size ); st_ivas->hTcBuffer->slots_rendered += slots_to_render; *nSamplesRendered = (uint16_t) slots_to_render * slot_size; first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; last_sf++; } + for ( ch_idx = 0; ch_idx < st_ivas->hTcBuffer->nchan_transport_jbm; ch_idx++ ) { mvr2r( st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered, output[ch_idx], *nSamplesRendered ); } st_ivas->hTcBuffer->subframes_rendered = last_sf; + + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_tc_buffer_close() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_tc_buffer_close( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) @@ -1632,20 +1689,31 @@ void ivas_jbm_dec_tc_buffer_close( free( *phTcBuffer ); *phTcBuffer = NULL; } + return; } + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_td_renderers_adapt_subframes() + * + * Close JBM transport channel buffer + *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_td_renderers_adapt_subframes( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { int16_t nMaxSlotsPerSubframe, nSlotsAvailable; uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe; + nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; st_ivas->hTcBuffer->num_slots = nSlotsAvailable; st_ivas->hTcBuffer->n_samples_available = nSlotsAvailable * st_ivas->hTcBuffer->n_samples_granularity; nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; st_ivas->hTcBuffer->nb_subframes = 0; + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->nb_subframes = 1; @@ -1655,19 +1723,33 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe; set_s( st_ivas->hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); set_s( st_ivas->hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, st_ivas->hTcBuffer->nb_subframes ); + if ( nSlotsInFirstSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe; } + if ( nSlotsInLastSubframe > 0 ) { st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe; } + st_ivas->hTcBuffer->slots_rendered = 0; st_ivas->hTcBuffer->subframes_rendered = 0; + + return; } -TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) + +/*--------------------------------------------------------------------------* + * ivas_jbm_dec_get_tc_buffer_mode() + * + * + *--------------------------------------------------------------------------*/ + +TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) { TC_BUFFER_MODE buffer_mode; buffer_mode = TC_BUFFER_MODE_BUFFER; @@ -1736,7 +1818,6 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode( Decoder_Struct *st_ivas ) #endif } - return buffer_mode; } #endif diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 7e63c2d539ad965107966cecc3e676a167e96c69..e89453686feeee5ac20a55f1ebf14bdb9245027f 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -167,7 +167,7 @@ static void d_autocorr( * of input signal *---------------------------------------------------------------------*/ -/* !r: energy of prediction error */ +/*! r: energy of prediction error */ static int16_t d_lev_dur( double *a, /* o : LP coefficients (a[0] = 1.0) */ const double *r, /* i : vector of autocorrelations */ diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c index 2c9fcbd008e0b289dd3359a479835ad9ab9eb4f8..ddecbed30a51c53ed39cfd1994bb568d2248907e 100644 --- a/lib_dec/ivas_masa_dec.c +++ b/lib_dec/ivas_masa_dec.c @@ -44,6 +44,7 @@ #include #include "wmc_auto.h" + /*-----------------------------------------------------------------------* * Local constants *-----------------------------------------------------------------------*/ @@ -55,6 +56,7 @@ /*-----------------------------------------------------------------------* * Local function prototypes *-----------------------------------------------------------------------*/ + #ifndef HR_METADATA static int16_t quantize_theta( float x, int16_t no_cb, float *xhat ); static uint16_t index_theta_phi_16( float theta, float phi, SPHERICAL_GRID_DATA *Sph_Grid16 ); @@ -196,6 +198,7 @@ ivas_error ivas_masa_decode( /* Remove already read bits from the bit budget */ hQMetaData->metadata_max_bits -= *nb_bits_read; + #ifdef HR_METADATA if ( ivas_total_brate >= IVAS_384k ) { @@ -411,11 +414,13 @@ ivas_error ivas_masa_dec_open( { int16_t nchan_to_allocate; TC_BUFFER_MODE buffer_mode; + buffer_mode = TC_BUFFER_MODE_RENDERER; if ( st_ivas->mc_mode == MC_MODE_MCMASA && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO ) ) { buffer_mode = TC_BUFFER_MODE_BUFFER; } + nchan_to_allocate = ivas_jbm_dec_get_num_tc_channels( st_ivas ); if ( ( error = ivas_jbm_dec_tc_buffer_open( st_ivas, buffer_mode, nchan_to_allocate, nchan_to_allocate, nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) { @@ -518,14 +523,20 @@ static ivas_error ivas_masa_dec_config( if ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->hDecoderConfig->ivas_total_brate == IVAS_512k ) { hMasa->config.mergeRatiosOverSubframes = 0; - /* initialize spherical grid */ + + /* allocate and initialize spherical grid */ if ( hMasa->data.sph_grid16 == NULL ) { - hMasa->data.sph_grid16 = (SPHERICAL_GRID_DATA *) malloc( sizeof( SPHERICAL_GRID_DATA ) ); + if ( ( hMasa->data.sph_grid16 = (SPHERICAL_GRID_DATA *) malloc( sizeof( SPHERICAL_GRID_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA spherical grid structure" ); + } + generate_gridEq( hMasa->data.sph_grid16 ); } } #endif + st_ivas->hQMetaData->metadata_max_bits = hMasa->config.max_metadata_bits; st_ivas->hQMetaData->bandMap = hMasa->data.band_mapping; st_ivas->hQMetaData->nchan_transport = st_ivas->nchan_transport; @@ -787,8 +798,8 @@ static void index_16bits( { for ( block = 0; block < hQMetaData->q_direction[0].cfg.nblocks; block++ ) { - hQMetaData->q_direction[d].band_data[band].spherical_index[block] = index_theta_phi_16( &( hQMetaData->q_direction[d].band_data[band].elevation[block] ), - &( hQMetaData->q_direction[d].band_data[band].azimuth[block] ), Sph_Grid16 ); + hQMetaData->q_direction[d].band_data[band].spherical_index[block] = ivas_qmetadata_index_theta_phi_16( &( hQMetaData->q_direction[d].band_data[band].elevation[block] ), + &( hQMetaData->q_direction[d].band_data[band].azimuth[block] ), Sph_Grid16 ); } } } @@ -1158,6 +1169,10 @@ ivas_error ivas_masa_dec_reconfigure( #endif #ifdef FIX_425_MASA_BRSW_RENDERER + /*-----------------------------------------------------------------* + * Renderer selection + *-----------------------------------------------------------------*/ + /* renderer might have changed, reselect */ ivas_renderer_select( st_ivas ); @@ -1233,6 +1248,7 @@ ivas_error ivas_masa_dec_reconfigure( } } } + #ifdef FIX_425_MASA_BRSW_RENDERER if ( st_ivas->hDiracDecBin != NULL ) { @@ -1240,6 +1256,7 @@ ivas_error ivas_masa_dec_reconfigure( st_ivas->hDiracDecBin->reqularizationFactor = configure_reqularization_factor( st_ivas->ivas_format, st_ivas->hDecoderConfig->ivas_total_brate ); } #endif + #ifdef FIX_417_TD_DECORR_BRATE_SW /*-----------------------------------------------------------------* * TD Decorrelator @@ -1278,11 +1295,13 @@ ivas_error ivas_masa_dec_reconfigure( buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); tc_nchan_transport = ivas_jbm_dec_get_num_tc_channels( st_ivas ); + tc_nchan_to_allocate = tc_nchan_transport; if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) { tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; } + if ( tc_nchan_transport != st_ivas->hTcBuffer->nchan_transport_jbm || tc_nchan_to_allocate != st_ivas->hTcBuffer->nchan_transport_internal || buffer_mode_new != st_ivas->hTcBuffer->tc_buffer_mode ) { if ( ( error = ivas_jbm_dec_tc_buffer_reconfigure( st_ivas, buffer_mode_new, tc_nchan_transport, tc_nchan_to_allocate, tc_nchan_to_allocate, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) @@ -1292,6 +1311,7 @@ ivas_error ivas_masa_dec_reconfigure( } } #endif + return error; } @@ -1571,7 +1591,6 @@ void ivas_spar_param_to_masa_param_mapping( float slot_fac; #endif - /* Set values */ hDirAC = st_ivas->hDirAC; hDirAC->numSimultaneousDirections = 1; diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index d19e2d33ccb1ab0ff5254d1a3b7dcbd48b23adc1..356116b254c3ca326d92553630bb16d6fde3875c 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -2364,7 +2364,8 @@ static void ivas_param_mc_dec_copy_diffuse_proto( * * decode a number of bits to an integer *------------------------------------------------------------------------*/ -/* r : decoded integer */ + +/*! r: decoded integer */ static int16_t ivas_param_mc_bin2dec( uint16_t bits[PARAM_MC_MAX_BITS], /* i : bit buffer */ const int16_t N /* i : number of bits to decode */ diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c old mode 100755 new mode 100644 index 0dd2552c0f161ac455ac746f48d179993dea6eac..2567f340e92c82f3829aa0efe494e805104a6247 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -155,8 +155,7 @@ ivas_error ivas_mct_dec( set_zero( x[n][1], L_FRAME48k / 2 ); } - ivas_mdct_core_invQ( st_ivas->hCPE[cpe_id], - nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], + ivas_mdct_core_invQ( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id], fUseTns[cpe_id], tnsData[cpe_id], x, x, Aq[cpe_id], NULL, 1 ); st_ivas->BER_detect |= st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect; @@ -226,8 +225,7 @@ ivas_error ivas_mct_dec( x[n][1] = &output[n + cpe_id * CPE_CHANNELS][L_FRAME48k / 2]; } - ivas_mdct_core_reconstruct( hCPE, x, synth, - fUseTns[cpe_id], 1 ); + ivas_mdct_core_reconstruct( hCPE, x, synth, fUseTns[cpe_id], 1 ); /*----------------------------------------------------------------* * CoreCoder Post-processing and updates @@ -235,7 +233,6 @@ ivas_error ivas_mct_dec( for ( n = 0; n < CPE_CHANNELS; n++ ) { - if ( st_ivas->sba_dirac_stereo_flag ) { ivas_post_proc( NULL, hCPE, n, synth[n], NULL, output_frame, 1 ); @@ -374,8 +371,7 @@ ivas_error create_mct_dec( } } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( ( hMCT->nchan_out_woLFE ) % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -485,8 +481,7 @@ ivas_error mct_dec_reconfigure( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( ( hMCT->nchan_out_woLFE ) % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -503,11 +498,12 @@ ivas_error mct_dec_reconfigure( st->total_brate = st_ivas->hCPE[cpe_id]->element_brate; - if ( !( - ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) ) ) + if ( st->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); + st->igf = getIgfPresent( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->rf_flag ); + if ( st->igf ) { IGFDecSetMode( st->hIGFDec, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, -1, -1, st->rf_flag ); @@ -629,7 +625,7 @@ void ivas_mct_dec_close( * - reconfigure the MC format decoder *-------------------------------------------------------------------------*/ -/*! r : MC format mode */ +/*! r: MC format mode */ ivas_error ivas_mc_dec_config( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int16_t idx /* i : LS config. index */ @@ -740,8 +736,13 @@ static ivas_error ivas_mc_dec_reconfig( { nchan_hp20_old = nchan_transport_old; } + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + /*-----------------------------------------------------------------* + * Renderer selection + *-----------------------------------------------------------------*/ + #ifdef JBM_TSM_ON_TCS /* save old IntSetup, might be needed for JBM flushing...*/ intern_config_old = st_ivas->intern_config; @@ -757,6 +758,10 @@ static ivas_error ivas_mc_dec_reconfig( /* side effect of the renderer selection can be a changed internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + /*-----------------------------------------------------------------* + * Reconfigure MC handles + *-----------------------------------------------------------------*/ + #ifdef JBM_TSM_ON_TCS if ( st_ivas->hDecoderConfig->voip_active ) { @@ -918,7 +923,6 @@ static ivas_error ivas_mc_dec_reconfig( } #endif - if ( last_mc_mode == MC_MODE_MCT ) { if ( st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS ) @@ -1017,7 +1021,6 @@ static ivas_error ivas_mc_dec_reconfig( if ( st->hHQ_core == NULL ) { - if ( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); @@ -1038,6 +1041,7 @@ static ivas_error ivas_mc_dec_reconfig( st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode ); } + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { uint8_t separateChannelEnabled; @@ -1083,7 +1087,6 @@ static ivas_error ivas_mc_dec_reconfig( } } - /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ @@ -1132,7 +1135,6 @@ static ivas_error ivas_mc_dec_reconfig( return error; } - set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN ); set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k ); } @@ -1322,6 +1324,7 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * Reconfigure TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_full_new; @@ -1341,6 +1344,7 @@ static ivas_error ivas_mc_dec_reconfig( { tc_nchan_full_new = 0; } + /* reconfigure buffer */ if ( hTcBuffer->tc_buffer_mode != tc_buffer_mode_new || hTcBuffer->nchan_transport_jbm != tc_nchan_tc_new || hTcBuffer->nchan_buffer_full != tc_nchan_full_new || hTcBuffer->nchan_transport_internal != tc_nchan_allocate_new || @@ -1351,6 +1355,7 @@ static ivas_error ivas_mc_dec_reconfig( return error; } } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ if ( st_ivas->hDirAC != NULL ) { @@ -1370,5 +1375,6 @@ static ivas_error ivas_mc_dec_reconfig( } } #endif + return error; } diff --git a/lib_dec/ivas_mct_dec_mct.c b/lib_dec/ivas_mct_dec_mct.c index 987a9cc72f25a60b4e820972aeb8ae6c4fcb4b8e..de22b6346d652d2a491cf485330702a81a6dcb57 100644 --- a/lib_dec/ivas_mct_dec_mct.c +++ b/lib_dec/ivas_mct_dec_mct.c @@ -99,8 +99,7 @@ void ivas_mct_dec_mct( /*first get core and overlap info for all channels*/ for ( ch = 0; ch < nchan; ch++ ) { - if ( - hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( hMCT->currBlockDataCnt && sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { hMCT->mc_global_ild[ch] = get_next_indice( sts[0], SMDCT_GLOBAL_ILD_BITS ); } @@ -124,8 +123,7 @@ void ivas_mct_dec_mct( for ( ch = 0; ch < nchan; ch++ ) { - if ( - sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode != MCT_CHAN_MODE_IGNORE ) { nchan_active++; } @@ -226,6 +224,7 @@ void apply_MCT_dec( return; } + /*----------------------------------------------------------* * mctStereoIGF_dec() * diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index 81a8dda3549bc069ea6bdde12056d5338b63b9c0..b1d2e8101d8957682ed6869fdc51d75acd5d81f5 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -199,6 +199,7 @@ static void dec_prm_tcx_sidebits( getTCXparam( st, st0, hm_cfg, param, 0, 0, ( ( ch > 0 ) && ( tnsSize ) && ( tnsSize[0] + tnsSize[1] > 0 ) ? tnsSize : NULL ), p_param, nTnsBitsTCX10, 0 ); st->side_bits_frame_channel = st0->next_bit_pos - start_bit_pos; + return; } @@ -330,6 +331,7 @@ void ivas_mdct_dec_side_bits_frame_channel( { continue; } + st = sts[ch]; if ( MCT_flag ) { @@ -706,6 +708,7 @@ void ivas_mdct_core_invQ( sts[1]->core = sts[1]->last_core; } } + mvr2r( tmp_ms_sig[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); mvr2r( tmp_ms_sig[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0] ); } @@ -943,8 +946,7 @@ void ivas_mdct_core_reconstruct( decoder_tcx_imdct( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], &x[ch][k][0], xn_buf, ( ( hCPE->nchan_out == 1 && st->hTcxDec->kernel_type[k] == MDST_IV ) || st->hTcxCfg->tcx_last_overlap_mode == TRANSITION_OVERLAP ) ? MDCT_IV : st->hTcxDec->kernel_type[k], - fUseTns[ch][k], &synth[k * L_frame[ch]], &synthFB[k * L_frameTCX[ch]], bfi, k, - 0 ); + fUseTns[ch][k], &synth[k * L_frame[ch]], &synthFB[k * L_frameTCX[ch]], bfi, k, 0 ); } else { @@ -1118,7 +1120,6 @@ void ivas_mdct_core_tns_ns( set_f( xn_buf, 0, L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX ); - /* TNS, ITF, IMDCT and updates */ for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 873c75938a8866752dc2bb2a01ba7998a9f6e475..d84df109d5825ea710db2a5aed889f2631e3ece6 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -83,18 +83,20 @@ ivas_error ivas_td_binaural_renderer( ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL, output, output_frame ); } + #ifdef JBM_TSM_ON_TCS /*---------------------------------------------------------------------* - * ObjRenderIVASFrame() + * ivas_td_binaural_renderer_sf() * * Receives the current frames for the object streams, updates metadata * and renders the current frame. *---------------------------------------------------------------------*/ -void ObjRenderIVASSubframe( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* i/o: SCE channels / Binaural synthesis */ - const int16_t n_samples_asked ) +ivas_error ivas_td_binaural_renderer_sf( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ + const int16_t n_samples_granularity /* i : granularity of the renderer/buffer */ +) { int16_t first_sf, last_sf, subframe_idx; float reverb_signal[BINAURAL_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; @@ -102,24 +104,31 @@ void ObjRenderIVASSubframe( float *output_f_local[BINAURAL_CHANNELS]; float *tc_local[MAX_TRANSPORT_CHANNELS]; int16_t ch, slot_size, slots_to_render, output_frame; + ivas_error error; + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_reverb_signal[ch] = reverb_signal[ch]; } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] = st_ivas->hTcBuffer->tc[ch] + st_ivas->hTcBuffer->n_samples_rendered; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] = output[ch]; } + slot_size = st_ivas->hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_asked / slot_size ); + slots_to_render = min( st_ivas->hTcBuffer->num_slots - st_ivas->hTcBuffer->slots_rendered, n_samples_granularity / slot_size ); first_sf = st_ivas->hTcBuffer->subframes_rendered; last_sf = first_sf; st_ivas->hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= st_ivas->hTcBuffer->subframe_nbslots[last_sf]; @@ -129,22 +138,28 @@ void ObjRenderIVASSubframe( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { output_frame = st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] * st_ivas->hTcBuffer->n_samples_granularity; + /* Update object position(s) */ TDREND_Update_object_positions( st_ivas->hBinRendererTd, st_ivas->nchan_transport, LFE_CHANNEL, st_ivas->ivas_format, st_ivas->hIsmMetaData, tc_local ); /* Update the listener's location/orientation */ - TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, - st_ivas->hDecoderConfig->Opt_Headrotation, + TDREND_Update_listener_orientation( st_ivas->hBinRendererTd, st_ivas->hDecoderConfig->Opt_Headrotation, ( st_ivas->hHeadTrackData != NULL ) ? &st_ivas->hHeadTrackData->Quaternions[0] : NULL, ( st_ivas->hHeadTrackData != NULL ) ? st_ivas->hHeadTrackData->Pos : NULL ); if ( ( st_ivas->hRenderConfig != NULL ) && ( st_ivas->hRenderConfig->roomAcoustics.late_reverb_on ) ) { - ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ); + if ( ( error = ivas_reverb_process( st_ivas->hReverb, st_ivas->transport_config, 0, tc_local, p_reverb_signal, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } } /* Render subframe */ - TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ); + if ( ( error = TDREND_GetMix( st_ivas->hBinRendererTd, output_f_local, output_frame, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } if ( st_ivas->hRenderConfig != NULL ) /* Renderer Configuration not enabled in TD standalone renderer */ { @@ -155,16 +170,20 @@ void ObjRenderIVASSubframe( v_add( reverb_signal[1], output_f_local[1], output_f_local[1], output_frame ); } } + for ( ch = 0; ch < st_ivas->hTcBuffer->nchan_transport_internal; ch++ ) { tc_local[ch] += output_frame; } + for ( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { output_f_local[ch] += output_frame; } } + st_ivas->hTcBuffer->subframes_rendered = last_sf; - return; + + return IVAS_ERR_OK; } #endif diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index 3f95113f604f8249e1034492dfe1c92fb926645c..1d6db5eebfd9c83f3b65c7436a5ca0b0d4597317 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -1161,7 +1161,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ #ifdef JBM_TSM_ON_TCS - int16_t num_timeslots, + const int16_t num_timeslots, #endif float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 5480f73a33538aefb9ee7974e07342b04bccc430..bda3bfa3fff78ff8a267fe67706af1438f73ea5b 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -136,9 +136,9 @@ static int16_t read_coherence_data_hr_512( uint16_t *bitstream, int16_t *p_bit_p /*! r: number of bits read */ int16_t ivas_qmetadata_dec_decode( - IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ - uint16_t *bitstream, /* i : bitstream */ - int16_t *index /* i/o: bitstream position */ + IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: hQMetaData handle */ + uint16_t *bitstream, /* i : bitstream */ + int16_t *index /* i/o: bitstream position */ #ifdef HODIRAC , const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode */ @@ -896,6 +896,7 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( hQMetaData->q_direction[0].band_data[b].energy_ratio[m] = 1.0f - diffuseness_reconstructions_hr[hQMetaData->q_direction[0].band_data[b].energy_ratio_index[m]]; } } + if ( hQMetaData->no_directions == 2 ) { for ( b = hQMetaData->q_direction[1].cfg.start_band; b < hQMetaData->q_direction[1].cfg.nbands; b++ ) @@ -982,7 +983,6 @@ int16_t ivas_qmetadata_dec_decode_hr_384_512( ivas_qmetadata_raw_decode_dir_512( q_direction, bitstream, index, nbands, start_band, sph_grid16 ); #ifdef DEBUG_MODE_QMETADATA - fprintf( pF, "frame %d: diff %d surcoh %d ", frame, bits_diff_sum, bits_sur_coherence ); fprintf( pF, "dir %d\n", start_index_0 - *index ); fprintf( pF_azi, "frame %d/dir/ec %d: ", frame, d ); @@ -1252,9 +1252,9 @@ int16_t ivas_qmetadata_dec_sid_decode( q_direction->band_data[b].spherical_index[i] = value; } - deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, - &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], - q_direction->cfg.mc_ls_setup ); + ivas_qmetadata_deindex_spherical_component( q_direction->band_data[b].spherical_index[0], &avg_azimuth, &avg_elevation, + &q_direction->band_data[b].azimuth_index[0], &q_direction->band_data[b].elevation_index[0], q_direction->band_data[b].bits_sph_idx[0], + q_direction->cfg.mc_ls_setup ); ivas_qmetadata_azimuth_elevation_to_direction_vector( avg_azimuth, avg_elevation, avg_direction_vector ); ivas_qmetadata_azimuth_elevation_to_direction_vector( q_direction->band_data[b].azimuth[nblocks - 1], q_direction->band_data[b].elevation[nblocks - 1], direction_vector ); @@ -1856,6 +1856,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( if ( bands_entropic[b] ) { int16_t tmp_index; + #ifdef HR_METADATA if ( hrmasa_flag ) { @@ -1933,6 +1934,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( for ( m = 0; m < nblocks; m++ ) { int16_t tmp_index; + if ( q_direction->cfg.mc_ls_setup != MC_LS_SETUP_INVALID ) { avg_elevation_index_projected = ivas_chan_project_elevation_index( avg_elevation_idx, avg_elevation_alphabet, elev_alph[b] ); @@ -2101,6 +2103,7 @@ static int16_t ivas_qmetadata_entropy_decode_dir( { v_multc( avg_direction_vector, 0.5f, avg_direction_vector, 3 ); } + /*compute the average direction per already coded subband */ ivas_qmetadata_azimuth_elevation_to_direction_vector( q_direction->band_data[b].azimuth[m], q_direction->band_data[b].elevation[m], direction_vector ); v_add( avg_direction_vector, direction_vector, avg_direction_vector, 3 ); @@ -2152,17 +2155,18 @@ static int16_t ivas_qmetadata_raw_decode_dir_512( { value = ( value << 1 ) + bitstream[( *index )--]; } + q_direction->band_data[b].spherical_index[m] = value; if ( q_direction->band_data[b].bits_sph_idx[m] == 16 ) { - deindex_sph_idx( value, sph_grid16, &( q_direction->band_data[b].elevation[m] ), &( q_direction->band_data[b].azimuth[m] ) ); + ivas_qmetadata_deindex_sph_idx( value, sph_grid16, &( q_direction->band_data[b].elevation[m] ), &( q_direction->band_data[b].azimuth[m] ) ); } else { - deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], - &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + ivas_qmetadata_deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], + &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], + q_direction->cfg.mc_ls_setup ); } } } @@ -2368,7 +2372,7 @@ static int16_t ivas_qmetadata_ReorderElevationDecoded( /*-----------------------------------------------------------------------* - * Local functions: requentizeEC3 + * Local functions: *-----------------------------------------------------------------------*/ /*! r: number of bits read */ @@ -2925,9 +2929,9 @@ static int16_t decode_fixed_rate( q_direction->band_data[b].spherical_index[m] = value; nbits += q_direction->band_data[b].bits_sph_idx[m]; - deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], - &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], - q_direction->cfg.mc_ls_setup ); + ivas_qmetadata_deindex_spherical_component( q_direction->band_data[b].spherical_index[m], &q_direction->band_data[b].azimuth[m], &q_direction->band_data[b].elevation[m], + &q_direction->band_data[b].azimuth_index[m], &q_direction->band_data[b].elevation_index[m], q_direction->band_data[b].bits_sph_idx[m], + q_direction->cfg.mc_ls_setup ); } return nbits; @@ -3040,6 +3044,7 @@ static void set_zero_direction( const int16_t len ) { int16_t k; + for ( k = 0; k < len; k++ ) { q_direction->band_data[idx_band].azimuth[k] = 0; @@ -3517,7 +3522,6 @@ static int16_t decode_fixed_rate_composed_index_coherence( /* fixed rate */ uint64_t no_cb; uint16_t temp_index[MASA_MAXIMUM_CODING_SUBBANDS]; - uint64_t idx_fr; int16_t no_bits_vec1, half_no_bands; int16_t bit_pos; @@ -3590,7 +3594,9 @@ static int16_t decode_fixed_rate_composed_index_coherence( { idx_fr = ( idx_fr << 1 ) + bitstream[bit_pos--]; } + nbits += no_bits_vec1; + decode_combined_index( idx_fr, &no_cv_vec[half_no_bands], &temp_index[half_no_bands], half_no_bands ); } else @@ -3600,7 +3606,9 @@ static int16_t decode_fixed_rate_composed_index_coherence( { idx_fr = ( idx_fr << 1 ) + bitstream[bit_pos--]; } + nbits += no_bits_vec; + decode_combined_index( idx_fr, no_cv_vec, temp_index, no_bands ); } @@ -3624,7 +3632,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 */ @@ -3645,10 +3653,10 @@ static int16_t read_coherence_data_hr_512( nbands = hQMetaData->q_direction[idx_dir].cfg.nbands; nblocks = hQMetaData->q_direction[idx_dir].cfg.nblocks; - cb_size = 1 << nbits_coh; delta = 256.0f / cb_size; nbits = *p_bit_pos; + for ( k = 0; k < nblocks; k++ ) { /* read method */ @@ -3661,11 +3669,13 @@ static int16_t read_coherence_data_hr_512( { min_index = ( min_index << 1 ) + bitstream[( *p_bit_pos )--]; } + /* read GR param */ GR_param = bitstream[( *p_bit_pos )--]; for ( j = 0; j < nbands; j++ ) { decoded_idx = ivas_qmetadata_DecodeExtendedGR( bitstream, p_bit_pos, 2 * cb_size, GR_param ); + if ( decoded_idx % 2 ) { decoded_idx = ( ( decoded_idx + 1 ) >> 1 ) + min_index; @@ -3674,6 +3684,7 @@ static int16_t read_coherence_data_hr_512( { decoded_idx = -( decoded_idx >> 1 ) + min_index; } + hQMetaData->q_direction[idx_dir].coherence_band_data[j].spread_coherence[k] = (uint8_t) ( decoded_idx * delta + delta / 2.0f ); } } @@ -3686,6 +3697,7 @@ static int16_t read_coherence_data_hr_512( { min_index = ( min_index << 1 ) + bitstream[( *p_bit_pos )--]; } + /* read GR param */ GR_param = bitstream[( *p_bit_pos )--]; for ( j = 0; j < nbands; j++ ) @@ -3695,7 +3707,9 @@ static int16_t read_coherence_data_hr_512( } } } + nbits = nbits - *p_bit_pos; + return nbits; } #endif @@ -3761,6 +3775,7 @@ static int16_t read_coherence_data( #ifdef HR_METADATA } #endif + no_cv_vec[j] = idx_ER + 1; } @@ -4145,6 +4160,7 @@ static int16_t read_surround_coherence_hr( IVAS_QDIRECTION *q_direction; int16_t min_index; int16_t d, idx; + coding_subbands = hQMetaData->q_direction[0].cfg.nbands; q_direction = hQMetaData->q_direction; @@ -4168,7 +4184,6 @@ static int16_t read_surround_coherence_hr( error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[sf]; } - if ( error_ratio_surr <= 0 ) { error_ratio_surr = 0; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c old mode 100755 new mode 100644 index 0dcaec91da54020113ede586536eb13f1da1d064..fd379c6b4a7b47a4c50c144039bcfcb6c84be593 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -117,6 +117,7 @@ ivas_error ivas_sba_dec_reconfigure( DECODER_CONFIG_HANDLE hDecoderConfig; ivas_error error; + error = IVAS_ERR_OK; hDecoderConfig = st_ivas->hDecoderConfig; @@ -137,6 +138,7 @@ ivas_error ivas_sba_dec_reconfigure( sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->sba_order ); + #ifdef JBM_TSM_ON_TCS /* save old */ if ( st_ivas->hDirAC == NULL && st_ivas->hSpar != NULL ) @@ -201,6 +203,7 @@ ivas_error ivas_sba_dec_reconfigure( hSpar = st_ivas->hSpar; st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hSpar->num_slots = st_ivas->hTcBuffer->num_slots; @@ -209,6 +212,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; mvs2s( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); #endif + if ( st_ivas->nchan_transport == 1 ) { st_ivas->element_mode_init = IVAS_SCE; @@ -291,6 +295,7 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } + #ifdef JBM_TSM_ON_TCS /* synchronize subframe info */ st_ivas->hDirAC->num_slots = st_ivas->hTcBuffer->num_slots; @@ -377,8 +382,9 @@ ivas_error ivas_sba_dec_reconfigure( #ifdef JBM_TSM_ON_TCS /*-----------------------------------------------------------------* - * TC buffer + * JBM TC buffer *-----------------------------------------------------------------*/ + if ( st_ivas->hDecoderConfig->voip_active == 1 ) { int16_t tc_nchan_to_allocate; @@ -424,10 +430,17 @@ ivas_error ivas_sba_dec_reconfigure( } } #endif + return error; } #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_sba_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + ivas_error ivas_sba_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nCldfbSlots, /* i : number of CLDFB slots */ @@ -445,22 +458,27 @@ ivas_error ivas_sba_dec_digest_tc( { ivas_dirac_dec_set_md_map( st_ivas, nCldfbSlots ); } + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) { ivas_spar_dec_digest_tc( st_ivas, st_ivas->nchan_transport, nCldfbSlots, nSamplesForRendering ); } + if ( st_ivas->hDiracDecBin != NULL && ( st_ivas->hDiracDecBin->useTdDecorr ) ) { int16_t nSamplesLeftForTD, default_frame; float *decorr_signal[BINAURAL_CHANNELS]; float *p_tc[2 * BINAURAL_CHANNELS]; + default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; + for ( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx + BINAURAL_CHANNELS]; p_tc[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx]; } + while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); @@ -473,21 +491,30 @@ ivas_error ivas_sba_dec_digest_tc( nSamplesLeftForTD -= nSamplesToDecorr; } } + /* if we have a late CNG generation, do it here */ if ( st_ivas->nchan_transport == 1 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cna_dirac_flag && st_ivas->sba_mode != SBA_MODE_SPAR ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; generate_masking_noise_lb_dirac( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } + return error; } + +/*-------------------------------------------------------------------* + * ivas_sba_dec_render() + * + * + *-------------------------------------------------------------------*/ + void ivas_sba_dec_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -503,7 +530,9 @@ void ivas_sba_dec_render( st_ivas->hDecoderConfig->ivas_total_brate #endif ); + nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; + #ifdef DEBUGGING assert( hSpar ); #endif @@ -511,12 +540,15 @@ void ivas_sba_dec_render( { output_f_local[ch] = output_f[ch]; } + slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hSpar->num_slots - hSpar->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hSpar->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hSpar->subframe_nbslots[last_sf]; @@ -525,9 +557,11 @@ void ivas_sba_dec_render( #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif + for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { int16_t n_samples_sf = slot_size * hSpar->subframe_nbslots[subframe_idx]; + ivas_spar_dec_upmixer_sf( st_ivas, output_f_local, nchan_internal ); for ( ch = 0; ch < nchan_out; ch++ ) { @@ -539,6 +573,7 @@ void ivas_sba_dec_render( { ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); } + if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -550,6 +585,7 @@ void ivas_sba_dec_render( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + *nSamplesAvailable = ( hSpar->num_slots - hSpar->slots_rendered ) * slot_size; return; diff --git a/lib_dec/ivas_sba_dirac_stereo_dec.c b/lib_dec/ivas_sba_dirac_stereo_dec.c index 089492048021527ec3d025ab1d6d3b96e25383df..9cd7a6bd7a1e24190038b33be57de7b7e6db8ce9 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec.c @@ -51,8 +51,9 @@ * Set sba_dirac_stereo_flag *-------------------------------------------------------------------*/ +/*! r: SBA DirAC stereo flag */ int16_t ivas_get_sba_dirac_stereo_flag( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i : IVAS decoder structure */ ) { int16_t sba_dirac_stereo_flag; @@ -90,7 +91,7 @@ int16_t ivas_get_sba_dirac_stereo_flag( *-------------------------------------------------------------------*/ void ivas_sba_dirac_stereo_config( - STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ + STEREO_DFT_CONFIG_DATA_HANDLE hConfig /* o : DFT stereo configuration */ ) { if ( hConfig != NULL ) diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 6d71f1f8b8e9d1ae738d5659cd9f9313edcc9130..081786b30c508c29464c846146ed03e20f7229e9 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -92,6 +92,7 @@ void ivas_sba2mc_cldfb( g = hoa_dec_mtx[SBA_NHARM_HOA3 * n + m]; p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -115,6 +116,7 @@ void ivas_sba2mc_cldfb( { p_realOut = realOut[n]; p_imagOut = imagOut[n]; + #ifdef JBM_TSM_ON_TCS for ( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) #else @@ -239,6 +241,7 @@ void ivas_mc2sba( * Get TCs from Ambisonics signal in ACN *-------------------------------------------------------------------*/ +/*! r: number of remapped SBA TCs */ int16_t ivas_sba_remapTCs( float sba_data[][L_FRAME48k], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ @@ -429,7 +432,6 @@ void ivas_sba_upmixer_renderer( const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_internal; #ifndef JBM_TSM_ON_TCS int16_t i; @@ -466,10 +468,12 @@ void ivas_sba_upmixer_renderer( #ifdef JBM_TSM_ON_TCS float *output_f[MAX_OUTPUT_CHANNELS]; int16_t ch; + for ( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { output_f[ch] = output[ch]; } + ivas_sba_linear_renderer( output_f, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); #else ivas_sba_linear_renderer( output, output_frame, st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ); diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c index 9a940b9b6da17e326145e2d9ba39c49e63931ff1..6f32612f0b51fb3618852f03316c43410f44a260 100755 --- a/lib_dec/ivas_sce_dec.c +++ b/lib_dec/ivas_sce_dec.c @@ -453,6 +453,7 @@ void destroy_sce_dec( free( hSCE->save_synth ); hSCE->save_synth = NULL; } + if ( hSCE->save_hb_synth != NULL ) { free( hSCE->save_hb_synth ); diff --git a/lib_dec/ivas_sns_dec.c b/lib_dec/ivas_sns_dec.c index 4812091ecc5aff53331660c12bb35f2d2f38b112..0284622f62fd9e0b7c17e7614b389d665b6f8ff4 100644 --- a/lib_dec/ivas_sns_dec.c +++ b/lib_dec/ivas_sns_dec.c @@ -320,7 +320,14 @@ void sns_avq_dec_stereo( return; } + #ifdef SNS_MSVQ +/*------------------------------------------------------------------- + * dequantize_sns() + * + * Dequantize SNS + *-------------------------------------------------------------------*/ + void dequantize_sns( int16_t indices[CPE_CHANNELS][NPRM_LPC_NEW], float snsQ_out[CPE_CHANNELS][NB_DIV][M], @@ -377,6 +384,7 @@ void dequantize_sns( { msvq_dec( cdbks, NULL, NULL, nStages, M, M, &indices[ch][idxIndices + SNS_STEREO_MODE_OFFSET_INDICES], 0, NULL, snsQ, NULL ); } + idxIndices += nStages; } } @@ -406,5 +414,7 @@ void dequantize_sns( } } #endif + + return; } #endif // SNS_MSVQ diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index d1104594a11a879df6fe1850505ffda2213c304f..096688e824d39510c94d95d8b8e846c50dc9b1ea 100755 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -213,6 +213,7 @@ ivas_error ivas_spar_dec_open( hSpar->subframes_rendered = 0; hSpar->slots_rendered = 0; hSpar->num_slots = DEFAULT_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME; + /* init render timeslot mapping */ { int16_t map_idx; @@ -222,6 +223,7 @@ ivas_error ivas_spar_dec_open( hSpar->render_to_md_map[map_idx] = map_idx; } } + /* allocate transport channels*/ if ( st_ivas->hDecoderConfig->voip_active == 1 && st_ivas->hTcBuffer == NULL ) { @@ -1037,11 +1039,17 @@ static void ivas_spar_get_skip_mat( } +/*-------------------------------------------------------------------* + * ivas_spar_calc_smooth_facs() + * + * + *-------------------------------------------------------------------*/ + static void ivas_spar_calc_smooth_facs( float *cldfb_in_ts_re[CLDFB_NO_COL_MAX], float *cldfb_in_ts_im[CLDFB_NO_COL_MAX], - int16_t nbands_spar, - ivas_fb_bin_to_band_data_t *bin2band, + const int16_t nbands_spar, + const ivas_fb_bin_to_band_data_t *bin2band, float *smooth_fac, float smooth_buf[IVAS_MAX_NUM_BANDS][2 * SBA_DIRAC_NRG_SMOOTH_LONG + 1] ) { @@ -1088,8 +1096,10 @@ static void ivas_spar_calc_smooth_facs( /* calculate smoothing factor based on energy averages */ /* reduce factor for higher short-term energy */ smooth_fac[b] = min( 1.f, smooth_long_avg[b] / smooth_short_avg[b] ); + /* map factor to range [0;1] */ smooth_fac[b] = max( 0.f, smooth_fac[b] - (float) SBA_DIRAC_NRG_SMOOTH_SHORT / SBA_DIRAC_NRG_SMOOTH_LONG ) * ( (float) SBA_DIRAC_NRG_SMOOTH_LONG / ( SBA_DIRAC_NRG_SMOOTH_LONG - SBA_DIRAC_NRG_SMOOTH_SHORT ) ); + /* compress factor (higher compression in lowest bands) */ if ( b < 2 ) { @@ -1115,14 +1125,20 @@ static void ivas_spar_calc_smooth_facs( return; } + #ifdef JBM_TSM_ON_TCS +/*-------------------------------------------------------------------* + * ivas_spar_dec_agc_pca() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_agc_pca( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - float output[][L_FRAME48k], /* i/o: input/output audio channels */ - const int16_t output_frame /* i : output frame length */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ + const int16_t output_frame /* i : output frame length */ ) { - int16_t nchan_transport; int16_t num_in_ingest; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -1160,6 +1176,7 @@ void ivas_spar_dec_agc_pca( { num_in_ingest = nchan_transport; } + /*---------------------------------------------------------------------* * AGC *---------------------------------------------------------------------*/ @@ -1179,12 +1196,21 @@ void ivas_spar_dec_agc_pca( #endif } pop_wmops(); + return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_set_render_map() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_set_render_map( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - int16_t nCldfbTs ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int16_t nCldfbTs /* i : number of CLDFB time slots */ +) { SPAR_DEC_HANDLE hSpar; @@ -1203,6 +1229,8 @@ void ivas_spar_dec_set_render_map( return; } + + /*-------------------------------------------------------------------* * ivas_spar_dec_upmixer() * @@ -1219,11 +1247,14 @@ void ivas_spar_dec_set_render_params( int16_t num_bands_out; hSpar = st_ivas->hSpar; + /*---------------------------------------------------------------------* * Gen umx mat *---------------------------------------------------------------------*/ + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, st_ivas->bfi #ifdef HODIRAC , @@ -1236,6 +1267,13 @@ void ivas_spar_dec_set_render_params( return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_digest_tc() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const int16_t nchan_transport, /* i : number of transport channels */ @@ -1253,6 +1291,7 @@ void ivas_spar_dec_digest_tc( float *p_tc[MAX_SPAR_INTERNAL_CHANNELS]; int16_t nchan_internal, ch; int16_t nSamplesLeftForTD, default_frame; + /* TD decorrelator */ default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); nSamplesLeftForTD = nSamplesForRendering; @@ -1262,6 +1301,7 @@ void ivas_spar_dec_digest_tc( st_ivas->hDecoderConfig->ivas_total_brate #endif ); + for ( ch = 0; ch < nchan_internal; ch++ ) { pPcm_tmp[ch] = Pcm_tmp[ch]; @@ -1271,6 +1311,7 @@ void ivas_spar_dec_digest_tc( while ( nSamplesLeftForTD ) { int16_t nSamplesToDecorr = min( nSamplesLeftForTD, default_frame ); + ivas_td_decorr_process( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr ); #ifdef HODIRAC if ( hSpar->hTdDecorr->num_apd_outputs >= ( nchan_internal - nchan_transport ) ) @@ -1301,16 +1342,23 @@ void ivas_spar_dec_digest_tc( { p_tc[ch] += nSamplesToDecorr; } + nSamplesLeftForTD -= nSamplesToDecorr; } } ivas_spar_dec_set_render_params( st_ivas, nCldfbSlots ); - return; } + +/*-------------------------------------------------------------------* + * ivas_spar_dec_upmixer() + * + * + *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float output[][L_FRAME48k], /* i/o: input/output audio channels */ @@ -1330,10 +1378,12 @@ void ivas_spar_dec_upmixer( nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n_samples_sf = JBM_CLDFB_SLOTS_IN_SUBFRAME * NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + for ( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { output_f_local[n] = &output[n][0]; } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = output[n]; @@ -1342,10 +1392,12 @@ void ivas_spar_dec_upmixer( /*---------------------------------------------------------------------* * TD decorrelation *---------------------------------------------------------------------*/ + for ( i = 0; i < nchan_internal; i++ ) { pPcm_tmp[i] = Pcm_tmp[i]; } + if ( hSpar->hMdDec->td_decorr_flag ) { ivas_td_decorr_process( hSpar->hTdDecorr, st_ivas->hTcBuffer->tc, pPcm_tmp, output_frame ); @@ -1376,7 +1428,6 @@ void ivas_spar_dec_upmixer( #endif } - ivas_spar_dec_set_render_params( st_ivas, DEFAULT_JBM_CLDFB_TIMESLOTS ); if ( st_ivas->hDirAC != 0 ) @@ -1392,10 +1443,12 @@ void ivas_spar_dec_upmixer( output_f_local[n] += n_samples_sf; } } + for ( n = 0; n < nchan_internal; n++ ) { st_ivas->hTcBuffer->tc[n] = NULL; } + if ( st_ivas->hDirAC != 0 ) { if ( st_ivas->hDirAC->hConfig->dec_param_estim == 1 ) @@ -1407,6 +1460,7 @@ void ivas_spar_dec_upmixer( st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } } + return; } #endif @@ -1418,6 +1472,7 @@ void ivas_spar_dec_upmixer( * * IVAS SPAR upmixer *-------------------------------------------------------------------*/ + void ivas_spar_dec_upmixer_sf( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output[], /* o : output audio channels */ diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c old mode 100755 new mode 100644 index bfca6c62802068d4d726e21653b4841f0f2ef8b0..3de976426c31ded5c597f4ce9e9118c1fc5eaa91 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -740,6 +740,7 @@ void ivas_spar_md_dec_process( hMdDec = st_ivas->hSpar->hMdDec; int16_t active_w_vlbr; + active_w_vlbr = ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_24k4 ) ? 1 : 0; #ifdef HODIRAC @@ -755,6 +756,7 @@ void ivas_spar_md_dec_process( ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, ivas_spar_br_table_consts[hMdDec->table_idx].usePlanarCoeff, st_ivas->hQMetaData->sba_inactive_mode ); +#ifdef DEBUG_LBR_SBA #if 0 { char f_name[100]; @@ -764,8 +766,8 @@ void ivas_spar_md_dec_process( #ifdef HODIRAC , st_ivas->hDecoderConfig->ivas_total_brate -#endif - ); +#endif + ); for ( b = 0; b < num_bands; b++ ) { sprintf( f_name, "spar_band_pred_coeffs_dec.bin" ); @@ -807,7 +809,6 @@ void ivas_spar_md_dec_process( } } #endif -#ifdef DEBUG_LBR_SBA /* Dumping SPAR HOA Coefficients */ /*char f_name[100]; int16_t nbands = 12; @@ -1409,6 +1410,7 @@ static void ivas_get_spar_matrices( } active_w = hMdDec->spar_md_cfg.active_w; active_w_dm_fac = ( dtx_vad == 0 ) ? IVAS_ACTIVEW_DM_F_SCALE_DTX : ( ( active_w_vlbr ) ? IVAS_ACTIVEW_DM_F_SCALE_VLBR : IVAS_ACTIVEW_DM_F_SCALE ); + for ( i_ts = 0; i_ts < n_ts; i_ts++ ) { for ( i = 0; i < numch_out; i++ ) @@ -3026,9 +3028,8 @@ void ivas_spar_to_dirac( Decoder_Struct *st_ivas, ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const int16_t dtx_vad, /* i : DTX frame flag */ - const int16_t num_bands_out /* i : number of output bands */ - , - const int16_t bw /* i : band joining factor */ + const int16_t num_bands_out, /* i : number of output bands */ + const int16_t bw /* i : band joining factor */ ) { DIRAC_DEC_HANDLE hDirAC; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 98df8c3dcade50d3a372f45734cf1fd60b0fe72f..849a03bdcdeb53db61004ae36d19464c7d23e67a 100755 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -440,6 +440,7 @@ typedef struct param_ism_rendering float *Cldfb_RealBuffer_tc; float *Cldfb_ImagBuffer_tc; #endif + } PARAM_ISM_RENDERING_DATA, *PARAM_ISM_RENDERING_HANDLE; @@ -1052,7 +1053,6 @@ typedef struct ivas_lfe_dec_data_structure } LFE_DEC_DATA, *LFE_DEC_HANDLE; -// Note: the following structures are used only in lib_dec but this would likely change in the future /*----------------------------------------------------------------------------------* * VBAP structures *----------------------------------------------------------------------------------*/ @@ -1259,8 +1259,11 @@ typedef struct decoder_tc_buffer_structure int16_t slots_rendered; int16_t num_slots; int16_t n_samples_discard; /* number of samples to discard from the beginning of the output */ + } DECODER_TC_BUFFER, *DECODER_TC_BUFFER_HANDLE; #endif + + /*----------------------------------------------------------------------------------* * * Main IVAS decoder structure @@ -1287,6 +1290,7 @@ typedef struct Decoder_Struct int16_t codec_mode; /* Mode 1 or 2 */ int16_t ini_frame; /* initialization frames counter */ int16_t ini_active_frame; /* initialization active frames counter */ + int32_t last_active_ivas_total_brate; /* last active frame IVAS total bitrate in bps */ int16_t bfi; /* FEC - bad frame indicator */ int16_t BER_detect; /* BER detect flag */ /* IVAS_fmToDo: eventually replace hCoreCoder->BER_detect by a pointer to ease the updating of this main parameter */ @@ -1339,28 +1343,29 @@ typedef struct Decoder_Struct EFAP_HANDLE hEFAPdata; /* EFAP structure */ VBAP_HANDLE hVBAPdata; /* VBAP structure */ MONO_DOWNMIX_RENDERER_HANDLE hMonoDmxRenderer; /* Mono downmix structure */ - CREND_WRAPPER_HANDLE hCrendWrapper; - REVERB_HANDLE hReverb; /* Reverb handle */ - HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */ + CREND_WRAPPER_HANDLE hCrendWrapper; /* Crend wrapper handle */ + HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (Crend) */ HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */ HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */ + REVERB_HANDLE hReverb; /* Reverb handle */ LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */ float *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */ HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */ RENDER_CONFIG_DATA *hRenderConfig; /* Renderer config pointer */ int32_t binaural_latency_ns; /* Binauralization latency in ns */ +#ifdef JBM_TSM_ON_TCS + /* JBM module */ + DECODER_TC_BUFFER_HANDLE hTcBuffer; /* JBM handle */ +#endif + #ifdef DEBUGGING int32_t noClipping; /* number of clipped samples */ #endif - int32_t last_active_ivas_total_brate; + int16_t ism_extmeta_active; /* Extended metadata active in decoder */ int16_t ism_extmeta_cnt; /* Change frame counter for extended metadata */ - -#ifdef JBM_TSM_ON_TCS - DECODER_TC_BUFFER_HANDLE hTcBuffer; -#endif } Decoder_Struct; /* clang-format on */ diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 08ca989f3d4a4f4a82ae02805682b96132513da3..1eb105c3ea1b12942755dcba168c66977bd63c5c 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -1205,10 +1205,7 @@ void stereo_dft_dec( /* Smoothing for the current frame */ if ( sba_dirac_stereo_flag ) { - ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, - hMdDec, - cross_fade_start_offset, - output_Fs ); + ivas_sba_dirac_stereo_smooth_parameters( hStereoDft, hMdDec, cross_fade_start_offset, output_Fs ); } else { diff --git a/lib_dec/ivas_stereo_mdct_core_dec.c b/lib_dec/ivas_stereo_mdct_core_dec.c index cbeaf2a1e516f0b4d2473fd8f8ca1ff406dd2c2c..94579b2d7df9f83051fe51396ca856eec31167d5 100644 --- a/lib_dec/ivas_stereo_mdct_core_dec.c +++ b/lib_dec/ivas_stereo_mdct_core_dec.c @@ -126,7 +126,6 @@ static void stereo_mdct_dec_stereo( sts[0]->bits_frame_channel += sts[0]->core * SMDCT_MINIMUM_ARITH_BITS; sts[1]->bits_frame_channel += sts[1]->core * SMDCT_MINIMUM_ARITH_BITS; - sts[1]->bit_stream = &sts[0]->bit_stream[sts[0]->next_bit_pos + sts[0]->bits_frame_channel + sts[0]->core * NF_GAIN_BITS]; return; @@ -221,8 +220,7 @@ void stereo_mdct_core_dec( if ( !bfi ) { - ivas_mdct_dec_side_bits_frame_channel( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], - nTnsBitsTCX10, param, 0, 0 ); + ivas_mdct_dec_side_bits_frame_channel( hCPE, param_lpc, p_param, hCPE->hCoreCoder[0], nTnsBitsTCX10, param, 0, 0 ); if ( sts[0]->igf ) { @@ -253,8 +251,7 @@ void stereo_mdct_core_dec( } } - ivas_mdct_core_invQ( hCPE, - nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0, x, Aq, ms_mask, 0 ); + ivas_mdct_core_invQ( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0, x, Aq, ms_mask, 0 ); for ( ch = 0; ch < nChannels; ch++ ) { @@ -347,8 +344,7 @@ void stereo_mdct_core_dec( stereo_decoder_tcx( hCPE->hStereoMdct, ms_mask, x_0[1], x[0], x[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 ); } - ivas_mdct_core_tns_ns( hCPE, - fUseTns, tnsData, x, Aq, 0 ); + ivas_mdct_core_tns_ns( hCPE, fUseTns, tnsData, x, Aq, 0 ); if ( st_ivas->renderer_type == RENDERER_MC_PARAMMC && ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_MONO || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_STEREO ) ) { @@ -362,8 +358,7 @@ void stereo_mdct_core_dec( apply_dmx_weights( hCPE, x, sts[0]->transform_type, sts[1]->transform_type ); } - ivas_mdct_core_reconstruct( hCPE, x, signal_outFB_tmp, - fUseTns, 0 ); + ivas_mdct_core_reconstruct( hCPE, x, signal_outFB_tmp, fUseTns, 0 ); mvr2r( signal_out_tmp[0], signal_out[0], L_FRAME48k ); mvr2r( signal_out_tmp[1], signal_out[1], L_FRAME48k ); diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index 0e788a0821103ce0b6b3e1c8a3891fb9579e3f29..90d94f5b069bc15e920716749ee0bf894455aa70 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -475,6 +475,7 @@ ivas_error initMdctStereoDtxData( } #endif } + #ifdef FIX_413_SBA_DTX if ( st->first_CNG == 0 ) { diff --git a/lib_dec/ivas_svd_dec.c b/lib_dec/ivas_svd_dec.c index 785a9067804c9b252fb08d1922d4354d675ab801..caa4798946e5a4e9d0103de3df110825a84e9157 100644 --- a/lib_dec/ivas_svd_dec.c +++ b/lib_dec/ivas_svd_dec.c @@ -179,7 +179,7 @@ void svdMat2mat( * perform a singular value decomposition X=USV of a matrix X *-------------------------------------------------------------------------*/ -/* !r: error or success */ +/*! r: error or success */ int16_t svd( float InputMatrix[][MAX_OUTPUT_CHANNELS], /* i : matrix to be decomposed (M) */ float singularVectors_Left[][MAX_OUTPUT_CHANNELS], /* o : left singular vectors (U) */ diff --git a/lib_dec/jbm_pcmdsp_apa.c b/lib_dec/jbm_pcmdsp_apa.c index c224b4cfbf011792e21bb1e621f096553d11dbbb..9742a01183753e39f0de9897f9821ad58ad7bbb4 100644 --- a/lib_dec/jbm_pcmdsp_apa.c +++ b/lib_dec/jbm_pcmdsp_apa.c @@ -412,7 +412,9 @@ bool apa_set_renderer_residual_samples( return 0; } -bool apa_set_evs_compat_mode( apa_state_t *ps, bool mode ) +bool apa_set_evs_compat_mode( + apa_state_t *ps, + bool mode ) { /* make sure pointer is valid */ if ( ps == NULL ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 17c718bb48291022b3cd71862a3c2399c5c1f239..ba14c70a45fee60da3286059333e68d83d3a9e81 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -279,6 +279,7 @@ static void init_decoder_config( #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 0; #endif + return; } @@ -535,8 +536,8 @@ ivas_error IVAS_DEC_Configure( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -557,11 +558,9 @@ ivas_error IVAS_DEC_EnableVoIP( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; hIvasDec->Opt_VOIP = 1; - #ifdef JBM_TSM_ON_TCS hDecoderConfig->voip_active = 1; #endif @@ -582,7 +581,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #endif - #ifndef JBM_TSM_ON_TCS assert( hDecoderConfig->nchan_out > 0 && "EXT output not yet supported in VoIP mode" ); #endif @@ -612,6 +610,7 @@ ivas_error IVAS_DEC_EnableVoIP( #else hIvasDec->hVoIP->nSamplesFrame = (uint16_t) ( hDecoderConfig->output_Fs * hDecoderConfig->nchan_out / FRAMES_PER_SEC ); #endif + #ifdef JBM_TSM_ON_TCS /* postpone init of the buffers until we know the real number of TCs*/ hIvasDec->hVoIP->apaExecBuffer = NULL; @@ -680,7 +679,6 @@ ivas_error IVAS_DEC_EnableVoIP( #endif #ifdef JBM_TSM_ON_TCS - /* postpone init of time scaler until we know the real number of TCs */ hIvasDec->hVoIP->hTimeScaler = NULL; /* create output pcm fifo*/ @@ -933,6 +931,7 @@ static ivas_error IVAS_DEC_Setup( return error; } + /*---------------------------------------------------------------------* * IVAS_DEC_GetTcSamples( ) * @@ -1891,6 +1890,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return IVAS_ERR_VS_FRAME_NEEDED; } #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->nSamplesAvailableNext == 0 ) { @@ -1909,6 +1909,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( extBufferedTime_ms = extBufferedSamples * 1000 / hDecoderConfig->output_Fs; dataUnit = NULL; + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VOIP ) { @@ -1968,6 +1969,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef VARIABLE_SPEED_DECODING } #endif + /* decode */ if ( !hIvasDec->hasBeenFedFirstGoodFrame ) { @@ -1998,6 +2000,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef JBM_TSM_ON_TCS uint16_t l_ts = 1; uint16_t nSamplesRendered_loop; + /* setup ivas decoder and get the number of TCs */ /* might render some remaining samples from the previous frame too if the renderer granularity changed */ if ( hVoIP->hFifoOut ) @@ -2019,11 +2022,13 @@ ivas_error IVAS_DEC_VoIP_GetSamples( return error; } } + nSamplesRendered += nSamplesRendered_loop; if ( nTransportChannels != hVoIP->nTransportChannelsOld ) { IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ); } + /* decode TCs only */ if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hVoIP->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) { @@ -2062,6 +2067,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hVoIP->lastDecodedWasActive = 1; } #endif + /* limit scale to range supported by time scaler */ if ( scale < APA_MIN_SCALE ) { @@ -2117,10 +2123,12 @@ ivas_error IVAS_DEC_VoIP_GetSamples( { /* render IVAS frames */ int16_t nResidualSamples; + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hVoIP->apaExecBuffer ) ) != IVAS_ERR_OK ) { return error; } + /* feed residual samples to TSM for the next call */ if ( apa_set_renderer_residual_samples( hVoIP->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) { @@ -2158,6 +2166,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef JBM_TSM_ON_TCS } + if ( hIvasDec->hasBeenFedFirstGoodFrame && hVoIP->rendererType != JBM_RENDERER_NONE ) { uint16_t nSamplesRendered_loop; @@ -2165,12 +2174,15 @@ ivas_error IVAS_DEC_VoIP_GetSamples( if ( hVoIP->hFifoOut ) { int16_t rendererPcmBuf[( MAX_OUTPUT_CHANNELS * L_FRAME_MAX * APA_MAX_SCALE ) / 100]; + nSamplesToRender = nSamplesPerChannel - pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ); + /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesRendered_loop ) != 0 ) { return IVAS_ERR_UNKNOWN; @@ -2179,13 +2191,16 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { nSamplesToRender = nSamplesPerChannel - nSamplesRendered; + /* render IVAS frames directly to the output buffer */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesRendered_loop, &hVoIP->nSamplesAvailableNext, pcmBuf + nSamplesRendered * nOutChannels ) ) != IVAS_ERR_OK ) { return error; } } + nSamplesRendered += nSamplesRendered_loop; + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext == 0 ) { @@ -2200,12 +2215,14 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else { hVoIP->nSamplesAvailableNext = max( 0, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoOut ) - nSamplesPerChannel ); + #ifdef VARIABLE_SPEED_DECODING if ( hVoIP->mode == IVAS_DEC_VOIP_MODE_VARIABLE_SPEED && hVoIP->nSamplesAvailableNext < nSamplesPerChannel ) { hVoIP->needNewFrame = true; } #endif + hVoIP->nSamplesAvailableNext = 0; } #endif @@ -2254,11 +2271,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( VARIABLE_SPEED_DECODING ) || defined( JBM_TSM_ON_TCS ) ivas_error IVAS_DEC_VoIP_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ int16_t *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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ) { ivas_error error; @@ -2268,6 +2285,7 @@ ivas_error IVAS_DEC_VoIP_Flush( uint16_t nSamplesToRender; uint16_t nSamplesFlushedLocal; #endif + error = IVAS_ERR_OK; hVoIP = hIvasDec->hVoIP; @@ -2276,6 +2294,7 @@ ivas_error IVAS_DEC_VoIP_Flush( #else *nSamplesFlushed = min( nSamplesPerChannel, pcmdsp_fifo_nReadableSamplesPerChannel( hVoIP->hFifoAfterTimeScaler ) ); #endif + #ifdef JBM_TSM_ON_TCS if ( hVoIP->rendererType == JBM_RENDERER_NONE ) { @@ -2299,25 +2318,28 @@ ivas_error IVAS_DEC_VoIP_Flush( } else { - nSamplesToRender = (uint16_t) *nSamplesFlushed; /* render IVAS frames */ if ( ( error = IVAS_DEC_GetRenderedSamples( hIvasDec, nSamplesToRender, &nSamplesFlushedLocal, &hVoIP->nSamplesAvailableNext, rendererPcmBuf ) ) != IVAS_ERR_OK ) { return error; } + if ( pcmdsp_fifo_write( hVoIP->hFifoOut, (uint8_t *) rendererPcmBuf, nSamplesFlushedLocal ) != 0 ) { return IVAS_ERR_UNKNOWN; } + if ( pcmdsp_fifo_read( hVoIP->hFifoOut, nSamplesFlushedLocal, (uint8_t *) pcmBuf ) != 0 ) { return IVAS_ERR_UNKNOWN; } + *nSamplesAvailableNext = hVoIP->nSamplesAvailableNext; *nSamplesFlushed = (int16_t) nSamplesFlushedLocal; } #endif + return error; } #endif @@ -2333,7 +2355,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ) { @@ -2387,6 +2409,7 @@ static void IVAS_DEC_Close_VoIP( #else pcmdsp_fifo_destroy( &hVoIP->hFifoAfterTimeScaler ); #endif + if ( hVoIP->apaExecBuffer != NULL ) { free( hVoIP->apaExecBuffer ); @@ -2972,7 +2995,6 @@ static ivas_error evs_dec_main( /* BE workaround */ int16_t pcm_buf_local[L_FRAME48k]; - /* convert 'float' output data to 'short' */ #ifdef DEBUGGING st_ivas->noClipping += @@ -3006,6 +3028,7 @@ static ivas_error evs_dec_main( #ifdef JBM_TSM_ON_TCS } #endif + return error; } @@ -3197,14 +3220,30 @@ static ivas_error input_format_API_to_internal( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS -static int16_t IVAS_DEC_VoIP_GetRenderGranularity( Decoder_Struct *st_ivas ) +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRenderGranularity() + * + * + *---------------------------------------------------------------------*/ + +static int16_t IVAS_DEC_VoIP_GetRenderGranularity( + Decoder_Struct *st_ivas ) { return st_ivas->hTcBuffer->n_samples_granularity; } -static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasDec ) + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_GetRendererConfig() + * + * + *---------------------------------------------------------------------*/ + +static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( + IVAS_DEC_HANDLE hIvasDec ) { JBM_RENDERER_TYPE rendererType; rendererType = JBM_RENDERER_NONE; @@ -3221,13 +3260,22 @@ static JBM_RENDERER_TYPE IVAS_DEC_VoIP_GetRendererConfig( IVAS_DEC_HANDLE hIvasD return rendererType; } -ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t nTransportChannels, const uint16_t l_ts ) + +/*---------------------------------------------------------------------* + * IVAS_DEC_VoIP_reconfigure() + * + * + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_VoIP_reconfigure( + IVAS_DEC_HANDLE hIvasDec, + const uint16_t nTransportChannels, + const uint16_t l_ts ) { IVAS_DEC_VOIP *hVoIP; ivas_error error; - hVoIP = hIvasDec->hVoIP; if ( hIvasDec->hVoIP->hTimeScaler == NULL ) @@ -3242,6 +3290,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n #else startQuality = 1.0f; #endif + /* get current renderer type*/ hVoIP->rendererType = IVAS_DEC_VoIP_GetRendererConfig( hIvasDec ); hDecoderConfig = hIvasDec->st_ivas->hDecoderConfig; @@ -3269,12 +3318,13 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n { return IVAS_ERR_INIT_ERROR; } - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); + if ( apa_init( &hIvasDec->hVoIP->hTimeScaler, nTransportChannels ) != IVAS_ERR_OK || apa_set_rate( hIvasDec->hVoIP->hTimeScaler, hDecoderConfig->output_Fs ) != 0 || @@ -3284,6 +3334,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n { return IVAS_ERR_INIT_ERROR; } + if ( hVoIP->hFifoOut == NULL && hVoIP->rendererType == JBM_RENDERER_NONE ) { /* we still need the FIFO out buffer */ @@ -3303,6 +3354,7 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n } } #endif + if ( hIvasDec->mode == IVAS_DEC_MODE_EVS ) { if ( apa_set_evs_compat_mode( hIvasDec->hVoIP->hTimeScaler, true ) != 0 ) @@ -3320,12 +3372,11 @@ ivas_error IVAS_DEC_VoIP_reconfigure( IVAS_DEC_HANDLE hIvasDec, const uint16_t n /* realloc apa_exe_buffer */ free( hIvasDec->hVoIP->apaExecBuffer ); - hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ); - set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); - if ( hIvasDec->hVoIP->apaExecBuffer == NULL ) + if ( ( hIvasDec->hVoIP->apaExecBuffer = malloc( sizeof( float ) * APA_BUF_PER_CHANNEL * nTransportChannels ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate VoIP handle" ); } + set_zero( hIvasDec->hVoIP->apaExecBuffer, APA_BUF_PER_CHANNEL * nTransportChannels ); } hIvasDec->hVoIP->nTransportChannelsOld = (uint8_t) nTransportChannels; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index fd8735dda63eff206e85de26e0ab2721dbaa0e41..94d1543ac7435ceb11a35a75fa5f4f97dedbb1c9 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -229,8 +229,8 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( #ifdef VARIABLE_SPEED_DECODING /*! r: error code */ ivas_error IVAS_DEC_VoIP_SetScale( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t scale /* i : TSM scale to set */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t scale /* i : TSM scale to set */ ); #endif @@ -242,7 +242,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( const uint32_t systemTimestamp_ms /* i : current system timestamp */ #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) , - uint16_t *sampleAvailableNext /* o : samples available for the next call */ + uint16_t *sampleAvailableNext /* o : samples available for the next call */ #endif #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, @@ -252,11 +252,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #if defined( JBM_TSM_ON_TCS ) || defined(VARIABLE_SPEED_DECODING ) ivas_error IVAS_DEC_VoIP_Flush( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - int16_t *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 */ - uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ - int16_t *nSamplesFlushed /* o : number of samples flushed */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + int16_t *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 */ + uint16_t *nSamplesAvailableNext, /* o : number of samples still available */ + int16_t *nSamplesFlushed /* o : number of samples flushed */ ); #endif @@ -266,8 +266,8 @@ ivas_error IVAS_DEC_VoIP_Flush( ivas_error IVAS_DEC_EnableVoIP( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ #ifdef VARIABLE_SPEED_DECODING - const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or varable speed */ - const uint16_t speedFac, /* i : speed factor for varable speed */ + const IVAS_DEC_VOIP_MODE voipMode, /* i : VoIP or variable speed */ + const uint16_t speedFac, /* i : speed factor for variable speed */ #endif const int16_t jbmSafetyMargin, /* i : allowed delay reserve for JBM, in milliseconds */ const IVAS_DEC_INPUT_FORMAT inputFormat /* i : format of the input bitstream */ @@ -336,8 +336,8 @@ ivas_error IVAS_DEC_GetHrtfHandle( /*! r: error code */ ivas_error IVAS_DEC_GetHrtfCRendHandle( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o : Set of HRTF handle */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF /* o : Set of HRTF handle */ ); ivas_error IVAS_DEC_GetHrtfFastConvHandle( @@ -386,7 +386,7 @@ bool IVAS_DEC_VoIP_IsEmpty( IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ #ifdef JBM_TSM_ON_TCS , - int16_t nSamplesAsked + const int16_t nSamplesAsked #endif ); diff --git a/lib_dec/lsf_dec.c b/lib_dec/lsf_dec.c index 73f8933daff76c16e4c0117877280bd95a8be8d7..eb71afd842f410d7556598454ad6d1477251eef0 100644 --- a/lib_dec/lsf_dec.c +++ b/lib_dec/lsf_dec.c @@ -64,16 +64,15 @@ static void dqlsf_CNG( Decoder_State *st, float *lsf_q ); *---------------------------------------------------------------------*/ void lsf_dec( - Decoder_State *st, /* i/o: State structure */ - const int16_t tc_subfr, /* i : TC subframe index */ - float *Aq, /* o : quantized A(z) for 4 subframes */ - int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - float *lsf_new, /* o : de-quantized LSF vector */ - float *lsp_new, /* o : de-quantized LSP vector */ - float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ - const int16_t tdm_low_rate_mode /* i : secondary channel low rate mode flag */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + Decoder_State *st, /* i/o: State structure */ + const int16_t tc_subfr, /* i : TC subframe index */ + float *Aq, /* o : quantized A(z) for 4 subframes */ + int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ + float *lsf_new, /* o : de-quantized LSF vector */ + float *lsp_new, /* o : de-quantized LSP vector */ + float *lsp_mid, /* o : de-quantized mid-frame LSP vector */ + const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { int16_t i, nBits, coder_type, no_param_lpc; @@ -258,9 +257,8 @@ void lsf_end_dec( float *qlsf, /* o : quantized LSFs in the cosine domain */ int16_t *lpc_param, /* i : LPC parameters */ int16_t *LSF_Q_prediction, /* o : LSF prediction mode */ - int16_t *nb_indices /* o : number of indices */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + int16_t *nb_indices, /* o : number of indices */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { float pred0[M]; /* Prediction for the safety-net quantizer (usually mean)*/ @@ -362,7 +360,6 @@ void lsf_end_dec( st->safety_net = safety_net; - /* Make sure there are the correct bit allocations */ if ( st->idchan == 1 && predmode > 2 ) { diff --git a/lib_enc/FEC_enc.c b/lib_enc/FEC_enc.c index 5bf8d1f1f40ad22daf5caf15e6570cfaf9a00d74..9b753c97b82ac3fb515fe8a241d42c34fe2dd742 100644 --- a/lib_enc/FEC_enc.c +++ b/lib_enc/FEC_enc.c @@ -133,8 +133,7 @@ void FEC_encode( { /* retrieve the last glottal pulse position of the previous frame */ /* use the current pitch information to scale or not the quantization */ - tmp_FER_pitch = (int16_t) ( fpit[0] ); /* take the 1st subframe pitch, since it is easier to retieve it on decoder side */ - + tmp_FER_pitch = (int16_t) ( fpit[0] ); /* take the 1st subframe pitch, since it is easier to retrieve it on decoder side */ sign = 0; maxi = *last_pulse_pos; diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c index c0c0b4f18e51df211b71704c96ec4d4c6772a236..b2c2051492f59e743f7d75caf692e90213fe0c97 100644 --- a/lib_enc/amr_wb_enc.c +++ b/lib_enc/amr_wb_enc.c @@ -342,8 +342,7 @@ void amr_wb_enc( * WB, SWB and FB bandwidth detector *----------------------------------------------------------------*/ - bw_detect( st, st->input, NULL, NULL, - 0 ); + bw_detect( st, st->input, NULL, NULL, 0 ); /* in AMR_WB IO, limit the maximum band-width to WB */ if ( st->bwidth > WB ) diff --git a/lib_enc/bw_detect.c b/lib_enc/bw_detect.c index 6de35a211a50ba5e2461bb2f42041346828d5e30..9ad0fc9ae05d1633fa3a71d1c5422fb3c072f1b9 100644 --- a/lib_enc/bw_detect.c +++ b/lib_enc/bw_detect.c @@ -68,12 +68,11 @@ *-------------------------------------------------------------------*/ void bw_detect( - Encoder_State *st, /* i/o: Encoder State */ - const float signal_in[], /* i : input signal */ - float *spectrum, /* i : MDCT spectrum */ - const float *enerBuffer /* i : energy buffer */ - , - const int16_t mct_on /* i : flag MCT mode */ + Encoder_State *st, /* i/o: Encoder State */ + const float signal_in[], /* i : input signal */ + float *spectrum, /* i : MDCT spectrum */ + const float *enerBuffer, /* i : energy buffer */ + const int16_t mct_on /* i : flag MCT mode */ ) { int16_t i, j, k, bw_max, bin_width, n_bins; diff --git a/lib_enc/dtx.c b/lib_enc/dtx.c index 08d4316750868e4b72df31b8bf6ec6a11e393a84..1c71d00854abe64cc0c5dcb2946d86b9c9a06c05 100644 --- a/lib_enc/dtx.c +++ b/lib_enc/dtx.c @@ -69,6 +69,7 @@ #else #define MAX_BRATE_DTX_IVAS IVAS_80k /* maximum bitrate to which the default DTX is applied in IVAS; otherwise DTX is applied only in silence */ #endif + /*-------------------------------------------------------------------* * Local function prototypes *-------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index 83dbdad1e183efb3bb5990657633b3c68323b389..03cb2aa2edef36792b2d7c0a36d8e99eb2c125fc 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -455,7 +455,6 @@ void ivas_agc_enc_process( /* writing to a temporary bitstream file */ if ( ivas_agc_writeBits( agcOut, n_channels, pState ) ) { - /* TODO: return error once error codes are harmonized */ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "SPAR ENC AGC Failed to open agcOut\n " ); } #endif @@ -477,7 +476,6 @@ static int16_t ivas_agc_writeBits( FILE *stream, const int16_t n_channels, ivas_ if ( pState->gain_data[i].absGainExpCurr < 0 || pState->gain_data[i].absGainExpCurr >= (int16_t) pow( 2, pState->agc_com.betaE ) ) { - /* TODO: return error once error codes are harmonized */ IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error Gain values to write!!\n\n" ); } diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c index c2627b923bed0d309efd02e639da02d21a894147..a675709f75ce68161f1188087f6e229aabb3db26 100644 --- a/lib_enc/ivas_core_enc.c +++ b/lib_enc/ivas_core_enc.c @@ -259,8 +259,7 @@ ivas_error ivas_core_enc( if ( MCT_flag ) { ivas_mdct_core_whitening_enc( hCPE, old_inp_16k, old_wsp, pitch_buf, hMCT->p_mdst_spectrum_long[cpe_id], hMCT->tnsBits[cpe_id], hMCT->p_orig_spectrum_long[cpe_id], - hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, - 1, hMCT->nchan_out_woLFE ); + hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], hMCT->hBstr, 1, hMCT->nchan_out_woLFE ); } else { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index cf23ddef539f2e2f7ceeba7997129b0f07829b9c..40f0435e672d621456589408db6c3f9a8b16e77f 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -479,8 +479,7 @@ ivas_error pre_proc_front_ivas( if ( st->idchan == 0 && element_mode != IVAS_CPE_MDCT ) { - bw_detect( st, st->input, NULL, enerBuffer, - 0 ); + bw_detect( st, st->input, NULL, enerBuffer, 0 ); } if ( element_mode != IVAS_CPE_MDCT ) /* in MDCT stereo, set_bw_stereo() is used instead */ diff --git a/lib_enc/ivas_enc_cov_handler.c b/lib_enc/ivas_enc_cov_handler.c index 6575d751a9a366c0e32b5a389d65f2e6cc84841c..8111679d1e67eb4437844976e89ba756f867ca75 100644 --- a/lib_enc/ivas_enc_cov_handler.c +++ b/lib_enc/ivas_enc_cov_handler.c @@ -73,9 +73,8 @@ ivas_error ivas_spar_covar_enc_open( ivas_enc_cov_handler_state_t **hCovEnc, /* i/o: SPAR Covar. encoder handle */ ivas_filterbank_t *pFb, /* i/o: FB handle */ const int32_t input_Fs, /* i : input sampling rate */ - const int16_t nchan_inp /* i : number of input channels */ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t nchan_inp, /* i : number of input channels */ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ) { ivas_enc_cov_handler_state_t *hCovState; diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c index e858074445b286935945a97ae7f9c5f0168d8d03..db2e209669d3bb7b5de51b5674d51e6306f6e753 100644 --- a/lib_enc/ivas_init_enc.c +++ b/lib_enc/ivas_init_enc.c @@ -375,6 +375,7 @@ ivas_error ivas_init_encoder( st_ivas->sba_mode = SBA_MODE_NONE; st_ivas->nchan_transport = -1; + /*-----------------------------------------------------------------* * Allocate and initialize SCE/CPE and other handles *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_ism_enc.c b/lib_enc/ivas_ism_enc.c index 5c310ac30fcb3a66be6e666712db0a70fd870d67..12dc813a41c8d43887f3ed2aa66c6cce47b19f6f 100644 --- a/lib_enc/ivas_ism_enc.c +++ b/lib_enc/ivas_ism_enc.c @@ -222,7 +222,6 @@ ivas_error ivas_ism_enc( } else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { - // VE: call ivas_ism_metadata_enc() with 'st_ivas' - TBD ivas_ism_metadata_enc( st_ivas->hEncoderConfig->ivas_total_brate, nchan_ism, st_ivas->nchan_transport, st_ivas->hIsmMetaData, st_ivas->hSCE, st_ivas->hSCE[st_ivas->nSCE - 1]->hMetaData, nb_bits_metadata, vad_flag, st_ivas->ism_mode, st_ivas->hDirAC->hParamIsm, st_ivas->hEncoderConfig->ism_extended_metadata_flag ); diff --git a/lib_enc/ivas_ism_metadata_enc.c b/lib_enc/ivas_ism_metadata_enc.c index 732ffec21b7a2cf68d889caec204e9a9da3b0811..1d482ab73e7658afd22689268e729f09a8b9e2b3 100644 --- a/lib_enc/ivas_ism_metadata_enc.c +++ b/lib_enc/ivas_ism_metadata_enc.c @@ -85,9 +85,9 @@ static void encode_radius( BSTR_ENC_HANDLE hBstr, int16_t *last_radius_idx, int1 ivas_error ivas_set_ism_metadata( ISM_METADATA_HANDLE hIsmMeta, /* o : ISM metadata handle */ const float azimuth, /* i : azimuth value */ - const float elevation, /* i : elevation */ - const float radius_meta, /* i : radius */ - const float yaw, /* i : yaw */ + const float elevation, /* i : elevation */ + const float radius_meta, /* i : radius */ + const float yaw, /* i : yaw */ #ifdef ISM_NON_DIEGETIC_PAN const float pitch, /* i : pitch */ const int16_t non_diegetic_flag /* i : non-diegetic object flag*/ @@ -522,13 +522,17 @@ ivas_error ivas_ism_metadata_enc( } } + /*----------------------------------------------------------------* + * Write ParamISM parameters into the bitstream + *----------------------------------------------------------------*/ + if ( ism_mode == ISM_MODE_PARAM ) { - /* Keep the metdata transmission as is during active parts */ + /* Keep the metadata transmission as is during active parts */ /* 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++ ) @@ -540,7 +544,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++ ) @@ -820,14 +824,14 @@ static void encode_radius( * Encoding of an angle *----------------------------------------------------------------*/ static void encode_angle_indices( - BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ - ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ - const int16_t last_ism_metadata_flag, /* i : last frame ism_metadata_flag */ - const int16_t ini_frame, /* i : initialization frames counter */ - const int16_t idx_angle1_abs, /* i : Azimuth index */ - const int16_t idx_angle2_abs, /* i : Elevation index */ - int16_t *flag_abs_angle1, /* o : Azimuth/yaw encoding mode */ - int16_t *flag_abs_angle2 /* o : Elevation/pitch encoding mode */ + BSTR_ENC_HANDLE hBstr, /* i/o: bitstream handle */ + ISM_METADATA_ANGLE_HANDLE angle, /* i/o: angle handle */ + const int16_t last_ism_metadata_flag, /* i : last frame ism_metadata_flag */ + const int16_t ini_frame, /* i : initialization frames counter */ + const int16_t idx_angle1_abs, /* i : Azimuth index */ + const int16_t idx_angle2_abs, /* i : Elevation index */ + int16_t *flag_abs_angle1, /* o : Azimuth/yaw encoding mode */ + int16_t *flag_abs_angle2 /* o : Elevation/pitch encoding mode */ ) { int16_t idx_angle1, nbits_diff_angle1, diff; diff --git a/lib_enc/ivas_masa_enc.c b/lib_enc/ivas_masa_enc.c index 2527fa91aabc9fc6f29477f31246637889489b33..11d3252282f5bd4f3c0a0b9a636265d047c5685e 100644 --- a/lib_enc/ivas_masa_enc.c +++ b/lib_enc/ivas_masa_enc.c @@ -1088,6 +1088,7 @@ static void move_metadata_to_qmetadata( #ifdef HR_METADATA hQMeta->q_direction[dir].band_data[band].spherical_index[sf] = hMeta->directional_meta[dir].spherical_index[sf][band]; #endif + if ( hQMeta->q_direction[dir].coherence_band_data != NULL ) { hQMeta->q_direction[dir].coherence_band_data[band].spread_coherence[sf] = (uint8_t) roundf( hMeta->directional_meta[dir].spread_coherence[sf][band] * UINT8_MAX ); @@ -1827,13 +1828,15 @@ static void average_masa_metadata( j = 0; hMeta->directional_meta[i].azimuth[j][k] = atan2f( y_sum, x_sum ) / EVS_PI * 180.0f; hMeta->directional_meta[i].elevation[j][k] = atan2f( z_sum, sqrtf( x_sum * x_sum + y_sum * y_sum ) ) / EVS_PI * 180.0f; + #ifdef HR_METADATA if ( Sph_Grid16->no_theta > 0 ) { - hMeta->directional_meta[i].spherical_index[j][k] = index_theta_phi_16( &( hMeta->directional_meta[i].elevation[j][k] ), - &( hMeta->directional_meta[i].azimuth[j][k] ), Sph_Grid16 ); + hMeta->directional_meta[i].spherical_index[j][k] = ivas_qmetadata_index_theta_phi_16( &( hMeta->directional_meta[i].elevation[j][k] ), + &( hMeta->directional_meta[i].azimuth[j][k] ), Sph_Grid16 ); } #endif + vec_len = sqrtf( x_sum * x_sum + y_sum * y_sum + z_sum * z_sum ); hMeta->directional_meta[i].energy_ratio[j][k] = vec_len / ( energy_sum + EPSILON ); @@ -1954,11 +1957,12 @@ static void copy_masa_metadata( * Compare the similarity of MASA metadata in two sub-frames *-------------------------------------------------------------------*/ +/* r: similarity decision */ static uint8_t are_masa_subframes_similar( const MASA_METADATA_HANDLE frame1, /* i : MASA metadata frame 1 */ const uint8_t sf1_idx, /* i : index of the subframe of frame1 to inspect */ const MASA_METADATA_HANDLE frame2, /* i : MASA metadata frame 2 */ - const uint8_t sf2_idx /* o : index of the subframe of frame2 to inspect */ + const uint8_t sf2_idx /* i : index of the subframe of frame2 to inspect */ ) { uint8_t num_dir; @@ -2032,7 +2036,6 @@ static uint8_t are_masa_subframes_similar( } } - /* TODO: a nicer negation */ // VE: ?? if ( sf_differ ) { return FALSE; diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index ba378ab1d68b673a3ffde43e29e168c2444ce7d8..df7e71fbee8094a6207a4056c20deafb23a0ae38 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -1484,7 +1484,7 @@ static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], - const int16_t enc_param_start_band, /* i: first band to process */ + const int16_t enc_param_start_band, /* i : first band to process */ const int16_t num_frequency_bands, float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] ) { diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index d1f47bcee301d0879caedf5377967cae0d38e021..a513d22b581325e77c467fa605de7368f0ce38a9 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -432,8 +432,7 @@ void ivas_mct_core_enc( for ( ch = 0; ch < nChannels; ch++ ) { st = sts[ch]; - if ( - sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) + if ( sts[ch]->mct_chan_mode == MCT_CHAN_MODE_IGNORE ) { continue; } @@ -462,8 +461,7 @@ void ivas_mct_core_enc( write_mct_bitstream( sts, hMCT, nChannels ); - FindChannelRatio( - sts, chBitRatios, nChannels ); + FindChannelRatio( sts, chBitRatios, nChannels ); nAvailBits = (int16_t) ( ( ivas_total_brate / FRAMES_PER_SEC ) - NBITS_BWIDTH - hMCT->nBitsMCT - lfe_bits ); diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c index 393c60f49eada48a8d03d7d4c1baa127fb8df467..4dc79662f8b004a244f6689df7bc858d66f0d23c 100644 --- a/lib_enc/ivas_mct_enc.c +++ b/lib_enc/ivas_mct_enc.c @@ -101,10 +101,11 @@ static void set_mct_enc_params( * cpe_id 1: L=data[4] R=data[5] * cpe_id 2: L=data[2] (mid) R=NULL *-------------------------------------------------------------------*/ + static void map_input_to_cpe_channels( const Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - float *pdata[MAX_INPUT_CHANNELS], /* o: mapped input pointers */ - float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i: input channel data */ + float *pdata[MAX_INPUT_CHANNELS], /* o : mapped input pointers */ + float data[MCT_MAX_CHANNELS][L_FRAME48k] /* i : input channel data */ ) { int16_t i, n; @@ -150,6 +151,8 @@ static void map_input_to_cpe_channels( return; } + + /*-------------------------------------------------------------------* * ivas_mct_enc() * @@ -231,6 +234,7 @@ ivas_error ivas_mct_enc( /*for MC and MCT remove pointer to LFE input that has been processed seperately */ map_input_to_cpe_channels( st_ivas, pdata, data ); + /* pre-processing */ for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -260,8 +264,7 @@ ivas_error ivas_mct_enc( { hCPE = st_ivas->hCPE[cpe_id]; - ivas_mdct_quant_coder( hCPE, - hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); + ivas_mdct_quant_coder( hCPE, hMCT->tnsBits[cpe_id], hMCT->tnsSize[cpe_id], hMCT->p_param[cpe_id], 1 ); /* update input samples buffer (as done in ivas_cpe_enc() for other than MCT coding) */ for ( n = 0; n < CPE_CHANNELS; n++ ) @@ -351,8 +354,7 @@ ivas_error create_mct_enc( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( ( hMCT->nchan_out_woLFE ) % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -471,8 +473,7 @@ ivas_error mct_enc_reconfigure( } /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */ - if ( ( hMCT->nchan_out_woLFE ) % - 2 ) + if ( ( hMCT->nchan_out_woLFE ) % 2 ) { st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE; } @@ -658,7 +659,7 @@ ivas_error ivas_mc_enc_config( static ivas_error ivas_mc_enc_reconfig( Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */ - const int16_t last_mc_mode /* i: last frame mc mode */ + const int16_t last_mc_mode /* i : last frame MC mode */ ) { int16_t nchan_transport_old, nSCE_old, nCPE_old; @@ -909,6 +910,7 @@ static ivas_error ivas_mc_enc_reconfig( /* set last core to TCX20 */ st->last_core = TCX_20_CORE; } + if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c index 8135390f5a9006e9d9fe02039d0837689ac58e99..1075a488404e4c0ffc5b3cc67a72b5080d5299b1 100644 --- a/lib_enc/ivas_mdct_core_enc.c +++ b/lib_enc/ivas_mdct_core_enc.c @@ -121,6 +121,7 @@ static void enc_prm_pre_mdct( return; } + /*--------------------------------------------------------------* * kernel_switch_detect() * @@ -1160,8 +1161,9 @@ void ivas_mdct_core_whitening_enc( /*--------------------------------------------------------------------------------* * SNS parameters *--------------------------------------------------------------------------------*/ + #ifdef SNS_MSVQ - if ( !mct_on && sts[0]->sr_core == 25600 && ( ( hCPE->element_brate == IVAS_48k || hCPE->element_brate == IVAS_64k ) ) ) + if ( !mct_on && sts[0]->sr_core == 25600 && ( hCPE->element_brate == IVAS_48k || hCPE->element_brate == IVAS_64k ) ) { nbits_sns = 0; idx = 0; @@ -1246,6 +1248,7 @@ void ivas_mdct_core_whitening_enc( push_next_indice( hBstr, sns_low_br_mode, 1 ); } } + encode_lpc_avq( hBstr, num_sns, param_lpc[ch], st->core, st->element_mode ); st->side_bits_frame_channel += hBstr->nb_bits_tot - nbits_start_sns; diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index 64d5b8e6aa86c91574a962280fcfff859334f420..70675a56c7550900532f16d5bcfa9c12aea874c8 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -51,7 +51,6 @@ static float direction_distance( float elevation[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], float azimuth[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], IVAS_QDIRECTION *q_direction, const int16_t dim1, const int16_t dim2, float mat_dist[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] ); #endif - static void ivas_qmetadata_quantize_diffuseness_nrg_ratios( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, int16_t *nbits_diff, int16_t *dfRatioBits #ifdef HODIRAC , @@ -65,7 +64,7 @@ static void ivas_qmetadata_reorder_2dir_bands( IVAS_QMETADATA_HANDLE hQMetaData static int16_t ivas_qmetadata_entropy_encode_df_ratio( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, int16_t *df_ratio_bits ); -static int16_t ivas_qmetadata_entropy_encode_dir( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, const uint16_t diffuseness_index_max_ec_frame, const int16_t nbands, const int16_t start_band, const int16_t direction_bits_raw, int16_t max_bits +static int16_t ivas_qmetadata_entropy_encode_dir( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, const uint16_t diffuseness_index_max_ec_frame, const int16_t nbands, const int16_t start_band, const int16_t direction_bits_raw, const int16_t max_bits #ifdef HR_METADATA , const int16_t hrmasa_flag @@ -160,8 +159,8 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( IVAS_QMETADATA *hQMetaD *-----------------------------------------------------------------------*/ ivas_error ivas_qmetadata_enc_encode( - BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ - IVAS_QMETADATA *hQMetaData /* i/o: metadata handle */ + BSTR_ENC_HANDLE hMetaData, /* i/o: metadata bitstream handle */ + IVAS_QMETADATA *hQMetaData /* i/o: metadata handle */ #ifdef HODIRAC , const int16_t hodirac_flag /* i : flag to indicate HO-DirAC mode*/ @@ -1311,11 +1310,11 @@ void reset_metadata_spatial( /*! r: quantized spherical index */ int16_t quantize_direction2D( - float phi, /* i : input azimuth value */ - const int16_t no_cw, /* i : number of bits */ - float *phi_q, /* o : quantized azimuth value */ - uint16_t *index_phi, /* o : quantized azimuth index */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ + float phi, /* i : input azimuth value */ + const int16_t no_cw, /* i : number of bits */ + float *phi_q, /* o : quantized azimuth value */ + uint16_t *index_phi, /* o : quantized azimuth index */ + const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ) { int16_t idx_sph; @@ -1495,6 +1494,12 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr( } +/*------------------------------------------------------------------------- + * ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512() + * + * + *------------------------------------------------------------------------*/ + static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, @@ -2460,7 +2465,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( const int16_t nbands, const int16_t start_band, const int16_t direction_bits_raw, - int16_t max_bits + const int16_t max_bits #ifdef HR_METADATA , const int16_t hrmasa_flag @@ -2501,6 +2506,7 @@ static int16_t ivas_qmetadata_entropy_encode_dir( int16_t avg_azimuth_index_upd = 0, use_adapt_avg; int16_t make_gain = 0; int16_t bits_gained = 0; + nblocks = q_direction->cfg.nblocks; /* estimate the number of bits for entropy coding of the direction values */ @@ -4733,9 +4739,9 @@ static int16_t coherence_coding_length( /*! r: number of bits written */ static int16_t encode_spread_coherence_1sf( - IVAS_QMETADATA *q_metadata, /* i : quantized metadata */ - const int16_t idx_d, /* i : current direction index */ - BSTR_ENC_HANDLE hMasaMetaData /* i/o: metadata bitstream handle */ + IVAS_QMETADATA *q_metadata, /* i : quantized metadata */ + const int16_t idx_d, /* i : current direction index */ + BSTR_ENC_HANDLE hMasaMetaData /* i/o: metadata bitstream handle */ #ifdef HR_METADATA , const int16_t hrmasa_flag /* i : flag indicating high-rate MASA MD coding */ @@ -4765,7 +4771,6 @@ static int16_t encode_spread_coherence_1sf( GR_ord = 1; idx_shift = 0; - /* number of codevectors added dependent on number of subbands */ extra_cv = coding_subbands / MASA_FACTOR_CV_COH; for ( j = 0; j < coding_subbands; j++ ) @@ -5133,6 +5138,12 @@ static int16_t encode_surround_coherence( #ifdef HR_METADATA +/*-------------------------------------------------------------------* + * static int16_t encode_surround_coherence_hr() + * + * encoding surround coherence at HRs + *-------------------------------------------------------------------*/ + static int16_t encode_surround_coherence_hr( IVAS_QMETADATA *hQMetaData, /* i : quantized metadata */ BSTR_ENC_HANDLE hMetaData /* i/o: metadata bitstream handle */ @@ -5185,7 +5196,6 @@ static int16_t encode_surround_coherence_hr( error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[sf]; } - if ( error_ratio_surr <= 0 ) { error_ratio_surr = 0; @@ -5218,6 +5228,7 @@ static int16_t encode_surround_coherence_hr( } nbits_max = MASA_MAX_NO_CV_SUR_COH - max_val; /* encoded with GR0 as max_no_vals - no_vals*/ } + if ( max_val == 0 ) { for ( j = 0; j < coding_subbands; j++ ) @@ -5225,6 +5236,7 @@ static int16_t encode_surround_coherence_hr( hQMetaData->surcoh_band_data[j].surround_coherence[sf] = 0; } } + nbits_sf = coherence_coding_length( idx_sur_coh_shift, idx_shift, coding_subbands, no_cv, mr_idx_sur_coh, no_cv_shift, &min_idx, &GR_ord, &nbits_fr, &nbits_fr1 ); half_coding_subbands = coding_subbands / 2; @@ -5329,7 +5341,6 @@ static int16_t encode_surround_coherence_hr( } } - return nbits; } @@ -5403,6 +5414,7 @@ static float quantize_DCT_0_coh( *p_no_cb = len_cb_dct0_masa[q_direction->band_data[j].energy_ratio_index[0]]; #endif + *idx_x = idx; return xhat; @@ -5451,8 +5463,8 @@ static int16_t encode_coherence_indexesDCT1( *-------------------------------------------------------------------*/ static void dct4_transform( - uint8_t *v, /* i : input 4D vector */ - float *dct_v /* o : output transformed vector */ + uint8_t *v, /* i : input 4D vector */ + float *dct_v /* o : output transformed vector */ ) { float a, b, c, d; @@ -5479,10 +5491,10 @@ static void dct4_transform( *-------------------------------------------------------------------*/ static int16_t ivas_qmetadata_quantize_coherence_hr_512( - IVAS_QMETADATA *hQMetaData, /* i/o: quantized metadata */ - const int16_t idx_d, /* i : current direction index */ - const int16_t all_coherence_zero, /* i : all coherence is zero - flag */ - BSTR_ENC_HANDLE hMetaData, /* i : metadata handle */ + IVAS_QMETADATA *hQMetaData, /* i/o: quantized metadata */ + const int16_t idx_d, /* i : current direction index */ + const int16_t all_coherence_zero, /* i : all coherence is zero - flag */ + BSTR_ENC_HANDLE hMetaData, /* i : metadata handle */ const int16_t bits_coh ) { int16_t j, k; @@ -5575,6 +5587,7 @@ static int16_t ivas_qmetadata_quantize_coherence_hr_512( } nbits = hMetaData->nb_bits_tot - nbits; + return nbits; } #endif @@ -5901,6 +5914,7 @@ static void ivas_qmetadata_reorder_2dir_bands_hr( { if ( hQMetaData->q_direction[0].band_data[band].energy_ratio[sf] < hQMetaData->q_direction[1].band_data[band].energy_ratio[sf] ) { + uint16_tmp = hQMetaData->q_direction[0].band_data[band].spherical_index[sf]; hQMetaData->q_direction[0].band_data[band].spherical_index[sf] = hQMetaData->q_direction[1].band_data[band].spherical_index[sf]; hQMetaData->q_direction[1].band_data[band].spherical_index[sf] = uint16_tmp; diff --git a/lib_enc/ivas_qspherical_enc.c b/lib_enc/ivas_qspherical_enc.c index 4c79b875b7b1dfbc53971c0aec0e400cbabea077..716a28df1448c189178fb6453056184f3c5a026f 100644 --- a/lib_enc/ivas_qspherical_enc.c +++ b/lib_enc/ivas_qspherical_enc.c @@ -508,12 +508,12 @@ uint16_t quantize_direction( /*! r: distortion value */ static float direction_distance_cp( - float theta, /* i : elevation absolute value */ - float theta_hat, /* i : quantized elevation value in absolute value */ - float theta_hat1, /* i : quantized elevation value in absolute value */ - const float phi, /* i : azimuth value */ - const float phi_hat, /* i : quantized azimuth value */ - const float phi_hat1, /* i : quantized azimuth value */ + float theta, /* i : elevation absolute value */ + float theta_hat, /* i : quantized elevation value in absolute value */ + float theta_hat1, /* i : quantized elevation value in absolute value */ + const float phi, /* i : azimuth value */ + const float phi_hat, /* i : quantized azimuth value */ + const float phi_hat1, /* i : quantized azimuth value */ float *d1 ) { float d, ct, st, st1, st2; @@ -541,19 +541,19 @@ static float direction_distance_cp( /*! r: quantized elevation value */ static float quantize_theta_phi( - float *theta_cb, /* i : elevation codebook */ - const int16_t no_th, /* i : elevation codebook size */ + float *theta_cb, /* i : elevation codebook */ + const int16_t no_th, /* i : elevation codebook size */ const int16_t *no_phi_loc, /* i : number of azimuth values for each elevation codeword*/ - const float abs_theta, /* i : absolute value of elevation to be quantized */ - int16_t *id_phi, /* o : azimuth index */ - int16_t *id_phi_remap, /* o : remapped azimuth index */ - float *phi_hat, /* o : quantized azimuth value */ - const float phi, /* i : input azimuth value; to be quantized */ - const int16_t no_bits, /* i : number of bits used for quantization */ - int16_t *id_theta, /* o : elevation index */ - float *phi_q, /* o : rotated quantized azimuth */ - const int16_t remap, /* i : flag for remapping */ - const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ + const float abs_theta, /* i : absolute value of elevation to be quantized */ + int16_t *id_phi, /* o : azimuth index */ + int16_t *id_phi_remap, /* o : remapped azimuth index */ + float *phi_hat, /* o : quantized azimuth value */ + const float phi, /* i : input azimuth value; to be quantized */ + const int16_t no_bits, /* i : number of bits used for quantization */ + int16_t *id_theta, /* o : elevation index */ + float *phi_q, /* o : rotated quantized azimuth */ + const int16_t remap, /* i : flag for remapping */ + const MC_LS_SETUP mc_format /* i : channel format if in MC-mode */ ) { float theta_hat, theta_hat1, phi_hat1; diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index d013df5f4e5d064524c42e057eda823c9ad51b4b..5a025de4fea1b1165903fd202e881c143a43268b 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -131,6 +131,7 @@ ivas_error ivas_sba_enc_reconfigure( nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); + analysis_order_old = ivas_sba_get_analysis_order( hEncoderConfig->last_ivas_total_brate, hEncoderConfig->sba_order ); #ifdef FIX_DTX_428 nbands_old = st_ivas->hQMetaData->q_direction->cfg.nbands; @@ -207,6 +208,7 @@ ivas_error ivas_sba_enc_reconfigure( old_mem_hp20_in = NULL; } } + ivas_spar_config( ivas_total_brate, min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ), &st_ivas->nchan_transport, &st_ivas->nSCE, &st_ivas->nCPE, &st_ivas->hSpar->core_nominal_brate, -1 ); @@ -219,6 +221,7 @@ ivas_error ivas_sba_enc_reconfigure( } } hDirAC->num_samples_synchro_delay = 0; + hSpar = st_ivas->hSpar; if ( st_ivas->nchan_transport == 1 ) @@ -249,7 +252,9 @@ ivas_error ivas_sba_enc_reconfigure( return error; } } + hEncoderConfig->spar_reconfig_flag = spar_reconfig_flag; + if ( ( error = ivas_dirac_enc_reconfigure( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -274,6 +279,7 @@ ivas_error ivas_sba_enc_reconfigure( #endif mvs2s( hDirAC->dirac_to_spar_md_bands, hSpar->dirac_to_spar_md_bands, DIRAC_MAX_NBANDS ); hSpar->enc_param_start_band = hDirAC->hConfig->enc_param_start_band; + /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ diff --git a/lib_enc/ivas_sns_enc.c b/lib_enc/ivas_sns_enc.c index 7a93e335f21b775e1dda2463edc3391db354585f..86387c80bd003677111f3280b834a5369eef9bc4 100644 --- a/lib_enc/ivas_sns_enc.c +++ b/lib_enc/ivas_sns_enc.c @@ -498,7 +498,14 @@ void sns_avq_cod_stereo( return; } + #ifdef SNS_MSVQ +/*------------------------------------------------------------------- + * quantize_sns() + * + * Quantize SNS + *-------------------------------------------------------------------*/ + int16_t quantize_sns( float sns_in[CPE_CHANNELS][NB_DIV][M], float snsQ_out[CPE_CHANNELS][NB_DIV][M], diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index a7c359b7c96b6eaade81cf7fe35b58d88d154781..e71c7320aeb49cf0b2e37c943d82cc26775169fe 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -178,6 +178,7 @@ ivas_error ivas_spar_enc_open( return error; } } + /* PCA handle */ hSpar->hPCA = NULL; if ( hEncoderConfig->Opt_PCA_ON ) @@ -509,6 +510,7 @@ static ivas_error ivas_spar_enc_process( { transient_det[1] = 0; } + /* store previous input samples for W in local buffer */ assert( num_del_samples <= IVAS_FB_1MS_48K_SAMP ); #ifdef SBA_TD_RESIDUAL @@ -883,6 +885,7 @@ static ivas_error ivas_spar_enc_process( } } #endif + /*-----------------------------------------------------------------------------------------* * FB mixer *-----------------------------------------------------------------------------------------*/ @@ -1022,6 +1025,7 @@ static ivas_error ivas_spar_enc_process( } fclose( fp );*/ #endif + /*-----------------------------------------------------------------------------------------* * AGC *-----------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 4f9882cd245d9c9ed51aed8ffc0121292c0ba4d2..a658341473d45726a677c229e063b01313ec4182 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -559,8 +559,7 @@ ivas_error ivas_spar_md_enc_process( BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ const int16_t dtx_vad, const int16_t nchan_inp, - const int16_t sba_order /* i : Ambisonic (SBA) order */ - , + const int16_t sba_order, /* i : Ambisonic (SBA) order */ float *prior_mixer[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i : prior mixer_matrix */ ) { @@ -1426,6 +1425,7 @@ static void ivas_get_huffman_coded_bs( { int16_t code, len; int16_t ndm, ndec; + ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[i * bands_bw]; ndec = hMdEnc->spar_md_cfg.num_decorr_per_band[i * bands_bw]; @@ -1746,6 +1746,7 @@ static void ivas_store_prior_coeffs( const int16_t qsi ) { int16_t i, j, b; + if ( dtx_vad == 0 ) { hMdEnc->spar_md_cfg.prior_strat = START; diff --git a/lib_enc/ivas_stereo_dft_enc.c b/lib_enc/ivas_stereo_dft_enc.c index 43546261a41b954622c9bdaa07ef0bee191c2072..14233595ec0df9991fb067e05fe0c058f2cfc855 100644 --- a/lib_enc/ivas_stereo_dft_enc.c +++ b/lib_enc/ivas_stereo_dft_enc.c @@ -1228,10 +1228,10 @@ float stereo_dft_enc_synthesize( *-------------------------------------------------------------------------*/ void stereo_dft_enc_process( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ - const int16_t input_frame /* i : input frame length */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ + const int16_t input_frame /* i : input frame length */ ) { int16_t i, j, b; @@ -3190,7 +3190,7 @@ static void res_pred_gain_mode_decision( *------------------------------------------------------------------------*/ static float stereo_dft_calc_mean_bipd( - float *pIpd, /* i: current bandwise IPD */ + float *pIpd, /* i : current bandwise IPD */ float ipd_buf[STEREO_DFT_IPD_BUF_LEN] /* i/o: previous bandwise IPDs */ ) { @@ -3255,9 +3255,9 @@ static float stereo_dft_calc_mean_bipd( *------------------------------------------------------------------------*/ static float stereo_dft_calc_mean_ipd_change( - float *pIpd, /* i: bandwise IPDs */ - float *ipd_smooth, /* i: mean of previous bandwise IPDs */ - int16_t gipd_band_max /* i: number of IPD bands */ + float *pIpd, /* i : bandwise IPDs */ + float *ipd_smooth, /* i : mean of previous bandwise IPDs */ + int16_t gipd_band_max /* i : number of IPD bands */ ) { int16_t b; @@ -3293,8 +3293,8 @@ static float stereo_dft_calc_mean_ipd_change( static void stereo_dft_gipd_stabilization( float *pgIpd, /* i/o: global IPD to be stabilized */ - float prev_gipd, /* i: previous global IPD */ - float ipd_mean_change /* i: mean of previous bandwise IPDs */ + float prev_gipd, /* i : previous global IPD */ + float ipd_mean_change /* i : mean of previous bandwise IPDs */ ) { float diff_gipd; diff --git a/lib_enc/ivas_stereo_dft_td_itd.c b/lib_enc/ivas_stereo_dft_td_itd.c index b7fb95422f3136080892b0df097b65719ef747c6..556f112bb4fa5effe84a9585e02197336049118d 100644 --- a/lib_enc/ivas_stereo_dft_td_itd.c +++ b/lib_enc/ivas_stereo_dft_td_itd.c @@ -383,10 +383,10 @@ void stereo_td_itd( * ---------------------------------------------------------------*/ void stereo_td_itd_mdct_stereo( - CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ - const int16_t vad_flag_dtx[], /* i: VAD dtx flags */ - const int16_t vad_hover_flag[], /* i: VAD hangover flags */ - const int16_t input_frame /* i : frame length */ + CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder handle */ + const int16_t vad_flag_dtx[], /* i : VAD dtx flags */ + const int16_t vad_hover_flag[], /* i : VAD hangover flags */ + const int16_t input_frame /* i : frame length */ ) { int16_t i; diff --git a/lib_enc/ivas_stereo_mdct_core_enc.c b/lib_enc/ivas_stereo_mdct_core_enc.c index 2e739cc90651f43dc4f4d7d9adb4e733425e15fd..4e9f63aa7ac9ce317020111cc1a7ca7bbef5f69a 100644 --- a/lib_enc/ivas_stereo_mdct_core_enc.c +++ b/lib_enc/ivas_stereo_mdct_core_enc.c @@ -72,9 +72,8 @@ static void sync_tcx_mode( } } - if ( - ( prevAccNrg0 * 25.0f > prevAccNrg1 ) && ( prevAccNrg1 * 25.0f > prevAccNrg0 ) && /* 14 dB */ - ( lastAccNrg0 * 16.0f > lastAccNrg1 ) && ( lastAccNrg1 * 16.0f > lastAccNrg0 ) ) /* 12 dB */ + if ( ( prevAccNrg0 * 25.0f > prevAccNrg1 ) && ( prevAccNrg1 * 25.0f > prevAccNrg0 ) && /* 14 dB */ + ( lastAccNrg0 * 16.0f > lastAccNrg1 ) && ( lastAccNrg1 * 16.0f > lastAccNrg0 ) ) /* 12 dB */ { st[0]->hTcxEnc->tcxMode = st[1]->hTcxEnc->tcxMode = max( st[0]->hTcxEnc->tcxMode, st[1]->hTcxEnc->tcxMode ); /* synchronize TCX mode of both channels */ @@ -235,8 +234,7 @@ void stereo_mdct_core_enc( *---------------------------------------------------------------*/ ivas_mdct_core_whitening_enc( hCPE, new_samples, old_wsp, pitch_buf, p_mdst_spectrum_long, - tnsBits, p_orig_spectrum_long, tnsSize, p_param, hBstr, - 0, CPE_CHANNELS ); + tnsBits, p_orig_spectrum_long, tnsSize, p_param, hBstr, 0, CPE_CHANNELS ); for ( ch = 0; ch < CPE_CHANNELS; ch++ ) { @@ -251,10 +249,10 @@ void stereo_mdct_core_enc( sts[0]->side_bits_frame_channel += SMDCT_NBBITS_SPLIT_RATIO; - /*--------------------------------------------------------------* * Stereo Processing *---------------------------------------------------------------*/ + if ( !hStereoMdct->isSBAStereoMode ) { stereo_coder_tcx( hStereoMdct, sts, ms_mask, mdst_spectrum, inv_spectrum, inv_mdst_spectrum, 0 ); @@ -450,8 +448,7 @@ void stereo_mdct_core_enc( } #endif - ivas_mdct_quant_coder( hCPE, - tnsBits, tnsSize, p_param, 0 ); + ivas_mdct_quant_coder( hCPE, tnsBits, tnsSize, p_param, 0 ); pop_wmops(); diff --git a/lib_enc/ivas_stereo_mdct_stereo_enc.c b/lib_enc/ivas_stereo_mdct_stereo_enc.c index 4ef24de8a191368165a8406f556121d047f5be93..7b5cff21f62728ace594121503701db0e3ebf3ff 100644 --- a/lib_enc/ivas_stereo_mdct_stereo_enc.c +++ b/lib_enc/ivas_stereo_mdct_stereo_enc.c @@ -180,7 +180,7 @@ void stereo_coder_tcx( float *mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: MDST spectrum */ float *inv_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse spectrum */ float *inv_mdst_spectrum[CPE_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ + const int16_t mct_on /* i : flag mct block (1) or stereo (0)*/ ) { STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL; @@ -705,6 +705,7 @@ int16_t write_stereo_to_bitstream( return ( hBstr->nb_bits_tot - start_bits ); } + /*-------------------------------------------------------------------* * Band-wise M/S stereo processing * @@ -732,6 +733,7 @@ static void convertToBwMS( return; } + /*-------------------------------------------------------------------* * convertToMS() * @@ -750,6 +752,7 @@ void convertToMS( return; } + /*-------------------------------------------------------------------* * SQ_gain_estimate_stereo() * @@ -827,6 +830,7 @@ static float SQ_gain_estimate_stereo( return powf( 10.0f, 0.45f + 0.5f * offset ); } + /*-------------------------------------------------------------------* * QuantSpecEstimateBits() * @@ -857,6 +861,7 @@ static int16_t QuantSpecEstimateBits( return sqBits; } + /*-------------------------------------------------------------------* * context_update() * @@ -879,6 +884,7 @@ static void context_update( return; } + /*-------------------------------------------------------------------* * GetChannelEnergyRatio() * @@ -924,6 +930,7 @@ static float GetChannelEnergyRatio( return ( nrg[0] + nrg[1] ) > 0 ? nrg[0] / ( nrg[0] + nrg[1] ) : -1.0f; } + /*-------------------------------------------------------------------* * FindSplitRatio() * @@ -962,6 +969,7 @@ void FindSplitRatio( return; } + /*-------------------------------------------------------------------* * MsStereoDecision() * @@ -1175,6 +1183,7 @@ void initMdctStereoEncData( return; } + /*-----------------------------------------------------------------------* * initMdctItdHandling() * @@ -1211,6 +1220,7 @@ ivas_error initMdctItdHandling( return IVAS_ERR_OK; } + /*------------------------------------------------------------------------- * stereo_mdct_enc_destroy() * diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index c0c23b8dd9cf7a725e55b22a37dd78d140bcc8a7..7923e8d8be4303b71218214d75dfc2a7bbfceb37 100755 --- 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 ); @@ -785,7 +785,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; } @@ -1730,7 +1730,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; } @@ -1970,7 +1970,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 ) { @@ -2002,7 +2002,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/lsf_enc.c b/lib_enc/lsf_enc.c index 66f8847608b989e47ec7068d02972d36203383db..968a9a0d25e555e7539cdb0ca0556f8abefcf9df 100644 --- a/lib_enc/lsf_enc.c +++ b/lib_enc/lsf_enc.c @@ -82,9 +82,8 @@ void lsf_enc( float *lsp_mid, /* i/o: mid-frame LSP vector */ float *Aq, /* o : quantized A(z) for 4 subframes */ const int16_t tdm_low_rate_mode, /* i : secondary channel low rate mode flag */ - const int16_t GSC_IVAS_mode /* i : GSC IVAS mode */ - , - const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ + const int16_t GSC_IVAS_mode, /* i : GSC IVAS mode */ + const float tdm_lsfQ_PCh[M] /* i : Q LSFs for primary channel */ ) { int16_t i, nBits, force_sf, no_param_lpc; diff --git a/lib_enc/lsf_msvq_ma_enc.c b/lib_enc/lsf_msvq_ma_enc.c index 0f7a798a75a8971530b55965a1ae43a7cb1b5a64..a2ff87f25234eaf6471d2c034baac1202b768f4e 100644 --- a/lib_enc/lsf_msvq_ma_enc.c +++ b/lib_enc/lsf_msvq_ma_enc.c @@ -41,85 +41,80 @@ #endif #include "cnst.h" #include "prot.h" +#include "ivas_prot.h" #include "rom_com.h" #include "rom_enc.h" #include "basop_proto_func.h" #include "wmc_auto.h" -#define kMaxC 8 - -#include "ivas_prot.h" +/*--------------------------------------------------------------------------* + * Local constants + *--------------------------------------------------------------------------*/ -// void dctT2_N_apply_matrix( const float *input, float *output, const int16_t dct_dim, int16_t fdcngvq_dim, const float *idctT2_24_X_matrixQ16, const int16_t matrix_1st_dim, DCTTYPE dcttype ); +#define kMaxC 8 #ifdef ERI_MSVQ_CLEANUP +/*--------------------------------------------------------------------------* + * msvq_stage1_dct_search() + * + * stage1 search in a segmentwise truncated dct N domain without weights + *--------------------------------------------------------------------------*/ +/*! r: (p_max , best candidate sofar ) */ int16_t msvq_stage1_dct_search( - /* o : (p_max , best candidate sofar ) */ - const float *u, /* i : target */ - const int16_t N, /* i : target length and IDCT synthesis length */ - - /* parameterization of segmented DCT domain storage */ - const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ - - const DCTTYPE dcttype, /* e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ - const int16_t max_dct_trunc, /* i: maximum of truncation lenghts */ - float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ - - const float *midQ_truncQ, /* i: midQ vector */ - const float *dct_invScaleF, /* i: global inv scale factors*/ - const float *dct_scaleF, /* i: global scale factors*/ - const Word16 n_segm, /* i: number of segments */ - const Word16 *cols_per_segment, /* i: remaining length per segment */ - const Word16 *trunc_dct_cols_per_segment, /* i: trunc length per segment */ - const Word16 *entries_per_segment, /* i: number of rows per segment */ - const Word16 *cum_entries_per_segment, /* i: number of cumulative entries */ - - const Word8 *const W8Qx_dct_sections[], /*i: Word8(byte) segment table ptrs */ - const Word16 *col_syn_shift[], /*i: columnwise syn shift tables */ - const Word8 *segm_neighbour_fwd, /*i: circular neighbour list fwd */ - const Word8 *segm_neighbour_rev, /*i: circular neighbour list reverse */ - const Word16 npost_check, /*i: number of neigbours to check , should be even */ - - float *st1_mse_ptr, /*i: dynRAM buffer for MSEs */ - int16_t *indices_st1_local, /*o: selected cand indices */ - float *st1_syn_vec_ptr, /*i/o: buffer for IDCT24 synthesis */ - float *dist1_ptr /*o: resulting stage 1 MSEs in DCT-N domain */ + const float *u, /* i : target */ + const int16_t N, /* i : target length and IDCT synthesis length */ + const int16_t maxC_st1, /* i : number of final stage 1 candidates to provide */ + const DCTTYPE dcttype, /* i : e.g. DCT_T2_16_XX, DCT_T2_24_XX; */ + const int16_t max_dct_trunc, /* i : maximum of truncation lenghts */ + float *invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ + const float *midQ_truncQ, /* i : midQ vector */ + const float *dct_invScaleF, /* i : global inv scale factors */ + const float *dct_scaleF, /* i : global scale factors */ + const Word16 n_segm, /* i : number of segments */ + const Word16 *cols_per_segment, /* i : remaining length per segment */ + const Word16 *trunc_dct_cols_per_segment, /* i : trunc length per segment */ + const Word16 *entries_per_segment, /* i : number of rows per segment */ + const Word16 *cum_entries_per_segment, /* i : number of cumulative entries */ + const Word8 *const W8Qx_dct_sections[], /* i : Word8(byte) segment table ptrs */ + const Word16 *col_syn_shift[], /* i : columnwise syn shift tables */ + const Word8 *segm_neighbour_fwd, /* i : circular neighbour list fwd */ + const Word8 *segm_neighbour_rev, /* i : circular neighbour list reverse */ + const Word16 npost_check, /* i : number of neigbours to check , should be even */ + float *st1_mse_ptr, /* i : dynRAM buffer for MSEs */ + int16_t *indices_st1_local, /* o : selected cand indices */ + float *st1_syn_vec_ptr, /* i/o: buffer for IDCT24 synthesis */ + float *dist1_ptr /* o : resulting stage 1 MSEs in DCT-N domain */ ) -{ /* stage1 search in a segmentwise truncated dct N domain without weights */ - +{ float dct_target[FDCNG_VQ_DCT_MAXTRUNC]; float u_mr[FDCNG_VQ_MAX_LEN]; float u_mr_scaled[FDCNG_VQ_MAX_LEN]; float mse_trunc_segm[FDCNG_VQ_DCT_NSEGM]; float tmp, check_mse; float mse; /* Word32 in BASOP */ - int16_t p_max, c, c2, segm, j_full, j, i; int16_t n_ana, p_mins[2], idx_min[2]; - const Word8 *cbpW8; const Word16 *dct_col_shift_tab; - float *st1_mse_pair; int16_t *st1_idx_pair; - float tmp2; int16_t check_ind[FDCNG_VQ_DCT_NPOST]; - assert( ( npost_check % 2 == 0 ) && ( npost_check <= FDCNG_VQ_DCT_NPOST ) ); + assert( ( npost_check % 2 == 0 ) && ( npost_check <= FDCNG_VQ_DCT_NPOST ) ); assert( n_segm <= FDCNG_VQ_DCT_NSEGM ); n_ana = N; /* VQ stage#1 core is currently always using stored DCT N coeffs */ - assert( n_ana >= max_dct_trunc ); /* check for FDCNGVQ WB , SWB, FB operation */ + assert( n_ana >= max_dct_trunc ); /* check for FDCNGVQ WB, SWB, FB operation */ - /* remove mid stage#1 vector, in original input domain */ + /* remove mid stage#1 vector, in original input domain */ v_sub( u, midQ_truncQ, u_mr, n_ana ); v_multc( u_mr, dct_invScaleF[1], u_mr_scaled, n_ana ); /* scale up target to upscaled W8x storage domain */ - /* 16.0-->scale up from Q0 to search domain in Q4, not really needed in BASOP , impl. by shifts */ + /* 16.0-->scale up from Q0 to search domain in Q4, not really needed in BASOP, impl. by shifts */ dctT2_N_apply_matrix( (const float *) u_mr_scaled, dct_target, min( max_dct_trunc, n_ana ), n_ana, invTrfMatrix, max_dct_trunc, dcttype ); @@ -130,7 +125,8 @@ int16_t msvq_stage1_dct_search( set_f( mse_trunc_segm, 0.0f, n_segm ); for ( segm = 0; segm < n_segm; segm++ ) - { /* point to a new paired location for each segment */ + { + /* point to a new paired location for each segment */ p_max = 0; /* req. to point to one of 1 or 0, this init can potentially be omitted here,as p_max is always 1 or 0 */ /* compute segment common trunction error in dctN domain */ @@ -141,11 +137,11 @@ int16_t msvq_stage1_dct_search( for ( j = 0; j < entries_per_segment[segm]; j++ ) { /* unweighted segmented search DCT domain loop */ - j_full = j + cum_entries_per_segment[segm]; /* or simply use j_full++ */ + j_full = j + cum_entries_per_segment[segm]; - mse = mse_trunc_segm[segm]; /* init mse with with common mse truncation part, in BASOP a move32() */ + mse = mse_trunc_segm[segm]; - dct_col_shift_tab = col_syn_shift[segm]; /* ptr init */ + dct_col_shift_tab = col_syn_shift[segm]; for ( c2 = 0; c2 < cols_per_segment[segm]; c2++ ) { @@ -153,66 +149,56 @@ int16_t msvq_stage1_dct_search( tmp = dct_target[c2] - (float) ( ( (Word16) cbpW8[c2] ) << dct_col_shift_tab[c2] ); /* Word8 storage MSE inner loop */ LOGIC( 1 ); SHIFT( 1 ); - ADD( 1 ); /* in BASOP: s_and(for W8->W16), shl(), sub()*/ + ADD( 1 ); #undef WMC_TOOL_SKIP - mse += tmp * tmp; /* L_mac or L_mac0() square Word16 -> Word32*/ + mse += tmp * tmp; } st1_mse_ptr[j_full] = mse; /* save MSE in shared dynamic RAM, move32() in BASOP */ #define WMC_TOOL_SKIP - cbpW8 += cols_per_segment[segm]; /* fixed pointer increment for each segment */ + cbpW8 += cols_per_segment[segm]; #undef WMC_TOOL_SKIP /* overwrite with a new worst index at p_max */ - - /* Note: The three inner loop if's below are not 100% properly instrumented by WMC tool */ - if ( mse < st1_mse_pair[p_max] ) /* L_sub */ + if ( mse < st1_mse_pair[p_max] ) { - st1_idx_pair[p_max] = j_full; /* move16, single BASOP */ - } /* BASOP 2 ops */ + st1_idx_pair[p_max] = j_full; + } if ( st1_idx_pair[p_max] == j_full ) - { /* idx updated --> also update mse */ - st1_mse_pair[p_max] = mse; /* move32(), single BASOP */ - } /* BASOP 3 ops */ - - /* avoid WC costly candidate list management by always updating p_max, - as we have only a pair in each segment to maintain */ - p_max = 0; /* move16() */ - if ( ( st1_mse_pair[0] - st1_mse_pair[1] ) < 0 ) /* L_sub()*/ { - p_max = 1; /* move16() */ - } /* BASOP 3 ops ,Note 2 ops possible in BASOP with L_sub and L_lshr */ - - /* Note: logical shift right not available in ANSI-C */ - /* p_max = (st1_mse_pair[0] - st1_mse_pair[1]) ">>>" 31; */ - /* in java logical shift right is available as >>> , in BASOP it is available as L_lshr */ - - /* Cost: weighted sum with cond moves ('if') => 8 in float , 7 in BASOP with L_lshr */ - } /* j in section */ + /* idx updated --> also update mse */ + st1_mse_pair[p_max] = mse; + } - st1_mse_pair += 2; /* req. ptr init */ - st1_idx_pair += 2; /* req. ptr init */ + p_max = 0; + if ( ( st1_mse_pair[0] - st1_mse_pair[1] ) < 0 ) + { + p_max = 1; + } + } - } /* next segment */ + st1_mse_pair += 2; + st1_idx_pair += 2; + } for ( j = 0; j < maxC_st1; j++ ) { - /* compute_full mse using stored DCT24 domain MSE's */ - /* calculate MSE from stage1 inner using existing inner DCT domain variables */ - dist1_ptr[j] *= dct_scaleF[2]; /* multiplication to get the DCT inner MSE scale to the correct input domain */ + /* compute_full mse using stored DCT24 domain MSE's */ + /* calculate MSE from stage1 inner using existing inner DCT domain variables */ + dist1_ptr[j] *= dct_scaleF[2]; /* multiplication to get the DCT inner MSE scale to the correct input domain */ } assert( ( maxC_st1 >= 3 ) ); assert( ( maxC_st1 <= 8 ) ); - p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish current worst candidate for MSVQ stage#2 among all maxC_st1 candidates so far */ + p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish current worst candidate for MSVQ stage#2 among all maxC_st1 candidates so far */ - p_mins[0] = minimum( dist1_ptr, maxC_st1, NULL ); /* find best entry among all maxC_pre */ + p_mins[0] = minimum( dist1_ptr, maxC_st1, NULL ); /* find best entry among all maxC_pre */ tmp = dist1_ptr[p_mins[0]]; dist1_ptr[p_mins[0]] = FLT_MAX; /* exclude 1st */ - p_mins[1] = minimum( dist1_ptr, maxC_st1, NULL ); /* find 2nd best entry */ + p_mins[1] = minimum( dist1_ptr, maxC_st1, NULL ); /* find 2nd best entry */ tmp2 = dist1_ptr[p_mins[1]]; dist1_ptr[p_mins[1]] = FLT_MAX; /* exclude 2nd */ @@ -222,13 +208,12 @@ int16_t msvq_stage1_dct_search( idx_min[0] = indices_st1_local[p_mins[0]]; idx_min[1] = indices_st1_local[p_mins[1]]; - - /* use global exclusion list to never reselect the two (best) global MSE values sofar */ - st1_mse_ptr[idx_min[0]] = FLT_MAX; /* move32() */ - st1_mse_ptr[idx_min[1]] = FLT_MAX; /* move32() */ + /* use global exclusion list to never reselect the two (best) global MSE values sofar */ + st1_mse_ptr[idx_min[0]] = FLT_MAX; + st1_mse_ptr[idx_min[1]] = FLT_MAX; /* circular MSE-neigbour list in use to potentially replace some segment search candidates */ - /* using both 1st and 2nd best neighbours in fwd and rev directions */ + /* using both 1st and 2nd best neighbours in fwd and rev directions */ check_ind[0] = segm_neighbour_fwd[idx_min[0]]; check_ind[1] = segm_neighbour_rev[idx_min[0]]; @@ -243,45 +228,49 @@ int16_t msvq_stage1_dct_search( for ( i = 0; i < npost_check; i++ ) { - /* move MSE from DCT-inner loop search to input synthesis domain */ - /* multiplication by fdcng_dct_scaleF[2] to get the float outer loop scale correct in IDCT synthesis domain */ + /* move MSE from DCT-inner loop search to input synthesis domain */ + /* multiplication by fdcng_dct_scaleF[2] to get the float outer loop scale correct in IDCT synthesis domain */ check_mse = st1_mse_ptr[check_ind[i]] * dct_scaleF[2]; if ( check_mse < dist1_ptr[p_max] ) - { /* new winner , replace worst */ + { + /* new winner, replace worst */ dist1_ptr[p_max] = check_mse; indices_st1_local[p_max] = check_ind[i]; - st1_mse_ptr[check_ind[i]] = FLT_MAX; /* exclude, BASOP: move32() */ - p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish a new current worst candidate among all maxC */ + st1_mse_ptr[check_ind[i]] = FLT_MAX; /* exclude, BASOP: move32() */ + p_max = maximum( dist1_ptr, maxC_st1, NULL ); /* establish a new current worst candidate among all maxC */ } } - /* extract the selected stage one vectors in DCT_N domain , apply IDCT_N and scale up */ - /* always extract full length signal(e.g. 24) to be able to update WB(e.g. N_in==21) candidate MSE values */ - /* in the case that only a part of the IDCT N vector is in final use */ + /* extract the selected stage one vectors in DCT_N domain, apply IDCT_N and scale up */ + /* always extract full length signal(e.g. 24) to be able to update WB( e.g. N_in==21) candidate MSE values */ + /* in the case that only a part of the IDCT N vector is in final use */ /* note: synthesis not yet fully parameterized/generalized for other IDCT lengths */ assert( N == 24 ); + for ( c = 0; c < maxC_st1; c++ ) { - for ( c = 0; c < maxC_st1; c++ ) - { - dec_FDCNG_MSVQ_stage1( indices_st1_local[c], N, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * N] ), NULL ); - } + dec_FDCNG_MSVQ_stage1( indices_st1_local[c], N, invTrfMatrix, dcttype + 1, &( st1_syn_vec_ptr[c * N] ), NULL ); } return p_max; /*ptr to worst performing candidate */ } -/* recalc MSE for fdcng WB(0..20) coeffs , - essentially subtract res21^2 ,res22^2, res23^2 that was included in stage1 MSE in the DCT24 domain truncated search, - excludes the waveform contributions at pos 21,22,23 to the MSE, important to keep the WB MSEs update for the subsequent stages -*/ -int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( /* o : (updated p_max) */ - const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ - const float *u, /* i : target signal */ - const int16_t maxC_st1, /* i : number of candidates in stage1 */ - float *dist_ptr /* i/o: updated MSE vector for stage1 */ +/*--------------------------------------------------------------------------* + * msvq_stage1_dct_recalc_candidates_fdcng_wb() + * + * recalc MSE for fdcng WB(0..20) coeffs , + * essentially subtract res21^2 ,res22^2, res23^2 that was included in stage1 MSE in the DCT24 domain truncated search, + * excludes the waveform contributions at pos 21,22,23 to the MSE, important to keep the WB MSEs update for the subsequent stages + *--------------------------------------------------------------------------*/ + +/*! r: updated p_max */ +int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( + const float *st1_syn_vec_ptr, /* i : IDCT24 synthesis vectors */ + const float *u, /* i : target signal */ + const int16_t maxC_st1, /* i : number of candidates in stage1 */ + float *dist_ptr /* i/o: updated MSE vector for stage1 */ ) { int16_t p_max_local, c; @@ -289,17 +278,18 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( float res24, high_diff[FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB]; for ( c = 0; c < maxC_st1; c++ ) - { /* point to extended synthesis part */ + { + /* point to extended synthesis part */ p2 = (const float *) &( st1_syn_vec_ptr[c * FDCNG_VQ_MAX_LEN + FDCNG_VQ_MAX_LEN_WB] ); /* ptr init to synthesis candidate c */ - /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ + + /* for stage#1 use "u" instead of the shortened resid[0], to access the extended/extrapolated input target */ v_sub( p2, &( u[FDCNG_VQ_MAX_LEN_WB] ), high_diff, FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB ); - res24 = dotp( high_diff, high_diff, FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB ); /* sum squared over top env. values above WB coeffs */ + res24 = dotp( high_diff, high_diff, FDCNG_VQ_MAX_LEN - FDCNG_VQ_MAX_LEN_WB ); /* sum squared over top env. values above WB coeffs */ dist_ptr[c] -= res24; /* remove DCT24 high band error contribution */ } - /* finally update p_max, as it may potentially change, - due to the core DCT24 search originally optimizing over the longer basis vectors than DCT21 */ + /* finally update p_max, as it may potentially change, due to the core DCT24 search originally optimizing over the longer basis vectors than DCT21 */ p_max_local = maximum( dist_ptr, maxC_st1, NULL ); return p_max_local; @@ -312,6 +302,7 @@ int16_t msvq_stage1_dct_recalc_candidates_fdcng_wb( * * MSVQ encoder *--------------------------------------------------------------------------*/ + void msvq_enc( const float *const *cb, /* i : Codebook (indexed cb[*stages][levels][p]) */ const int16_t dims[], /* i : Dimension of each codebook stage (NULL: full dim.) */ @@ -324,8 +315,8 @@ void msvq_enc( const float w[], /* i : Weights */ const int16_t N, /* i : Vector dimension */ const int16_t maxN, /* i : Codebook dimension */ - const int16_t applyDCT_flag, /* i : applyDCT flag */ - float *invTrfMatrix, /*i/o : synthesis matrix */ + const int16_t applyDCT_flag, /* i : applyDCT flag */ + float *invTrfMatrix, /*i/o : synthesis matrix */ int16_t Idx[] /* o : Indices */ ) { @@ -378,8 +369,6 @@ void msvq_enc( #ifndef ERI_MSVQ_CLEANUP dcttype = DCT_T2_24_XX; #endif - - /*----------------------------------------------------------------* * Allocate memory for previous (parent) and current nodes. * Parent node is indexed [0], current node is indexed [1]. @@ -418,6 +407,7 @@ void msvq_enc( { /* codebook pointer is set to point to first stage */ cbp = cb[s]; + /* Save pointer to beginning of current stage */ cb_stage = cbp; @@ -456,6 +446,7 @@ void msvq_enc( set_zero( Tmp, start ); set_zero( Tmp + start + n, N - ( start + n ) ); + /* Set distortions to a large value */ for ( j = 0; j < maxC; j++ ) { @@ -469,27 +460,12 @@ void msvq_enc( assert( N == FDCNG_VQ_MAX_LEN || N == FDCNG_VQ_MAX_LEN_WB ); /* 21 and 24 allowed */ assert( maxC == 2 * FDCNG_VQ_DCT_NSEGM ); - p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, - DCT_T2_24_XX, - FDCNG_VQ_DCT_MAXTRUNC, - invTrfMatrix, /* i : IDCT synthesis matrix for dim N */ - cdk1r_tr_midQ_truncQ, /* i: midQ vector */ - fdcng_dct_invScaleF, /* i: global inv scale factors*/ - fdcng_dct_scaleF, /* i: global scale factors*/ - FDCNG_VQ_DCT_NSEGM, /* i: number of segments */ - cdk1_ivas_cols_per_segment, /* i: remaining length per segment */ - cdk1_ivas_trunc_dct_cols_per_segment, /* i: trunc length per segment */ - cdk1_ivas_entries_per_segment, /* i: number of rows per segment */ - cdk1_ivas_cum_entries_per_segment, /* i: number of cumulative entries */ - cdk_37bits_ivas_stage1_W8Qx_dct_sections, /*i: Word8(byte) segment table ptrs */ - stage1_dct_col_syn_shift, /*i: columnwise syn shift tables */ - cdk1_ivas_segm_neighbour_fwd, /*i: circular neighbour list fwd */ - cdk1_ivas_segm_neighbour_rev, /*i: circular neighbour list reverse */ - FDCNG_VQ_DCT_NPOST, /*i: number of circ. neigbours to post check */ - st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); - - - /* move established stage#1 indices to the global MSVQ list structure */ + p_max = msvq_stage1_dct_search( u, FDCNG_VQ_MAX_LEN, maxC, DCT_T2_24_XX, FDCNG_VQ_DCT_MAXTRUNC, invTrfMatrix, cdk1r_tr_midQ_truncQ, fdcng_dct_invScaleF, + fdcng_dct_scaleF, FDCNG_VQ_DCT_NSEGM, cdk1_ivas_cols_per_segment, cdk1_ivas_trunc_dct_cols_per_segment, cdk1_ivas_entries_per_segment, + cdk1_ivas_cum_entries_per_segment, cdk_37bits_ivas_stage1_W8Qx_dct_sections, stage1_dct_col_syn_shift, cdk1_ivas_segm_neighbour_fwd, + cdk1_ivas_segm_neighbour_rev, FDCNG_VQ_DCT_NPOST, st1_mse_ptr, indices_st1_local, st1_syn_vec_ptr, dist[1] ); + + /* move established stage#1 indices to the global MSVQ list structure */ for ( c = 0; c < maxC; c++ ) { indices[1][c * stages] = indices_st1_local[c]; @@ -656,40 +632,90 @@ void msvq_enc( assert( maxC == maxC_pre ); } #endif - else - /* non-DCT Stage #1 code below */ - if ( !s ) /* means: m==1 */ + /* non-DCT Stage #1 code below */ + else if ( !s ) /* means: m==1 */ + { + /* This loop is identical to the one below, except, that the inner loop over c=0..m is hardcoded to c=0, since m=1. */ + + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) { - /* This loop is identical to the one below, except, that the inner - loop over c=0..m is hardcoded to c=0, since m=1. */ - /* dist[0][0] */ - for ( j = 0; j < levels[s]; j++ ) + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) + { + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; + } + cbp += maxn; /* pointer is incremented */ + + pTmp = &resid[0][0]; + /* Tmp */ + tmp = ( *pTmp++ ) * Tmp[0]; + for ( c2 = 1; c2 < N; c2++ ) + { + tmp += ( *pTmp++ ) * Tmp[c2]; + } + tmp = en - 2.0f * tmp; + tmp += dist[0][0]; + if ( tmp < dist[1][p_max] ) { - en = 0.0f; - /* w,Tmp */ - /* Compute weighted codebook element and its energy */ - for ( c2 = 0; c2 < n; c2++ ) + /* Replace worst */ + dist[1][p_max] = tmp; + indices[1][p_max * stages] = j; + parents[p_max] = 0; + + p_max = 0; + for ( c2 = 1; c2 < maxC; c2++ ) { - Tmp[start + c2] = w[start + c2] * cbp[c2]; - en += cbp[c2] * Tmp[start + c2]; + if ( dist[1][c2] > dist[1][p_max] ) + { + p_max = c2; + } } - cbp += maxn; /* pointer is incremented */ + } + } + + /* update p_max location , for next stage */ + p_max = maximum( dist[1], maxC, NULL ); + } + else + { + /* subsequent stages after first stage */ + /* dist[0][0] */ + for ( j = 0; j < levels[s]; j++ ) + { + en = 0.0f; + /* w,Tmp */ + /* Compute weighted codebook element and its energy */ + for ( c2 = 0; c2 < n; c2++ ) + { + Tmp[start + c2] = w[start + c2] * cbp[c2]; + en += cbp[c2] * Tmp[start + c2]; + } + cbp += maxn; /* pointer is incremented */ - pTmp = &resid[0][0]; - /* Tmp */ + /* dist[0][0] */ + pTmp = &resid[0][0]; + + /* Iterate over all parent nodes */ + for ( c = 0; c < m; c++ ) + { + /* Tmp[0] */ tmp = ( *pTmp++ ) * Tmp[0]; for ( c2 = 1; c2 < N; c2++ ) { tmp += ( *pTmp++ ) * Tmp[c2]; } tmp = en - 2.0f * tmp; - tmp += dist[0][0]; + tmp += dist[0][c]; if ( tmp < dist[1][p_max] ) { /* Replace worst */ dist[1][p_max] = tmp; - indices[1][p_max * stages] = j; - parents[p_max] = 0; + indices[1][p_max * stages + s] = j; + parents[p_max] = c; p_max = 0; for ( c2 = 1; c2 < maxC; c2++ ) @@ -699,63 +725,15 @@ void msvq_enc( p_max = c2; } } - } /* if (tmp <= dist[1][p_max]) */ - } /* for (j=0; j dist[1][p_max] ) - { - p_max = c2; - } - } - } /* if (tmp <= dist[1][p_max]) */ - } /* for(c=0; cinput, NULL, enerBuffer, - 0 ); + bw_detect( st, st->input, NULL, enerBuffer, 0 ); /*----------------------------------------------------------------* * Noise energy down-ward update and total noise energy estimation @@ -382,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 a7572aea3fe8d0e2bd0663d981ce9e67d6e9f01b..05a5a483e4eaecd0725d02ef6c39e42bb5c7df27 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 */ ) { @@ -105,6 +105,7 @@ static ivas_error ivas_hrtf_open( ) { HRTFS_HANDLE hHrtf; + ivas_error error; if ( *hHrtf_out == NULL ) { @@ -113,7 +114,10 @@ static ivas_error ivas_hrtf_open( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder\n" ); } - ivas_hrtf_init( hHrtf ); + if ( ( error = ivas_hrtf_init( hHrtf ) ) != IVAS_ERR_OK ) + { + return error; + } *hHrtf_out = hHrtf; } @@ -1103,17 +1107,17 @@ static ivas_error ivas_rend_crendConvolver( *-----------------------------------------------------------------------------------------*/ ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ #ifdef JBM_TSM_ON_TCS float *output[], /* i/o: input/output audio channels */ #else - float output[][L_FRAME48k], /* i/o: input/output audio channels */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ #endif const int32_t output_Fs ) { @@ -1145,18 +1149,19 @@ ivas_error ivas_rend_crendProcess( output_frame = (int16_t) ( output_Fs / FRAMES_PER_SEC ); subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES; + #ifdef JBM_TSM_ON_TCS for ( i = 0; i < BINAURAL_CHANNELS; i++ ) { p_pcm_tmp[i] = pcm_tmp[i]; } #endif + for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ ) { + /* Rotation */ if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { - /* Orientation tracking */ - /* Rotation in SHD for: MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL SBA SPAR -> BINAURAL or BINAURAL_ROOM @@ -1172,6 +1177,7 @@ ivas_error ivas_rend_crendProcess( } } + /* Reverberation */ if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) ) { #ifdef JBM_TSM_ON_TCS @@ -1212,20 +1218,28 @@ ivas_error ivas_rend_crendProcess( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*-----------------------------------------------------------------------------------------* + * Function ivas_rend_crendProcessSubframe() + * + * + *-----------------------------------------------------------------------------------------*/ + ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ) + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +) { int16_t subframe_idx, subframe_len; int16_t nchan_out, nchan_in, ch, first_sf, last_sf, slot_size, slots_to_render; @@ -1245,10 +1259,12 @@ ivas_error ivas_rend_crendProcessSubframe( in_config = getIvasAudioConfigFromRendAudioConfig( inRendConfig ); inConfigType = getAudioConfigType( inRendConfig ); + if ( ( error = getAudioConfigNumChannels( outRendConfig, &nchan_out ) ) != IVAS_ERR_OK ) { return error; } + if ( ( error = getAudioConfigNumChannels( inRendConfig, &nchan_in ) ) != IVAS_ERR_OK ) { return error; @@ -1258,17 +1274,20 @@ ivas_error ivas_rend_crendProcessSubframe( { tc_local[ch] = input_f[ch]; } + for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { p_pcm_tmp[ch] = pcm_tmp[ch]; } slot_size = hTcBuffer->n_samples_granularity; + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, n_samples_to_render / slot_size ); first_sf = hTcBuffer->subframes_rendered; last_sf = first_sf; hTcBuffer->slots_rendered += slots_to_render; + while ( slots_to_render > 0 ) { slots_to_render -= hTcBuffer->subframe_nbslots[last_sf]; @@ -1278,9 +1297,9 @@ ivas_error ivas_rend_crendProcessSubframe( for ( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { subframe_len = hTcBuffer->subframe_nbslots[subframe_idx] * hTcBuffer->n_samples_granularity; + if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 ) { - /* Rotation in SHD for: MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL SBA SPAR -> BINAURAL or BINAURAL_ROOM @@ -1331,7 +1350,6 @@ ivas_error ivas_rend_crendProcessSubframe( mvr2r( pcm_tmp[ch], output[ch], n_samples_to_render ); } - hTcBuffer->subframes_rendered = last_sf; pop_wmops(); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 06fd160bb2819cdb9c10a65cfa6b668ff536592b..ec05cab974fda409cf8b12b7801ef6ae61df717c 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -140,6 +140,8 @@ static void ivas_dirac_dec_binaural_internal_sf( Decoder_Struct *st_ivas, float static void ivas_dirac_dec_decorrelate_slot_sf( DIRAC_DEC_HANDLE hDirAC, const int8_t slot, float inRe[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float inIm[][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float decRe[][CLDFB_NO_CHANNELS_MAX], float decIm[][CLDFB_NO_CHANNELS_MAX] ); #endif #endif + + /*------------------------------------------------------------------------- * ivas_dirac_dec_init_binaural_data() * @@ -408,8 +410,7 @@ ivas_error ivas_dirac_dec_init_binaural_data( return error; } } - -#endif /* JBM_TMS_ON_TCS*/ +#endif return IVAS_ERR_OK; } @@ -489,14 +490,21 @@ ivas_error ivas_dirac_dec_binaural_copy_hrtfs( return IVAS_ERR_OK; } + #ifdef JBM_TSM_ON_TCS +/*------------------------------------------------------------------------- + * void ivas_dirac_dec_binaural_render() + * + * + *------------------------------------------------------------------------*/ + void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ) { int16_t slots_to_render, first_sf, last_sf, subframe_idx; @@ -515,16 +523,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] = output_f[ch]; } slot_size = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = min( hDirAC->num_slots - hDirAC->slots_rendered, nSamplesAsked / slot_size ); *nSamplesRendered = slots_to_render * slot_size; first_sf = hDirAC->subframes_rendered; last_sf = first_sf; + while ( slots_to_render > 0 ) { slots_to_render -= hDirAC->subframe_nbslots[last_sf]; last_sf++; } + #ifdef DEBUGGING assert( slots_to_render == 0 ); #endif @@ -541,16 +552,19 @@ void ivas_dirac_dec_binaural_render( output_f_local[ch] += n_samples_sf; } } + if ( hDirAC->slots_rendered == hDirAC->num_slots ) { st_ivas->hDirAC->dirac_read_idx = ( st_ivas->hDirAC->dirac_read_idx + DEFAULT_JBM_SUBFRAMES_5MS ) % st_ivas->hDirAC->dirac_md_buffer_length; } + *nSamplesAvailable = ( hDirAC->num_slots - hDirAC->slots_rendered ) * slot_size; return; } #endif + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural() * @@ -612,14 +626,15 @@ void ivas_dirac_dec_binaural( #endif } output_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); + #ifdef JBM_TSM_ON_TCS - { - ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); - } + ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, p_output, decorr_signal, output_frame ); + #else ivas_td_decorr_process( st_ivas->hDiracDecBin->hTdDecorr, output_f, decorr_signal, output_frame ); #endif } + #ifdef JBM_TSM_ON_TCS if ( nchan_transport == 1 && st_ivas->nchan_transport != 2 && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) { @@ -634,7 +649,9 @@ void ivas_dirac_dec_binaural( { #ifdef JBM_TSM_ON_TCS int16_t n_samples_sf = slot_size * st_ivas->hDirAC->subframe_nbslots[subframe]; + ivas_dirac_dec_binaural_internal( st_ivas, p_output, nchan_transport, subframe ); + for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { p_output[ch] += n_samples_sf; @@ -658,12 +675,14 @@ void ivas_dirac_dec_binaural( ivas_dirac_dec_binaural_internal( st_ivas, output_f, nchan_transport, 0u, (uint8_t) MAX_PARAM_SPATIAL_SUBFRAMES ); } #endif + #ifdef JBM_TSM_ON_TCS for ( ch = 0; ch < 2 * BINAURAL_CHANNELS; ch++ ) { st_ivas->hTcBuffer->tc[ch] = NULL; } #endif + return; } diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 7875165e51d0ce47be819eba3bd6124fe92061be..fe11721020345e82e185fe8c33f9296cb61a947b 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -100,7 +100,7 @@ static int16_t detect_strong_saturations( * Allocate and initialize limiter struct *-------------------------------------------------------------------*/ -/*! r : limiter struct handle */ +/*! 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 */ diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index 83db83293750b00ae85ae5b3a5f721d9c2a0da84..d1c5246655fa7628ca25959b9f4dab58d490acf7 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -316,7 +316,6 @@ ivas_error ivas_td_binaural_renderer_unwrap( } } - if ( hReverb != NULL && hReverb->pConfig.roomAcoustics.late_reverb_on ) { /* add reverb to rendered signals */ @@ -452,7 +451,7 @@ void TDREND_Update_object_positions( const IVAS_FORMAT in_format, /* i : Format of input sources */ const ISM_METADATA_HANDLE *hIsmMetaData, /* i : Input metadata for ISM objects */ #ifdef JBM_TSM_ON_TCS - float *output[] + float *output[] /* i/o: SCE/MC channels */ #else float output[][L_FRAME48k] /* i/o: SCE/MC channels */ #endif diff --git a/lib_rend/ivas_objectRenderer_sfx.c b/lib_rend/ivas_objectRenderer_sfx.c index af3231df613a8717b5e8ada8603bc5fa92f94848..870a9c43dc35042cd56117e0f9cbda5efdd1b5de 100644 --- a/lib_rend/ivas_objectRenderer_sfx.c +++ b/lib_rend/ivas_objectRenderer_sfx.c @@ -56,14 +56,15 @@ static void sincResample( const float *input, float *output, const int16_t lengt * * Apply ITD by delaying late channel *---------------------------------------------------------------------*/ + void TDREND_Apply_ITD( - float *input, /* i: Input subframe to be time adjusted */ - float *out_left, /* o: Output left channel with ITD applied */ - float *out_right, /* o: Output right channel with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ + float *input, /* i : Input subframe to be time adjusted */ + float *out_left, /* o : Output left channel with ITD applied */ + float *out_right, /* o : Output right channel with ITD applied */ + int16_t *previtd, /* i/o: Previous ITD value */ + const int16_t itd, /* i : Current subframe ITD value */ + float *mem_itd, /* i/o: ITD buffer memory */ + const int16_t length /* i : Subframe length */ ) { int16_t transition_len; diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 91253748b2eb4ee2554f80c6d8f2782b72c31fe8..21968d5e54b3db9b11d90ffc0c0cc9b93409feda 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -248,19 +248,19 @@ static void TDREND_SRC_REND_Init( --------------------------------------------------------------------*/ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ - TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, /* i/o: Source pointer */ - const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ + TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ + const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ) { TDREND_MIX_Listener_t *Listener_p; diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index b43a048f38f901638e8e2885fa4da2d0feaaf0fc..ba89b59b9c17ebbad7f40a3a59b314066b190387 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -93,7 +93,7 @@ void ivas_limiter_dec ( IVAS_LIMITER_HANDLE hLimiter, /* i/o: limiter struct handle */ #ifdef JBM_TSM_ON_TCS - float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ + float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer */ #else float output[MAX_OUTPUT_CHANNELS][L_FRAME48k], /* i/o: input/output buffer */ #endif @@ -171,12 +171,12 @@ void ivas_dirac_dec_binaural( #ifdef JBM_TSM_ON_TCS void ivas_dirac_dec_binaural_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ - uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ - uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - const int16_t nchan_transport, - float *output_f[] /* o : rendered time signal */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nSamplesAsked, /* i : number of CLDFB slots requested */ + uint16_t *nSamplesRendered, /* o : number of CLDFB slots rendered */ + uint16_t *nSamplesAvailable, /* o : number of CLDFB slots still to render */ + const int16_t nchan_transport, /* i : number of transport channels */ + float *output_f[] /* o : rendered time signal */ ); #endif @@ -206,8 +206,12 @@ void ivas_HRTF_binary_close( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); +ivas_error ivas_hrtf_init( + HRTFS_DATA *hHrtf /* i/o: HRTF handle */ +); + ivas_error ivas_HRTF_fastconv_binary_open( - HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ + HRTFS_FASTCONV **hHrtfFastConv /* i/o: FASTCONV HRTF structure */ ); void ivas_HRTF_fastconv_binary_close( @@ -223,11 +227,11 @@ void ivas_HRTF_parambin_binary_close( ); ivas_error ivas_HRTF_CRend_binary_open( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); void ivas_HRTF_CRend_binary_close( - HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ + HRTFS_CREND **hSetOfHRTF /* i/o: Set of HRTF handle */ ); @@ -247,9 +251,9 @@ ivas_error ivas_td_binaural_renderer_unwrap( const IVAS_QUATERNION *Quaternions, /* i : Head tracking data per subframe */ const IVAS_VECTOR3 *Pos, /* i : Listener position data per subframe */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: SCE channels / Binaural synthesis */ + float *output[], /* i/o: SCE channels / Binaural synthesis */ #else - float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ + float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ #endif const int16_t output_frame /* i : output frame length */ ); @@ -343,9 +347,9 @@ void HRTF_model_precalc( ivas_error TDREND_REND_RenderSourceHRFilt( TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */ - const float *hrf_left_delta, /* i: Left filter interpolation delta */ - const float *hrf_right_delta, /* i: Right filter interpolation delta */ - const int16_t intp_count, /* i: Interpolation count */ + const float *hrf_left_delta, /* i : Left filter interpolation delta */ + const float *hrf_right_delta, /* i : Right filter interpolation delta */ + const int16_t intp_count, /* i : Interpolation count */ float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */ const int16_t subframe_length /* i : Subframe length in use */ ); @@ -380,15 +384,15 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ TDREND_SRC_SPATIAL_t *SrcSpatial_p, /* i : Spatial aspects of source */ - float *hrf_left_prev, /* o: Left filter */ - float *hrf_right_prev, /* o: Right filter */ - float *hrf_left_delta, /* o: Left filter interpolation delta */ - float *hrf_right_delta, /* o: Right filter interpolation delta */ - int16_t *intp_count, /* o: Interpolation count */ - int16_t *filterlength, /* o: Length of filters */ - int16_t *itd, /* o: ITD value */ - float *Gain, /* o: Gain value */ - TDREND_SRC_t *Src_p, + float *hrf_left_prev, /* o : Left filter */ + float *hrf_right_prev, /* o : Right filter */ + float *hrf_left_delta, /* o : Left filter interpolation delta */ + float *hrf_right_delta, /* o : Right filter interpolation delta */ + int16_t *intp_count, /* o : Interpolation count */ + int16_t *filterlength, /* o : Length of filters */ + int16_t *itd, /* o : ITD value */ + float *Gain, /* o : Gain value */ + TDREND_SRC_t *Src_p, /* i/o: Source pointer */ const int16_t subframe_idx /* i : Subframe index to 5 ms subframe */ ); @@ -481,13 +485,13 @@ ivas_error TDREND_MIX_Init( /* ----- Object renderer - sfx ----- */ void TDREND_Apply_ITD( - float *input, /* i: Input SCE subframe to be time adjusted */ - float *out_left, /* o: Output left channels with ITD applied */ - float *out_right, /* o: Output right channels with ITD applied */ - int16_t *previtd, /*i/o: Previous ITD value */ - const int16_t itd, /* i: Current subframe ITD value */ - float *mem_itd, /*i/o: ITD buffer memory */ - const int16_t length /* i: Subframe length */ + float *input, /* i : Input SCE subframe to be time adjusted */ + float *out_left, /* o : Output left channels with ITD applied */ + float *out_right, /* o : Output right channels with ITD applied */ + int16_t *previtd, /* i/o: Previous ITD value */ + const int16_t itd, /* i : Current subframe ITD value */ + float *mem_itd, /* i/o: ITD buffer memory */ + const int16_t length /* i : Subframe length */ ); void TDREND_firfilt( @@ -524,38 +528,40 @@ void ivas_rend_closeCrend( CREND_WRAPPER_HANDLE *pCrend ); ivas_error ivas_rend_initCrendWrapper( - CREND_WRAPPER_HANDLE *pCrend ); + CREND_WRAPPER_HANDLE *pCrend +); ivas_error ivas_rend_crendProcess( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: input/output audio channels */ + float *output[], /* i/o: input/output audio channels */ #else - float output[][L_FRAME48k], /* i/o: input/output audio channels */ + float output[][L_FRAME48k], /* i/o: input/output audio channels */ #endif const int32_t output_Fs ); #ifdef JBM_TSM_ON_TCS ivas_error ivas_rend_crendProcessSubframe( - const CREND_WRAPPER *pCrend, - const AUDIO_CONFIG inConfig, - const AUDIO_CONFIG outConfig, - DECODER_CONFIG_HANDLE hDecoderConfig, - HEAD_TRACK_DATA_HANDLE hHeadTrackData, - IVAS_OUTPUT_SETUP_HANDLE hIntSetup, - EFAP_HANDLE hEFAPdata, - DECODER_TC_BUFFER_HANDLE hTcBuffer, - float *input_f[], - float *output[], /* i/o: input/output audio channels */ - const int16_t n_samples_to_render, - const int32_t output_Fs ); + const CREND_WRAPPER *pCrend, /* i/o: Crend wrapper handle */ + const AUDIO_CONFIG inConfig, /* i : input audio configuration */ + const AUDIO_CONFIG outConfig, /* i : output audio configuration */ + const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : decoder config. structure */ + const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : Head tracking data structure */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetup, /* i : internal setup handle */ + const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ + DECODER_TC_BUFFER_HANDLE hTcBuffer, /* i/o: JBM handle */ + float *input_f[], /* i : transport channels */ + float *output[], /* i/o: input/output audio channels */ + const int16_t n_samples_to_render, /* i : output frame length per channel */ + const int32_t output_Fs /* i : output sampling rate */ +); #endif @@ -651,8 +657,8 @@ ivas_error ivas_reverb_process( const AUDIO_CONFIG input_audio_config, /* i : reverb. input audio configuration */ const int16_t mix_signals, /* i : add reverb to output signal */ #ifdef JBM_TSM_ON_TCS - float *pcm_in[], /* i : the PCM audio to apply reverb on */ - float *pcm_out[], /* o : the PCM audio with reverb applied */ + float *pcm_in[], /* i : the PCM audio to apply reverb on */ + float *pcm_out[], /* o : the PCM audio with reverb applied */ #else float pcm_in[][L_FRAME48k], /* i : the PCM audio to apply reverb on */ float pcm_out[][L_FRAME48k], /* o : the PCM audio with reverb applied */ @@ -667,7 +673,7 @@ void ivas_rev_delay_line_init( const uint16_t maxdelay /* i : maximum delay to be supported */ ); -/* !r: sample gotten out of delay line, and amplified by set gain */ +/*! r: sample gotten out of delay line, and amplified by set gain */ float ivas_rev_delay_line_get_sample( ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ); @@ -839,18 +845,18 @@ void ivas_reverb_get_hrtf_set_properties( *-----------------------------------------------------------------------------------*/ ivas_error ivas_headTrack_open( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); void ivas_headTrack_close( - HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ ); void Euler2Quat( - const float yaw, /* i : yaw (x) */ - const float pitch, /* i : pitch (y) */ - const float roll, /* i : roll (z) */ - IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ + const float yaw, /* i : yaw (x) */ + const float pitch, /* i : pitch (y) */ + const float roll, /* i : roll (z) */ + IVAS_QUATERNION *quat /* o : quaternion describing the rotation */ ); float deg2rad( float degrees ); @@ -882,7 +888,7 @@ void rotateFrame_shd( #ifdef JBM_TSM_ON_TCS float *output[], /* i/o: unrotated HOA3 signal buffer in TD */ #else - float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ + float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */ #endif const int16_t subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ @@ -892,9 +898,9 @@ void rotateFrame_shd( void rotateFrame_sd( HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */ #ifdef JBM_TSM_ON_TCS - float *output[], /* i/o: unrotated SD signal buffer in TD */ + float *output[], /* i/o: unrotated SD signal buffer in TD */ #else - float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ + float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */ #endif const int16_t subframe_len, /* i : subframe length per channel */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */ @@ -908,7 +914,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, /* i : number of time slots to process */ + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ); diff --git a/lib_rend/ivas_reverb_delay_line.c b/lib_rend/ivas_reverb_delay_line.c index 892a0d21c9854000fce1f913f16ff88ac3f3a7d8..a91551f71d63d0edf763ba24077ad3e3a34126e9 100644 --- a/lib_rend/ivas_reverb_delay_line.c +++ b/lib_rend/ivas_reverb_delay_line.c @@ -160,7 +160,7 @@ void ivas_rev_delay_line_feed_sample_blk( * NOTE: get a sample out of the line before feeding the next *-----------------------------------------------------------------------------------------*/ -/* !r: sample gotten out of delay line, and amplified by set gain */ +/*! r: sample gotten out of delay line, and amplified by set gain */ float ivas_rev_delay_line_get_sample( ivas_rev_delay_line_t *pDelay /* i/o: the delay line */ ) diff --git a/lib_rend/ivas_reverb_fft_filter.c b/lib_rend/ivas_reverb_fft_filter.c index 725f5e6bc14dc5a43eecb292e2e23745d85c2be5..8b14d2d41ed9ef41881162e79a3e2e8fb5950845 100644 --- a/lib_rend/ivas_reverb_fft_filter.c +++ b/lib_rend/ivas_reverb_fft_filter.c @@ -58,7 +58,7 @@ static void ifft_wrapper_2ch( float *buffer_L, float *buffer_R, const int16_t ff * NOT valid for integers thar are NOT a power of 2 *-----------------------------------------------------------------------------------------*/ -/* !r: integer log2 */ +/*! r: integer log2 */ uint16_t int_log2( uint32_t powerOf2 ) { diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 5719e2ffddf4f5079d8d6dde0922434cd679115b..a97ff1b9e3ec9502f232ee0695d1bdd590174135 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -187,11 +187,13 @@ void Euler2Quat( return; } + /*------------------------------------------------------------------------- * deg2rad() * * Converts degrees to normalized radians *------------------------------------------------------------------------*/ + float deg2rad( float degrees ) { @@ -207,6 +209,7 @@ float deg2rad( return PI_OVER_180 * degrees; } + /*------------------------------------------------------------------------- * rotateAziEle() * @@ -219,7 +222,7 @@ void rotateAziEle( int16_t *azi, /* o : rotated azimuth */ int16_t *ele, /* o : rotated elevation */ float Rmat[3][3], /* i : real-space rotation matrix */ - const int16_t isPlanar /* i : is rotation planar and elevation meaningless? */ + const int16_t isPlanar /* i : is rotation planar and elevation meaningless? */ ) { int16_t n; @@ -511,7 +514,7 @@ void rotateFrame_shd_cldfb( float Rmat[3][3], /* i : real-space rotation matrix */ const int16_t nInChannels, /* i : number of channels */ #ifdef JBM_TSM_ON_TCS - const int16_t numTimeSlots, + const int16_t numTimeSlots, /* i : number of time slots to process */ #endif const int16_t shd_rot_max_order /* i : split-order rotation method */ ) @@ -721,6 +724,7 @@ void rotateFrame_sd_cldfb( return; } + /*-----------------------------------------------------------------------* * Local Function definitions *-----------------------------------------------------------------------*/ diff --git a/lib_rend/ivas_sba_rendering.c b/lib_rend/ivas_sba_rendering.c index c549461c37f2f4275be8899bc39fd913782250ba..7affa9a913500cdfe9d1a2d0d3a62165dd4d11bd 100644 --- a/lib_rend/ivas_sba_rendering.c +++ b/lib_rend/ivas_sba_rendering.c @@ -93,10 +93,12 @@ void ivas_sba_prototype_renderer_sf( outChEnd = 2; } slot_idx_start = hSpar->slots_rendered; + /* Apply mixing matrix */ for ( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ ) { int16_t md_idx = hSpar->render_to_md_map[ts + slot_idx_start]; + /* determine SPAR parameters for this time slot */ ivas_spar_get_parameters( hSpar, hDecoderConfig, md_idx, numch_out, numch_in, num_spar_bands, mixer_mat ); @@ -202,6 +204,7 @@ void ivas_sba_prototype_renderer_sf( } #endif + #ifdef FIX_355_REFACTOR_PARAMBIN_TO_5MS void ivas_sba_prototype_renderer( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d82e00c067b188c43a54804ba1e5acc5b870c75d..a1a75a2e8deeec3be745185ab33436a2c29a0ff5 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -4420,6 +4420,7 @@ static ivas_error renderIsmToBinauralRoom( const IVAS_REND_HeadRotData *headRotData; #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4802,10 +4803,10 @@ static ivas_error renderMcToBinaural( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4886,10 +4887,10 @@ static ivas_error renderMcToBinauralRoom( IVAS_REND_AudioConfig inConfig; ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpRendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; + for ( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { p_tmpRendBuffer[i] = tmpRendBuffer[i]; @@ -4973,7 +4974,6 @@ static ivas_error renderMcCustomLsToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif @@ -5229,10 +5229,8 @@ static ivas_error renderSbaToBinaural( IVAS_REND_AudioBuffer outAudio ) { float tmpCrendBuffer[MAX_OUTPUT_CHANNELS][L_FRAME48k]; - ivas_error error; IVAS_REND_AudioBuffer tmpRotBuffer; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; int16_t i; @@ -5301,7 +5299,6 @@ static ivas_error renderSbaToBinauralRoom( IVAS_REND_AudioBuffer tmpRotBuffer; IVAS_REND_AudioBuffer tmpMcBuffer; IVAS_REND_AudioBuffer *tmpBufPtr; - #ifdef JBM_TSM_ON_TCS float *p_tmpCrendBuffer[MAX_OUTPUT_CHANNELS]; #endif diff --git a/lib_rend/lib_rend.h b/lib_rend/lib_rend.h index f9b2781110875e8d03da2a8e4d7f4c206e0b1d8a..502b5ee0c8c3cd460acbec5b9690214422128369 100644 --- a/lib_rend/lib_rend.h +++ b/lib_rend/lib_rend.h @@ -234,8 +234,8 @@ ivas_error IVAS_REND_FeedInputMasaMetadata( ); ivas_error IVAS_REND_InitConfig( - IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ - const IVAS_REND_AudioConfig outAudioConfig /* i : output audioConfig */ + IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle */ + const IVAS_REND_AudioConfig outAudioConfig /* i : output audioConfig */ ); int16_t IVAS_REND_GetRenderConfig( diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index b7ffe8168201577d495040cf84e2e20ac6b51add..7dfa2e7cf01d48a7873591ee7fa0ccbda7b71263 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -674,51 +674,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() * @@ -726,8 +681,8 @@ static ivas_error ivas_hrtf_init( *---------------------------------------------------------------------*/ static ivas_error create_HRTF_from_rawdata( - HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ - char *hrtf_data /* i: pointer to binary file */ + HRTFS_HANDLE *hHRTF, /* i/o: HRTF CRend handle */ + char *hrtf_data /* i : pointer to binary file */ ) { int16_t i, j, k; @@ -736,6 +691,7 @@ static ivas_error create_HRTF_from_rawdata( uint32_t mem_size; char *hrtf_data_rptr; float *pOut_to_bin_wptr; + ivas_error error; if ( *hHRTF == NULL ) { @@ -744,7 +700,10 @@ static ivas_error create_HRTF_from_rawdata( return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Can not allocate memory for HRTF binary data\n" ); } - ivas_hrtf_init( *hHRTF ); + if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK ) + { + return error; + } } else { diff --git a/lib_util/hrtf_file_reader.h b/lib_util/hrtf_file_reader.h index 2b59c3150b25c054aaaece41fc1829a8fc781f84..2e20cad02a77ee785bf7fd5b3d4ccbf797a93e60 100644 --- a/lib_util/hrtf_file_reader.h +++ b/lib_util/hrtf_file_reader.h @@ -86,9 +86,9 @@ ivas_error load_HRTF_binary( *---------------------------------------------------------------------*/ ivas_error create_SetOfHRTF_from_binary( - IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ - const hrtfFileReader *hrtfReader, /* i: pointer to hrtfFileReader handle */ - int32_t output_Fs /* i: Output sampling frequency */ + IVAS_DEC_HRTF_CREND_HANDLE hSetOfHRTF, /* i/o: Set of HRTF CRend handle */ + const hrtfFileReader *hrtfReader, /* i : pointer to hrtfFileReader handle */ + int32_t output_Fs /* i : Output sampling frequency */ ); diff --git a/lib_util/masa_file_reader.c b/lib_util/masa_file_reader.c index 90756a39b1ec5dcb33c3c2034f832ba5f1d9042e..d73732d16c5321f0b2118dee95881b3a08af1b05 100644 --- a/lib_util/masa_file_reader.c +++ b/lib_util/masa_file_reader.c @@ -252,7 +252,6 @@ static void deindex_sph_idx( } #endif - /*------------------------------------------------------------------------- * MasaFileReader_readNextFrame() * @@ -343,7 +342,7 @@ ivas_error MasaFileReader_readNextFrame( for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ ) { - deindex_sph_idx( readIndex[b], &self->sph_grid16, &( hMeta->directional_meta[i].elevation[j][b] ), &( hMeta->directional_meta[i].azimuth[j][b] ) ); + ivas_qmetadata_deindex_sph_idx( readIndex[b], &self->sph_grid16, &( hMeta->directional_meta[i].elevation[j][b] ), &( hMeta->directional_meta[i].azimuth[j][b] ) ); #ifdef HR_METADATA hMeta->directional_meta[i].spherical_index[j][b] = readIndex[b]; #endif @@ -417,7 +416,7 @@ ivas_error MasaFileReader_readNextFrame( *------------------------------------------------------------------------*/ void MasaFileReader_close( - MasaFileReader **selfPtr /* i/o: pointer to MasaFileReader handle */ + MasaFileReader **selfPtr /* i/o: pointer to MasaFileReader handle */ ) { if ( selfPtr == NULL || *selfPtr == NULL ) diff --git a/lib_util/render_config_reader.c b/lib_util/render_config_reader.c index 54f2d012ce7f06c567ba87d1e216e98680306845..72d8393ba5daa35c82eadd747e5b6529e3e459e3 100644 --- a/lib_util/render_config_reader.c +++ b/lib_util/render_config_reader.c @@ -79,7 +79,7 @@ struct RenderConfigReader * Reads a boolean value from a line *-----------------------------------------------------------------------------------------*/ -/* !r: false on success, true on failure */ +/*! r: false on success, true on failure */ static int16_t read_bool( const char *pLine, /* i : String to read from */ int16_t *pTarget /* o : Output pointer (int16_t type used instead of bool because of coding rules/specs) */ @@ -193,7 +193,7 @@ static void strip_spaces_upper( * Prints error message and exits *-----------------------------------------------------------------------------------------*/ -/* !r: error accumulation */ +/*! r: error accumulation */ static int32_t errorHandler( const char *badStr, /* i : String to complain about */ const ERROR_CODES_t error ) diff --git a/readme.txt b/readme.txt index 21a5a19e7940665f7cf537520a0cf248466d22e7..5660aa353f4ccb354dbe8ff5c7cae3d3846c6bf4 100644 --- a/readme.txt +++ b/readme.txt @@ -245,6 +245,8 @@ Options: The decoder may read rtpdump files containing TS26.445 Annex A.2.2 EVS RTP Payload Format. The SDP parameter hf_only is required. Reading RFC4867 AMR/AMR-WB RTP payload format is not supported. +-VS fac : Varaible Speed mode: change speed of playout fac as integer in percent. + fac<100 faster, fac>100 slower -Tracefile TF : VoIP mode: Generate trace file named TF -fec_cfg_file : Optimal channel aware configuration computed by the JBM as described in Section 6.3.1 of TS26.448. The output is