void spl_write(SPL_LOCAL_STRUCT_T * HeapPtr)
{
	int     i, ch, n_ch;
	int     Count;
	int     OutRdIdx;
	int     OffsetInc;
	int *OutPtr;
	int *MemPtr;
	int len1;
	n_ch      = HeapPtr->NumberChannel;
	OffsetInc = HeapPtr->DataOutOffset;
	Count     = HeapPtr->ConsumedSamples;
	OutRdIdx  = HeapPtr->OutRdIdx;
	if(Count > 0)
	{
		for(ch = 0; ch < n_ch; ch++)
		{
			MemPtr = HeapPtr->MainOutBuf[ch] + OutRdIdx;
			OutPtr = HeapPtr->SysMainOutPtr[ch];
			//-------------- replace mod_add_M4 to gain MIPS ----------------------
			len1=(HeapPtr->MainOutBuf[ch] + HeapPtr->Tuning.BlockSize * 2)-MemPtr;
			len1=(len1>Count ? Count : len1);
			for(i=0;i<len1;i++)
			{
				*OutPtr=(__ssat((*MemPtr++),24))<<8;
				OutPtr += OffsetInc;
			}
			MemPtr=HeapPtr->MainOutBuf[ch];
			for(;i<Count;i++)
			{
				*OutPtr=(__ssat((*MemPtr++),24))<<8;
				OutPtr += OffsetInc;
			}
			//--------------------------------------------------------------------
		}
	}
	// Write globals into heap
	OutRdIdx         += Count;
	HeapPtr->OutRdIdx = CIRC_ADD_H(OutRdIdx, HeapPtr->Tuning.BlockSize * 2);
}
Esempio n. 2
0
/*
 * Saturating intrinsics
 * Second argument for SSAT and USAT intrinsics must be compile-time constant,
 * otherwise an error should be raised.
 */
int32_t test_ssat_const_diag(int32_t t, const int32_t v) {
  return __ssat(t, v);  // expected-error-re {{argument to {{.*}} must be a constant integer}}
}
Esempio n. 3
0
// AArch32-LABEL: test_ssat
// AArch32: call i32 @llvm.arm.ssat(i32 %t, i32 1)
int32_t test_ssat(int32_t t) {
  return __ssat(t, 1);
}
int
resample_ML_block_M4(ResampleContext *ctx,
		int             *in,
		int             nb_channels,
		int             *nSamples_inmsec,
		int             *out,
		int             *nbOutSamples_inmsec,
		int             *flush)
{
#ifdef OPT_M4    
	int *CoefRam;
	ResampleContextChannel *ctxChan;
	ResampleDelayLine *delayLine;
	ResampleFilter *filterInfo;
	// convert ms to nsamples using Q10 format 
	int nSamples=(*nSamples_inmsec*ctx->nSamples_coef)>>10;
	// find nbOutRequested according to M/L ration in Q10 format
	unsigned int nbOutRequested;
	unsigned int    M;
	const EXTERN int *incr_offset_tab;
	unsigned int actualLen;
	int currIndex;
	unsigned int offset;
	short  val ;	
    short *p_val_s ;
    int Acc=0;
   	int *p_coef_s;
    int *p_val ;

	unsigned int j,k,delayLine_len;

	int i,incr;
	int nbin_to_consume;
	int   *baseAddress;	
	short 	 *max_adr_s;
	short 	 *min_adr_s;
	short *inptr,*outptr;
	*flush=0;
	// convert nbout to msec
	*nbOutSamples_inmsec=*nSamples_inmsec;
	if (ctx->fin_khz==ctx->fout_khz)
	{
		for (j=(nSamples-1);j>0;j--) 
            out[j]=in[j];

        out[j]=in[j];
		return 0;
	}

	nbOutRequested=(nSamples*ctx->nbOutReq_coef)>>10;
	CoefRam=ctx->CoefRam[0];
	filterInfo=ctx->filterInfo[0];
	incr_offset_tab=filterInfo->incr_offset_tab;
	M = filterInfo->M;
	ctxChan = &ctx->ctxChan[0];
	delayLine=ctxChan->delay[0];
	currIndex = delayLine->currIndex;
	offset = delayLine->offset;
	baseAddress = &delayLine->baseAddress[0];
    delayLine_len = delayLine->len ;
	max_adr_s = (short*)baseAddress+(short)(delayLine_len);
	min_adr_s = (short *)baseAddress;
	p_val_s=(short *)baseAddress;
	p_val_s += (short)currIndex;
	outptr=(short*)out;

	actualLen = delayLine_len+((delayLine_len)&1); //number of additional coefs needed to be a multiple of 2 and the last ones are set to 0
	nbin_to_consume=nSamples;
	inptr=(short*)in;

	{
		if (offset>=M)
		{
			incr=(incr_offset_tab[offset]>>8)&0xff;
			offset=incr_offset_tab[offset]&0xff;
          
			for (i=incr;i>0;i--)
			{
				if (p_val_s==min_adr_s)
					p_val_s=max_adr_s-1;
				else
					p_val_s--;
				val=*inptr;
				inptr++;
				*p_val_s=(short)val;
				*(p_val_s+(short)delayLine_len)=(short)val;
			}
			nbin_to_consume-=incr;
		}
		for (j=nbOutRequested;j>0;j--)
		{
			p_coef_s = (int *)((short*)CoefRam+offset*(actualLen));
            p_val    = (int *)p_val_s;			
            
            Acc = __smuad( p_val[0],p_coef_s[0]);

            for (k=((actualLen>>1)-1);k>0;k--)
                Acc = __smlad( p_val[k],p_coef_s[k],Acc );		          			
            
            Acc = (Acc+0x4000)>>15;             
			Acc=__ssat(Acc,16);

            val = Acc ;            
            *outptr=val;          
			outptr++;
			
            incr=(incr_offset_tab[offset]>>8)&0xff;
			if (nbin_to_consume<incr)
				incr=nbin_to_consume;

			offset=incr_offset_tab[offset]&0xff;           

			for (i=incr;i>0;i--)
			{
				if (p_val_s==min_adr_s)
					p_val_s=max_adr_s-1;
				else
					p_val_s--;

				val=*inptr;
				inptr++;
				
                *p_val_s=(short)val;
				*(p_val_s+delayLine_len)=(short)val;
			}

			nbin_to_consume-=incr;
		}
	}