#include "basic_op.h"


#ifndef VC_PROJ
#include <xtensa/tie/xt_hifi2.h>
#include <xtensa/tie/xt_misc.h>
#endif


#ifndef HW_PITCH_OFF2
int speech_pitch_xcorr_c(const short *_x, const short *_y, int *xcorr, short len, short max_pitch);





#ifndef HW_CODESIZE
static void dual_inner_prod(const short *x, const short *y01, const short *y02,
	short N, int *xy1, int *xy2)
{
	short i;
#ifndef HW_HIFI3
	int xy01=0;
	int xy02=0;
	for (i=0;i<N;i++)
	{
		xy01 += SSC_MULT16x16(x[i], y01[i]);
		xy02 += SSC_MULT16x16(x[i], y02[i]);
	}
	*xy1 = xy01;
	*xy2 = xy02;
#else

	ae_int16x4 *x_4 = (ae_int16x4 *)(x);
	ae_int16x4 *y01_4 = (ae_int16x4 *)(y01);
	ae_int16x4 *y02_4 = (ae_int16x4 *)(y02);

	ae_int16x4 x_4_v ;
	ae_int16x4 y01_4_v;
	ae_int16x4 y02_4_v;

	ae_valign align1 = AE_LA64_PP(x_4);
	ae_valign align2 = AE_LA64_PP(y01_4);
	ae_valign align3 = AE_LA64_PP(y02_4);

	ae_int32x4 xy_01_4 = 0;
	ae_int32x4 xy_02_4 = 0;


	for (i=0;i<(N>>2);i++)
	{
		AE_LA16X4_IP(x_4_v,align1,x_4);
		AE_LA16X4_IP(y01_4_v,align2,y01_4);
		AE_MULA16X4_vector(xy_01_4, x_4_v, y01_4_v);
		AE_LA16X4_IP(y02_4_v,align3,y02_4);
		AE_MULA16X4_vector(xy_02_4, x_4_v, y02_4_v);
	}

	*xy1 = AE_INT32X4_RADD(xy_01_4);
	*xy2 = AE_INT32X4_RADD(xy_02_4);


#endif
}
#endif
#endif
