Scaling inconsistencies in function add_HB_to_mono_dmx_fx
When decoding a stereo file a 32 kbps stereo bitsteam to mono with the following command line:
IVAS_dec MONO 32 bit syn.wav
Some part of the synthesis shows inconsistencies.
At the beginning of the fix point function, hCPE->hStereoDftDmx->memOutHB is convert to fixed point with its own scaling and then memOutHB_fx is copied to a temporary buffer complemented with outputHB. outputHB has a fix Q11 scaling and the is not corrected which lead to a vector having 2 different scalings.
void add_HB_to_mono_dmx_fx(
CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure */
Word32 output[L_FRAME48k], /* i/o: output synthesis */
Word32 outputHB[L_FRAME48k], /* i : HB synthesis */
const int16_t last_core, /* i : last core, primary channel */
const int16_t output_frame /* i : frame length */
)
{
int16_t i, j, decoderDelay, icbweOLASize, dftOvlLen, memOffset;
Word32 temp_fx[L_FRAME48k + NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)];
Word32 winSlope_fx = 0;
Word32 alpha_fx;
const Word32 *win_dft_fx;
int32_t output_Fs;
Word32 *memOutHB_fx, *memTransitionHB_fx;
output_Fs = hCPE->hCoreCoder[0]->output_Fs;
Word16 q_memOutHB = Q_factor_arr(hCPE->hStereoDftDmx->memOutHB, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS)); <<<<<<
floatToFixed_arrL(hCPE->hStereoDftDmx->memOutHB, hCPE->hStereoDftDmx->memOutHB_fx, q_memOutHB, NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS));
memOutHB_fx = hCPE->hStereoDftDmx->memOutHB_fx;
Word16 q_memTransitionHB = Q_factor_arr(hCPE->hStereoDftDmx->memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS)); <<<<<<
floatToFixed_arrL(hCPE->hStereoDftDmx->memTransitionHB, hCPE->hStereoDftDmx->memTransitionHB_fx, q_memTransitionHB, NS2SA(48000, STEREO_DFT32MS_OVL_NS));
memTransitionHB_fx = hCPE->hStereoDftDmx->memTransitionHB_fx;
On top of that, the floating point hCPE->hStereoDftDmx->memOutHB is not updated at the end of the function with the new content of memOutHB_fx.
My suggestion would be to ensure memOutHB_fx has the same scaling as outputHB (and to add the update of the memOutHB at the end of the function) or to remove the update from float to fix at the beginning of the function, as memOutHB_fx seems to have a consistent scaling for the non down-mixed modes.