Commit c99317e1 authored by Arash Azizi's avatar Arash Azizi
Browse files

issue 2586: Necessary changes in order to make dynamic Q value assignment...

issue 2586: Necessary changes in order to make dynamic Q value assignment possible with normalization of every value in the smaller loop.
parent 319d2528
Loading
Loading
Loading
Loading
+31 −14
Original line number Diff line number Diff line
@@ -411,7 +411,7 @@ ivas_error stereo_memory_dec_fx(
    {
        delay_comp_DFT = NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); /* Q0 */
        move16();

#ifndef FIX_ISSUE_2586_Q_VALUE
        /* redressing of the DFT OLA part */
        FOR(n = 0; n < CPE_CHANNELS; n++)
        {
@@ -420,17 +420,34 @@ ivas_error stereo_memory_dec_fx(
                div_m = BASOP_Util_Divide3216_Scale(hCPE->output_mem_fx[n][i - delay_comp_DFT], hCPE->hStereoDft->win32ms_fx[STEREO_DFT32MS_STEP * (hCPE->hStereoDft->dft32ms_ovl - 1 + delay_comp_DFT - i)], &div_e);
                hCPE->output_mem_fx[n][i - delay_comp_DFT] = L_shl(div_m, add(div_e, 16)); /* div_e + Q16 */
                move32();
#ifdef FIX_ISSUE_2586_Q_VALUE
                IF( i != delay_comp_DFT )
                {
                    assert( EQ_16( hCPE->q_output_mem_fx[n], sub( 31, div_e ) ) );
                // hCPE->output_mem_fx[n][sub(i, delay_comp_DFT)] = hCPE->hStereoDft->win32ms_fx[i_mult(STEREO_DFT32MS_STEP, ( sub(add(sub(hCPE->hStereoDft->dft32ms_ovl, 1), delay_comp_DFT), i) ))];
            }
                hCPE->q_output_mem_fx[n] = sub( 31, div_e );
#endif // FIX_ISSUE_2586_Q_VALUE
        }
#else
        Word16* exponent_array;
        Word32* L_output_buffer;
        Word16 max_exponent;
        /* redressing of the DFT OLA part */
        FOR(n = 0; n < CPE_CHANNELS; n++)
        {   
            max_exponent = 0xffe1; // Q0
            FOR(i = delay_comp_DFT; i < hCPE->hStereoDft->dft32ms_ovl; i++)
            {
                div_m = BASOP_Util_Divide3216_Scale(hCPE->output_mem_fx[n][i - delay_comp_DFT], hCPE->hStereoDft->win32ms_fx[STEREO_DFT32MS_STEP * (hCPE->hStereoDft->dft32ms_ovl - 1 + delay_comp_DFT - i)], &div_e); // div_e <--> Q(15-div_e)
                L_output_buffer[i - delay_comp_DFT] = L_deposit_h(div_m); // Q(31-div_e)
                exponent_array[i - delay_comp_DFT] = div_e;
                move16();
                max_exponent = s_max(max_exponent, div_e);
                // hCPE->output_mem_fx[n][sub(i, delay_comp_DFT)] = hCPE->hStereoDft->win32ms_fx[i_mult(STEREO_DFT32MS_STEP, ( sub(add(sub(hCPE->hStereoDft->dft32ms_ovl, 1), delay_comp_DFT), i) ))];
            }
            
            FOR(i = delay_comp_DFT; i < hCPE->hStereoDft->dft32ms_ovl; i++) {
                hCPE->output_mem_fx[n][i - delay_comp_DFT] = L_shr(L_output_buffer[i - delay_comp_DFT], sub(max_exponent,exponent_array[i-delay_comp_DFT]));
                move32();
            }
            hCPE->q_output_mem_fx[n] = sub( 0x001f, max_exponent);
        }
#endif // !FIX_ISSUE_2586_Q_VALUE

        IF( hCPE->hCoreCoder[0]->last_core != ACELP_CORE )
        {