/* * Save a frames worth of new speech in the history buffer. * Return the output speech delayed by POVERLAPMAX. */ void savespeech(G711_PLC_state *PLC, short *s) { short *p_history = history; /* make room for new signal */ ippsCopy_16s(&p_history[FRAMESZ], p_history, HISTORYLEN - FRAMESZ); /* copy in the new frame */ ippsCopy_16s(s, &p_history[HISTORYLEN - FRAMESZ], FRAMESZ); /* copy out the delayed frame */ if(erasecnt==1) /* do delay when first erasure occured (different to the ref code) */ ippsCopy_16s(&p_history[HISTORYLEN - FRAMESZ - POVERLAPMAX], s, FRAMESZ); }
static void saveHist(Ipp16s *histSout,int histSoutLen,int *histSoutCurLen, Ipp16s *sout,int len){ if((*histSoutCurLen) < histSoutLen){ ippsCopy_16s(sout,histSout+(*histSoutCurLen),len); (*histSoutCurLen)=((*histSoutCurLen)+len); return; } if(histSoutLen>len){ ippsMove_16s(histSout+len,histSout,histSoutLen-len); } ippsCopy_16s(sout,histSout+histSoutLen-len,len); return; }
void PLC_dofe(G711_PLC_state *PLC, short *out) { if (erasecnt == 0) { ippsCopy_16s(history, pitchbuf, HISTORYLEN); /* get history */ pitch = findpitch(PLC); /* find pitch */ poverlap = pitch >> 2; /* OLA 1/4 wavelength */ /* save original last poverlap samples */ ippsCopy_16s(pitchbufend - poverlap, lastq, poverlap); poffset = 0; /* create pitch buffer with 1 period */ pitchblen = pitch; pitchbufstart = pitchbufend - pitchblen; overlapadd(lastq, pitchbufstart - poverlap, pitchbufend - poverlap, poverlap); /* update last 1/4 wavelength in history buffer */ ippsCopy_16s(pitchbufend - poverlap, &history[HISTORYLEN-poverlap], poverlap); getfespeech(PLC, out, FRAMESZ); /* get synthesized speech */ } else if (erasecnt == 1 || erasecnt == 2) {
static USC_Status Encode(USC_Handle handle, USC_PCMStream *in, USC_Bitstream *out) { AMRWB_Handle_Header *amrwb_header; int bitrate_idx; AMRWBEncoder_Obj *EncObj; unsigned short work_buf[AMRWB_Frame]; int WrkRate, out_WrkRate; if(in==NULL) return USC_BadDataPointer; if(in->nbytes<AMRWB_Frame*sizeof(short)) return USC_NoOperation; amrwb_header = (AMRWB_Handle_Header*)handle; if(amrwb_header == NULL) return USC_InvalidHandler; bitrate_idx = CheckRate_AMRWB(in->bitrate); if(bitrate_idx < 0) return USC_UnsupportedBitRate; amrwb_header->bitrate = in->bitrate; EncObj = (AMRWBEncoder_Obj *)((char*)handle + sizeof(AMRWB_Handle_Header)); /* check for homing frame */ amrwb_header->reset_flag = ownTestPCMFrameHoming((short*)in->pBuffer); if (amrwb_header->trunc) { /* Delete the LSBs */ ippsAndC_16u((Ipp16u*)in->pBuffer, (Ipp16u)IO_MASK, work_buf, AMRWB_Frame); // int i; // short *pPCM = (short *)in->pBuffer; // for (i = 0; i < AMRWB_Frame; i ++) work_buf[i] = (IO_MASK & pPCM[i]); } else { ippsCopy_16s((const Ipp16s*)in->pBuffer, (Ipp16s*)work_buf, AMRWB_Frame); } WrkRate = usc2amrwb[bitrate_idx]; if(apiAMRWBEncode(EncObj,(const unsigned short*)work_buf,(unsigned char*)out->pBuffer,(AMRWB_Rate_t *)&WrkRate,EncObj->iDtx) != APIAMRWB_StsNoErr){ return USC_NoOperation; } /* include frame type and mode information in serial bitstream */ ownSidSync(&amrwb_header->sid_state, WrkRate, (TXFrameType *)&out->frametype); out->nbytes = getBitstreamSize(bitrate_idx, out->frametype, &out_WrkRate); out->bitrate = CheckIdxRate_AMRWB(out_WrkRate); if (amrwb_header->reset_flag != 0) { ownSidSyncInit(&amrwb_header->sid_state); apiAMRWBEncoder_Init(EncObj, EncObj->iDtx); } in->nbytes = AMRWB_Frame*sizeof(short); return USC_NoError; }