Commit 9ed13c10 authored by vaillancour's avatar vaillancour
Browse files

add missing code to reuse EVS pit_enc

parent 21969231
Loading
Loading
Loading
Loading
+55 −1
Original line number Diff line number Diff line
@@ -80,8 +80,9 @@ Word16 pit_encode_fx( /* o : Fractional pitc
    Word16 pit_flag, delta, mult_Top, nBits;
    Word16 L_sufr_sft;
    Word16 T_op[2]; /* values for two half-frames */
#ifndef REUSE_EVS_ACELP
    (void) tdm_Pitch_reuse_flag;

#endif
    L_sufr_sft = 6;
    move16();
    if ( EQ_16( L_subfr, 2 * L_SUBFR ) )
@@ -265,6 +266,59 @@ Word16 pit_encode_fx( /* o : Fractional pitc

            pit_Q_enc_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
        }
#ifdef REUSE_EVS_ACELP
        ELSE IF( EQ_16( tdm_Pitch_reuse_flag, 1 ) || EQ_16( nBits, 4 ) )
        {
            /*-------------------------------------------------------*
             *  Pitch encoding with reusing primary channel information
             *-------------------------------------------------------*/
            Word16 loc_T0, loc_frac;

            delta = 4;
            move16();

            pit_flag = L_SUBFR;
            move16();

            Word16 idx1 = shr( i_subfr, L_sufr_sft );
            Word16 idx2 = shr( add( i_subfr, 64 ), L_sufr_sft );

            IF( EQ_16( L_subfr, 2 * L_SUBFR ) )
            {
                loc_T0 = add( shr( tdm_Pri_pitch_buf[idx1], 1 ), shr( tdm_Pri_pitch_buf[idx2], 1 ) ); // Q6
                loc_frac = shr( sub( loc_T0, shl( shr( loc_T0, 6 ), 6 ) ), 4 );                       // Q2
                loc_T0 = shr( loc_T0, 6 );                                                            // Q0
            }
            ELSE
            {
                loc_T0 = tdm_Pri_pitch_buf[idx1];                               // Q6
                loc_frac = shr( sub( loc_T0, shl( shr( loc_T0, 6 ), 6 ) ), 4 ); // Q2
                loc_T0 = shr( loc_T0, 6 );                                      // Q0
            }

            /* pitch lag search limitation */
            limit_T0_fx( L_FRAME, delta, pit_flag, *limit_flag, loc_T0, loc_frac, T0_min, T0_max );
            IF( nBits > 0 )
            {
                /* search and encode the closed loop pitch period */
                *T0 = pitch_fr4_fx( &exc[i_subfr], xn, h1, *T0_min, *T0_max, T0_frac, pit_flag, *limit_flag, PIT_MIN, PIT_FR1_8b, L_FRAME, L_SUBFR );
                move16();
                IF( EQ_16( delta, 8 ) )
                {
                    *T0_frac = 0;
                    move16();
                }
                pit_Q_enc_ivas_fx( hBstr, 0, nBits, delta, pit_flag, *limit_flag, *T0, *T0_frac, T0_min, T0_max );
            }
            ELSE
            {
                *T0 = loc_T0;
                move16();
                *T0_frac = loc_frac;
                move16();
            }
        }
#endif
        ELSE
        {
            /*-------------------------------------------------------*