Commit b20d2be3 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch '3gpp_issue_824_fix_2' into 'main'

Fix for incorrect (zero) values of bandnoiseshape as mentioned in 3gpp issue 824

See merge request !541
parents b2f48acd a26fbebb
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -2468,15 +2468,15 @@ void perform_noise_estimation_dec_ivas_fx(
        SWITCH( hFdCngDec->hFdCngCom->fftlen )
        {
            case 640:
                rescale_fac = 20972; // 4/(640 * 640) in Q31
                rescale_fac = 83886; // 4/(640 * 640) in Q33
                move32();
                BREAK;
            case 512:
                rescale_fac = 32768; // 4/(512 * 512) in Q31
                rescale_fac = 131072; // 4/(512 * 512) in Q33
                move32();
                BREAK;
            case 320:
                rescale_fac = 83886; // 4/(320 * 320) in Q31
                rescale_fac = 335544; // 4/(320 * 320) in Q33
                move32();
                BREAK;
            default:
@@ -2486,10 +2486,11 @@ void perform_noise_estimation_dec_ivas_fx(
        IF( startBand == 0 )
        {
            W_tmp = W_mult0_32_32( fftBuffer[0], fftBuffer[0] );
            min_q = 2;
            tmp_s = W_norm( W_tmp );
            ( *ptr_per ) = W_extract_h( W_shl( W_tmp, tmp_s ) );
            tmp_q = sub( add( i_mult( sub( 31, fftBuffer_exp ), 2 ), tmp_s ), 32 );
            min_q = tmp_q;
            move16();
            ( *ptr_per ) = W_extract_l( W_shr( W_tmp, sub( i_mult( sub( 31, fftBuffer_exp ), 2 ), min_q ) ) );
            move32();
            ptr_per++;
            ptr_r = fftBuffer + 2;
        }
@@ -2530,11 +2531,11 @@ void perform_noise_estimation_dec_ivas_fx(
                    *reIter = L_shr( *reIter, diff );
                    move32();
                }
                IF( GE_16( tmp_q, 0 ) )
                IF( tmp_q >= 0 )
                {
                    min_q = tmp_q;
                }
                ELSE IF( LT_16( tmp_q, 0 ) )
                ELSE IF( tmp_q < 0 )
                {
                    min_q = 0;
                }
@@ -2544,10 +2545,10 @@ void perform_noise_estimation_dec_ivas_fx(
            move32();

            /* Rescale to get energy/sample: it should be 2*(1/N)*(2/N), parseval relation with 1/N,*2 for nrg computed till Nyquist only, 2/N as windowed samples correspond to half a frame*/
            ( *ptr_per ) = Mpy_32_32_r( ( *ptr_per ), rescale_fac ); // Q = min_q
            ( *ptr_per ) = Mpy_32_32_r( ( *ptr_per ), rescale_fac ); // Q = min_q+2
            move32();

            IF( LT_16( tmp_q, 0 ) )
            IF( tmp_q < 0 )
            {
                ( *ptr_per ) = L_shl( ( *ptr_per ), negate( tmp_q ) );
                move32();
@@ -2557,7 +2558,7 @@ void perform_noise_estimation_dec_ivas_fx(
            ptr_i += 2;
        }

        hFdCngDec->hFdCngCom->periodog_exp = sub( 31, min_q );
        hFdCngDec->hFdCngCom->periodog_exp = sub( 31 - 2, min_q );
        hFdCngDec->hFdCngCom->fftBuffer_exp = fftBuffer_exp;
        move16();
        move16();
@@ -2635,9 +2636,9 @@ void perform_noise_estimation_dec_ivas_fx(
                msPeriodog[p] = L_add( msPeriodog[p], L_tmp );
                move32();

                if ( LT_32( msPeriodog[p], 0 ) )
                IF( LT_32( msPeriodog[p], L_shr( 21474, hFdCngDec->msPeriodog_exp ) ) )
                {
                    msPeriodog[p] = 0;
                    msPeriodog[p] = L_shr( 21474, hFdCngDec->msPeriodog_exp );
                    move32();
                }
            }