diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj
index ad725ce034c3df38a7444c547b2ac7dc1637c505..34b63eba780daaa19b319666d1510a4bf97d2d09 100644
--- a/Workspace_msvc/lib_dec.vcxproj
+++ b/Workspace_msvc/lib_dec.vcxproj
@@ -283,6 +283,7 @@
+
diff --git a/Workspace_msvc/lib_dec.vcxproj.filters b/Workspace_msvc/lib_dec.vcxproj.filters
index 5b52aabb77ad23750f34b254d5d9c37e5180106d..4dcff8d503d594bb101ae9d579828038b11b58e7 100644
--- a/Workspace_msvc/lib_dec.vcxproj.filters
+++ b/Workspace_msvc/lib_dec.vcxproj.filters
@@ -500,6 +500,9 @@
dec_ivas_c
+
+ dec_ivas_c
+
diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c
index 34c68d254044d09a087ea600b70a378130770157..0f32cf22bac9c2ac595b6d72df73ab3b61ab18b1 100644
--- a/lib_com/bitstream.c
+++ b/lib_com/bitstream.c
@@ -879,10 +879,12 @@ static ivas_error write_indices_element(
for ( n = 0; n < n_channels; n++ )
{
+#ifndef MC_BITRATE_SWITCHING
if ( ( st_ivas->hEncoderConfig->ivas_format == MC_FORMAT ) && ( st_ivas->mc_mode == MC_MODE_MCT ) && ( element_id * CPE_CHANNELS + n == LFE_CHANNEL ) )
{
continue;
}
+#endif
reset_indices_enc( sts[n]->hBstr, MAX_NUM_INDICES );
}
}
diff --git a/lib_com/ivas_mc_param_com.c b/lib_com/ivas_mc_param_com.c
index 3690c1219f84e50bf0db2f074d9aad3d83bfb9ad..424e7cc4b98a289c5e79d59098e2fc0e5087dbb3 100644
--- a/lib_com/ivas_mc_param_com.c
+++ b/lib_com/ivas_mc_param_com.c
@@ -330,6 +330,100 @@ void ivas_param_mc_default_icc_map(
}
+#ifdef MC_BITRATE_SWITCHING
+/*-------------------------------------------------------------------------
+ * ivas_param_mc_get_num_param_bands()
+ *
+ *
+ *------------------------------------------------------------------------*/
+
+static int16_t ivas_param_mc_get_num_param_bands(
+ const MC_LS_SETUP mc_ls_setup, /* i : MC ls setup */
+ const int32_t ivas_total_brate /* i : IVAS total bitrate */
+)
+{
+ int16_t num_parameter_bands;
+
+ num_parameter_bands = 0;
+
+ /* parameter bands */
+ switch ( mc_ls_setup )
+ {
+ case MC_LS_SETUP_5_1:
+ switch ( ivas_total_brate )
+ {
+ case IVAS_48k:
+ num_parameter_bands = 10;
+ break;
+ case IVAS_64k:
+ case IVAS_80k:
+ num_parameter_bands = 14;
+ break;
+ default:
+ assert( 0 && "PARAM_MC: bitrate for CICP6 not supported!" );
+ }
+ break;
+
+ case MC_LS_SETUP_7_1:
+ switch ( ivas_total_brate )
+ {
+ case IVAS_48k:
+ num_parameter_bands = 10;
+ break;
+ case IVAS_64k:
+ case IVAS_80k:
+ num_parameter_bands = 14;
+ break;
+ case IVAS_96k:
+ num_parameter_bands = 20;
+ break;
+ }
+ break;
+ case MC_LS_SETUP_5_1_2:
+ switch ( ivas_total_brate )
+ {
+ case IVAS_48k:
+ num_parameter_bands = 10;
+ break;
+ case IVAS_64k:
+ case IVAS_80k:
+ num_parameter_bands = 14;
+ break;
+ case IVAS_96k:
+ num_parameter_bands = 20;
+ break;
+ }
+ break;
+ case MC_LS_SETUP_5_1_4:
+ switch ( ivas_total_brate )
+ {
+ case IVAS_96k:
+ num_parameter_bands = 14;
+ break;
+ case IVAS_128k:
+ num_parameter_bands = 20;
+ break;
+ }
+ break;
+ case MC_LS_SETUP_7_1_4:
+ switch ( ivas_total_brate )
+ {
+ case IVAS_128k:
+ num_parameter_bands = 20;
+ break;
+ case IVAS_160k:
+ num_parameter_bands = 20;
+ break;
+ }
+ break;
+ default:
+ assert( 0 && "PARAM_MC: channel configuration not supportet!" );
+ }
+
+ return num_parameter_bands;
+}
+#endif
+
/*-------------------------------------------------------------------------
* Local functions
*------------------------------------------------------------------------*/
@@ -427,6 +521,9 @@ static void ivas_param_mc_set_coding_scheme(
assert( 0 && "PARAM_MC: channel configuration not supported!" );
}
+#ifdef MC_BITRATE_SWITCHING
+ hMetadataPMC->num_parameter_bands = ivas_param_mc_get_num_param_bands( mc_ls_setup, ivas_total_brate );
+#else
/* parameter bands */
switch ( mc_ls_setup )
{
@@ -500,6 +597,6 @@ static void ivas_param_mc_set_coding_scheme(
default:
assert( 0 && "PARAM_MC: channel configuration not supportet!" );
}
-
+#endif
return;
}
diff --git a/lib_com/ivas_mcmasa_com.c b/lib_com/ivas_mcmasa_com.c
index 2441cf7973792d920a5b72a94ecf98317ba1356f..4c0f014bb0b00dbc357d554f032e23c5586b8447 100644
--- a/lib_com/ivas_mcmasa_com.c
+++ b/lib_com/ivas_mcmasa_com.c
@@ -91,6 +91,8 @@ void ivas_mcmasa_set_separate_channel_mode(
return;
}
+
+#ifndef MC_BITRATE_SWITCHING
/*--------------------------------------------------------------------------*
* ivas_mcmasa_mono_brate()
*
@@ -105,10 +107,49 @@ int32_t ivas_mcmasa_mono_brate(
/* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */
if ( ivas_total_brate < IVAS_96k )
{
- return ( const int32_t )( MCMASA_MONOBITRATIO_64k * ivas_total_brate );
+ return (int32_t) ( MCMASA_MONOBITRATIO_64k * ivas_total_brate );
+ }
+ else
+ {
+ return (int32_t) ( MCMASA_MONOBITRATIO * ivas_total_brate );
+ }
+}
+#else
+/*--------------------------------------------------------------------------*
+ * ivas_mcmasa_split_brate()
+ *
+ * Split the total bitrate to elements in McMASA
+ *--------------------------------------------------------------------------*/
+
+void ivas_mcmasa_split_brate(
+ const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */
+ const int32_t ivas_total_brate, /* i : Total bitrate available to be split */
+ const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */
+ const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */
+ int32_t *brate_sce, /* o : Pointer to SCE element bitrate */
+ int32_t *brate_cpe /* o : Pointer to CPE element bitrate */
+)
+{
+ if ( separateChannelEnabled )
+ {
+ /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */
+ if ( ivas_total_brate < IVAS_96k )
+ {
+ *brate_sce = (int32_t) ( MCMASA_MONOBITRATIO_64k * ivas_total_brate );
+ }
+ else
+ {
+ *brate_sce = (int32_t) ( MCMASA_MONOBITRATIO * ivas_total_brate );
+ }
+
+ *brate_cpe = ivas_total_brate - *brate_sce;
}
else
{
- return ( const int32_t )( MCMASA_MONOBITRATIO * ivas_total_brate );
+ *brate_sce = nSCE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0;
+ *brate_cpe = nCPE > 0 ? ivas_total_brate / ( nCPE + nSCE ) : 0;
}
+
+ return;
}
+#endif
diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h
index d0fd20fd3c1c34dceb51fffad4634d990a44101c..59ada3de0eef59676f02eb0acf40704eefd52cf8 100644
--- a/lib_com/ivas_prot.h
+++ b/lib_com/ivas_prot.h
@@ -147,7 +147,14 @@ ivas_error ivas_corecoder_enc_reconfig(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t nSCE_old, /* i : number of SCEs in previous frame */
const int16_t nCPE_old, /* i : number of CPEs in previous frame */
+#ifdef MC_BITRATE_SWITCHING
+ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
+ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */
+ const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */
+ const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */
+#else
const int16_t nchan_transport_old /* i : number of TCs in previous frame */
+#endif
);
ivas_error ivas_sce_enc(
@@ -355,11 +362,21 @@ void ivas_mct_dec_close(
);
ivas_error ivas_corecoder_dec_reconfig(
+#ifdef MC_BITRATE_SWITCHING
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const int16_t nSCE_old, /* i : number of SCEs in previous frame */
+ int16_t nCPE_old, /* i : number of CPEs in previous frame */
+ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
+ const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */
+ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */
+ const int32_t brate_CPE /* i : bitrate to be set for the CPEs */
+#else
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nSCE_old, /* i : number of SCEs in previous frame */
const int16_t nCPE_old, /* i : number of CPEs in previous frame */
const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */
+#endif
);
ivas_error ivas_hp20_dec_reconfig(
@@ -2587,6 +2604,9 @@ ivas_error stereo_memory_dec(
const int16_t nb_bits_metadata, /* i : number of metadata bits */
const int32_t output_Fs, /* i : output sampling rate */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
+#ifdef MC_BITRATE_SWITCHING
+ const MC_MODE mc_mode, /* i : MC mode */
+#endif
const int16_t nchan_transport /* i : number of transport channels */
);
@@ -2637,19 +2657,19 @@ int16_t read_GR0(
*----------------------------------------------------------------------------------*/
void ivas_mdct_core_whitening_enc(
- CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
- float new_samples[CPE_CHANNELS][L_INP], /* i : new samples */
- float old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
- float pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */
- float *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */
- int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */
- float *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */
- int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */
- BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
- int16_t *LFE_off, /* o : flag if LFE has content */
- const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
- const int16_t nChannels /* i : total number of coded channels */
+ CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */
+ float new_samples[CPE_CHANNELS][L_INP], /* i : new samples */
+ float old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */
+ float pitch_buf[CPE_CHANNELS][NB_SUBFR16k], /* o : floating pitch for each subframe */
+ float *mdst_spectrum_long[CPE_CHANNELS], /* o : buffer for MDST spectrum */
+ int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* o : buffer TNS bits */
+ float *orig_spectrum_long[CPE_CHANNELS], /* o : origingal spectrum w/o whitening */
+ int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* o : size of TNS */
+ int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to parameter array */
+ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
+ int16_t *LFE_off, /* o : flag if LFE has content */
+ const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
+ const int16_t nChannels /* i : total number of coded channels */
);
void ivas_mct_core_enc(
@@ -2665,108 +2685,108 @@ void ivas_mct_core_enc(
);
void ivas_mdct_quant_coder(
- CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */
- const int16_t LFE_off, /* i : flag if LFE has content */
- int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */
- int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */
+ CPE_ENC_HANDLE hCPE, /* i/o: Encoder CPE handle */
+ const int16_t LFE_off, /* i : flag if LFE has content */
+ int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */
+ int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */
+ int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void apply_MCT_enc(
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- Encoder_State **sts, /* i/o: encoder state structure */
- float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
- float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
- float *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
- const int16_t nchan /* i : number of channels */
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ Encoder_State **sts, /* i/o: encoder state structure */
+ float *mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: MDST spectrum */
+ float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse spectrum */
+ float *inv_mdst_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i/o: inverse MDST spectrum */
+ const int16_t nchan /* i : number of channels */
);
void write_mct_bitstream(
- Encoder_State **sts, /* i/o: encoder state structure */
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- const int16_t nchan /* i : number of channels */
+ Encoder_State **sts, /* i/o: encoder state structure */
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ const int16_t nchan /* i : number of channels */
);
void splitAvailableBitsMCT(
- void **sts, /* i/o: encoder/decoder state structure */
- const int16_t total_bits, /* i : total number of available bits */
- const int16_t split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits */
- const int16_t enc_dec, /* i : encoder or decoder flag */
- const int16_t nchan /* i : number of channels */
+ void **sts, /* i/o: encoder/decoder state structure */
+ const int16_t total_bits, /* i : total number of available bits */
+ const int16_t split_ratio[MCT_MAX_CHANNELS], /* i : ratio for splitting the bits */
+ const int16_t enc_dec, /* i : encoder or decoder flag */
+ const int16_t nchan /* i : number of channels */
);
void getChannelEnergies(
- Encoder_State **sts, /* i : Encoder state structure */
- float nrg[MCT_MAX_CHANNELS], /* o : energies */
- const int16_t nchan /* i : number of channels */
+ Encoder_State **sts, /* i : Encoder state structure */
+ float nrg[MCT_MAX_CHANNELS], /* o : energies */
+ const int16_t nchan /* i : number of channels */
);
void mctStereoIGF_enc(
- MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
- Encoder_State **sts, /* i/o: encoder state structure */
- float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */
+ MCT_ENC_HANDLE hMCT, /* i/o: MCT encoder structure */
+ Encoder_State **sts, /* i/o: encoder state structure */
+ float *orig_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : MDCT spectrum for ITF */
float powerSpec[MCT_MAX_CHANNELS][L_FRAME48k], /* i/o: MDCT^2 + MDST^2 spectrum,or estimate */
float *powerSpecMsInv[MCT_MAX_CHANNELS][NB_DIV], /* i : same as above but for inverse spect. */
- float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
- const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */
+ float *inv_spectrum[MCT_MAX_CHANNELS][NB_DIV], /* i : inverse spectrum */
+ const int16_t sp_aud_decision0[MCT_MAX_CHANNELS] /* i : speech audio decision */
);
void ivas_mdct_dec_side_bits_frame_channel(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- int16_t param_lpc[MCT_MAX_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */
- Decoder_State *st0, /* i : pointer to bitstream handle */
- int16_t *LFE_off, /* o : flag if LFE has content */
- int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */
- int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ int16_t param_lpc[MCT_MAX_CHANNELS][NPRM_LPC_NEW], /* o : lpc_parameters */
+ int16_t p_param[CPE_CHANNELS][NB_DIV], /* o : pointer to param buffer */
+ Decoder_State *st0, /* i : pointer to bitstream handle */
+ int16_t *LFE_off, /* o : flag if LFE has content */
+ int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */
+ int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
- const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */
+ const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */
);
void ivas_mct_side_bits(
- MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
- CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */
- const int16_t nCPE, /* i : number of CPEs */
- Decoder_State *st0, /* i : decoder handle for Bstr */
- const int16_t bfi, /* i : BFI flag */
- uint16_t *bitstream, /* o : bitstream indices */
- const int32_t ivas_total_brate, /* i : IVAS total bitrate */
- const int16_t nb_bits_metadata /* i : number of metadata bits */
+ MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
+ CPE_DEC_HANDLE hCPE[MCT_MAX_BLOCKS], /* i/o: CPE decoder structure */
+ const int16_t nCPE, /* i : number of CPEs */
+ Decoder_State *st0, /* i : decoder handle for Bstr */
+ const int16_t bfi, /* i : BFI flag */
+ uint16_t *bitstream, /* o : bitstream indices */
+ const int32_t ivas_total_brate, /* i : IVAS total bitrate */
+ const int16_t nb_bits_metadata /* i : number of metadata bits */
);
void ivas_mdct_core_invQ(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
- const int16_t LFE_off, /* i : flag if LFE content */
- int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */
- int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */
- int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */
- int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i : param buffer */
- int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */
- STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */
- float *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
- float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
- float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */
- int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE handle */
+ const int16_t LFE_off, /* i : flag if LFE content */
+ int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* i : number of TNS bits */
+ int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to param buffer */
+ int16_t param_lpc[CPE_CHANNELS][NPRM_LPC_NEW], /* i : lpc parameters */
+ int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i : param buffer */
+ int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */
+ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */
+ float *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
+ float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
+ float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */
+ int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void ivas_mdct_core_reconstruct(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */
- float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */
- const int16_t LFE_off, /* i : flag if LFE content */
- int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ float *x[][NB_DIV], /* i/o: pointers to synthesis @internal_FS */
+ float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */
+ const int16_t LFE_off, /* i : flag if LFE content */
+ int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void ivas_mdct_core_tns_ns(
- CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
- const int16_t LFE_off, /* i : flag if LFE has content */
+ CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
+ const int16_t LFE_off, /* i : flag if LFE has content */
int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : two entries for each channel in TCX10 */
- STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */
- float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */
- float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */
+ STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */
+ float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */
+ float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
@@ -3215,14 +3235,14 @@ void ivas_dirac_enc_close(
);
void ivas_dirac_enc(
- DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */
- IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
- BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
- int16_t *nb_bits_metadata, /* o : number of metadata bits written */
- const int16_t Opt_DTX_ON, /* i : flag signaling DTX on */
+ DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */
+ IVAS_QMETADATA_HANDLE hQMetaData, /* i/o: q_metadata handle */
+ BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
+ int16_t *nb_bits_metadata, /* o : number of metadata bits written */
+ const int16_t Opt_DTX_ON, /* i : flag signaling DTX on */
float data_f[][L_FRAME48k], /* i/o: SBA channels */
- const int16_t input_frame, /* i : input frame length */
- const int16_t sba_planar /* i : SBA planar flag */
+ const int16_t input_frame, /* i : input frame length */
+ const int16_t sba_planar /* i : SBA planar flag */
);
ivas_error ivas_dirac_config(
@@ -3530,6 +3550,12 @@ ivas_error ivas_param_mc_enc_open(
Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
);
+#ifdef MC_BITRATE_SWITCHING
+ivas_error ivas_param_mc_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+);
+#endif
+
void ivas_param_mc_enc_close(
PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */
const int32_t input_Fs /* i : input sampling rate */
@@ -3546,6 +3572,12 @@ ivas_error ivas_param_mc_dec_open(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
+#ifdef MC_BITRATE_SWITCHING
+ivas_error ivas_param_mc_dec_reconfig(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+);
+#endif
+
void ivas_param_mc_dec_close(
PARAM_MC_DEC_HANDLE *hParamMC /* i/o: Parametric MC decoder handle */
);
@@ -4817,6 +4849,16 @@ void ivas_mcmasa_enc_close(
const int32_t input_Fs /* i : input sampling rate */
);
+#ifdef MC_BITRATE_SWITCHING
+ivas_error ivas_mcmasa_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+);
+
+ivas_error ivas_mcmasa_dec_reconfig(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */
+);
+#endif
+
void ivas_mcmasa_setNumTransportChannels(
int16_t* nchan_transport, /* o : Pointer to number of transport channels to be set */
int16_t* element_mode, /* o : Pointer to element mode to be set */
@@ -4829,10 +4871,21 @@ void ivas_mcmasa_set_separate_channel_mode(
const int32_t ivas_total_brate /* i : Total bitrate of IVAS */
);
+#ifndef MC_BITRATE_SWITCHING
/*! r: McMASA SCE bitrate */
int32_t ivas_mcmasa_mono_brate(
const int32_t ivas_total_brate /* i : IVAS total bitrate */
);
+#else
+void ivas_mcmasa_split_brate(
+ const uint8_t separateChannelEnabled, /* i : Transport running in "separate channel" mode */
+ const int32_t ivas_total_brate, /* i : Total bitrate available to be split */
+ const int16_t nSCE, /* i : Number of SCEs in use (0 or 1) */
+ const int16_t nCPE, /* i : Number of CPEs in use (0 or 1) */
+ int32_t *brate_sce, /* o : Pointer to SCE element bitrate */
+ int32_t *brate_cpe /* o : Pointer to CPE element bitrate */
+);
+#endif
void ivas_mcmasa_enc(
MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */
@@ -4848,27 +4901,36 @@ void ivas_mcmasa_param_est_enc(
MCMASA_ENC_HANDLE hMcMasa, /* i/o: Encoder McMASA handle */
MASA_ENCODER_HANDLE hMasa, /* i/o: Encoder MASA handle */
float data_f[][L_FRAME48k], /* i : Input frame of audio */
- float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation */
- float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth */
+ float elevation_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated elevation */
+ float azimuth_m_values[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated azimuth */
float energyRatio[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated direct-to-total ratio*/
- float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence */
- float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated surround coherence */
+ float spreadCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated spread coherence */
+ float surroundingCoherence[MAX_PARAM_SPATIAL_SUBFRAMES][MASA_FREQUENCY_BANDS], /* o : Estimated surround coherence */
const int16_t input_frame, /* i : Input frame size */
const int16_t nchan_inp /* i : Number of input channels */
);
+#ifdef MC_BITRATE_SWITCHING
+void ivas_mcmasa_dmx_modify(
+ const int16_t n_samples, /* i : input frame length in samples */
+ float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format */
+ const int16_t n_chnls_dmx_old, /* i : number of downmix channels in the old format */
+ const int16_t n_chnls_dmx_new /* i : number of downmix channels in the target format */
+);
+#endif
+
void v_multc_acc(
- const float x[], /* i : Input vector */
- const float c, /* i : Constant */
- float y[], /* o : Output vector that contains y + c*x */
- const int16_t N /* i : Vector length */
+ const float x[], /* i : Input vector */
+ const float c, /* i : Constant */
+ float y[], /* o : Output vector that contains y + c*x */
+ const int16_t N /* i : Vector length */
);
void lls_interp_n(
- float x[], /* i/o: input/output vector */
- const int16_t N, /* i : length of the input vector */
- float *a, /* o : calculated slope */
- float *b, /* o : calculated offset */
+ float x[], /* i/o: input/output vector */
+ const int16_t N, /* i : length of the input vector */
+ float *a, /* o : calculated slope */
+ float *b, /* o : calculated offset */
const int16_t upd /* i : use 1 to update x[] with the interpolated output*/
);
@@ -4885,7 +4947,7 @@ void computeReferencePower_enc(
ivas_error ivas_mono_dmx_renderer_open(
- Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
void ivas_mono_downmix_render_passive(
@@ -5105,7 +5167,7 @@ ivas_error TDREND_SRC_Alloc(
);
void TDREND_SRC_Dealloc(
- TDREND_SRC_t *Src_p /* i/o: Source to deallocate */
+ TDREND_SRC_t *Src_p /* i/o: Source to deallocate */
);
void TDREND_SRC_Init(
@@ -5239,8 +5301,8 @@ void ivas_fb_mixer_pcm_ingest(
);
void ivas_dirac_enc_spar_delay_synchro(
- Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
- const int16_t input_frame, /* i : input frame length */
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const int16_t input_frame, /* i : input frame length */
float data_f[][L_FRAME48k] /* i/o: SBA channels (ACN / SN3D) */
);
diff --git a/lib_com/ivas_stereo_mdct_bands_com.c b/lib_com/ivas_stereo_mdct_bands_com.c
index 16149941e4e4f17f8b729b4ebad123ba30a70fa2..445eec09f9799a5455aec56705f58c092d215f23 100644
--- a/lib_com/ivas_stereo_mdct_bands_com.c
+++ b/lib_com/ivas_stereo_mdct_bands_com.c
@@ -225,6 +225,9 @@ void stereo_mdct_init_igf_start_band(
{
int16_t i, bitRateIndex, igfStartLine;
const int16_t *swb_offset;
+#ifdef DEBUGGING
+ stbParams->sfbIgfStart = 0;
+#endif
bitRateIndex = IGF_MapBitRateToIndex( element_brate, bwidth, IVAS_CPE_MDCT, 0 );
swb_offset = &swb_offset_LB_new[bitRateIndex][1];
diff --git a/lib_com/options.h b/lib_com/options.h
index 551e0e1f58562825cb353296b8604ff10dac3cb8..b23661f4d59d466450a70650f8192553fcf05588 100755
--- a/lib_com/options.h
+++ b/lib_com/options.h
@@ -157,6 +157,11 @@
#define FIX_I59_CREND /* Issue 59: Fixes for gcc compiler warnings in ivas_crend_utest_utils.c */
#define LOW_RATE_TRANS /* Eri: Contribution 20: low rate encoding of transients */
+
+
+#define MC_BITRATE_SWITCHING /* Issue 116: support bitrate switching in MC format */
+
+
/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
#endif
diff --git a/lib_com/prot.h b/lib_com/prot.h
index b0476efdb3930211f5ab92e8a9b8c08724a8691c..9563601d334b5aa5395df98754cfdfb74969a51c 100755
--- a/lib_com/prot.h
+++ b/lib_com/prot.h
@@ -3918,8 +3918,11 @@ void updt_enc(
);
void updt_enc_common(
- Encoder_State *st, /* i/o: encoder state structure */
- const float Etot /* i : total energy */
+ Encoder_State *st /* i/o: encoder state structure */
+#ifndef MC_BITRATE_SWITCHING
+ ,
+ const float Etot /* i : total energy */
+#endif
);
void updt_IO_switch_enc(
diff --git a/lib_com/swb_tbe_com.c b/lib_com/swb_tbe_com.c
index cc0c70cbbf3753f6d2f5726ccae756f7d0080e20..e30f5cc465e5a1673071f99108818f584779d888 100644
--- a/lib_com/swb_tbe_com.c
+++ b/lib_com/swb_tbe_com.c
@@ -1897,6 +1897,10 @@ void tbe_celp_exc(
return;
}
+#ifdef MC_BITRATE_SWITCHING
+ assert( bwe_exc != NULL && "BWE excitation is NULL" );
+#endif
+
if ( L_frame == L_FRAME )
{
offset = tbe_celp_exc_offset( T0, T0_frac );
diff --git a/lib_debug/mem_count.c b/lib_debug/mem_count.c
old mode 100644
new mode 100755
index 278126d35e0b25bff1bad675f77a36f38e8bcc42..07fb0083dfc34b469bfe36559aa0180c1b991b64
--- a/lib_debug/mem_count.c
+++ b/lib_debug/mem_count.c
@@ -102,6 +102,7 @@ typedef INT64 int64_t;
#else
#define MAX_INFO_RECORDS 3000
#endif
+
/* This is the length after which the function name
will be truncated when the summary is printed. */
#define MAX_FUNCTION_NAME_LENGTH 18
diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c
index b8d4e66cf4cb9ccdd09be64b1072a6d83a2b6f55..c2092c7efee66cc88ca9701923a286e3b05ca13e 100644
--- a/lib_dec/ivas_corecoder_dec_reconfig.c
+++ b/lib_dec/ivas_corecoder_dec_reconfig.c
@@ -49,20 +49,33 @@
/*-------------------------------------------------------------------*
* ivas_corecoder_dec_reconfig()
*
- * Allocate, initalize, and configure SCE/CPE/MCT handles in case of bitrate switching
+ * Allocate, initialize, and configure SCE/CPE/MCT handles in case of bitrate switching
*-------------------------------------------------------------------*/
ivas_error ivas_corecoder_dec_reconfig(
+#ifdef MC_BITRATE_SWITCHING
+ Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
+ const int16_t nSCE_old, /* i : number of SCEs in previous frame */
+ int16_t nCPE_old, /* i : number of CPEs in previous frame */
+ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
+ const int16_t sba_dirac_stereo_flag_old, /* i : signal stereo rendering using DFT upmix in previous frame */
+ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */
+ const int32_t brate_CPE /* i : bitrate to be set for the CPEs */
+#else
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nSCE_old, /* i : number of SCEs in previous frame */
const int16_t nCPE_old, /* i : number of CPEs in previous frame */
const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */
+#endif
)
{
int16_t n, sce_id, cpe_id, output_frame;
int16_t nSCE_existing, nCPE_existing;
int32_t ivas_total_brate;
+#ifdef MC_BITRATE_SWITCHING
+ MC_MODE last_mc_mode;
+#endif
DECODER_CONFIG_HANDLE hDecoderConfig;
ivas_error error;
@@ -75,13 +88,27 @@ ivas_error ivas_corecoder_dec_reconfig(
error = IVAS_ERR_OK;
output_frame = (int16_t) ( hDecoderConfig->output_Fs / FRAMES_PER_SEC );
-
+#ifdef MC_BITRATE_SWITCHING
+ if ( st_ivas->ivas_format == MC_FORMAT )
+ {
+ last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */
+ }
+ else
+ {
+ last_mc_mode = MC_MODE_NONE;
+ }
+#endif
/*-----------------------------------------------------------------*
* Allocate, initalize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/
/* remove dummy CPE element for DFT stereo-like upmix */
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) ||
+ ( st_ivas->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag ) )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT && sba_dirac_stereo_flag_old && !st_ivas->sba_dirac_stereo_flag )
+#endif
{
st_ivas->hCPE[0]->hCoreCoder[0] = NULL;
st_ivas->hCPE[0]->hCoreCoder[1] = NULL;
@@ -98,18 +125,29 @@ ivas_error ivas_corecoder_dec_reconfig(
}
}
+#ifdef MC_BITRATE_SWITCHING
+ if ( st_ivas->nchan_transport == nchan_transport_old && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old )
+#else
if ( st_ivas->nchan_transport == nchan_transport_old )
+#endif
{
for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+#else
st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport;
+#endif
st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+#else
st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
-
+#endif
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -144,6 +182,19 @@ ivas_error ivas_corecoder_dec_reconfig(
st_ivas->hCPE[cpe_id] = NULL;
}
+#ifdef MC_BITRATE_SWITCHING
+ /* the CPE-internal settings depend from ivas_format and mc_mode, so clean-up when switching between mc_modes */
+ if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != last_mc_mode && ( st_ivas->mc_mode == MC_MODE_MCMASA || last_mc_mode == MC_MODE_MCMASA ) )
+ {
+ for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ )
+ {
+ destroy_cpe_dec( st_ivas->hCPE[cpe_id] );
+ st_ivas->hCPE[cpe_id] = NULL;
+ }
+ nCPE_old = 0;
+ nCPE_existing = min( nCPE_old, st_ivas->nCPE );
+ }
+#endif
if ( st_ivas->nCPE <= 1 && st_ivas->hMCT != NULL )
{
ivas_mct_dec_close( &st_ivas->hMCT );
@@ -158,12 +209,20 @@ ivas_error ivas_corecoder_dec_reconfig(
for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+#else
st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport;
+#endif
st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
for ( ; sce_id < st_ivas->nSCE; sce_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = create_sce_dec( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK )
+#else
if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -171,8 +230,11 @@ ivas_error ivas_corecoder_dec_reconfig(
for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+#else
st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
-
+#endif
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -181,7 +243,11 @@ ivas_error ivas_corecoder_dec_reconfig(
}
for ( ; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK )
+#else
if ( ( error = create_cpe_dec( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -234,7 +300,12 @@ ivas_error ivas_corecoder_dec_reconfig(
}
/* create dummy CPE element for DFT stereo-like upmix */
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) ||
+ ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old ) )
+#else
if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_dirac_stereo_flag && !sba_dirac_stereo_flag_old )
+#endif
{
if ( ( error = create_cpe_dec( st_ivas, 0, ivas_total_brate / ( st_ivas->nSCE + st_ivas->nCPE ) ) ) != IVAS_ERR_OK )
{
diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c
index d415407c7b62f0815249b0f5a84c3939c1073f72..f06b65860474877d675498ac179e86d4a23b616e 100644
--- a/lib_dec/ivas_cpe_dec.c
+++ b/lib_dec/ivas_cpe_dec.c
@@ -103,7 +103,11 @@ ivas_error ivas_cpe_dec(
* dynamically allocate data structures depending on the actual stereo mode
*----------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = stereo_memory_dec( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
+#else
if ( ( error = stereo_memory_dec( ivas_total_brate, hCPE, nb_bits_metadata, st_ivas->hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -508,8 +512,13 @@ ivas_error ivas_cpe_dec(
for ( i = 0; i < n; i++ )
{
+#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
+ dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate.cpe", 0, cpe_id, DEC ) );
+ dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode.cpe", 0, cpe_id, DEC ) );
+#else
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, cpe_id, DEC ) );
dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, cpe_id, DEC ) );
+#endif
for ( int16_t j = 0; j < CPE_CHANNELS; j++ )
{
@@ -829,6 +838,14 @@ void destroy_cpe_dec(
int16_t n;
Decoder_State *st;
+#ifdef MC_BITRATE_SWITCHING
+ /* make sure we deallocate a potential distinct hTcxCfg for a MCT LFE channel (can only happen in rs) */
+ if ( hCPE->hCoreCoder[1] != NULL && hCPE->hCoreCoder[1]->mct_chan_mode == MCT_CHAN_MODE_LFE && hCPE->hCoreCoder[1]->hTcxCfg != hCPE->hCoreCoder[0]->hTcxCfg )
+ {
+ hCPE->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
+ }
+#endif
+
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st = hCPE->hCoreCoder[n];
diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c
index 676c84fc7a9f44b28f03bc221bd965dbb87e8254..4eb6477db7ac29ed04bec6deccb902c752e5facc 100644
--- a/lib_dec/ivas_dec.c
+++ b/lib_dec/ivas_dec.c
@@ -354,7 +354,14 @@ ivas_error ivas_dec(
/* LFE channel decoder */
if ( st_ivas->mc_mode == MC_MODE_MCT )
{
- st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg;
+#ifdef MC_BITRATE_SWITCHING
+ if ( st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg == NULL )
+ {
+#endif
+ st_ivas->hCPE[1]->hCoreCoder[1]->hTcxCfg = st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg;
+#ifdef MC_BITRATE_SWITCHING
+ }
+#endif
ivas_lfe_dec( st_ivas->hLFE, st, output_frame, st_ivas->bfi, output_lfe_ch );
}
diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c
index 9e693150c058bf3096683af34459ac0ac750a0be..35d8ecf183e93ebf10927c4307f3a60e44500fa7 100644
--- a/lib_dec/ivas_init_dec.c
+++ b/lib_dec/ivas_init_dec.c
@@ -279,7 +279,7 @@ ivas_error ivas_dec_setup(
{
if ( ( error = doSanityChecks_IVAS( st_ivas ) ) != IVAS_ERR_OK )
{
- return IVAS_ERROR( error, "Sanitiy checks failed" );
+ return IVAS_ERROR( error, "Sanity checks failed" );
}
if ( ( error = ivas_init_decoder( st_ivas ) ) != IVAS_ERR_OK )
@@ -702,7 +702,7 @@ ivas_error ivas_init_decoder(
}
/*-----------------------------------------------------------------*
- * Allocate and initalize SCE/CPE and other handles
+ * Allocate and initialize SCE/CPE and other handles
*-----------------------------------------------------------------*/
if ( st_ivas->ivas_format == MONO_FORMAT )
@@ -1024,6 +1024,10 @@ ivas_error ivas_init_decoder(
}
else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
{
+#ifdef MC_BITRATE_SWITCHING
+ int32_t brate_sce, brate_cpe;
+#endif
+
ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
@@ -1060,8 +1064,18 @@ ivas_error ivas_init_decoder(
}
}
+#ifdef MC_BITRATE_SWITCHING
+ ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe );
+#endif
+
for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = create_sce_dec( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#else
if ( st_ivas->hOutSetup.separateChannelEnabled )
{
if ( ( error = create_sce_dec( st_ivas, sce_id, ivas_mcmasa_mono_brate( ivas_total_brate ) ) ) != IVAS_ERR_OK )
@@ -1076,15 +1090,23 @@ ivas_error ivas_init_decoder(
return error;
}
}
+#endif
reset_indices_dec( st_ivas->hSCE[sce_id]->hCoreCoder[0] );
}
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */
+ if ( ( error = create_cpe_dec( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#else
if ( st_ivas->hOutSetup.separateChannelEnabled )
{
- st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ st_ivas->element_mode_init = IVAS_CPE_MDCT; /* element_mode_init was IVAS_SCE for SCE initialization */
if ( ( error = create_cpe_dec( st_ivas, cpe_id, ivas_total_brate - st_ivas->hSCE[0]->element_brate ) ) != IVAS_ERR_OK )
{
@@ -1100,6 +1122,7 @@ ivas_error ivas_init_decoder(
return error;
}
}
+#endif
for ( n = 0; n < CPE_CHANNELS; n++ )
{
diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c
index 8ebf27afb5b31c8fe665286a4f716d39e6e39c44..aa2fcaed6bae6ae6a5bfc8b8a95b8d7c7791895d 100644
--- a/lib_dec/ivas_ism_param_dec.c
+++ b/lib_dec/ivas_ism_param_dec.c
@@ -1019,13 +1019,25 @@ static ivas_error ivas_ism_bitrate_switching(
{
ivas_error error;
int32_t element_brate_tmp[MAX_NUM_OBJECTS];
+#ifdef MC_BITRATE_SWITCHING
+ int16_t nSCE_old, nCPE_old;
+#endif
error = IVAS_ERR_OK;
+#ifdef MC_BITRATE_SWITCHING
+ nCPE_old = st_ivas->nCPE;
+ nSCE_old = st_ivas->nSCE;
+#endif
+
ivas_ism_config( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, num_obj, NULL, NULL, NULL, element_brate_tmp, NULL, NULL );
st_ivas->nSCE = st_ivas->nchan_transport;
+#ifdef MC_BITRATE_SWITCHING
+ ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, 0, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS );
+#else
ivas_corecoder_dec_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old, 0 );
+#endif
ivas_hp20_dec_reconfig( st_ivas, nchan_transport_old );
diff --git a/lib_dec/ivas_masa_dec.c b/lib_dec/ivas_masa_dec.c
index 3df378440516783b997c7bed8d4dfaaafd806a74..087b6cab163c3dbefdca4947e8b8822a6c617312 100644
--- a/lib_dec/ivas_masa_dec.c
+++ b/lib_dec/ivas_masa_dec.c
@@ -1031,7 +1031,7 @@ ivas_error ivas_masa_dec_reconfigure(
last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
/*-----------------------------------------------------------------*
- * Allocate and initalize SCE/CPE and other handles
+ * Allocate and initialize SCE/CPE and other handles
*-----------------------------------------------------------------*/
bit_stream = st_ivas->hSCE[0] != NULL ? st_ivas->hSCE[0]->hCoreCoder[0]->bit_stream : st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream;
diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c
index 7557fed2140808452f4d97adc501d981ab833770..3e49aca706eb6fc9a51dde4b7fd6de89d6e26a37 100644
--- a/lib_dec/ivas_mc_param_dec.c
+++ b/lib_dec/ivas_mc_param_dec.c
@@ -32,6 +32,7 @@
#include
#include "options.h"
+#include
#include "cnst.h"
#include "rom_enc.h"
#include "rom_com.h"
@@ -56,13 +57,26 @@
#define PARAM_MC_LOCAL_SZ_LFE_MAP 5
+#ifdef MC_BITRATE_SWITCHING
+/*-----------------------------------------------------------------------*
+ * Local typedefs
+ *-----------------------------------------------------------------------*/
+
+typedef struct parameter_band_mapping_struct
+{
+ int16_t n_source_bands[20];
+ int16_t source_band_idx[20][4];
+ float source_band_factor[20][4];
+
+} PARAM_MC_PARAMETER_BAND_MAPPING;
+#endif
+
/*-----------------------------------------------------------------------*
* Local function prototypes
*-----------------------------------------------------------------------*/
static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, const int16_t nchan_in, const int16_t nchan_out );
-
static void param_mc_protoSignalComputation( float RealBuffer[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], float ImagBuffer[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_NSLOTS][CLDFB_NO_CHANNELS_MAX], float *proto_frame_f, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t slot_index, const int16_t num_freq_bands );
static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, float Cldfb_buffer_real[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], float Cldfb_buffer_imag[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const int16_t nY, const int16_t slot_idx );
@@ -87,7 +101,11 @@ static void param_mc_get_diff_proto_info( const float *proto_mtx, const uint16_t
static void ivas_param_mc_mc2sba_cldfb( IVAS_OUTPUT_SETUP hTransSetup, float *hoa_encoder, const int16_t slot_idx, float Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], float Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], const int16_t nBands, const float gain_lfe );
-void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer );
+#ifdef MC_BITRATE_SWITCHING
+static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, const int16_t *target_band_grouping, const int16_t n_source_bands, const int16_t *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping );
+#endif
+
+static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer );
/*-------------------------------------------------------------------------
* ivas_param_mc_dec_open()
@@ -410,6 +428,490 @@ ivas_error ivas_param_mc_dec_open(
return error;
}
+
+#ifdef MC_BITRATE_SWITCHING
+/*-------------------------------------------------------------------------
+ * ivas_param_mc_get_param_band_mapping()
+ *
+ *
+ *-------------------------------------------------------------------------*/
+
+static void ivas_param_mc_get_param_band_mapping(
+ const int16_t n_target_bands,
+ const int16_t *target_band_grouping,
+ const int16_t n_source_bands,
+ const int16_t *source_band_grouping,
+ PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping )
+{
+ int16_t target_band_idx;
+ int16_t source_band_idx = 0;
+ int16_t source_band_cnt_total;
+
+ for ( target_band_idx = 0; target_band_idx < n_target_bands; target_band_idx++ )
+ {
+ int16_t upper = target_band_grouping[target_band_idx + 1];
+ int16_t lower = target_band_grouping[target_band_idx];
+ int16_t source_band_in_target_band_cnt = 0;
+ float norm_fac = 1.0f;
+ source_band_cnt_total = 0;
+ for ( source_band_idx = 0; source_band_idx < n_source_bands; source_band_idx++ )
+ {
+ /* find lowest corresponding source band*/
+ if ( source_band_grouping[source_band_idx] <= lower && source_band_grouping[source_band_idx + 1] >= lower )
+ {
+ do
+ {
+ int16_t source_bands_in_target_band = min( source_band_grouping[source_band_idx + 1], upper ) - max( source_band_grouping[source_band_idx], lower );
+ if ( source_bands_in_target_band )
+ {
+ source_band_cnt_total += source_bands_in_target_band;
+ parameter_band_mapping->source_band_idx[target_band_idx][source_band_in_target_band_cnt] = source_band_idx;
+ parameter_band_mapping->source_band_factor[target_band_idx][source_band_in_target_band_cnt++] = (float) source_bands_in_target_band;
+ }
+ source_band_idx++;
+ } while ( source_band_grouping[source_band_idx] <= upper && source_band_idx < n_source_bands );
+ break;
+ }
+ }
+ norm_fac = 1.0f / ( (float) source_band_cnt_total );
+ for ( source_band_idx = 0; source_band_idx < source_band_in_target_band_cnt; source_band_idx++ )
+ {
+
+ parameter_band_mapping->source_band_factor[target_band_idx][source_band_idx] *= norm_fac;
+ }
+ parameter_band_mapping->n_source_bands[target_band_idx] = source_band_in_target_band_cnt;
+ }
+
+ return;
+}
+
+
+/*-------------------------------------------------------------------------
+ * ivas_param_mc_dec_reconfig()
+ *
+ * Reconfiguration of ParamMC decoder
+ *-------------------------------------------------------------------------*/
+
+ivas_error ivas_param_mc_dec_reconfig(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ int16_t k, nchan_transport;
+ PARAM_MC_DEC_HANDLE hParamMC;
+ IVAS_OUTPUT_SETUP hTransportSetup;
+ int16_t nchan_out_transport;
+ int16_t nchan_out_cov;
+ float proto_matrix[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
+ float proto_mtx_norm;
+ int16_t max_param_band_residual;
+ uint16_t config_index;
+ MC_LS_SETUP mc_ls_setup;
+ float frequency_axis[CLDFB_NO_CHANNELS_MAX];
+ int32_t output_Fs, ivas_total_brate;
+ ivas_error error;
+ int16_t nchan_transport_old;
+ int16_t num_param_bands_old;
+ PARAM_MC_PARAMETER_BAND_MAPPING parameter_band_mapping;
+ int16_t band_grouping_old[20 + 1];
+
+ error = IVAS_ERR_OK;
+ hParamMC = st_ivas->hParamMC;
+
+ /* save important config information from the previous state */
+ nchan_transport_old = st_ivas->nchan_transport;
+ num_param_bands_old = hParamMC->hMetadataPMC->num_parameter_bands;
+
+ /*-----------------------------------------------------------------*
+ * prepare library opening
+ *-----------------------------------------------------------------*/
+
+ output_Fs = st_ivas->hDecoderConfig->output_Fs;
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+
+ hTransportSetup = st_ivas->hTransSetup;
+ mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config );
+ nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe;
+ hParamMC->hoa_encoder = NULL;
+
+ if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO )
+ {
+ nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe;
+ }
+ else
+ {
+ nchan_out_cov = nchan_out_transport;
+ }
+
+ st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup );
+ config_index = ivas_param_mc_get_configuration_index( mc_ls_setup, ivas_total_brate );
+ nchan_transport = st_ivas->nchan_transport;
+
+ switch ( nchan_transport )
+ {
+ case 4:
+ case 3:
+ st_ivas->nCPE = 2;
+ st_ivas->nSCE = 0;
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ break;
+ case 2:
+ st_ivas->nCPE = 1;
+ st_ivas->nSCE = 0;
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+
+ break;
+#ifdef DEBUGGING
+ default:
+ assert( 0 && "Number of TC not supported for Parametric MC!" );
+#endif
+ }
+
+ /*-----------------------------------------------------------------*
+ * set input parameters
+ *-----------------------------------------------------------------*/
+
+ hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX;
+ hParamMC->subframe_nbslots = CLDFB_NO_COL_MAX / PARAM_MC_NSUBFRAMES_DEC;
+
+ hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f );
+ hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands;
+
+ /* deallocate the full icc map, gets newly allocated in the metadata open function */
+
+ for ( k = 0; k < 2; k++ )
+ {
+#ifdef DEBUGGING
+ assert( hParamMC->hMetadataPMC->icc_map_full[k] != NULL );
+#endif
+ if ( hParamMC->hMetadataPMC->icc_map_full[k] != NULL )
+ {
+ count_free( hParamMC->hMetadataPMC->icc_map_full[k] );
+ hParamMC->hMetadataPMC->icc_map_full[k] = NULL;
+ }
+ }
+
+ mvs2s( hParamMC->band_grouping, band_grouping_old, hParamMC->hMetadataPMC->num_parameter_bands + 1 );
+
+ ivas_param_mc_metadata_open( mc_ls_setup, hTransportSetup.index_lfe[0], ivas_total_brate, hParamMC->hMetadataPMC );
+
+ /* Band Grouping */
+ if ( hParamMC->hMetadataPMC->num_parameter_bands == 20 )
+ {
+ mvs2s( param_mc_band_grouping_20, hParamMC->band_grouping, 20 + 1 );
+ }
+ else if ( hParamMC->hMetadataPMC->num_parameter_bands == 14 )
+ {
+ mvs2s( param_mc_band_grouping_14, hParamMC->band_grouping, 14 + 1 );
+ }
+ else if ( hParamMC->hMetadataPMC->num_parameter_bands == 10 )
+ {
+ mvs2s( param_mc_band_grouping_10, hParamMC->band_grouping, 10 + 1 );
+ }
+ else
+ {
+ assert( 0 && "nbands must be 20, 14, or 10!" );
+ }
+
+ ivas_param_mc_get_param_band_mapping( hParamMC->hMetadataPMC->num_parameter_bands, hParamMC->band_grouping, num_param_bands_old, band_grouping_old, ¶meter_band_mapping );
+
+ if ( nchan_transport_old != nchan_transport || num_param_bands_old != hParamMC->hMetadataPMC->num_parameter_bands )
+ {
+ float *ild_q_old = hParamMC->icld_q;
+ float *icc_q_old = hParamMC->icc_q;
+
+
+ /* init arrays for the quantized parameters */
+ hParamMC->icc_q = (float *) count_malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( float ) );
+ hParamMC->icld_q = (float *) count_malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( float ) );
+ set_f( hParamMC->icld_q, PARAM_MC_DEFAULT_MIN_ILD, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe );
+ set_f( hParamMC->icc_q, 0.0f, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe );
+
+ /* map old to new parameter banding, only for same number of TCs, needs some more thought for a changing number of TCs */
+ if ( num_param_bands_old != hParamMC->hMetadataPMC->num_parameter_bands && nchan_transport_old == nchan_transport )
+ {
+ int16_t new_param_band_idx, param_idx, source_param_idx;
+ int16_t num_param_lfe;
+ float *p_icc_new = hParamMC->icc_q;
+ float *p_ild_new = hParamMC->icld_q;
+
+ /* ICC */
+ num_param_lfe = hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe;
+ for ( new_param_band_idx = 0; new_param_band_idx < hParamMC->hMetadataPMC->num_parameter_bands; new_param_band_idx++ )
+ {
+ for ( param_idx = 0; param_idx < num_param_lfe; param_idx++ )
+ {
+ *p_icc_new = 0.0f;
+ for ( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ )
+ {
+ *p_icc_new += icc_q_old[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx] * num_param_lfe + param_idx] * parameter_band_mapping.source_band_factor[new_param_band_idx][source_param_idx];
+ }
+ p_icc_new++;
+ }
+ }
+
+ /* ILD */
+ num_param_lfe = hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe;
+ for ( new_param_band_idx = 0; new_param_band_idx < hParamMC->hMetadataPMC->num_parameter_bands; new_param_band_idx++ )
+ {
+ for ( param_idx = 0; param_idx < num_param_lfe; param_idx++ )
+ {
+ *p_ild_new = 0.0f;
+ for ( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ )
+ {
+ *p_ild_new += powf( 10.0f, ild_q_old[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx] * num_param_lfe + param_idx] / 10.0f ) * parameter_band_mapping.source_band_factor[new_param_band_idx][source_param_idx];
+ }
+ *p_ild_new = 10.0f * log10f( *p_ild_new );
+ p_ild_new++;
+ }
+ }
+ }
+ count_free( ild_q_old );
+ count_free( icc_q_old );
+ }
+
+ param_mc_set_num_synth_bands( output_Fs, hParamMC );
+
+
+ /* set max parameter band for abs cov */
+ k = 0;
+ while ( hParamMC->band_grouping[k] <= PARAM_MC_MAX_BAND_ABS_COV_DEC )
+ {
+ hParamMC->max_param_band_abs_cov = ( k++ );
+ }
+
+
+ /*-----------------------------------------------------------------*
+ * open sub-modules
+ *-----------------------------------------------------------------*/
+
+ /* prototype signal computation */
+
+ if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO )
+ {
+ if ( nchan_transport_old != nchan_transport )
+ {
+ if ( st_ivas->hLsSetUpConversion != NULL )
+ {
+ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
+ }
+
+ if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */
+ count_free( hParamMC->ls_conv_dmx_matrix );
+ hParamMC->ls_conv_dmx_matrix = (float *) count_malloc( nchan_out_transport * nchan_out_cov * sizeof( float ) );
+ for ( k = 0; k < nchan_out_transport; k++ )
+ {
+ mvr2r( st_ivas->hLsSetUpConversion->dmxMtx[k], &hParamMC->ls_conv_dmx_matrix[k * nchan_out_cov], nchan_out_cov );
+ }
+ }
+ /* convert ParamMC parameter bands to SFB */
+
+ st_ivas->hLsSetUpConversion->sfbCnt = hParamMC->num_param_bands_synth;
+ for ( k = 0; k <= hParamMC->num_param_bands_synth; k++ )
+ {
+ st_ivas->hLsSetUpConversion->sfbOffset[k] = PARAM_MC_BAND_TO_MDCT_BAND_RATIO * hParamMC->band_grouping[k];
+ }
+ for ( ; k < MAX_SFB + 2; k++ )
+ {
+ st_ivas->hLsSetUpConversion->sfbOffset[k] = 0;
+ }
+ }
+
+ if ( nchan_transport_old != nchan_transport )
+ {
+ count_free( hParamMC->proto_matrix_int );
+ hParamMC->proto_matrix_int = (float *) count_malloc( nchan_out_transport * nchan_transport * sizeof( float ) );
+ mvr2r( ivas_param_mc_conf[config_index].dmx_fac, hParamMC->proto_matrix_int, nchan_transport * nchan_out_transport );
+ }
+ if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO )
+ {
+ matrix_product( hParamMC->ls_conv_dmx_matrix, nchan_out_cov, nchan_out_transport, 0,
+ ivas_param_mc_conf[config_index].dmx_fac, nchan_out_transport, nchan_transport, 0,
+ proto_matrix );
+
+ if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO )
+ {
+ proto_mtx_norm = 1.f;
+ for ( k = 0; k < nchan_transport * nchan_out_cov; k++ )
+ {
+ proto_mtx_norm = max( fabsf( proto_mtx_norm ), fabsf( proto_matrix[k] ) );
+ }
+ proto_mtx_norm = 1.f / proto_mtx_norm;
+
+ /* transfer flattened proto_matrix to 2D in hLsSetupConversion->dmxMtx */
+ for ( k = 0; k < nchan_transport; k++ )
+ {
+ for ( int16_t i = 0; i < nchan_out_cov; i++ )
+ {
+ st_ivas->hLsSetUpConversion->dmxMtx[k][i] = proto_matrix[k * nchan_out_cov + i] * proto_mtx_norm;
+ }
+ }
+ }
+ }
+ else
+ {
+ mvr2r( ivas_param_mc_conf[config_index].dmx_fac, proto_matrix, nchan_out_transport * nchan_transport );
+ }
+
+ if ( nchan_transport_old != nchan_transport && hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO )
+ {
+ int16_t i;
+ int16_t len;
+
+ /* close decorrelator */
+ ivas_dirac_dec_decorr_close( &hParamMC->h_freq_domain_decorr_ap_params, &hParamMC->h_freq_domain_decorr_ap_state );
+
+ /* deallocate diffuse prototype info */
+ if ( hParamMC->diff_proto_info )
+ {
+ for ( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ )
+ {
+ count_free( hParamMC->diff_proto_info->source_chan_idx[i] );
+ hParamMC->diff_proto_info->source_chan_idx[i] = NULL;
+
+ count_free( hParamMC->diff_proto_info->proto_fac[i] );
+ hParamMC->diff_proto_info->proto_fac[i] = NULL;
+ }
+
+ count_free( hParamMC->diff_proto_info->source_chan_idx );
+ hParamMC->diff_proto_info->source_chan_idx = NULL;
+
+ count_free( hParamMC->diff_proto_info->proto_fac );
+ hParamMC->diff_proto_info->proto_fac = NULL;
+
+ count_free( hParamMC->diff_proto_info->proto_index_diff );
+ hParamMC->diff_proto_info->proto_index_diff = NULL;
+
+ count_free( hParamMC->diff_proto_info->num_source_chan_diff );
+ hParamMC->diff_proto_info->num_source_chan_diff = NULL;
+
+ count_free( hParamMC->diff_proto_info );
+ hParamMC->diff_proto_info = NULL;
+ }
+
+ hParamMC->num_outputs_diff = nchan_out_cov;
+ hParamMC->diff_proto_info = (PARAM_MC_DIFF_PROTO_INFO *) count_malloc( sizeof( PARAM_MC_DIFF_PROTO_INFO ) );
+
+ param_mc_get_diff_proto_info( proto_matrix, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info );
+
+ /* decorrelation */
+ hParamMC->h_freq_domain_decorr_ap_params = NULL;
+ hParamMC->h_freq_domain_decorr_ap_state = NULL;
+
+ ivas_dirac_dec_get_frequency_axis( frequency_axis, output_Fs, hParamMC->num_freq_bands );
+
+ ivas_dirac_dec_decorr_open( &( hParamMC->h_freq_domain_decorr_ap_params ),
+ &( hParamMC->h_freq_domain_decorr_ap_state ),
+ hParamMC->num_freq_bands,
+ hParamMC->num_outputs_diff,
+ hParamMC->diff_proto_info->num_protos_diff,
+ DIRAC_SYNTHESIS_COV_MC_LS,
+ frequency_axis,
+ nchan_transport,
+ output_Fs );
+
+ hParamMC->h_output_synthesis_params.use_onset_filters = 0;
+ hParamMC->max_band_decorr = hParamMC->h_freq_domain_decorr_ap_params->max_band_decorr;
+ /* init decorrelation */
+ if ( hParamMC->max_band_decorr > 0 )
+ {
+
+ len = hParamMC->diff_proto_info->num_protos_diff * hParamMC->h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr;
+
+ /* init onsetDetectionPower */
+ set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1, len );
+ set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2, len );
+ }
+ }
+ hParamMC->max_band_energy_compensation = hParamMC->band_grouping[hParamMC->hMetadataPMC->nbands_coded];
+ max_param_band_residual = 0;
+
+ for ( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- )
+ {
+ if ( hParamMC->band_grouping[k] <= hParamMC->max_band_decorr )
+ {
+ max_param_band_residual = k;
+ assert( hParamMC->band_grouping[k] == hParamMC->max_band_decorr );
+ break;
+ }
+ }
+
+ if ( nchan_transport_old != nchan_transport || num_param_bands_old != hParamMC->hMetadataPMC->num_parameter_bands )
+ {
+ DIRAC_OUTPUT_SYNTHESIS_COV_STATE cov_state_old = hParamMC->h_output_synthesis_cov_state;
+ DIRAC_OUTPUT_SYNTHESIS_PARAMS params_old = hParamMC->h_output_synthesis_params;
+ float tmp_buf[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
+
+ set_zero( tmp_buf, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS );
+ /* output synthesis */
+ ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ),
+ &( hParamMC->h_output_synthesis_cov_state ),
+ hParamMC->max_band_decorr,
+ PARAM_MC_MAX_NSLOTS,
+ hParamMC->hMetadataPMC->num_parameter_bands,
+ max_param_band_residual,
+ nchan_transport,
+ nchan_out_cov,
+ proto_matrix );
+
+ ivas_dirac_dec_output_synthesis_cov_init( &( hParamMC->h_output_synthesis_cov_state ), nchan_transport, nchan_out_cov, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual );
+
+
+ /* map old to new parameter banding, only for same number of TCs, needs some more thought for changing number of TCs */
+ if ( num_param_bands_old != hParamMC->hMetadataPMC->num_parameter_bands && nchan_transport_old == nchan_transport )
+ {
+ int16_t new_param_band_idx, source_param_idx;
+
+
+ for ( new_param_band_idx = 0; new_param_band_idx < hParamMC->hMetadataPMC->num_parameter_bands; new_param_band_idx++ )
+ {
+ for ( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ )
+ {
+ /* Cx */
+ v_multc( cov_state_old.cx_old[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor[new_param_band_idx][source_param_idx], tmp_buf, nchan_transport_old * nchan_transport_old );
+ v_add( tmp_buf, hParamMC->h_output_synthesis_cov_state.cx_old[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cx_old[new_param_band_idx], nchan_transport_old * nchan_transport_old );
+ /* Cy */
+ v_multc( cov_state_old.cy_old[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor[new_param_band_idx][source_param_idx], tmp_buf, nchan_out_cov * nchan_out_cov );
+ v_add( tmp_buf, hParamMC->h_output_synthesis_cov_state.cy_old[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.cy_old[new_param_band_idx], nchan_out_cov * nchan_out_cov );
+ /* mixing matrix*/
+ v_multc( cov_state_old.mixing_matrix_old[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor[new_param_band_idx][source_param_idx], tmp_buf, nchan_transport_old * nchan_out_cov );
+ v_add( tmp_buf, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[new_param_band_idx], nchan_transport_old * nchan_out_cov );
+ }
+ }
+ for ( new_param_band_idx = 0; new_param_band_idx < max_param_band_residual; new_param_band_idx++ )
+ {
+ for ( source_param_idx = 0; source_param_idx < parameter_band_mapping.n_source_bands[new_param_band_idx]; source_param_idx++ )
+ {
+ /* residual mixing matrix*/
+ v_multc( cov_state_old.mixing_matrix_res_old[parameter_band_mapping.source_band_idx[new_param_band_idx][source_param_idx]], parameter_band_mapping.source_band_factor[new_param_band_idx][source_param_idx], tmp_buf, nchan_out_cov * nchan_out_cov );
+ v_add( tmp_buf, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[new_param_band_idx], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[new_param_band_idx], nchan_out_cov * nchan_out_cov );
+ }
+ }
+ }
+
+ ivas_dirac_dec_output_synthesis_cov_close( ¶ms_old, &cov_state_old );
+ }
+
+
+ /*-----------------------------------------------------------------*
+ * memory allocation
+ *-----------------------------------------------------------------*/
+
+ if ( hParamMC->max_band_decorr > 0 && nchan_transport_old != nchan_transport )
+ {
+ count_free( hParamMC->proto_frame_f );
+ hParamMC->proto_frame_f = (float *) count_malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( float ) );
+ set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands );
+ }
+
+ return error;
+}
+#endif
+
/*-------------------------------------------------------------------------
* param_mc_get_num_cldfb_syntheses()
*
@@ -2263,7 +2765,7 @@ static void ivas_param_mc_mc2sba_cldfb(
* reads and decodes a sequence of Parametric MC parameters from the bitstream
*-------------------------------------------------------------------------*/
-void ivas_param_mc_bs_decode_parameter_values(
+static void ivas_param_mc_bs_decode_parameter_values(
uint16_t bit_buffer[], /* i : bitstream buffer */
int16_t *bit_pos, /* i/o: current bitstream buffer position */
const int16_t max_bits, /* i : maximum available bits in the buffer */
diff --git a/lib_dec/ivas_mcmasa_dec.c b/lib_dec/ivas_mcmasa_dec.c
new file mode 100644
index 0000000000000000000000000000000000000000..83e226f0a0086989ad3f3caf062bf82d733e49c1
--- /dev/null
+++ b/lib_dec/ivas_mcmasa_dec.c
@@ -0,0 +1,142 @@
+/******************************************************************************************************
+
+(C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
+Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+contributors to this repository. All Rights Reserved.
+
+This software is protected by copyright law and by international treaties.
+The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
+Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
+Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
+Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
+contributors to this repository retain full ownership rights in their respective contributions in
+the software. This notice grants no license of any kind, including but not limited to patent
+license, nor is any license granted by implication, estoppel or otherwise.
+
+Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
+contributions.
+
+This software is provided "AS IS", without any express or implied warranties. The software is in the
+development stage. It is intended exclusively for experts who have experience with such software and
+solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
+and fitness for a particular purpose are hereby disclaimed and excluded.
+
+Any dispute, controversy or claim arising under or in relation to providing this software shall be
+submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
+accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
+the United Nations Convention on Contracts on the International Sales of Goods.
+
+*******************************************************************************************************/
+
+#include "options.h"
+#include
+#include "ivas_cnst.h"
+#include "ivas_prot.h"
+#include "prot.h"
+#ifdef DEBUGGING
+#include "debug.h"
+#endif
+#include "wmops.h"
+
+#ifdef MC_BITRATE_SWITCHING
+
+/*-------------------------------------------------------------------------
+ * ivas_mcmasa_dec_reconfig()
+ *
+ * Reconfigure McMASA decoder
+ *------------------------------------------------------------------------*/
+
+ivas_error ivas_mcmasa_dec_reconfig(
+ Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
+)
+{
+ ivas_error error;
+ int32_t ivas_total_brate;
+
+ ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
+
+ /* close the old MASA instance */
+ if ( st_ivas->hMasa != NULL )
+ {
+ ivas_masa_dec_close( st_ivas->hMasa );
+ }
+
+ /* get new McMASA settings */
+ ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
+ ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate );
+ /* transport channel settings may affect renderer */
+ ivas_renderer_select( st_ivas );
+ /* renderer change may affect internal config */
+ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
+ ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate );
+
+ if ( ( error = ivas_masa_dec_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ st_ivas->sba_dirac_stereo_flag = ( st_ivas->nchan_transport == 1 && st_ivas->hOutSetup.output_config == AUDIO_CONFIG_STEREO );
+
+ if ( st_ivas->renderer_type != RENDERER_DISABLE && st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO )
+ {
+ if ( st_ivas->hDirAC == NULL )
+ {
+ if ( ( error = ivas_dirac_dec_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+
+ /*-------------------------------------------------------------------*
+ * Close binaural rendering handles and re-allocate proper ones
+ * in McMASA renderer_type can be only RENDERER_BINAURAL_PARAMETRIC, RENDERER_BINAURAL_PARAMETRIC_ROOM
+ *--------------------------------------------------------------------*/
+
+ if ( st_ivas->hBinRenderer != NULL )
+ {
+ ivas_binRenderer_close( &st_ivas->hBinRenderer );
+ }
+
+ if ( st_ivas->hDiracDecBin == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) )
+ {
+ /* open parametric binaural renderer */
+ if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->hDiracDecBin != NULL )
+ {
+ if ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM )
+ {
+ /* close unneeded renderer */
+ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
+ }
+ else
+ {
+ /* the decision for useTdDecorr is done in ivas_dirac_dec_init_binaural_data(). here, comparing against the same condition. */
+ if ( st_ivas->hDiracDecBin->useTdDecorr != ( st_ivas->hDecoderConfig->ivas_total_brate < IVAS_48k && st_ivas->nchan_transport == 1 ) )
+ {
+ /* st_ivas->hDiracDecBin->useTdDecorr will change => close and re-open. */
+ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
+ if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ }
+
+ return error;
+}
+#endif
diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c
old mode 100644
new mode 100755
index b4a4da3e3c0acbbcdb06facb2d12856a8c4aabe6..0283d7778dbf118cab080d68f72af835778d5289
--- a/lib_dec/ivas_mct_dec.c
+++ b/lib_dec/ivas_mct_dec.c
@@ -48,6 +48,16 @@
#include "deb_out.h"
#endif
+
+#ifdef MC_BITRATE_SWITCHING
+/*-----------------------------------------------------------------------*
+ * Local function prototypes
+ *-----------------------------------------------------------------------*/
+
+static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas );
+#endif
+
+
/*--------------------------------------------------------------------------*
* ivas_mct_dec()
*
@@ -458,6 +468,9 @@ ivas_error mct_dec_reconfigure(
* run into a number of problems */
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate;
+#endif
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st = st_ivas->hCPE[cpe_id]->hCoreCoder[n];
@@ -622,8 +635,11 @@ ivas_error ivas_mc_dec_config(
{
if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode )
{
- /*ivas_mc_dec_reconfigure( st_ivas );*/
+#ifdef MC_BITRATE_SWITCHING
+ ivas_mc_dec_reconfig( st_ivas );
+#else
return IVAS_ERROR( IVAS_ERR_RECONFIGURE_NOT_SUPPORTED, "Error: MC format switching not supported yet!!!\n\n" );
+#endif
}
}
@@ -632,3 +648,535 @@ ivas_error ivas_mc_dec_config(
return error;
}
+
+
+#ifdef MC_BITRATE_SWITCHING
+/*-------------------------------------------------------------------------
+ * ivas_mc_dec_reconfig()
+ *
+ * reconfigure the MC format decoder
+ *-------------------------------------------------------------------------*/
+
+static ivas_error ivas_mc_dec_reconfig(
+ Decoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+)
+{
+ int16_t nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old;
+#ifdef MC_BITRATE_SWITCHING
+ int16_t numCldfbAnalyses_old, numCldfbSyntheses_old;
+#else
+ int16_t numCldfbAnalyses_old, numCldfbAnalyses, numCldfbSyntheses, numCldfbSyntheses_old, i;
+#endif
+ int32_t new_brate_SCE, new_brate_CPE;
+ RENDERER_TYPE renderer_type_old;
+ ivas_error error;
+ MC_MODE mc_mode, last_mc_mode;
+
+ last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */
+
+ error = IVAS_ERR_OK;
+
+ nchan_transport_old = st_ivas->nchan_transport;
+
+ /* we have to temporally set the current mc_mode back to the previous one to make sure the following call to
+ ivas_init_dec_get_num_cldfb_instances() returns the correct counts */
+ mc_mode = st_ivas->mc_mode;
+ st_ivas->mc_mode = last_mc_mode;
+ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
+ st_ivas->mc_mode = mc_mode;
+
+ nSCE_old = st_ivas->nSCE;
+ nCPE_old = st_ivas->nCPE;
+ sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag;
+
+ /* special handling needed for the hp20 buffers for McMASA */
+ if ( last_mc_mode == MC_MODE_MCMASA )
+ {
+ nchan_hp20_old = getNumChanSynthesis( st_ivas );
+ }
+ else
+ {
+ nchan_hp20_old = nchan_transport_old;
+ }
+ st_ivas->sba_dirac_stereo_flag = 0; /* needs to be after getNumChanSynthesis() */
+
+ /* renderer might have changed, reselect */
+ renderer_type_old = st_ivas->renderer_type;
+ ivas_renderer_select( st_ivas );
+ /* side effect of the renderer selection can be a changed internal config */
+ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
+
+ if ( st_ivas->mc_mode == MC_MODE_MCT )
+ {
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) );
+ st_ivas->nSCE = 0;
+ st_ivas->nCPE = st_ivas->nchan_transport / 2;
+
+ if ( last_mc_mode != MC_MODE_MCT )
+ {
+ /*De-allocate handles for other MC modes*/
+ if ( st_ivas->hParamMC != NULL )
+ {
+ ivas_param_mc_dec_close( &st_ivas->hParamMC );
+ st_ivas->hParamMC = NULL;
+ /* remove ls conversion if it was allocated by ParamMC */
+ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
+ }
+
+ /* De-allocate McMasa-related handles */
+ if ( st_ivas->hMasa != NULL )
+ {
+ ivas_masa_dec_close( st_ivas->hMasa );
+ st_ivas->hMasa = NULL;
+ }
+
+ if ( st_ivas->hQMetaData != NULL )
+ {
+ ivas_qmetadata_close( &st_ivas->hQMetaData );
+ st_ivas->hQMetaData = NULL;
+ }
+
+ /* init LS conversion if the renderer type asks for it */
+ if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hLsSetUpConversion == NULL )
+ {
+ if ( ( error = ivas_ls_setup_conversion_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ {
+ if ( last_mc_mode != MC_MODE_PARAMMC )
+ {
+ /* remove old ls conversion for MCT if open, gets reopened correctly within ivas_param_mc_dec_open when needed */
+ if ( renderer_type_old == RENDERER_MC && st_ivas->hLsSetUpConversion != NULL )
+ {
+ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
+ }
+ if ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ ivas_param_mc_dec_reconfig( st_ivas );
+ }
+
+ /* De-allocate McMasa-related handles */
+ if ( st_ivas->hMasa != NULL )
+ {
+ ivas_masa_dec_close( st_ivas->hMasa );
+ st_ivas->hMasa = NULL;
+ }
+
+ if ( st_ivas->hQMetaData != NULL )
+ {
+ ivas_qmetadata_close( &st_ivas->hQMetaData );
+ st_ivas->hQMetaData = NULL;
+ }
+
+ if ( last_mc_mode == MC_MODE_MCT )
+ {
+ if ( st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS )
+ {
+ ivas_mct_dec_close( &st_ivas->hMCT );
+ st_ivas->hMCT = NULL;
+ }
+
+ /* LFE handle */
+ if ( st_ivas->hLFE != NULL )
+ {
+ ivas_lfe_dec_close( st_ivas->hLFE );
+ st_ivas->hLFE = NULL;
+ }
+ }
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), st_ivas->hDecoderConfig->ivas_total_brate );
+
+ if ( last_mc_mode != MC_MODE_MCMASA )
+ {
+ if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ if ( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* ls conversion */
+ if ( st_ivas->hLsSetUpConversion != NULL )
+ {
+ ivas_ls_setup_conversion_close( &st_ivas->hLsSetUpConversion );
+ }
+
+ if ( st_ivas->hParamMC != NULL )
+ {
+ ivas_param_mc_dec_close( &st_ivas->hParamMC );
+ st_ivas->hParamMC = NULL;
+ }
+
+ if ( last_mc_mode == MC_MODE_MCT )
+ {
+ if ( st_ivas->hMCT != NULL )
+ {
+ ivas_mct_dec_close( &st_ivas->hMCT );
+ st_ivas->hMCT = NULL;
+ }
+
+ /* LFE handle */
+ if ( st_ivas->hLFE != NULL )
+ {
+ ivas_lfe_dec_close( st_ivas->hLFE );
+ st_ivas->hLFE = NULL;
+ }
+ }
+ }
+
+ if ( st_ivas->mc_mode != MC_MODE_MCMASA )
+ {
+ if ( st_ivas->nchan_transport == 1 )
+ {
+ st_ivas->element_mode_init = IVAS_SCE;
+ }
+ else
+ {
+ st_ivas->element_mode_init = IVAS_CPE_MDCT;
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reconfigure core coder
+ *-----------------------------------------------------------------*/
+
+ /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1
+ and might have IGF static memory not allocated and the bit stream index list not set,
+ set correct mct_chan_mode and init missing static mem (IGF, HQ) and some config (TNS) do it here since it is _very_ MC specific */
+ if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS )
+ {
+ Decoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];
+
+ if ( st_ivas->nchan_transport == 3 )
+ {
+ st->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
+ }
+ else
+ {
+ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
+ }
+
+ if ( st->hIGFDec == NULL )
+ {
+ if ( ( st->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) count_malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) );
+ }
+
+ st->igf = 0;
+ init_igf_dec( st->hIGFDec );
+ }
+
+ if ( st->hHQ_core == NULL )
+ {
+
+ if ( ( st->hHQ_core = (HQ_DEC_HANDLE) count_malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) );
+ }
+
+ /* HQ core initialization */
+ HQ_core_dec_init( st->hHQ_core );
+ }
+
+ /* check if we have a doubly used hTxcCfg, if so, allocate a distint one for the old MCT LFE channel */
+ if ( st->hTcxCfg == st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg )
+ {
+ if ( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) count_malloc( sizeof( TCX_config ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) );
+ }
+ }
+
+ st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( st_ivas->hDecoderConfig->ivas_total_brate, st->igf, st->element_mode, st->mct_chan_mode );
+ }
+ else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 )
+ {
+#ifdef DEBUGGING
+ assert( st_ivas->hCPE[1] != NULL );
+#endif
+ Decoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];
+ st->mct_chan_mode = MCT_CHAN_MODE_LFE;
+ st->hTcxCfg->fIsTNSAllowed = 0;
+ }
+
+ if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ uint8_t separateChannelEnabled;
+ int16_t separateChannelIndex;
+ ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, st_ivas->hDecoderConfig->ivas_total_brate );
+ ivas_mcmasa_split_brate( separateChannelEnabled, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE );
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_MCT )
+ {
+ new_brate_SCE = 0;
+ new_brate_CPE = ( st_ivas->hDecoderConfig->ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS;
+ }
+ else
+ {
+ new_brate_SCE = 0; /*st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport;*/
+ new_brate_CPE = ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
+ }
+ if ( ( error = ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS )
+ {
+ Decoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];
+
+ /* TCX-LTP */
+ if ( st->hTcxLtpDec == NULL )
+ {
+ if ( ( st->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) count_malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) );
+ }
+ tcxltp_dec_init( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core );
+ }
+ }
+
+ /* re-configure hp20 memories */
+ ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old );
+
+ /*-----------------------------------------------------------------*
+ * CLDFB instances
+ *-----------------------------------------------------------------*/
+
+#ifdef MC_BITRATE_SWITCHING
+ ivas_cldfb_dec_reconfig( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old );
+
+#else
+ ivas_init_dec_get_num_cldfb_instances( st_ivas, &numCldfbAnalyses, &numCldfbSyntheses );
+
+ /* Analysis*/
+ if ( numCldfbAnalyses_old > numCldfbAnalyses )
+ {
+ /* delete superfluous CLDFB synthesis instances */
+ for ( i = numCldfbAnalyses; i < numCldfbAnalyses_old; i++ )
+ {
+ deleteCldfb( &( st_ivas->cldfbAnaDec[i] ) );
+ st_ivas->cldfbAnaDec[i] = NULL;
+ }
+ }
+ else if ( numCldfbAnalyses_old < numCldfbAnalyses )
+ {
+ /* create additional CLDFB synthesis instances */
+ for ( i = numCldfbAnalyses_old; i < numCldfbAnalyses; i++ )
+ {
+ if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[i] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+
+ if ( ( last_mc_mode == MC_MODE_MCMASA ) && ( nchan_transport_old == 1 ) && ( ( renderer_type_old == RENDERER_BINAURAL_PARAMETRIC ) || ( renderer_type_old == RENDERER_BINAURAL_PARAMETRIC_ROOM ) || ( renderer_type_old == RENDERER_STEREO_PARAMETRIC ) ) )
+ {
+ /* cldfbAnaDec[1] might be modified by DirAC (ivas_dirac_dec_binaural_internal) -> re-instantiate it */
+ if ( ( numCldfbAnalyses_old > 1 ) && ( numCldfbAnalyses > 1 ) )
+ {
+ deleteCldfb( &( st_ivas->cldfbAnaDec[1] ) );
+ st_ivas->cldfbAnaDec[1] = NULL;
+ if ( ( error = openCldfb( &( st_ivas->cldfbAnaDec[1] ), CLDFB_ANALYSIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+
+ /* Synthesis */
+ if ( numCldfbSyntheses_old > numCldfbSyntheses )
+ {
+ /* delete superfluous CLDFB synthesis instances */
+ for ( i = numCldfbSyntheses; i < numCldfbSyntheses_old; i++ )
+ {
+ deleteCldfb( &( st_ivas->cldfbSynDec[i] ) );
+ st_ivas->cldfbSynDec[i] = NULL;
+ }
+ }
+ else if ( numCldfbSyntheses_old < numCldfbSyntheses )
+ {
+ /* create additional CLDFB synthesis instances */
+ for ( i = numCldfbSyntheses_old; i < numCldfbSyntheses; i++ )
+ {
+ if ( ( error = openCldfb( &( st_ivas->cldfbSynDec[i] ), CLDFB_SYNTHESIS, st_ivas->hDecoderConfig->output_Fs, CLDFB_PROTOTYPE_5_00MS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+#endif
+
+ /*-----------------------------------------------------------------*
+ * Allocate the LFE handle that is coded seperately after the allocation of the core coders
+ *-----------------------------------------------------------------*/
+
+ if ( st_ivas->mc_mode == MC_MODE_MCT && st_ivas->hLFE == NULL )
+ {
+ if ( ( error = ivas_create_lfe_dec( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, st_ivas->hHrtf != NULL ? st_ivas->hHrtf->latency_s : 0 ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* reuse core-coder buffers for LFE decoder */
+ st_ivas->hLFE->prevsynth_buf = &st_ivas->hCPE[1]->hCoreCoder[1]->old_synth_sw[0];
+ st_ivas->hLFE->prior_out_buffer = &st_ivas->hCPE[1]->hCoreCoder[1]->previoussynth[0];
+
+ set_zero( st_ivas->hLFE->prevsynth_buf, LFE_PLC_BUFLEN );
+ set_zero( st_ivas->hLFE->prior_out_buffer, L_FRAME48k );
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reconfigure renderers
+ *-----------------------------------------------------------------*/
+
+ if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ if ( ( st_ivas->renderer_type != RENDERER_DISABLE ) && ( st_ivas->renderer_type != RENDERER_MCMASA_MONO_STEREO ) )
+ {
+ if ( st_ivas->hDirAC != NULL )
+ {
+ /* reconfigure existing DirAC dec */
+ if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ /* init a new DirAC dec */
+ if ( ( error = ivas_dirac_dec_config( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+ else if ( ( st_ivas->renderer_type == RENDERER_DISABLE ) && ( st_ivas->hDirAC != NULL ) )
+ {
+ ivas_dirac_dec_close( st_ivas->hDirAC );
+ st_ivas->hDirAC = NULL;
+ }
+ }
+
+ if ( renderer_type_old != st_ivas->renderer_type )
+ {
+ AUDIO_CONFIG output_config;
+
+ output_config = st_ivas->hDecoderConfig->output_config;
+
+ /* binaural renderers*/
+ if ( output_config == AUDIO_CONFIG_BINAURAL || output_config == AUDIO_CONFIG_BINAURAL_ROOM )
+ {
+ /* remove unneeded binaural renderers */
+ if ( st_ivas->hBinRenderer != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV && st_ivas->renderer_type != RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ ivas_binRenderer_close( &st_ivas->hBinRenderer );
+ }
+
+ if ( st_ivas->hCrend != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV && st_ivas->renderer_type != RENDERER_BINAURAL_MIXER_CONV_ROOM && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD || st_ivas->hRenderConfig->roomAcoustics.late_reverb_on == 0 ) ) )
+ {
+ ivas_crend_close( st_ivas );
+ }
+
+ if ( st_ivas->hBinRendererTd != NULL && ( st_ivas->renderer_type != RENDERER_BINAURAL_OBJECTS_TD ) )
+ {
+ ivas_td_binaural_close( &st_ivas->hBinRendererTd );
+ }
+
+ if ( st_ivas->hDiracDecBin != NULL )
+ {
+ if ( st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC_ROOM && st_ivas->renderer_type != RENDERER_STEREO_PARAMETRIC )
+ {
+ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
+ }
+ else
+ {
+ /* useTdDecorr may change => close and re-open */
+ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin );
+ if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ }
+
+ /* init necessary new renderers */
+ if ( st_ivas->hBinRenderer == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) )
+ {
+ if ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->hDiracDecBin == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) )
+ {
+ if ( ( error = ivas_dirac_dec_init_binaural_data( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else if ( st_ivas->hBinRendererTd == NULL && st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
+ {
+ if ( ( error = ivas_td_binaural_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( st_ivas->hCrend == NULL && st_ivas->hRenderConfig->roomAcoustics.late_reverb_on )
+ {
+ if ( ( st_ivas->hCrend = (CREND_HANDLE) count_malloc( sizeof( CREND_DATA ) ) ) == NULL )
+ {
+ return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR Crend\n" );
+ }
+ }
+ }
+ else if ( st_ivas->hCrend == NULL && ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM ) )
+ {
+ if ( ivas_crend_open( st_ivas ) != IVAS_ERR_OK )
+ {
+ return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "ivas_crend_open failed" );
+ }
+ }
+ }
+ /* mono/stereo */
+ else if ( output_config == AUDIO_CONFIG_MONO || output_config == AUDIO_CONFIG_STEREO )
+ {
+ /* nothing should happen here... */
+ }
+ /* LS */
+ else if ( output_config == AUDIO_CONFIG_5_1 || output_config == AUDIO_CONFIG_5_1_2 || output_config == AUDIO_CONFIG_5_1_4 || output_config == AUDIO_CONFIG_7_1 || output_config == AUDIO_CONFIG_7_1_4 || output_config == AUDIO_CONFIG_LS_CUSTOM )
+ {
+#ifdef DEBUGGING
+ assert( st_ivas->renderer_type == RENDERER_MC || st_ivas->renderer_type == RENDERER_MC_PARAMMC || st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_DISABLE );
+#endif
+ }
+#ifdef DEBUGGING
+ else if ( output_config == AUDIO_CONFIG_FOA || output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_HOA3 )
+ {
+ /* FOA/HOA output */
+ /* Nothing to do, renderer is always RENDERER_SBA_LINEAR_ENC */
+ assert( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC && renderer_type_old == RENDERER_SBA_LINEAR_ENC );
+ }
+#endif
+ }
+
+ return error;
+}
+#endif
diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c
old mode 100644
new mode 100755
index 3e186d61b8be5920ca39a0942985c8ccc2379ac5..85247f86cddcc28876b570b4c471679a96745e4e
--- a/lib_dec/ivas_mdct_core_dec.c
+++ b/lib_dec/ivas_mdct_core_dec.c
@@ -404,7 +404,11 @@ void ivas_mdct_dec_side_bits_frame_channel(
param_lpc[0][0] = get_next_indice( st0, 1 ) << 1;
/* read low br mode flag (if it is possible to be non-zero) */
+#ifdef MC_BITRATE_SWITCHING
+ if ( sts[0]->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) )
+#else
if ( sts[0]->element_brate == IVAS_48k && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) )
+#endif
{
sns_low_br_mode = get_next_indice( st0, 1 );
}
diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c
index 3016db05ec691aee114a736471926c9d0c59b543..04e0217f8aee27e6f96673fa26e983a4800680a6 100644
--- a/lib_dec/ivas_sba_dec.c
+++ b/lib_dec/ivas_sba_dec.c
@@ -840,7 +840,11 @@ ivas_error ivas_sba_dec_reconfigure(
* Allocate, initalize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS );
+#else
ivas_corecoder_dec_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old );
+#endif
/*-----------------------------------------------------------------*
* HP20 memories
diff --git a/lib_dec/ivas_sce_dec.c b/lib_dec/ivas_sce_dec.c
index 97ee2e83369b3a6c061237d40808e638f23bb288..9ac0a1c52874626def0a30b5fdb593b814d53d6d 100644
--- a/lib_dec/ivas_sce_dec.c
+++ b/lib_dec/ivas_sce_dec.c
@@ -273,8 +273,13 @@ ivas_error ivas_sce_dec(
for ( i = 0; i < n; i++ )
{
+#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
+ dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate.sce", 0, sce_id, DEC ) );
+ dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode.sce", 0, sce_id, DEC ) );
+#else
dbgwrite( &tmpF, sizeof( float ), 1, output_frame, fname( debug_dir, "element_brate", 0, sce_id, DEC ) );
dbgwrite( &st->element_mode, sizeof( int16_t ), 1, output_frame, fname( debug_dir, "element_mode", 0, sce_id, DEC ) );
+#endif
dbgwrite( output, sizeof( float ), output_frame, 1, fname( debug_dir, "output.sce", 0, sce_id, DEC ) );
tmpF = 0;
diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c
index da8c75844ae495c0fdb230cf3a74ba3a57f355f5..781834d29ee12ccd3e08588a9c0a131eb8b79d8a 100755
--- a/lib_dec/ivas_stereo_switching_dec.c
+++ b/lib_dec/ivas_stereo_switching_dec.c
@@ -342,7 +342,10 @@ ivas_error stereo_memory_dec(
const int16_t nb_bits_metadata, /* i : number of metadata bits */
const int32_t output_Fs, /* i : output sampling rate */
const IVAS_FORMAT ivas_format, /* i : IVAS format */
- const int16_t nchan_transport /* i : number of transport channels*/
+#ifdef MC_BITRATE_SWITCHING
+ const MC_MODE mc_mode, /* i : MC mode */
+#endif
+ const int16_t nchan_transport /* i : number of transport channels*/
)
{
DEC_CORE_HANDLE st;
@@ -951,6 +954,53 @@ ivas_error stereo_memory_dec(
}
}
+#ifdef MC_BITRATE_SWITCHING
+ /*--------------------------------------------------------------*
+ * Bitrate switching in MASA format
+ *---------------------------------------------------------------*/
+
+ if ( ivas_format == MC_FORMAT && hCPE->element_mode == IVAS_CPE_MDCT )
+ {
+ if ( mc_mode == MC_MODE_MCT )
+ {
+ /* deallocate the FdCNG handle */
+ for ( i = 0; i < CPE_CHANNELS; ++i )
+ {
+ deleteFdCngDec( &hCPE->hCoreCoder[i]->hFdCngDec );
+
+ /* deallocate CLDFB synthesis for LFE channel */
+ if ( hCPE->hCoreCoder[i]->mct_chan_mode == MCT_CHAN_MODE_LFE )
+ {
+ deleteCldfb( &hCPE->hCoreCoder[i]->cldfbSyn );
+ }
+ }
+ }
+ else
+ {
+ /* allocate the FdCNG handle (for noise estimation for TCX PLC fadeout)*/
+ for ( i = 0; i < CPE_CHANNELS; ++i )
+ {
+ if ( hCPE->hCoreCoder[i]->cldfbSyn == NULL ) /* could be NULL when we had the MCT LFE channel */
+ {
+ if ( ( error = openCldfb( &hCPE->hCoreCoder[i]->cldfbSyn, CLDFB_SYNTHESIS, hCPE->hCoreCoder[i]->output_Fs, CLDFB_PROTOTYPE_1_25MS ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( hCPE->hCoreCoder[i]->hFdCngDec == NULL )
+ {
+ if ( ( error = createFdCngDec( &hCPE->hCoreCoder[i]->hFdCngDec ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ initFdCngDec( hCPE->hCoreCoder[i] );
+ }
+ }
+ }
+ }
+#endif
+
return error;
}
diff --git a/lib_enc/amr_wb_enc.c b/lib_enc/amr_wb_enc.c
index 3b342220e3ac0dcdf541c6f3b8298a1af724697f..5bbc890b521012f34b5e58f42e85a16f47277a7b 100644
--- a/lib_enc/amr_wb_enc.c
+++ b/lib_enc/amr_wb_enc.c
@@ -531,7 +531,13 @@ void amr_wb_enc(
updt_enc( st, old_exc, pitch_buf, 0, Aq, isf_new, isp_new, dummy_buf );
/* update main codec paramaters */
+#ifdef MC_BITRATE_SWITCHING
+ st->hNoiseEst->Etot_last = Etot;
+ updt_enc_common( st );
+#else
updt_enc_common( st, Etot );
+#endif
+
#ifdef DEBUG_MODE_INFO
dbgwrite( &st->codec_mode, sizeof( int16_t ), 1, input_frame, "res/codec" );
diff --git a/lib_enc/evs_enc.c b/lib_enc/evs_enc.c
index 29b610db79e0f760e3f1fa76627235768cf3852f..8eb9bd9623162cbb6029c69a6f47c0771213b3dd 100644
--- a/lib_enc/evs_enc.c
+++ b/lib_enc/evs_enc.c
@@ -509,7 +509,12 @@ ivas_error evs_enc(
* Updates
*---------------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ st->hNoiseEst->Etot_last = Etot;
+ updt_enc_common( st );
+#else
updt_enc_common( st, Etot );
+#endif
if ( st->mdct_sw == MODE1 )
{
diff --git a/lib_enc/ivas_core_enc.c b/lib_enc/ivas_core_enc.c
index dc3247cbfbc11b84261bf67742331e48b6196540..edef26a6c2db2382e3bb3e11555dccb92baa3bce 100644
--- a/lib_enc/ivas_core_enc.c
+++ b/lib_enc/ivas_core_enc.c
@@ -405,11 +405,19 @@ ivas_error ivas_core_enc(
signaling_enc_rf( st );
- /*---------------------------------------------------------------------*
- * Common updates
- *---------------------------------------------------------------------*/
-
- updt_enc_common( st, Etot[n] );
+/*---------------------------------------------------------------------*
+ * Common updates
+ *---------------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ /* for MCT do this later, otherwise there can be a problem because TCX quant happens later and might get the wrong last_core on a bit rate switch */
+ st->hNoiseEst->Etot_last = Etot[n];
+ if ( !MCT_flag )
+ {
+ updt_enc_common( st );
+ }
+#else
+ updt_enc_common( st, Etot );
+#endif
}
diff --git a/lib_enc/ivas_corecoder_enc_reconfig.c b/lib_enc/ivas_corecoder_enc_reconfig.c
index dffd53bb93c0cdc7225a60c10a40553fdbeb8c1a..50d8e4faf8077c6cd590babd120fea73bbe18b79 100644
--- a/lib_enc/ivas_corecoder_enc_reconfig.c
+++ b/lib_enc/ivas_corecoder_enc_reconfig.c
@@ -50,10 +50,20 @@
*-------------------------------------------------------------------*/
ivas_error ivas_corecoder_enc_reconfig(
+#ifdef MC_BITRATE_SWITCHING
+ Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
+ const int16_t nSCE_old, /* i : number of SCEs in previous frame */
+ const int16_t nCPE_old, /* i : number of CPEs in previous frame */
+ const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
+ const int32_t brate_SCE, /* i : bitrate to be set for the SCEs */
+ const int32_t brate_CPE, /* i : bitrate to be set for the CPEs */
+ const MC_MODE last_mc_mode /* i : switching between MC modes: last mode */
+#else
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t nSCE_old, /* i : number of SCEs in previous frame */
const int16_t nCPE_old, /* i : number of CPEs in previous frame */
const int16_t nchan_transport_old /* i : number of TCs in previous frame */
+#endif
)
{
int16_t n, sce_id, cpe_id;
@@ -62,7 +72,9 @@ ivas_error ivas_corecoder_enc_reconfig(
BSTR_ENC_HANDLE hBstr, hMetaData;
Indice *ind_list, *ind_list_metadata;
int16_t nb_bits_tot, next_ind, last_ind;
+#ifndef MC_BITRATE_SWITCHING
int32_t ivas_total_brate;
+#endif
ENCODER_CONFIG_HANDLE hEncoderConfig;
ivas_error error;
@@ -71,7 +83,9 @@ ivas_error ivas_corecoder_enc_reconfig(
*-----------------------------------------------------------------*/
hEncoderConfig = st_ivas->hEncoderConfig;
+#ifndef MC_BITRATE_SWITCHING
ivas_total_brate = hEncoderConfig->ivas_total_brate;
+#endif
error = IVAS_ERR_OK;
len_inp_memory = (int16_t) ( hEncoderConfig->input_Fs / FRAMES_PER_SEC );
@@ -84,19 +98,30 @@ ivas_error ivas_corecoder_enc_reconfig(
* Switching between SCE(s)/CPE(s)/MCT
*-----------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ if ( st_ivas->nchan_transport == nchan_transport_old && st_ivas->nSCE == nSCE_old && st_ivas->nCPE == nCPE_old ) /* in McMASA, nchan_transport may be the same, but nSCE/nCPE differs */
+#else
if ( st_ivas->nchan_transport == nchan_transport_old )
+#endif
{
for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+#else
st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport;
+#endif
st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+#else
st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
-
+#endif
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -116,7 +141,27 @@ ivas_error ivas_corecoder_enc_reconfig(
}
else
{
+#ifdef MC_BITRATE_SWITCHING
+ int16_t nchan_transport_real, nchan_transport_old_real;
+
+ nchan_transport_old_real = nchan_transport_old;
+ nchan_transport_real = st_ivas->nchan_transport;
+ /* in SCE+CPE McMASA nchan_transport is still 2, fix the numbers */
+ if ( hEncoderConfig->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA )
+ {
+ nchan_transport_old_real = nSCE_old + CPE_CHANNELS * nCPE_old;
+ }
+ if ( hEncoderConfig->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ nchan_transport_real = st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE;
+ }
+
+ /* something in transport changes */
+ ind_list = NULL;
+ ind_list_metadata = NULL;
+#else
ind_list = NULL;
+#endif
hBstr = NULL;
hMetaData = NULL;
@@ -139,13 +184,43 @@ ivas_error ivas_corecoder_enc_reconfig(
#endif
/* save bitstream information */
- ind_list = hBstr->ind_list;
+ ind_list = hBstr->ind_list; /* pointer to the beginning of the global list */
nb_bits_tot = hBstr->nb_bits_tot;
next_ind = hBstr->next_ind;
last_ind = hBstr->last_ind;
- ind_list_metadata = hMetaData->ind_list;
+ ind_list_metadata = hMetaData->ind_list; /* pointer to the beginning of the global list */
+
+#ifdef MC_BITRATE_SWITCHING
+ if ( hEncoderConfig->ivas_format == MC_FORMAT && last_mc_mode == MC_MODE_MCMASA && st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ /* within McMASA we can modify the transport signals when switching */
+ /* copy earlier dmx buffers */
+ if ( nSCE_old > 0 )
+ {
+ set_zero( input_buff[0], len_inp_memory );
+ mvr2r( st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, input_buff[0], len_inp_memory );
+ }
+
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ set_zero( input_buff[n + 1], len_inp_memory );
+ if ( nCPE_old > 0 )
+ {
+ mvr2r( st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, input_buff[n + 1], len_inp_memory );
+ }
+ }
+
+ ivas_mcmasa_dmx_modify( len_inp_memory, input_buff, nSCE_old + CPE_CHANNELS * nCPE_old, st_ivas->nSCE + CPE_CHANNELS * st_ivas->nCPE );
+ n_CoreCoder_existing = 0;
+ }
+ else
+ {
+ n_CoreCoder_existing = min( nchan_transport_real, nchan_transport_old_real );
+ }
+#else
n_CoreCoder_existing = min( st_ivas->nchan_transport, nchan_transport_old );
+#endif
/* destroy superfluous core-coder elements */
for ( sce_id = st_ivas->nSCE; sce_id < nSCE_old; sce_id++ )
@@ -167,7 +242,7 @@ ivas_error ivas_corecoder_enc_reconfig(
{
if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n )
{
- mvr2r( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory );
+ mvr2r( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, input_buff[( cpe_id - st_ivas->nCPE ) * CPE_CHANNELS + n], len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */
}
}
@@ -196,13 +271,21 @@ ivas_error ivas_corecoder_enc_reconfig(
for ( sce_id = 0; sce_id < nSCE_existing; sce_id++ )
{
copy_encoder_config( st_ivas, st_ivas->hSCE[sce_id]->hCoreCoder[0], 0 );
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hSCE[sce_id]->element_brate = brate_SCE;
+#else
st_ivas->hSCE[sce_id]->element_brate = ivas_total_brate / st_ivas->nchan_transport;
+#endif
st_ivas->hSCE[sce_id]->hCoreCoder[0]->total_brate = st_ivas->hSCE[sce_id]->element_brate; /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
}
for ( sce_id = nSCE_existing; sce_id < st_ivas->nSCE; sce_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = create_sce_enc( st_ivas, sce_id, brate_SCE ) ) != IVAS_ERR_OK )
+#else
if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_total_brate / st_ivas->nchan_transport ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -239,19 +322,44 @@ ivas_error ivas_corecoder_enc_reconfig(
for ( cpe_id = 0; cpe_id < nCPE_existing; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->element_brate = brate_CPE;
+#else
st_ivas->hCPE[cpe_id]->element_brate = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
-
+#endif
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
copy_encoder_config( st_ivas, st_ivas->hCPE[cpe_id]->hCoreCoder[n], 0 );
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->total_brate = st_ivas->hCPE[cpe_id]->element_brate / ( st_ivas->nCPE > 1 ? 1 : CPE_CHANNELS ); /* dummy initialization for getting right pointers initialization of input buffers in init_coder_ace_plus() */
+
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES;
+ if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) )
+ {
+ reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES );
+ }
+ else
+ {
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->last_ind = last_ind;
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = nb_bits_tot;
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->next_ind = next_ind;
+ }
+#endif
}
}
for ( cpe_id = nCPE_existing; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ if ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->hMcMasa->separateChannelEnabled )
+ {
+ st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT; // !!! VE: can it be set in McMASA config module rather than here?
+ }
+ if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_CPE ) ) != IVAS_ERR_OK )
+#else
if ( ( error = create_cpe_enc( st_ivas, cpe_id, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS ) ) != IVAS_ERR_OK )
+#endif
{
return error;
}
@@ -261,15 +369,20 @@ ivas_error ivas_corecoder_enc_reconfig(
{
if ( n_CoreCoder_existing > cpe_id * CPE_CHANNELS + n )
{
- mvr2r( input_buff[n], st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, len_inp_memory );
+ mvr2r( input_buff[n], st_ivas->hCPE[cpe_id]->hCoreCoder[0]->input_buff, len_inp_memory ); /* TODO VoiceAge: Please check if this should be hCoreCoder[n] */
}
}
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n + st_ivas->nSCE ) * MAX_NUM_INDICES;
+ if ( cpe_id * CPE_CHANNELS + n > 0 || ( st_ivas->mc_mode == MC_MODE_MCMASA && st_ivas->nSCE > 0 ) )
+#else
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list + ( cpe_id * CPE_CHANNELS + n ) * MAX_NUM_INDICES;
if ( cpe_id * CPE_CHANNELS + n > 0 )
+#endif
{
reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES );
}
@@ -288,6 +401,24 @@ ivas_error ivas_corecoder_enc_reconfig(
}
}
+#ifdef MC_BITRATE_SWITCHING
+ if ( last_mc_mode == MC_MODE_MCMASA && st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ /* restore modified transport signal */
+ if ( st_ivas->nSCE )
+ {
+ mvr2r( input_buff[0], st_ivas->hSCE[0]->hCoreCoder[0]->input_buff, len_inp_memory );
+ }
+ if ( st_ivas->nCPE )
+ {
+ for ( n = 0; n < CPE_CHANNELS; n++ )
+ {
+ mvr2r( input_buff[n + 1], st_ivas->hCPE[0]->hCoreCoder[n]->input_buff, len_inp_memory );
+ }
+ }
+ }
+#endif
+
if ( st_ivas->nCPE > 1 && nCPE_old <= 1 )
{
if ( nCPE_old == 1 )
@@ -339,7 +470,11 @@ ivas_error ivas_corecoder_enc_reconfig(
}
}
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata + st_ivas->nSCE * MAX_NUM_INDICES;
+#else
st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData->ind_list = ind_list_metadata;
+#endif
reset_indices_enc( st_ivas->hCPE[st_ivas->nCPE - 1]->hMetaData, MAX_BITS_METADATA );
for ( cpe_id = 0; cpe_id < st_ivas->nCPE - 1; cpe_id++ )
@@ -385,6 +520,9 @@ ivas_error ivas_corecoder_enc_reconfig(
st_ivas->hCPE[0]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
}
+#ifdef DEBUGGING
+ st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->mdct_stereo_mode_cmdl = hEncoderConfig->stereo_mode_cmdl;
+#endif
initMdctStereoEncData( st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct, hEncoderConfig->ivas_format, st_ivas->hCPE[st_ivas->nCPE - 1]->element_mode, st_ivas->hCPE[st_ivas->nCPE - 1]->element_brate, hEncoderConfig->max_bwidth, 0, NULL, 1 );
st_ivas->hCPE[st_ivas->nCPE - 1]->hStereoMdct->isSBAStereoMode = ( ( hEncoderConfig->ivas_format == SBA_FORMAT ) && ( st_ivas->nchan_transport == 2 ) );
}
diff --git a/lib_enc/ivas_cpe_enc.c b/lib_enc/ivas_cpe_enc.c
index 5735de87d0e9b97dbb8d28b4394a874213fff9f5..008599e36ba705bd262fa892c59897ddbba49f22 100644
--- a/lib_enc/ivas_cpe_enc.c
+++ b/lib_enc/ivas_cpe_enc.c
@@ -417,7 +417,11 @@ ivas_error ivas_cpe_enc(
{
dbgwrite( sts[0]->input - NS2SA( sts[0]->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, fname( debug_dir, "input_DMX", n, sts[n]->id_element, ENC ) );
}
+#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
+ dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode.cpe", 0, sts[0]->id_element, ENC ) );
+#else
dbgwrite( &hCPE->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, sts[0]->id_element, ENC ) );
+#endif
#endif
/*----------------------------------------------------------------*
@@ -795,7 +799,14 @@ ivas_error create_cpe_enc(
* Metadata: allocate and initialize
*-----------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ /* we need the meta data handle also if we init as MC_FORMAT/MCT since it might be needed
+ at a bit rate switch to ParamMC or McMASA and the metadata index list is only really reachable
+ in the ivas_init_encoder() function and has to be connected to the MD handle there */
+ if ( cpe_id == ( st_ivas->nCPE - 1 ) )
+#else
if ( !( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) && ( cpe_id == ( st_ivas->nCPE - 1 ) ) )
+#endif
{
if ( ( hCPE->hMetaData = (BSTR_ENC_HANDLE) count_malloc( sizeof( BSTR_ENC_DATA ) ) ) == NULL )
{
diff --git a/lib_enc/ivas_init_enc.c b/lib_enc/ivas_init_enc.c
index 8d3f78d1541d9ed074a2eb7d5d7300ff7dc667f6..41a071aab3f54b6e12123d2ad04eefb7cdd6f9fe 100644
--- a/lib_enc/ivas_init_enc.c
+++ b/lib_enc/ivas_init_enc.c
@@ -526,10 +526,14 @@ ivas_error ivas_init_encoder(
st_ivas->mc_mode = ivas_mc_mode_select( hEncoderConfig->mc_input_setup, ivas_total_brate );
hEncoderConfig->nchan_inp = ivas_mc_ls_setup_get_num_channels( hEncoderConfig->mc_input_setup );
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hLFE = NULL; // !!! VE: already done in ivas_initialize_handles_enc()
+#else
if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
{
return error;
}
+#endif
if ( st_ivas->mc_mode == MC_MODE_MCT )
{
@@ -545,14 +549,24 @@ ivas_error ivas_init_encoder(
for ( n = 0; n < CPE_CHANNELS; n++ )
{
+ /* we need the correct bitstream also for the LFE channel since it might become a proper coded channel when
+ switching to ParamMC and ind_list is only visible here, can't be done later */
+#ifndef MC_BITRATE_SWITCHING
if ( cpe_id * CPE_CHANNELS + n == LFE_CHANNEL )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->nb_bits_tot = 0;
continue;
}
+#endif
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr->ind_list = ind_list[cpe_id * CPE_CHANNELS + n];
reset_indices_enc( st_ivas->hCPE[cpe_id]->hCoreCoder[n]->hBstr, MAX_NUM_INDICES );
}
+ /* Metadata only initialized for the last CPE index*/
+ if ( cpe_id == st_ivas->nCPE - 1 )
+ {
+ st_ivas->hCPE[cpe_id]->hMetaData->ind_list = ind_list_metadata[st_ivas->nSCE];
+ reset_indices_enc( st_ivas->hCPE[cpe_id]->hMetaData, MAX_BITS_METADATA );
+ }
}
if ( ( error = create_mct_enc( st_ivas ) ) != IVAS_ERR_OK )
@@ -560,6 +574,13 @@ ivas_error ivas_init_encoder(
return error;
}
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#endif
+
st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( st_ivas->hEncoderConfig->mc_input_setup );
}
else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
@@ -576,6 +597,7 @@ ivas_error ivas_init_encoder(
return error;
}
+
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
{
@@ -601,6 +623,10 @@ ivas_error ivas_init_encoder(
}
else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
{
+#ifdef MC_BITRATE_SWITCHING
+ int32_t brate_sce, brate_cpe;
+#endif
+
ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( hEncoderConfig->element_mode_init ), ivas_total_brate );
if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
@@ -618,8 +644,18 @@ ivas_error ivas_init_encoder(
return error;
}
+#ifdef MC_BITRATE_SWITCHING
+ ivas_mcmasa_split_brate( st_ivas->hMcMasa->separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe );
+#endif
+
for ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ if ( ( error = create_sce_enc( st_ivas, sce_id, brate_sce ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#else
if ( st_ivas->hMcMasa->separateChannelEnabled )
{
if ( ( error = create_sce_enc( st_ivas, sce_id, ivas_mcmasa_mono_brate( ivas_total_brate ) ) ) != IVAS_ERR_OK )
@@ -634,6 +670,7 @@ ivas_error ivas_init_encoder(
return error;
}
}
+#endif
/* prepare bitstream buffers */
st_ivas->hSCE[sce_id]->hCoreCoder[0]->hBstr->ind_list = ind_list[sce_id];
@@ -645,6 +682,14 @@ ivas_error ivas_init_encoder(
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+
+ if ( ( error = create_cpe_enc( st_ivas, cpe_id, brate_cpe ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+#else
if ( st_ivas->hMcMasa->separateChannelEnabled )
{
hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
@@ -661,6 +706,7 @@ ivas_error ivas_init_encoder(
return error;
}
}
+#endif
/* prepare bitstream buffers */
for ( n = 0; n < CPE_CHANNELS; n++ )
diff --git a/lib_enc/ivas_ism_param_enc.c b/lib_enc/ivas_ism_param_enc.c
index 8dcdef30b50c3169fa74697896f5f0372dee114e..6574daf201a9fefdbae6e6bd20e9d6c8ed647ebe 100644
--- a/lib_enc/ivas_ism_param_enc.c
+++ b/lib_enc/ivas_ism_param_enc.c
@@ -415,6 +415,9 @@ ivas_error ivas_ism_enc_config(
ivas_error error;
ISM_MODE last_ism_mode;
int16_t nchan_transport_old;
+#ifdef MC_BITRATE_SWITCHING
+ int16_t nSCE_old, nCPE_old;
+#endif
error = IVAS_ERR_OK;
last_ism_mode = st_ivas->ism_mode;
@@ -439,12 +442,19 @@ ivas_error ivas_ism_enc_config(
st_ivas->nchan_transport = st_ivas->hEncoderConfig->nchan_inp;
}
+#ifdef MC_BITRATE_SWITCHING
+ nCPE_old = st_ivas->nCPE;
+ nSCE_old = st_ivas->nSCE;
+#endif
st_ivas->nSCE = st_ivas->nchan_transport;
st_ivas->nCPE = 0;
ivas_ism_config( st_ivas->hEncoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->hEncoderConfig->nchan_inp, NULL, NULL, NULL, element_brate_tmp, NULL, NULL );
-
+#ifdef MC_BITRATE_SWITCHING
+ ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport, ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE );
+#else
ivas_corecoder_enc_reconfig( st_ivas, nchan_transport_old, 0, nchan_transport_old );
+#endif
if ( st_ivas->ism_mode == ISM_MODE_PARAM && last_ism_mode == ISM_MODE_DISC )
{
diff --git a/lib_enc/ivas_mc_param_enc.c b/lib_enc/ivas_mc_param_enc.c
index af7a48a80b2b585d3f26fd34f4a5611436ccb60b..1f0d1334d595917c4443618f94973421e000e2ab 100644
--- a/lib_enc/ivas_mc_param_enc.c
+++ b/lib_enc/ivas_mc_param_enc.c
@@ -75,6 +75,7 @@ static void ivas_param_mc_encode_parameter( int16_t *idx_in, HANDLE_IVAS_PARAM_M
static void ivas_param_mc_range_encoder( const int16_t *seq_in, const int16_t num_symbols, const uint16_t *cum_freq, const uint16_t *sym_freq, const uint16_t tot_shift, const int16_t max_nb_bits, uint16_t *bit_buffer, int16_t *bit_pos );
+
/*-------------------------------------------------------------------------
* ivas_param_mc_enc_open()
*
@@ -219,6 +220,143 @@ ivas_error ivas_param_mc_enc_open(
}
+#ifdef MC_BITRATE_SWITCHING
+/*-------------------------------------------------------------------------
+ * ivas_param_mc_enc_reconfig()
+ *
+ * Reconfigure Parametric MC encoder
+ *------------------------------------------------------------------------*/
+
+ivas_error ivas_param_mc_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder handle */
+)
+{
+ int16_t i, k, l;
+ PARAM_MC_ENC_HANDLE hParamMC;
+ uint16_t config_index;
+ MC_LS_SETUP mc_input_setup;
+ int16_t max_bwidth;
+ int32_t input_Fs, ivas_total_brate;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+
+ mc_input_setup = st_ivas->hEncoderConfig->mc_input_setup;
+ max_bwidth = st_ivas->hEncoderConfig->max_bwidth;
+ input_Fs = st_ivas->hEncoderConfig->input_Fs;
+ ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate;
+ hParamMC = st_ivas->hParamMC;
+
+ /* Preparing Config */
+ st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_input_setup );
+
+ /* get configuration index */
+ config_index = ivas_param_mc_get_configuration_index( mc_input_setup, ivas_total_brate );
+
+ /* set core coder dependent on the number of transport channels */
+ switch ( st_ivas->nchan_transport )
+ {
+ case 4:
+ case 3:
+ st_ivas->nCPE = 2;
+ st_ivas->nSCE = 0;
+ st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ break;
+ case 2:
+ st_ivas->nCPE = 1;
+ st_ivas->nSCE = 0;
+ st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ break;
+#ifdef DEBUGGING
+ default:
+ assert( 0 && "Number of transport channels not supported by ParamMC!\n" );
+#endif
+ }
+
+ /* get dmx factors */
+ hParamMC->dmx_factors = ivas_param_mc_conf[config_index].dmx_fac;
+
+
+ /* deallocate the full icc map, gets newly allocated in the metadata open function */
+ for ( i = 0; i < 2; i++ )
+ {
+#ifdef DEBUGGING
+ assert( hParamMC->hMetadataPMC.icc_map_full[i] != NULL );
+#endif
+ if ( hParamMC->hMetadataPMC.icc_map_full[i] != NULL )
+ {
+ count_free( hParamMC->hMetadataPMC.icc_map_full[i] );
+ hParamMC->hMetadataPMC.icc_map_full[i] = NULL;
+ }
+ }
+
+ /* open/init parameter coding */
+ ivas_param_mc_metadata_open( mc_input_setup, hParamMC->lfe_index, ivas_total_brate, &hParamMC->hMetadataPMC );
+
+ /* init icc index states */
+ for ( i = 0; i < PARAM_MC_PARAMETER_FRAMES; i++ )
+ {
+ set_s( hParamMC->icc_map_index[i], -1, PARAM_MC_SZ_ICC_MAP );
+
+ for ( l = 0; l < hParamMC->hMetadataPMC.icc_mapping_conf->icc_map_size_lfe; l++ )
+ {
+ for ( k = 0; k < hParamMC->hMetadataPMC.icc_map_size_full; k++ )
+ {
+ if ( hParamMC->hMetadataPMC.icc_mapping[i][l][0] == hParamMC->hMetadataPMC.icc_map_full[0][k] && hParamMC->hMetadataPMC.icc_mapping[i][l][1] == hParamMC->hMetadataPMC.icc_map_full[1][k] )
+ {
+ hParamMC->icc_map_index[i][l] = k;
+ }
+ }
+ }
+ }
+
+ /* Band Grouping */
+ if ( hParamMC->hMetadataPMC.num_parameter_bands == 20 )
+ {
+ mvs2s( param_mc_band_grouping_20, hParamMC->band_grouping, 20 + 1 );
+ }
+ else if ( hParamMC->hMetadataPMC.num_parameter_bands == 14 )
+ {
+ mvs2s( param_mc_band_grouping_14, hParamMC->band_grouping, 14 + 1 );
+ }
+ else if ( hParamMC->hMetadataPMC.num_parameter_bands == 10 )
+ {
+ mvs2s( param_mc_band_grouping_10, hParamMC->band_grouping, 10 + 1 );
+ }
+ else
+ {
+ assert( 0 && "nbands must be 20, 14, or 10!" );
+ }
+
+ /* set max parameter band for abs cov */
+ i = 0;
+ while ( hParamMC->band_grouping[i] <= PARAM_MC_MAX_BAND_ABS_COV_ENC )
+ {
+ hParamMC->max_param_band_abs_cov = ( i++ );
+ }
+
+ /* parameter band grouping: 60 band CLDFB to 240 band MDFT resolution */
+ for ( i = 0; i < hParamMC->hMetadataPMC.num_parameter_bands + 1; i++ )
+ {
+ hParamMC->band_grouping[i] *= CLDFB_TO_MDFT_FAC;
+ }
+
+ /* set correct coded band width */
+ hParamMC->hMetadataPMC.coded_bwidth = max_bwidth;
+ hParamMC->hMetadataPMC.last_coded_bwidth = max_bwidth;
+ ivas_param_mc_set_coded_bands( &hParamMC->hMetadataPMC );
+
+ /* initialize offset for transient detection */
+ hParamMC->transient_detector_delay = ( NSUBBLOCKS_SHIFT + 1 ) + NSUBBLOCKS + 1 - (int16_t) ceilf( (float) NS2SA( input_Fs, DELAY_DIRAC_ENC_CMP_NS ) / (float) NS2SA( input_Fs, 2 * DIRAC_SLOT_NS ) );
+
+ /* Init total/dmx ener factors */
+ set_f( hParamMC->ener_fac, 0.0f, PARAM_MC_MAX_PARAMETER_BANDS );
+
+ return error;
+}
+#endif
+
+
/*-------------------------------------------------------------------------
* ivas_param_mc_enc_close()
*
diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c
index 8d127e17d5fd20311e32a9d52e0cb736c945b899..4622864e088c9a30c7c8be65b9f288315853bb62 100644
--- a/lib_enc/ivas_mcmasa_enc.c
+++ b/lib_enc/ivas_mcmasa_enc.c
@@ -396,6 +396,52 @@ ivas_error ivas_mcmasa_enc_open(
}
+#ifdef MC_BITRATE_SWITCHING
+/*-------------------------------------------------------------------------
+ * ivas_mcmasa_enc_reconfig()
+ *
+ * Reconfigure McMASA encoder
+ *------------------------------------------------------------------------*/
+
+ivas_error ivas_mcmasa_enc_reconfig(
+ Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
+)
+{
+ int32_t ivas_total_brate;
+ ivas_error error;
+
+ error = IVAS_ERR_OK;
+
+ ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate;
+
+ if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate )
+ {
+ /* bitrate changed, may need to do something */
+
+ /* brute-force solution: close McMASA and re-instantiate with new settings */
+ ivas_masa_enc_close( st_ivas->hMasa, st_ivas->nchan_transport, st_ivas->hEncoderConfig->ivas_format );
+ ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs );
+
+ /* Determine if to separate some channels from the analysis */
+ ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), ivas_total_brate );
+
+ if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( error = ivas_mcmasa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /* core SCE, CPE reconfiguration happens later */
+ }
+
+ return error;
+}
+#endif
+
/*--------------------------------------------------------------------------*
* ivas_mcmasa_enc_close()
*
@@ -1151,6 +1197,88 @@ void ivas_mcmasa_param_est_enc(
}
+/*--------------------------------------------------------------------------*
+ * ivas_mcmasa_dmx_modify()
+ *
+ *
+ *--------------------------------------------------------------------------*/
+
+#ifdef MC_BITRATE_SWITCHING
+void ivas_mcmasa_dmx_modify(
+ const int16_t n_samples, /* i : input frame length in samples */
+ float dmx[][L_FRAME48k + NS2SA( 48000, IVAS_FB_ENC_DELAY_NS )], /* i/o: downmix signal to be transformed into another format. TODO: buffer size into define? */
+ const int16_t n_chnls_dmx_old, /* i : number of downmix channels in the old format */
+ const int16_t n_chnls_dmx_new ) /* i : number of downmix channels in the target format */
+{
+ /* assumed data ordering in **dmx: [sce][cpe_chnl0][cpe_chnl1], i.e., [c][l][r] */
+ int16_t i;
+
+ assert( ( n_chnls_dmx_old == 1 || n_chnls_dmx_old == 2 || n_chnls_dmx_old == 3 ) && "Input downmix may contain only 1-3 channels." );
+ assert( ( n_chnls_dmx_new == 1 || n_chnls_dmx_new == 2 || n_chnls_dmx_new == 3 ) && "Output downmix may contain only 1-3 channels." );
+
+ if ( n_chnls_dmx_old == n_chnls_dmx_new )
+ {
+ /* same dmx layout -> nothing to do */
+ return;
+ }
+
+ if ( n_chnls_dmx_old == 1 )
+ {
+ /* split mono energy into identical channels */
+ for ( i = 0; i < n_samples; i++ )
+ {
+ if ( n_chnls_dmx_new == 2 )
+ {
+ dmx[1][i] = dmx[0][i] * INV_SQRT2;
+ dmx[2][i] = dmx[1][i];
+ }
+ else if ( n_chnls_dmx_new == 3 )
+ {
+ dmx[0][i] = dmx[0][i] * INV_SQRT3;
+ }
+ }
+ }
+ else if ( n_chnls_dmx_old == 2 )
+ {
+ for ( i = 0; i < n_samples; i++ )
+ {
+ if ( n_chnls_dmx_new == 1 )
+ {
+ /* sum l and r */
+ dmx[0][i] = dmx[1][i] + dmx[2][i];
+ }
+ else if ( n_chnls_dmx_new == 3 )
+ {
+ dmx[0][i] = 0.5f * ( dmx[1][i] + dmx[2][i] );
+ dmx[1][i] = dmx[1][i] - dmx[0][i];
+ dmx[2][i] = dmx[2][i] - dmx[0][i];
+ }
+ }
+ }
+ else if ( n_chnls_dmx_old == 3 )
+ {
+ for ( i = 0; i < n_samples; i++ )
+ {
+ if ( n_chnls_dmx_new == 1 )
+ {
+ /* sum all channels */
+ dmx[0][i] = dmx[0][i] + dmx[1][i] + dmx[2][i];
+ }
+ else if ( n_chnls_dmx_new == 2 )
+ {
+ /* mix center into sides */
+ dmx[0][i] *= INV_SQRT2;
+ dmx[1][i] += dmx[0][i];
+ dmx[2][i] += dmx[0][i];
+ }
+ }
+ }
+
+ return;
+}
+#endif
+
+
/*--------------------------------------------------------------------------*
* Local functions
*--------------------------------------------------------------------------*/
@@ -1263,6 +1391,7 @@ static void ivas_mcmasa_dmx(
/* Compute covariance matrix, i.e., xT * conj(x), and accumulate to the output */
+
static void compute_cov_mtx(
float sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, real, s[ch][freq] */
float si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Input matrix, imag, s[ch][freq] */
diff --git a/lib_enc/ivas_mct_enc.c b/lib_enc/ivas_mct_enc.c
old mode 100644
new mode 100755
index 0e9eaa1a5a7d5ff84ccd2c7364c21f6e5c7a81c8..3fa3ad04bdd84817d1f756275cac4ac8611d321a
--- a/lib_enc/ivas_mct_enc.c
+++ b/lib_enc/ivas_mct_enc.c
@@ -44,6 +44,15 @@
#include "wmops.h"
+#ifdef MC_BITRATE_SWITCHING
+/*-----------------------------------------------------------------------*
+ * Local function prototypes
+ *-----------------------------------------------------------------------*/
+
+static ivas_error ivas_mc_enc_reconfig( Encoder_Struct *st_ivas, const int16_t last_mc_mode );
+#endif
+
+
/*-------------------------------------------------------------------*
* set_mct_enc_params()
*
@@ -167,7 +176,13 @@ ivas_error ivas_mct_enc(
/* joint MCT encoding */
ivas_mct_core_enc( ivas_format, hMCT, st_ivas->hCPE, hMCT->nchan_out_woLFE + hMCT->num_lfe, ivas_total_brate, switch_bw,
- ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0, st_ivas->hEncoderConfig->sba_order );
+#ifdef MC_BITRATE_SWITCHING
+ ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCT ) ? (int16_t) st_ivas->hLFE->lfe_bits : 0
+#else
+ ivas_format == MC_FORMAT ? (int16_t) st_ivas->hLFE->lfe_bits : 0
+#endif
+ ,
+ st_ivas->hEncoderConfig->sba_order );
/* Spectrum quantization and coding */
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
@@ -180,6 +195,10 @@ ivas_error ivas_mct_enc(
for ( n = 0; n < CPE_CHANNELS; n++ )
{
mvr2r( hCPE->hCoreCoder[n]->input, hCPE->hCoreCoder[n]->old_input_signal, input_frame );
+#ifdef MC_BITRATE_SWITCHING
+ /* common encoder updates */
+ updt_enc_common( hCPE->hCoreCoder[n] );
+#endif
}
}
@@ -275,6 +294,7 @@ ivas_error create_mct_enc(
for ( n = 0; n < max_blocks; n++ )
{
+
assert( st_ivas->hEncoderConfig->element_mode_init == IVAS_CPE_MDCT && "MCT is not supported for other stereo modes" );
if ( ( hMCT->hBlockData[n] = (MCT_BLOCK_DATA_HANDLE) count_malloc( sizeof( MCT_BLOCK_DATA ) ) ) == NULL )
@@ -352,6 +372,13 @@ ivas_error mct_enc_reconfigure(
hMCT->nchan_out_woLFE = st_ivas->hEncoderConfig->nchan_inp - 1; /* LFE channel is coded separately */
hMCT->num_lfe = TRUE;
}
+#ifdef MC_BITRATE_SWITCHING
+ else if ( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC )
+ {
+ hMCT->nchan_out_woLFE = ivas_param_mc_getNumTransportChannels( ivas_total_brate, st_ivas->hEncoderConfig->mc_input_setup );
+ hMCT->num_lfe = FALSE;
+ }
+#endif
else if ( ivas_format == SBA_FORMAT )
{
hMCT->nchan_out_woLFE = st_ivas->nchan_transport;
@@ -368,6 +395,9 @@ ivas_error mct_enc_reconfigure(
/* indicate LFE for appropriate core-coder channel */
for ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
{
+#ifdef MC_BITRATE_SWITCHING
+ st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate;
+#endif
for ( n = 0; n < CPE_CHANNELS; n++ )
{
st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
@@ -540,9 +570,266 @@ ivas_error ivas_mc_enc_config(
/* MC format switching */
if ( st_ivas->hEncoderConfig->last_ivas_total_brate != st_ivas->hEncoderConfig->ivas_total_brate || st_ivas->mc_mode != last_mc_mode )
{
- /*ivas_mc_enc_reconfigure( st_ivas );*/
+#ifdef MC_BITRATE_SWITCHING
+ ivas_mc_enc_reconfig( st_ivas, last_mc_mode );
+#else
return IVAS_ERROR( IVAS_ERR_RECONFIGURE_NOT_SUPPORTED, "Error: MC format switching not supported yet!!!\n\n" );
+#endif
}
return error;
}
+
+
+#ifdef MC_BITRATE_SWITCHING
+/*-------------------------------------------------------------------------
+ * ivas_mc_enc_reconfig()
+ *
+ * Reconfigure the MC format encoder
+ *-------------------------------------------------------------------------*/
+
+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 */
+)
+{
+ int16_t nchan_transport_old, nSCE_old, nCPE_old;
+ ivas_error error;
+ int32_t new_brate_SCE, new_brate_CPE;
+
+ error = IVAS_ERR_OK;
+
+ nchan_transport_old = st_ivas->nchan_transport;
+ nSCE_old = st_ivas->nSCE;
+ nCPE_old = st_ivas->nCPE;
+
+ /*-----------------------------------------------------------------*
+ * Reconfigure MC modules
+ *-----------------------------------------------------------------*/
+
+ if ( st_ivas->mc_mode == MC_MODE_MCT )
+ {
+ st_ivas->nSCE = 0;
+ st_ivas->nCPE = st_ivas->hEncoderConfig->nchan_inp / 2;
+
+ st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( st_ivas->hEncoderConfig->mc_input_setup );
+
+ if ( last_mc_mode != MC_MODE_MCT )
+ {
+ /* create LFE handle */
+ if ( ( error = ivas_create_lfe_enc( &st_ivas->hLFE, st_ivas->hEncoderConfig->input_Fs ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ /*De-allocate handles for other MC modes*/
+ if ( st_ivas->hParamMC != NULL )
+ {
+ ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs );
+ st_ivas->hParamMC = NULL;
+ }
+
+ /* De-allocate McMasa-related handles */
+ if ( st_ivas->hMcMasa != NULL )
+ {
+ ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs );
+ st_ivas->hMcMasa = NULL;
+ }
+
+ if ( st_ivas->hMasa != NULL )
+ {
+ ivas_masa_enc_close( st_ivas->hMasa, nchan_transport_old, MC_FORMAT );
+ st_ivas->hMasa = NULL;
+ }
+
+ if ( st_ivas->hQMetaData != NULL )
+ {
+ ivas_qmetadata_close( &st_ivas->hQMetaData );
+ st_ivas->hQMetaData = NULL;
+ }
+ }
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
+ {
+ if ( last_mc_mode != MC_MODE_PARAMMC )
+ {
+ if ( ( error = ivas_param_mc_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ ivas_param_mc_enc_reconfig( st_ivas );
+ }
+
+ /* De-allocate McMasa-related handles */
+ if ( st_ivas->hMcMasa != NULL )
+ {
+ ivas_mcmasa_enc_close( st_ivas->hMcMasa, st_ivas->hEncoderConfig->input_Fs );
+ st_ivas->hMcMasa = NULL;
+ }
+ if ( st_ivas->hMasa != NULL )
+ {
+ ivas_masa_enc_close( st_ivas->hMasa, nchan_transport_old, MC_FORMAT );
+ st_ivas->hMasa = NULL;
+ }
+
+ if ( st_ivas->hQMetaData != NULL )
+ {
+ ivas_qmetadata_close( &st_ivas->hQMetaData );
+ st_ivas->hQMetaData = NULL;
+ }
+
+ /* De-allocate MCT handle if last mode was MCT */
+ if ( last_mc_mode == MC_MODE_MCT && st_ivas->hMCT != NULL && st_ivas->nchan_transport <= CPE_CHANNELS )
+ {
+ ivas_mct_enc_close( st_ivas->hMCT );
+ st_ivas->hMCT = NULL;
+ }
+
+ if ( last_mc_mode == MC_MODE_MCT && st_ivas->hLFE != NULL )
+ {
+ /* LFE handle */
+ ivas_lfe_enc_close( st_ivas->hLFE );
+ st_ivas->hLFE = NULL;
+ }
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
+ {
+ if ( last_mc_mode != MC_MODE_MCMASA )
+ {
+ ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->hEncoderConfig->element_mode_init ), st_ivas->hEncoderConfig->ivas_total_brate );
+
+ if ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( error = ivas_masa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ if ( ( error = ivas_mcmasa_enc_open( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+ else
+ {
+ /* reconfigure McMASA instance */
+ if ( ( error = ivas_mcmasa_enc_reconfig( st_ivas ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+ }
+
+ if ( st_ivas->hParamMC != NULL )
+ {
+ ivas_param_mc_enc_close( st_ivas->hParamMC, st_ivas->hEncoderConfig->input_Fs );
+ st_ivas->hParamMC = NULL;
+ }
+
+ if ( last_mc_mode == MC_MODE_MCT )
+ {
+ /* LFE handle */
+ if ( st_ivas->hLFE != NULL )
+ {
+ ivas_lfe_enc_close( st_ivas->hLFE );
+ st_ivas->hLFE = NULL;
+ }
+ if ( st_ivas->hMCT != NULL )
+ {
+ ivas_mct_enc_close( st_ivas->hMCT );
+ st_ivas->hMCT = NULL;
+ }
+ }
+ }
+
+ if ( st_ivas->mc_mode != MC_MODE_MCMASA )
+ {
+ if ( st_ivas->nchan_transport == 1 )
+ {
+ st_ivas->hEncoderConfig->element_mode_init = IVAS_SCE;
+ }
+ else
+ {
+ st_ivas->hEncoderConfig->element_mode_init = IVAS_CPE_MDCT;
+ }
+ }
+
+ /*-----------------------------------------------------------------*
+ * Reconfigure core coder
+ *-----------------------------------------------------------------*/
+
+ /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1
+ and might have IGF and TranDet static memory not allocated and the bit stream index list not set,
+ set correct mct_chan_mode and init missing static mem
+ do it here since it is _very_ MC specific */
+ if ( last_mc_mode == MC_MODE_MCT && st_ivas->mc_mode == MC_MODE_PARAMMC && st_ivas->nchan_transport > CPE_CHANNELS )
+ {
+ Encoder_State *st = st_ivas->hCPE[1]->hCoreCoder[1];
+
+ if ( st_ivas->nchan_transport == 3 )
+ {
+ st->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
+ }
+ else
+ {
+ st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
+ }
+
+ if ( st->hTranDet == NULL )
+ {
+ if ( ( st->hTranDet = (TRAN_DET_HANDLE) count_malloc( sizeof( TRAN_DET_DATA ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Transient Detection\n" ) );
+ }
+
+ InitTransientDetection( (int16_t) ( st->input_Fs / FRAMES_PER_SEC ), NS2SA( st->input_Fs, DELAY_FIR_RESAMPL_NS ), st->hTranDet, 0 );
+ }
+
+ if ( st->hIGFEnc == NULL )
+ {
+ if ( ( st->hIGFEnc = (IGF_ENC_INSTANCE_HANDLE) count_malloc( sizeof( IGF_ENC_INSTANCE ) ) ) == NULL )
+ {
+ return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hIGFEnc\n" ) );
+ }
+ }
+
+ st->igf = getIgfPresent( st->element_mode, st->total_brate, st->bwidth, st->rf_mode, st->mct_chan_mode );
+ /* set last core to TCX20 */
+ st->last_core = TCX_20_CORE;
+ }
+ else if ( last_mc_mode == MC_MODE_PARAMMC && st_ivas->mc_mode == MC_MODE_MCT && nchan_transport_old > 2 )
+ {
+#ifdef DEBUGGING
+ assert( st_ivas->hCPE[1] != NULL );
+#endif
+ st_ivas->hCPE[1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_LFE;
+ }
+
+ 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 );
+ }
+ else if ( st_ivas->mc_mode == MC_MODE_MCT )
+ {
+ new_brate_SCE = 0;
+ new_brate_CPE = ( st_ivas->hEncoderConfig->ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS;
+ }
+ else
+ {
+ new_brate_SCE = 0; /*st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport;*/
+ new_brate_CPE = ( st_ivas->hEncoderConfig->ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS;
+ }
+
+ if ( ( error = ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, new_brate_SCE, new_brate_CPE, last_mc_mode ) ) != IVAS_ERR_OK )
+ {
+ return error;
+ }
+
+ return error;
+}
+#endif
diff --git a/lib_enc/ivas_mdct_core_enc.c b/lib_enc/ivas_mdct_core_enc.c
old mode 100644
new mode 100755
index a999681ab48948089aca55ec4ae7c00f2f6dbba9..12ccb0c4fe6f492c427f4674b83e0c6a26d7ce4c
--- a/lib_enc/ivas_mdct_core_enc.c
+++ b/lib_enc/ivas_mdct_core_enc.c
@@ -894,7 +894,11 @@ void ivas_mdct_core_whitening_enc(
}
/* set low br mode, if possible. Can later be discarded, depending on the stereo mode used for SNS parameter decoding */
+#ifdef MC_BITRATE_SWITCHING
+ if ( hCPE->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) )
+#else
if ( hCPE->element_brate == IVAS_48k && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) )
+#endif
{
sns_low_br_mode = !sts[0]->sp_aud_decision0;
}
@@ -1110,7 +1114,11 @@ void ivas_mdct_core_whitening_enc(
{
push_next_indice( hBstr, param_lpc[0][0] >> 1, 1 );
+#ifdef MC_BITRATE_SWITCHING
+ if ( st->element_brate == IVAS_48k && !( ( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) || sts[1]->mct_chan_mode == MCT_CHAN_MODE_LFE ) )
+#else
if ( st->element_brate == IVAS_48k && !( sts[0]->core == TCX_20 && sts[1]->core == TCX_20 ) )
+#endif
{
/* write classifier decision to signal low br mode for SNS encoding, for all other configs, low_br mode is not possible */
push_next_indice( hBstr, sns_low_br_mode, 1 );
diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c
index 04aba97747c614c2803259e837c93055247e8eca..ca4d309c5e822ec814549d39e26c119c0bc545a9 100644
--- a/lib_enc/ivas_sba_enc.c
+++ b/lib_enc/ivas_sba_enc.c
@@ -396,7 +396,11 @@ ivas_error ivas_sba_enc_reconfigure(
* Allocate, initalize, and configure SCE/CPE/MCT handles
*-----------------------------------------------------------------*/
+#ifdef MC_BITRATE_SWITCHING
+ ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, ivas_total_brate / st_ivas->nchan_transport, ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS, MC_MODE_NONE );
+#else
ivas_corecoder_enc_reconfig( st_ivas, nSCE_old, nCPE_old, nchan_transport_old );
+#endif
}
return error;
diff --git a/lib_enc/ivas_sce_enc.c b/lib_enc/ivas_sce_enc.c
index 428dbb95c16cc51c18e09cd1fa50d11e9f73d8cb..cdd37d8ece0415ab607036f9582d57f11defd3b4 100644
--- a/lib_enc/ivas_sce_enc.c
+++ b/lib_enc/ivas_sce_enc.c
@@ -174,7 +174,11 @@ ivas_error ivas_sce_enc(
#ifdef DEBUG_MODE_INFO
dbgwrite( st->input - NS2SA( st->input_Fs, ACELP_LOOK_NS ), sizeof( float ), input_frame, 1, "res/input_DMX" );
+#ifdef MC_BITRATE_SWITCHING // !!! VE: Can it be removed?
+ dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode.sce", 0, st->id_element, ENC ) );
+#else
dbgwrite( &st->element_mode, sizeof( int16_t ), 1, input_frame, fname( debug_dir, "element_mode", 0, st->id_element, ENC ) );
+#endif
#endif
/*----------------------------------------------------------------*
diff --git a/lib_enc/updt_enc.c b/lib_enc/updt_enc.c
index c6663895e0ebaba6da51595189782b6cf66192a2..37f50c8cefe9dd351c770b1057e879080ef851c6 100644
--- a/lib_enc/updt_enc.c
+++ b/lib_enc/updt_enc.c
@@ -297,8 +297,11 @@ void updt_IO_switch_enc(
*-------------------------------------------------------------------*/
void updt_enc_common(
- Encoder_State *st, /* i/o: encoder state structure */
- const float Etot /* i : total energy */
+ Encoder_State *st /* i/o: encoder state structure */
+#ifndef MC_BITRATE_SWITCHING
+ ,
+ const float Etot /* i : total energy */
+#endif
)
{
/*---------------------------------------------------------------------*
@@ -316,7 +319,9 @@ void updt_enc_common(
st->last_extl = st->extl;
st->last_input_bwidth = st->input_bwidth;
st->last_bwidth = st->bwidth;
+#ifndef MC_BITRATE_SWITCHING
st->hNoiseEst->Etot_last = Etot;
+#endif
st->last_coder_type_raw = st->coder_type_raw;
if ( st->core_brate > SID_2k40 && st->hDtxEnc != NULL )
diff --git a/scripts/config/ivas_modes.json b/scripts/config/ivas_modes.json
index ab964a0752fbeedbaa84f49b84638bdf7318be2d..5eabeae024dadadb69f1efce29905234f711e7b5 100644
--- a/scripts/config/ivas_modes.json
+++ b/scripts/config/ivas_modes.json
@@ -1639,6 +1639,161 @@
512000
]
}
+ },
+ "MC_5_1_b{bitrate}_{bandwidth}_rs": {
+ "encmodeoption": [
+ "-mc",
+ "5_1"
+ ],
+ "encoptions": [
+ "-max_band",
+ "{bandwidth}"
+ ],
+ "dec": {
+ "5_1": []
+ },
+ "in_config": "5_1",
+ "table_name": "MC 5_1@{table_bitrate} kbps RS {bandwidth}",
+ "nummetadata": 0,
+ "metadatafilenames": [],
+ "rs": true,
+ "amr": false,
+ "mono": false,
+ "bitrates": {
+ "wb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "swb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "fb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ }
+ }
+ },
+ "MC_7_1_b{bitrate}_{bandwidth}_rs": {
+ "encmodeoption": [
+ "-mc",
+ "7_1"
+ ],
+ "encoptions": [
+ "-max_band",
+ "{bandwidth}"
+ ],
+ "dec": {
+ "7_1": []
+ },
+ "in_config": "7_1",
+ "table_name": "MC 7_1@{table_bitrate} kbps RS {bandwidth}",
+ "nummetadata": 0,
+ "metadatafilenames": [],
+ "rs": true,
+ "amr": false,
+ "mono": false,
+ "bitrates": {
+ "wb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "swb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "fb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ }
+ }
+ },
+ "MC_5_1_2_b{bitrate}_{bandwidth}_rs": {
+ "encmodeoption": [
+ "-mc",
+ "5_1_2"
+ ],
+ "encoptions": [
+ "-max_band",
+ "{bandwidth}"
+ ],
+ "dec": {
+ "5_1_2": []
+ },
+ "in_config": "5_1_2",
+ "table_name": "MC 5_1_2@{table_bitrate} kbps RS {bandwidth}",
+ "nummetadata": 0,
+ "metadatafilenames": [],
+ "rs": true,
+ "amr": false,
+ "mono": false,
+ "bitrates": {
+ "wb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "swb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "fb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ }
+ }
+ },
+ "MC_5_1_4_b{bitrate}_{bandwidth}_rs": {
+ "encmodeoption": [
+ "-mc",
+ "5_1_4"
+ ],
+ "encoptions": [
+ "-max_band",
+ "{bandwidth}"
+ ],
+ "dec": {
+ "5_1_4": []
+ },
+ "in_config": "5_1_4",
+ "table_name": "MC 5_1_4@{table_bitrate} kbps RS {bandwidth}",
+ "nummetadata": 0,
+ "metadatafilenames": [],
+ "rs": true,
+ "amr": false,
+ "mono": false,
+ "bitrates": {
+ "wb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "swb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "fb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ }
+ }
+ },
+ "MC_7_1_4_b{bitrate}_{bandwidth}_rs": {
+ "encmodeoption": [
+ "-mc",
+ "7_1_4"
+ ],
+ "encoptions": [
+ "-max_band",
+ "{bandwidth}"
+ ],
+ "dec": {
+ "7_1_4": []
+ },
+ "in_config": "7_1_4",
+ "table_name": "MC 7_1_4@{table_bitrate} kbps RS {bandwidth}",
+ "nummetadata": 0,
+ "metadatafilenames": [],
+ "rs": true,
+ "amr": false,
+ "mono": false,
+ "bitrates": {
+ "wb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "swb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ },
+ "fb": {
+ "all": "{sw_files_path}/sw_13k2_512k.bin"
+ }
+ }
}
},
"ISM1": {
diff --git a/scripts/pyivastest/IvasScriptsCommon.py b/scripts/pyivastest/IvasScriptsCommon.py
index 46e6a2f4a83b285a8e0c9db851c11c3691dc538c..b8dba704e8fef15a2d5493a99ee66dfc672e8096 100644
--- a/scripts/pyivastest/IvasScriptsCommon.py
+++ b/scripts/pyivastest/IvasScriptsCommon.py
@@ -546,7 +546,10 @@ def runner_setup(runner, args):
if "fer_file" in args.keys() or "ber_file" in args.keys():
# assert that the eid-xor tool is there
- eid_xor_path = os.path.join(runner.config["utilPath"], "eid-xor")
+ bin_ext=""
+ if platform.system() == "Windows":
+ bin_ext=".exe"
+ eid_xor_path = os.path.join(runner.config["utilPath"], "".join(["eid-xor", bin_ext]))
if not os.path.isfile(eid_xor_path):
raise FileNotFoundError(f"Could not find {eid_xor_path} (needed for error pattern insertion)")