Skip to content

Scaling error when going from FD stereo to TD stereo

When going from FD to TD, some parameters are copied from the main channel to the secondary channel instead of completely resetting the secondary channel. In particular, the excitation memory is copied from primary to secondary and its current scaling should be used instead of "forcing" it into the last known scaling of the secondary channel.

currently in stereo_switching_dec()

....
        Copy_Scale_sig( sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC, sub( sts[1]->Q_exc, sts[0]->Q_exc ) );

This leads to many saturation that are then passed into the ACB, causing difference in the core coding of the secondary channel.

instead I suggest something like :

        /* Should not force sts[1]->Q_exc on the data of st[0], instead it better to just reuse the current scaling of st[0]*/
        Copy(sts[0]->old_exc_fx, sts[1]->old_exc_fx, L_EXC_MEM_DEC);
        sts[1]->Q_exc = sts[0]->Q_exc;

... plus the initialisation of the other secondary channel scaling parameters to the value of its primary channel equivalent