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

Merge branch 'fxd_subfuncs_integration_15' into 'main'

Integration of fixed point sub-functions 15.

See merge request !244
parents 317e3d34 5d78d24a
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@
#define ONE_IN_Q30                      1073741824
#define ONE_IN_Q31                      0x7fffffff
#define MINUS_ONE_IN_Q31                      -2147483648
#define TWO_IN_Q29                      1073741824
#define FOUR_IN_Q28                     1073741824

#define MAX_WORD16                      32767
#define ONE_IN_Q62                      (Word64)0x4000000000000000
@@ -2991,7 +2993,8 @@ enum
#define SYNC_BAD_FRAME                        (UWord16) 0x6B20         /* synchronization word of a "bad" frame */
#define G192_BIN0                             (UWord16) 0x007F         /* binary "0" according to ITU-T G.192 */
#define G192_BIN1                             (UWord16) 0x0081         /* binary "1" according to ITU-T G.192 */

#define DEGREE_180                            (Word32)(180.0 *ONE_IN_Q23)
#define DEGREE_360                            (Word32)(360.0 *ONE_IN_Q23)
extern const Word16 Idx2Freq_Tbl[];
#if 0 
//TO do add in rom_com
+73 −0
Original line number Diff line number Diff line
@@ -1126,7 +1126,80 @@ void SynthesisSTFT_dirac_flt(
    return;
}

#ifdef IVAS_FLOAT_FIXED
void SynthesisSTFT_dirac_fx(
    Word32 *fftBuffer, /* i  : FFT bins */
    Word32 *timeDomainOutput,
    Word32 *olapBuffer,
    const Word16 *olapWin,
    const Word16 samples_out,
    HANDLE_FD_CNG_COM hFdCngCom /* i/o: FD_CNG structure containing all buffers and variables */
)
{
    Word16 i;
    Word32 buf[M + 1 + 320], tmp;

    /* Perform IFFT */
    RFFTN_fx( fftBuffer, hFdCngCom->fftSineTab_fx, hFdCngCom->fftlen, 1 );

    /* Handle overlap in P/S domain for stereo */
    Copy32( olapBuffer + hFdCngCom->frameSize, olapBuffer, hFdCngCom->frameSize );
    set32_fx( olapBuffer + hFdCngCom->frameSize, 0, hFdCngCom->frameSize ); /*olapBuffer, fftBuffer, olapWin*/

    FOR ( i = shr(hFdCngCom->frameSize, 2); i < i_mult(3, shr(hFdCngCom->frameSize, 2)); i++ )
    {
        olapBuffer[i] = L_add(olapBuffer[i], Mpy_32_16_1(fftBuffer[i], olapWin[i - hFdCngCom->frameSize / 4]));
    }
    FOR ( ; i < i_mult(5, shr(hFdCngCom->frameSize, 2)); i++ )
    {
        olapBuffer[i] = fftBuffer[i]; move32();
    }

    FOR ( ; i < i_mult(7, shr(hFdCngCom->frameSize, 2)); i++ )
    {
        olapBuffer[i] = fftBuffer[i]; move32();
    }

    FOR ( ; i < hFdCngCom->fftlen; i++ )
    {
      olapBuffer[i] = 0; move32();
    }

    Word32 fftScale = 0; move32();
    SWITCH(hFdCngCom->fftlen)
    {
        case 640:
          fftScale = FFT_SCALING_640; move32();
          break;
        case 512:
          fftScale = FFT_SCALING_512; move32();
          break;
        default:
          assert(!"Not supported FFT length!");
    }

    /* Get time-domain signal */
    v_multc_fixed(olapBuffer + hFdCngCom->frameSize / 4, fftScale, timeDomainOutput, samples_out); // Q_in - 9

    /* Get excitation */
    v_multc_fixed(olapBuffer + (hFdCngCom->frameSize / 4) - (M + 1), fftScale, buf, M + 1 + hFdCngCom->frameSize);
    tmp = buf[0];
    preemph_ivas_fx( buf + 1, PREEMPH_FAC, M + hFdCngCom->frameSize, &tmp );
    residu_ivas_fx( hFdCngCom->A_cng, Q13, M, buf + 1 + M, hFdCngCom->exc_cng_32fx, hFdCngCom->frameSize );

    /* update and window olapBuf if we have a output frame that is shorter than the default frame size...*/
    IF ( LT_16(samples_out, hFdCngCom->frameSize ))
    {
        Copy32( olapBuffer + samples_out, olapBuffer + hFdCngCom->frameSize, i_mult(3, shr(hFdCngCom->frameSize, 2)));
    }
    FOR ( i = i_mult(5, shr(hFdCngCom->frameSize, 2)); i < i_mult(7, shr(hFdCngCom->frameSize, 2)); i++ )
    {
        olapBuffer[i] = Mpy_32_16_1(olapBuffer[i], olapWin[i - 3 * hFdCngCom->frameSize / 4]);
    }

    return;
}
#endif
/*-------------------------------------------------------------------
 * mhvals_flt()
 *
+35 −381

File changed.

Preview size limit exceeded, changes collapsed.

+14 −0
Original line number Diff line number Diff line
@@ -50,9 +50,11 @@
#define _180_OVER_PI_Q25                         1922527233
#define _180_OVER_PI_FX                          (Word32) (( 180.0f / EVS_PI ) *ONE_IN_Q10)
#define PI_OVER_4_Q29                            421657440
#define _180_OVER_PI_Q9                          ( 29335 )
#define PI_OVER_Q29                              1686629760
#define Q31_0_99                                 2126008811
#define Q31_0_01                                 21474836
#define PI_OVER_180_FX                           (Word32) (( EVS_PI / 180.0f ) * ONE_IN_Q31)
#endif
#define PI_OVER_4_Q29                            421657440
#define PI_OVER_Q29                              1686629760
@@ -983,6 +985,12 @@ typedef enum
#define DIRAC_ONSET_ALPHA                       0.95f
#define DIRAC_ONSET_BETA                        0.995f
#define DIRAC_ONSET_GAIN                        4.0f
#ifdef IVAS_FLOAT_FIXED
#define DIRAC_ONSET_ALPHA_FX                    31129//Q15
#define DIRAC_ONSET_BETA_FX                     32604 //Q15
#define ONE_DIRAC_ONSET_BETA_FX                 163 //Q15   
#define DIRAC_ONSET_GAIN_FX                     16384 //Q12
#endif

#define DELAY_DIRAC_ENC_CMP_NS                  9500000L                    /* Delay to be compensated on DirAC encoder */
#define DELAY_DIRAC_SPAR_ENC_CMP_NS             500000L                    /* here we may set the 24 samples (at 48 kHz) additional delay to something else, leave as is for now*/       
@@ -1501,6 +1509,12 @@ typedef enum
#define IVAS_LFE_SHIFT_BITS                     5
#define IVAS_LFE_BITRATE_5000                   5000
#define IVAS_LFE_ABS_SUM_FLT_THR                (0.000001f)

#ifdef IVAS_FLOAT_FIXED
#define IVAS_LFE_ABS_SUM_FLT_THR_Q42                4398047
#endif // IVAS_FLOAT_FIXED


#define IVAS_ZERO_PAD_LEN_MULT_FAC              (0.5f)

#define IVAS_ZERO_PAD_LEN_MULT_FAC_fx             16384       //0.5*Q15
+72 −13
Original line number Diff line number Diff line
@@ -3198,10 +3198,8 @@ void mvr2r_inc_fixed_one(
);

void mvr2r_inc_fixed(
    const float x[],     /* i  : input vector               */
    const Word32 x_fx[],     /* i  : input vector               */
    const int16_t x_inc,     /* i  : increment for vector x[]   */
    float y[],           /* o  : output vector              */
    Word32 y_fx[],           /* o  : output vector              */
    const int16_t y_inc,     /* i  : increment for vector y[]   */
    const int16_t n          /* i  : vector size                */
@@ -3230,6 +3228,16 @@ void v_mult_inc_fx(
    const Word16 y_inc,                                         /* i  : increment for vector y[i]                        */
    const Word16 N                                              /* i  : Vector length                                    */
);

void v_add_inc_fx(
  const Word32 x1[], /* i  : Input vector 1                       */
  const Word16 x_inc, /* i  : Increment for input vector 1         */
  const Word32 x2[],   /* i  : Input vector 2                       */
  const Word16 x2_inc, /* i  : Increment for input vector 2         */
  Word32 y[],          /* o  : Output vector that contains vector 1 + vector 2  */
  const Word16 y_inc, /* i  : increment for vector y[]              */
  const Word16 N      /* i  : Vector length                         */
);
#endif

void v_mult_inc(
@@ -3274,7 +3282,18 @@ void v_min_fx(
    Word16 *y_q_fx,
    const Word16 N                                              /* i  : Vector length                                    */
);

void v_mult_inc_fixed(
  const Word32 x1_fx[], /* i  : Input vector 1                                   */
  const Word16 x1_inc,  /* i  : Increment for input vector 1                     */
  const Word32 x2_fx[], /* i  : Input vector 2                                   */
  const Word16 x2_inc, /* i  : Increment for input vector 1                     */
  Word32 y_fx[],       /* o  : Output vector that contains vector 1 .* vector 2 */
  const Word16 y_inc, /* i  : increment for vector y[i]                        */
  const Word16 N      /* i  : Vector length                                    */
);
#endif

void v_min(
    const float x1[],                                           /* i  : Input vector 1                                   */
    const float x2[],                                           /* i  : Input vector 2                                   */
@@ -4275,7 +4294,14 @@ void generate_masking_noise_lb_dirac(
    const int16_t nCldfbTs,                                     /* i  : number of CLDFB slots that will be rendered           */
    const int16_t cna_flag                                      /* i  : CNA flag for LB and HB                                */
);

#ifdef IVAS_FLOAT_FIXED
void generate_masking_noise_lb_dirac_fx(
    HANDLE_FD_CNG_COM hFdCngCom, /* i/o: FD_CNG structure containing all buffers and variables */
    Word32 *tdBuffer,             /* i/o: time-domain signal, if NULL no LB-CNA                 */
    const Word16 nCldfbTs,      /* i  : number of CLDFB slots that will be rendered           */
    const Word16 cna_flag       /* i  : CNA flag for LB and HB                                */
);
#endif
#ifdef IVAS_FLOAT_FIXED
void ivas_dirac_dec_close_fx(
    DIRAC_DEC_HANDLE *hDirAC_out
@@ -4840,8 +4866,7 @@ void ivas_sba_mix_matrix_determiner_fx(
    const Word16 bfi,                                          /* i  : BFI flag                                */
    const Word16 nchan_remapped,                               /* i  : num channels after remapping of TCs     */
    const Word16 output_frame,                                 /* i  : output frame length                     */
    const Word16 num_md_sub_frames,                             /* i  : number of subframes in mixing matrix    */
    Word16* Q_mixer_mat
    const Word16 num_md_sub_frames                             /* i  : number of subframes in mixing matrix    */
);
#endif // IVAS_FLOAT_FIXED

@@ -5081,11 +5106,22 @@ void ivas_spar_dec_agc_pca_fx(
  const Word16 output_frame /* i  : output frame length                     */
);
#endif
#ifdef IVAS_FLOAT_FIXED
void ivas_spar_dec_set_render_map_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const Word16 nCldfbTs                                      /* i  : number of CLDFB time slots              */
);
#endif
void ivas_spar_dec_set_render_map(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
    const int16_t nCldfbTs                                      /* i  : number of CLDFB time slots              */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_spar_dec_set_render_params_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                     */
    const Word16 n_cldfb_slots /* i  : number of cldfb slots in this frame     */
);
#endif
void ivas_spar_dec_set_render_params(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                     */
    const int16_t n_cldfb_slots                                 /* i  : number of cldfb slots in this frame     */
@@ -5097,13 +5133,26 @@ void ivas_spar_dec_digest_tc(
    const int16_t nCldfbSlots,                                  /* i  : number of CLDFB slots                   */
    const int16_t nSamplesForRendering                          /* i  : number of samples provided              */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_spar_dec_digest_tc_fx(
    Decoder_Struct *st_ivas,           /* i/o: IVAS decoder handle          */
    const Word16 nchan_transport,     /* i  : number of transport channels */
    const Word16 nCldfbSlots,         /* i  : number of CLDFB slots        */
    const Word16 nSamplesForRendering /* i  : number of samples provided   */
);
#endif
void ivas_sba_dec_digest_tc(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                     */
    const int16_t nCldfbSlots,                                  /* i  : number of CLDFB slots                   */
    const int16_t nSamplesForRendering                          /* i  : number of samples provided              */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_sba_dec_digest_tc_fx(
    Decoder_Struct *st_ivas,           /* i/o: IVAS decoder handle          */
    const Word16 nCldfbSlots,         /* i  : number of CLDFB slots        */
    const Word16 nSamplesForRendering /* i  : number of samples provided   */
);
#endif
ivas_error ivas_sba_dec_render(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                     */
    const uint16_t nSamplesAsked,                               /* i  : number of CLDFB slots requested         */
@@ -5343,8 +5392,7 @@ void ivas_spar_dec_gen_umx_mat_fx(
    const Word16 nchan_transport,                              /* i  : number of transport channels            */
    const Word16 num_bands_out,                                /* i  : number of output bands                  */
    const Word16 bfi,                                          /* i  : bad frame indicator                     */
    const Word16 num_md_sub_frames,
    Word16 * Q_mixer_mat
    const Word16 num_md_sub_frames
);
#endif // IVAS_FLOAT_FIXED

@@ -6518,6 +6566,17 @@ void ivas_lfe_enc(
    BSTR_ENC_HANDLE hBstr                                       /* i/o: bitstream handle                        */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_lfe_enc_fx(
	LFE_ENC_HANDLE hLFE,                                        /* i/o: LFE encoder handle                      */
	Word32 data_lfe_ch[],                                        /* i  : input LFE signal                        */
	Word16 q_data_lfe_ch,										/* i  : Q of input LFE signal                        */
	const Word16 input_frame,                                  /* i  : input frame length per channel          */
	BSTR_ENC_HANDLE hBstr                                       /* i/o: bitstream handle                        */
);
#endif // IVAS_FLOAT_FIXED


ivas_error ivas_create_lfe_dec( 
    LFE_DEC_HANDLE *hLFE_out,                                   /* o  : IVAS LFE decoder structure              */
    const int32_t output_Fs,                                    /* i  : output sampling rate                    */
Loading