Commit 6f706f8a authored by Adityaraj Jain's avatar Adityaraj Jain
Browse files

using diff exponents

parent 1ccc3c58
Loading
Loading
Loading
Loading
Loading
+32 −8
Original line number Diff line number Diff line
@@ -901,7 +901,7 @@ void cldfbAnalysis_ts_fx_fixed_q(
    const Word16 *ptr_pf_fx;
    Word16 ptr_pf_sf;
    Word32 *timeBuffer_fx, buffer_fx[( CLDFB_NO_CHANNELS_MAX * CLDFB_NO_COL_MAX ) + ( 9 * CLDFB_NO_CHANNELS_MAX )];
    Word16 offset, frameSize;
    Word16 offset, frameSize, gb, hr, shift;

    offset = sub( h_cldfb->p_filter_length, h_cldfb->no_channels );
    frameSize = i_mult( h_cldfb->no_channels, h_cldfb->no_col );
@@ -1071,10 +1071,33 @@ void cldfbAnalysis_ts_fx_fixed_q(
        *q_cldfb = sub( *q_cldfb, 2 );
        move16();

        gb = find_guarded_bits_fx( M1 );
        hr = L_norm_arr( iBuffer_fx, M1 );

        IF( LT_16( hr, gb ) )
        {
            scale_sig32( iBuffer_fx, M1, sub( hr, gb ) );
        }

        /* FFT of DCT IV */
        fft_cldfb_fx( iBuffer_fx, M2 );

        /* post modulation of DCT IV */
        IF( LT_16( hr, gb ) )
        {
            shift = sub( gb, hr );
            FOR( k = 0; k < M2; k++ )
            {
                /* do it inplace */
                /*cplxMult(&imagBuffer[2*k],&imagBuffer[M1-1-(2*k)],iBuffer[2*k],iBuffer[2*k+1],rot_vctr_re[k],rot_vctr_im[k]);*/
                imagBuffer_fx[2 * k] = L_shl( Msub_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_re_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_im_fx[k] ), shift );                  // q - 5
                imagBuffer_fx[( M1 - 1 ) - ( k * 2 )] = L_shl( Madd_32_32( Mpy_32_32( iBuffer_fx[2 * k], rot_vctr_im_fx[k] ), iBuffer_fx[2 * k + 1], rot_vctr_re_fx[k] ), shift ); // q - 5
                move32();
                move32();
            }
        }
        ELSE
        {
            FOR( k = 0; k < M2; k++ )
            {
                /* do it inplace */
@@ -1084,6 +1107,7 @@ void cldfbAnalysis_ts_fx_fixed_q(
                move32();
                move32();
            }
        }

        IF( EQ_32( h_cldfb->prototype, CLDFB_PROTOTYPE_5_00MS ) )
        {
+15 −27
Original line number Diff line number Diff line
@@ -177,9 +177,10 @@ void pre_echo_att_ivas_fx(
    move16();
    Word16 ratio_fx;
    Word16 attack_pos_fx, i;
    Word32 L_tmp, L_tmp1;
    Word16 tmp, n1, n2, exp, frac1, frac2;
    Word32 L_tmp;
    Word16 tmp, tmp_e;
    Word32 etmp1_fx;
    Word16 etmp_e;
    Word16 att_len;

    test();
@@ -220,32 +221,19 @@ void pre_echo_att_ivas_fx(
        IF( GT_32( etmp_fx, *Last_frame_ener_fx ) && attack_pos_fx > 0 )
        {
            /* Find the average energy before the attack */
            L_tmp = sum32_fx( finc_fx, attack_pos_fx );                  /*Q1 */
            L_tmp1 = L_shr( L_mult( attack_pos_fx, attack_pos_fx ), 1 ); /*Q0 */
            tmp = round_fx( Isqrt( L_tmp1 ) );                           /*Q15 */
            L_tmp = L_shr( L_tmp, 2 );                                   /*Q1 ; ATT_SEG_LEN=4 */
            etmp_fx = Mult_32_16( L_tmp, tmp );                          /*Q1 */
            etmp_fx = sum32_fx( finc_fx, attack_pos_fx );
            etmp_e = sub( 31, add( shl( Q_new, 1 ), 1 ) );
            etmp_fx = L_add( etmp_fx, L_shr( 21474836 /*0.01 in Q31*/, etmp_e ) ); /* etmp = etmp + 0.01;   (exp = etmp_e) */
            etmp_fx = L_deposit_h( BASOP_Util_Divide3232_Scale( etmp_fx, L_mult0( attack_pos_fx, ATT_SEG_LEN ), &tmp_e ) );
            tmp_e = add( tmp_e, sub( etmp_e, 31 ) );
            etmp_e = tmp_e;
            move16();

            etmp_fx = L_shr( etmp_fx, add( 1 - 4, shl( Q_new, 1 ) ) ); /* makes etmp i nQ4 as *Last_frame_ener_fx */
            /* Find the correction factor and apply it before the attack */
                                                                       /*   ratio = (float)sqrt(*Last_frame_ener/etmp);*/
                                                                       /*         = isqrt(etmp/(*Last_frame_ener))			*/
            etmp_fx = L_max( etmp_fx, 1 );
            *Last_frame_ener_fx = L_max( *Last_frame_ener_fx, 1 );
            move32();
            n1 = norm_l( etmp_fx );
            n2 = norm_l( *Last_frame_ener_fx );

            n1 = sub( n1, 1 );
            exp = sub( n1, n2 );

            frac1 = round_fx( L_shl( etmp_fx, n1 ) );
            frac2 = round_fx_sat( L_shl_sat( *Last_frame_ener_fx, n2 ) );
            L_tmp = L_mult0( 128, div_s( frac1, frac2 ) ); /* s = gain_out / gain_in */
            L_tmp = L_shr( L_tmp, exp );                   /* add exponent */

            L_tmp = Isqrt( L_tmp );
            ratio_fx = round_fx( L_shl( L_tmp, 9 ) );
            tmp = BASOP_Util_Divide3232_Scale( *Last_frame_ener_fx, etmp_fx, &tmp_e ); /* numerator Q = 2 * Q_new + 1;  denominator Q = 31 - tmp_e */
            tmp_e = add( tmp_e, sub( sub( 31, etmp_e ), add( shl( Q_new, 1 ), 1 ) ) ); /* tmp_e = tmp_e + (31 - tmp_e) - (2 * Q_new + 1) */
            tmp = Sqrt16( tmp, &tmp_e );
            ratio_fx = shr( tmp, sub( 2, tmp_e ) ); /* Q13 */

            /* Pre-echo atttenuation should never increase the energy */
            ratio_fx = s_min( ratio_fx, 8192 /* 1 in Q13 */ ); /* Q13 */
+10 −3
Original line number Diff line number Diff line
@@ -202,7 +202,14 @@ void sns_compute_scf_fx(
      -Q6 is for division with FDNS_NPTS and -Q1 is to reduce Q by one */
    mean = W_shl_sat_l( sum, -Q7 );                                   // q_out
    nf = Mpy_32_32( mean, 214748 /* powf( 10.0f, -4.0f ) in Q31 */ ); // q_out
    nf = L_max( nf, L_shl( 256, sub( q_out, 40 ) ) /* powf( 2.0f, -32.0f ) in Q40 */ ); // q_out

    IF( LE_32( nf, L_shl_sat( 256, sub( q_out, 40 ) ) ) ) /* powf( 2.0f, -32.0f ) in Q40 */
    {
        nf = 256;
        move32();
        q_out = 40;
        move16();
    }

    FOR( i = 0; i < FDNS_NPTS; i++ )
    {
+29 −2
Original line number Diff line number Diff line
@@ -2550,7 +2550,7 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
    DECODER_TC_BUFFER_HANDLE hTcBuffer;
    Word32 output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
    Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
    Word16 nchan_in, nchan_out;
    Word16 nchan_in, nchan_out, gd_bits, n_chan_inp, i, shift;
    IF( !st_ivas->hDecoderConfig->Opt_tsm )
    {
        return IVAS_ERR_OK;
@@ -2637,17 +2637,44 @@ ivas_error ivas_jbm_dec_flush_renderer_fx(
                    /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
                    set16_fx( st_ivas->hIsmRendererData->interpolator_fx, 32767, hTcBuffer->n_samples_granularity ); // 32767=1.0f in Q15

                    ivas_ism_render_sf_fx( st_ivas, p_output_fx, *nSamplesRendered );
                    ivas_ism_render_sf_fx( st_ivas, p_output_fx, hTcBuffer->n_samples_granularity );

                    st_ivas->hCrendWrapper->p_io_qfactor = &st_ivas->hCrendWrapper->io_qfactor;
                    *st_ivas->hCrendWrapper->p_io_qfactor = 11;
                    move16();

                    shift = MAX_16;
                    move16();
                    n_chan_inp = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe );

                    FOR( i = 0; i < n_chan_inp; i++ )
                    {
                        shift = s_min( shift, L_norm_arr( p_output_fx[i], hTcBuffer->n_samples_granularity ) );
                    }

                    gd_bits = sub( find_guarded_bits_fx( imult1616( hTcBuffer->subframe_nbslots[0], hTcBuffer->n_samples_granularity ) ), shift );

                    *st_ivas->hCrendWrapper->p_io_qfactor = sub( *st_ivas->hCrendWrapper->p_io_qfactor, gd_bits );
                    move16();

                    FOR( i = 0; i < n_chan_inp; i++ )
                    {
                        scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( *st_ivas->hCrendWrapper->p_io_qfactor, Q11 ) ); // Q(*st_ivas->hCrendWrapper->p_io_qfactor)
                    }

                    IF( NE_32( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
                                                                         NULL, NULL, st_ivas->hTcBuffer, p_output_fx, p_output_fx, hTcBuffer->n_samples_granularity, st_ivas->hDecoderConfig->output_Fs ) ),
                               IVAS_ERR_OK ) )
                    {
                        return error;
                    }

                    FOR( i = 0; i < n_chan_inp; i++ )
                    {
                        scale_sig32( p_output_fx[i], hTcBuffer->n_samples_granularity, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q(11)
                    }
                    *st_ivas->hCrendWrapper->p_io_qfactor = Q11;
                    move16();
                }
            }
            ELSE
+26 −1
Original line number Diff line number Diff line
@@ -419,7 +419,6 @@ ivas_error ivas_core_enc_fx(
        }
    }


    /*---------------------------------------------------------------------*
     * MDCT stereo: joint TCX Core Encoding
     *---------------------------------------------------------------------*/
@@ -532,6 +531,12 @@ ivas_error ivas_core_enc_fx(
                        st->hTcxEnc->exp_buf_speech_ltp = st->exp_buf_speech_enc;
                        move16();
                    }
                    Scale_sig( st->input_fx, input_frame, sub( -1, st->q_inp ) );
                    Scale_sig( st->input_fx - input_frame, input_frame, sub( -1, st->q_old_inp ) );
                    st->q_inp = -1;
                    move16();
                    st->q_old_inp = -1;
                    move16();
                }

                Word16 Q_spec_old[2], L_spec;
@@ -612,6 +617,8 @@ ivas_error ivas_core_enc_fx(
     * Postprocessing, BWEs and Updates
     *---------------------------------------------------------------------*/

    Word16 tmp_input_fx[L_FRAME48k], tmp_old_input_fx[L_FRAME48k], q_inp[2];

    FOR( n = 0; n < n_CoreChannels; n++ )
    {
        st = sts[n];
@@ -626,6 +633,17 @@ ivas_error ivas_core_enc_fx(
            move16();
        }

        Copy( st->input_fx - input_frame, tmp_old_input_fx, input_frame );
        Copy( st->input_fx, tmp_input_fx, input_frame );
        q_inp[0] = st->q_old_inp;
        q_inp[1] = st->q_inp;

        Scale_sig( st->input_fx - input_frame, 2 * input_frame, sub( -1, st->q_inp ) );
        st->q_inp = -1;
        move16();
        st->q_old_inp = -1;
        move16();

        /*---------------------------------------------------------------------*
         * Postprocessing for ACELP/HQ core switching
         *---------------------------------------------------------------------*/
@@ -787,6 +805,13 @@ ivas_error ivas_core_enc_fx(
            }
        }

        Copy( tmp_old_input_fx, st->input_fx - input_frame, input_frame );
        Copy( tmp_input_fx, st->input_fx, input_frame );
        st->q_old_inp = q_inp[0];
        move16();
        st->q_inp = q_inp[1];
        move16();

        /*---------------------------------------------------------------------*
         * Channel-aware mode - write signaling information into the bitstream
         *---------------------------------------------------------------------*/
Loading