/* loudness calculation (threshold to the power of redExp) */ static void calcThreshExp(float thrExp[MAX_CHANNELS][MAX_GROUPED_SFB], PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], const int nChannels) { int ch, sfb,sfbGrp; COUNT_sub_start("calcThreshExp"); LOOP(1); for (ch=0; ch<nChannels; ch++) { PSY_OUT_CHANNEL *psyOutChan = &psyOutChannel[ch]; PTR_INIT(1); /* counting operation above */ INDIRECT(2); LOOP(1); for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup) { PTR_INIT(2); /* pointer for thrExp[][], psyOutChan->sfbThreshold[] */ INDIRECT(1); LOOP(1); for (sfb=0; sfb<psyOutChan->maxSfbPerGroup; sfb++) { TRANS(1); STORE(1); thrExp[ch][sfbGrp+sfb] = (float) pow(psyOutChan->sfbThreshold[sfbGrp+sfb], redExp); } } } COUNT_sub_end(); }
void CShortBlock_Init(CAacDecoderChannelInfo *pAacDecoderChannelInfo) { int group,band; char *pCodeBook = pAacDecoderChannelInfo->pCodeBook; short *pScaleFactor = pAacDecoderChannelInfo->pScaleFactor; COUNT_sub_start("CShortBlock_Init"); INDIRECT(2); PTR_INIT(2); /* counting previous operations */ PTR_INIT(2); /* pCodeBook[] pScaleFactor[] */ LOOP(1); for (group=0; group<MaximumGroups; group++) { LOOP(1); for (band=0; band<MaximumScaleFactorBandsShort; band++) { MOVE(2); pCodeBook[group*MaximumScaleFactorBandsShort+band] = 0; pScaleFactor[group*MaximumScaleFactorBandsShort+band] = 0; } } COUNT_sub_end(); }
/* apply reduction formula */ static void reduceThresholds(PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], int ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], float thrExp[MAX_CHANNELS][MAX_GROUPED_SFB], const int nChannels, const float redVal) { int ch, sfb,sfbGrp; float sfbEn, sfbThr,sfbThrReduced; COUNT_sub_start("reduceThresholds"); LOOP(1); for(ch=0; ch<nChannels; ch++) { PSY_OUT_CHANNEL *psyOutChan = &psyOutChannel[ch]; PTR_INIT(1); /* counting previous operation */ INDIRECT(2); LOOP(1); for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ PTR_INIT(5); /* pointers for psyOutChan->sfbMinSnr[sfbGrp+sfb], psyOutChan->sfbEnergy[sfbGrp+sfb], psyOutChan->sfbThreshold[sfbGrp+sfb], thrExp[ch][sfbGrp+sfb], ahFlag[ch][sfbGrp+sfb] */ INDIRECT(1); LOOP(1); for (sfb=0; sfb<psyOutChan->maxSfbPerGroup; sfb++) { MOVE(2); sfbEn = psyOutChan->sfbEnergy[sfbGrp+sfb]; sfbThr = psyOutChan->sfbThreshold[sfbGrp+sfb]; ADD(1); BRANCH(1); if (sfbEn > sfbThr) { /* threshold reduction formula */ ADD(1); TRANS(1); sfbThrReduced = (float) pow(thrExp[ch][sfbGrp+sfb]+redVal, invRedExp); /* avoid holes */ MULT(1); ADD(2); LOGIC(1); BRANCH(1); if ((sfbThrReduced > psyOutChan->sfbMinSnr[sfbGrp+sfb] * sfbEn) && (ahFlag[ch][sfbGrp+sfb] != NO_AH)){ ADD(1); BRANCH(1); MOVE(1); sfbThrReduced = max(psyOutChan->sfbMinSnr[sfbGrp+sfb] * sfbEn, sfbThr); MOVE(1); ahFlag[ch][sfbGrp+sfb] = AH_ACTIVE; } MOVE(1); psyOutChan->sfbThreshold[sfbGrp+sfb] = sfbThrReduced; } } } } COUNT_sub_end(); }
static void twoChannelFiltering( const float *pQmf, float *mHybrid ) { int n; float cum0, cum1; FLC_sub_start("twoChannelFiltering"); LOOP(1); PTR_INIT(2); MULT(1); cum0 = 0.5f * pQmf[HYBRID_FILTER_DELAY]; MOVE(1); cum1 = 0; LOOP(1); PTR_INIT(2); for(n = 0; n < 6; n++) { MAC(1); MULT(1); cum1 += p2_6[n] * pQmf[2*n+1]; } ADD(1); STORE(1); mHybrid[0] = cum0 + cum1; ADD(1); STORE(1); mHybrid[1] = cum0 - cum1; FLC_sub_end(); }
void VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent) { LOOP("VideoConsumer::HandleEvent\n"); switch (event->type) { case BTimedEventQueue::B_START: PROGRESS("VideoConsumer::HandleEvent - START\n"); _SetPerformanceTimeBase(event->event_time); break; case BTimedEventQueue::B_WARP: case BTimedEventQueue::B_SEEK: PROGRESS("VideoConsumer::HandleEvent - WARP or SEEK\n"); _SetPerformanceTimeBase(event->bigdata); break; case BTimedEventQueue::B_STOP: PROGRESS("VideoConsumer::HandleEvent - STOP\n"); EventQueue()->FlushEvents(event->event_time, BTimedEventQueue::B_ALWAYS, true, BTimedEventQueue::B_HANDLE_BUFFER); // unset the target's bitmap _UnsetTargetBuffer(); break; case BTimedEventQueue::B_HANDLE_BUFFER: LOOP("VideoConsumer::HandleEvent - HANDLE BUFFER\n"); _HandleBuffer(static_cast<BBuffer*>(event->pointer)); break; default: ERROR("VideoConsumer::HandleEvent - BAD EVENT\n"); break; } }
/* The function creates the interpolated spectral data according to the energy of the last good frame and the current (good) frame. */ void CConcealment_InterpolateBuffer (float *spectrum, float *enPrev, float *enAct, int sfbCnt, const short *pSfbOffset) { int sfb, line = 0; float multiplier; FLC_sub_start("CConcealment_InterpolateBuffer"); MOVE(1); /* counting previous operation */ PTR_INIT(3); /* enAct[] enPrev[] spectrum[] */ LOOP(1); for(sfb = 0; sfb < sfbCnt; sfb++) { DIV(1); TRANS(1); multiplier = (float) pow(enAct[sfb] / enPrev[sfb], 0.25f); LOOP(1); for(; line < pSfbOffset[sfb+1]; line++) { MULT(1); STORE(1); spectrum [line] = spectrum[line] * multiplier; } } FLC_sub_end(); }
static double nonlocal_vec(real *u, uint n, int op, const nonlocal_info *info, MPI_Comm comm) { uint np = info->np, i; MPI_Request *reqs = info->reqs; uint *targ = info->target; uint *nshared = info->nshared; uint *sh_ind = info->sh_ind; uint id = info->id; real *buf = info->buf; uint size = n*sizeof(real); #ifdef GS_TIMING double time0, time1; #endif for(i=0;i<np;++i) { int nsn=n*nshared[i]; MPI_Irecv(buf,nsn,REAL_MPI,targ[i],targ[i],comm,reqs++); buf+=nsn; } #ifdef GS_BARRIER MPI_Barrier(comm); #endif #ifdef GS_TIMING time0 = MPI_Wtime(); #endif for(i=0;i<np;++i) { uint ns=nshared[i], c=ns; real *start = buf; for(;c;--c) memcpy(buf,u+n*(*sh_ind++),size), buf+=n; MPI_Isend(start,ns*n,REAL_MPI,targ[i],id,comm,reqs++); } MPI_Waitall(np*2,info->reqs,MPI_STATUSES_IGNORE); #ifdef GS_TIMING time1 = MPI_Wtime(); #endif buf = info->buf; sh_ind = info->sh_ind; # define LOOP(OP) do { \ for(i=0;i<np;++i) { \ uint c,j; \ for(c=nshared[i];c;--c) { \ real *uu=u+n*(*sh_ind++); \ for(j=n;j;--j) { OP(*uu,*buf); ++uu, ++buf; } \ } \ } \ } while(0) switch(op) { case OP_ADD: LOOP(DO_ADD); break; case OP_MUL: LOOP(DO_MUL); break; case OP_MIN: LOOP(DO_MIN); break; case OP_MAX: LOOP(DO_MAX); break; case OP_BPR: LOOP(DO_BPR); break; } # undef LOOP #ifdef GS_TIMING return time1-time0; #else return 0; #endif }
void Var_Dump(void) { Var **t; unsigned int i; const char *banner; bool first = true; t = sort_ohash_by_name(&global_variables); /* somewhat dirty, but does the trick */ #define LOOP(mask, value, do_stuff) \ for (i = 0; t[i] != NULL; i++) \ if ((t[i]->flags & (mask)) == (value)) { \ if (banner) { \ if (first) \ first = false; \ else \ putchar('\n'); \ fputs(banner, stdout); \ banner = NULL; \ } \ do_stuff; \ } banner = "#variables from command line:\n"; LOOP(VAR_FROM_CMD | VAR_DUMMY, VAR_FROM_CMD, print_var(t[i])); banner = "#global variables:\n"; LOOP(VAR_FROM_ENV| VAR_FROM_CMD | VAR_DUMMY, 0, print_var(t[i])); banner = "#variables from env:\n"; LOOP(VAR_FROM_ENV|VAR_DUMMY, VAR_FROM_ENV, print_var(t[i])); banner = "#variable name seen, but not defined:"; LOOP(VAR_DUMMY|POISONS, VAR_DUMMY, printf(" %s", t[i]->name)); #undef LOOP printf("\n\n"); for (i = 0; t[i] != NULL; i++) switch(t[i]->flags & POISONS) { case POISON_NORMAL: printf(".poison %s\n", t[i]->name); break; case POISON_EMPTY: printf(".poison empty(%s)\n", t[i]->name); break; case POISON_NOT_DEFINED: printf(".poison !defined(%s)\n", t[i]->name); break; default: break; } free(t); printf("\n"); }
/* constants that do not change during successive pe calculations */ void prepareSfbPe(PE_CHANNEL_DATA *peChanData, const float *sfbEnergy, const float *sfbThreshold, const float *sfbFormFactor, const int *sfbOffset, const int sfbCnt, const int sfbPerGroup, const int maxSfbPerGroup) { int sfbGrp,sfb; int sfbWidth; float avgFormFactor; COUNT_sub_start("prepareSfbPe"); LOOP(1); for(sfbGrp = 0;sfbGrp < sfbCnt;sfbGrp+=sfbPerGroup){ PTR_INIT(6); /* pointers for sfbEnergy[], sfbThreshold[], sfbOffset[], sfbFormFactor[], peChanData->sfbNLines[], peChanData->sfbLdEnergy[] */ LOOP(1); for (sfb=0; sfb<maxSfbPerGroup; sfb++) { ADD(1); BRANCH(1); if (sfbEnergy[sfbGrp+sfb] > sfbThreshold[sfbGrp+sfb]) { ADD(1); sfbWidth = sfbOffset[sfbGrp+sfb+1] - sfbOffset[sfbGrp+sfb]; /* estimate number of active lines */ DIV(1); TRANS(1); avgFormFactor = (float) pow(sfbEnergy[sfbGrp+sfb]/(float)sfbWidth, 0.25f); DIV(1); STORE(1); peChanData->sfbNLines[sfbGrp+sfb] = sfbFormFactor[sfbGrp+sfb]/avgFormFactor; /* ld(sfbEn) */ TRANS(1); MULT(1); STORE(1); peChanData->sfbLdEnergy[sfbGrp+sfb] = (float) (log(sfbEnergy[sfbGrp+sfb]) * LOG2_1); } else { MOVE(2); peChanData->sfbNLines[sfbGrp+sfb] = 0.0f; peChanData->sfbLdEnergy[sfbGrp+sfb] = 0.0f; } } } COUNT_sub_end(); }
void CalcBandEnergyMS(const float *mdctSpectrumLeft, const float *mdctSpectrumRight, const int *bandOffset, const int numBands, float *bandEnergyMid, float *bandEnergyMidSum, float *bandEnergySide, float *bandEnergySideSum) { int i, j; COUNT_sub_start("CalcBandEnergyMS"); MOVE(3); j = 0; *bandEnergyMidSum = 0.0f; *bandEnergySideSum = 0.0f; PTR_INIT(5); /* pointers for bandEnergyMid[], bandEnergySide[], bandOffset[], mdctSpectrumLeft[], mdctSpectrumRight[] */ LOOP(1); for(i=0; i<numBands; i++) { MOVE(2); bandEnergyMid[i] = 0.0f; bandEnergySide[i] = 0.0f; LOOP(1); while (j < bandOffset[i+1]) { float specm, specs; ADD(2); MULT(2); specm = 0.5f * (mdctSpectrumLeft[j] + mdctSpectrumRight[j]); specs = 0.5f * (mdctSpectrumLeft[j] - mdctSpectrumRight[j]); MAC(2); STORE(2); bandEnergyMid[i] += specm * specm; bandEnergySide[i] += specs * specs; j++; } ADD(2); STORE(2); *bandEnergyMidSum += bandEnergyMid[i]; *bandEnergySideSum += bandEnergySide[i]; } COUNT_sub_end(); }
static void local_condense_vec(real *u, uint n, int op, const sint *cm) { switch(op) { case OP_ADD: LOOP(DO_ADD); break; case OP_MUL: LOOP(DO_MUL); break; case OP_MIN: LOOP(DO_MIN); break; case OP_MAX: LOOP(DO_MAX); break; case OP_BPR: LOOP(DO_BPR); break; } }
static int findClosestEntry(int goalSb, unsigned char *v_k_master, int numMaster, int direction) { int index; COUNT_sub_start("findClosestEntry"); ADD(1); BRANCH(1); if( goalSb <= v_k_master[0] ) { COUNT_sub_end(); return v_k_master[0]; } INDIRECT(1); ADD(1); BRANCH(1); if( goalSb >= v_k_master[numMaster] ) { COUNT_sub_end(); return v_k_master[numMaster]; } BRANCH(1); if(direction) { MOVE(1); index = 0; PTR_INIT(1); /* v_k_master[index] */ LOOP(1); while( v_k_master[index] < goalSb ) { ADD(1); index++; } } else { MOVE(1); index = numMaster; PTR_INIT(1); /* v_k_master[index] */ LOOP(1); while( v_k_master[index] > goalSb ) { ADD(1); index--; } } COUNT_sub_end(); return v_k_master[index]; }
int main(int argc, char **argv) { int n, i; char *s; char tmp[256]; void *p=(void*)0xdeadbeef; if (argc < 3) { usage(); return 1; } s = argv[2]; /* pre-printf tests */ TEST("pre-printf"); RUN(printf("string\n")); RUN(printf("%s\n", s)); RUN(printf("%d\n", 45)); RUN(printf("%d\n", 45098)); RUN(printf("%d\n", (int32_t)INT_MAX)); RUN(printf("%u\n", (uint32_t)INT_MAX+1)); RUN(printf("%u\n", (uint32_t)UINT_MAX)); /* Test strtol */ TEST("strtol"); RUN(printf("%ld\n", strtol("678", NULL, 0))); RUN(printf("%ld\n", strtol("0x4567", NULL, 0))); RUN(printf("%ld\n", strtol("0777", NULL, 0))); RUN(printf("%ld\n", strtol(argv[1], NULL, 0))); n = strtol(argv[1], NULL, 0); /* Dynamic printf */ TEST("printf"); LOOP(n) RUN(printf("%d\n", i*i*2)); ENDLOOP; LOOP(n) RUN(printf("%.2f\n", 1000.0/i/i)); ENDLOOP LOOP(n) RUN(printf("%x\n", i+i*45)); ENDLOOP RUN(printf("%s%s\n", s, s)); RUN(printf("%s%d%x%.2f%x%u%lu\n", s, n, n*n, 1024.0/n/n/n, 879875, (unsigned)n*n, (unsigned long)n*765*n)); RUN(printf("%p\n", p)); /* snprintf tests */ TEST("snprintf"); RUN( snprintf(tmp, 256, "Testing snprintf %d", n); printf("%s\n", tmp); );
static double nonlocal(real *u, int op, const nonlocal_info *info, MPI_Comm comm) { uint np = info->np, i; MPI_Request *reqs = info->reqs; uint *targ = info->target; uint *nshared = info->nshared; uint *sh_ind = info->sh_ind; uint id = info->id; real *buf = info->buf; #ifdef GS_TIMING double time0, time1; #endif for(i=0;i<np;++i) { MPI_Irecv(buf,nshared[i],REAL_MPI,targ[i],targ[i],comm,reqs++); buf+=nshared[i]; } #ifdef GS_BARRIER MPI_Barrier(comm); #endif #ifdef GS_TIMING time0 = MPI_Wtime(); #endif for(i=0;i<np;++i) { uint c = nshared[i]; real *start = buf; for(;c;--c) *buf++ = u[*sh_ind++]; MPI_Isend(start,nshared[i],REAL_MPI,targ[i],id,comm,reqs++); } MPI_Waitall(np*2,info->reqs,MPI_STATUSES_IGNORE); #ifdef GS_TIMING time1 = MPI_Wtime(); #endif buf = info->buf; sh_ind = info->sh_ind; # define LOOP(OP) do { \ for(i=0;i<np;++i) { \ uint c; \ for(c=nshared[i];c;--c) { OP(u[*sh_ind],*buf); ++sh_ind, ++buf; } \ } \ } while(0) switch(op) { case OP_ADD: LOOP(DO_ADD); break; case OP_MUL: LOOP(DO_MUL); break; case OP_MIN: LOOP(DO_MIN); break; case OP_MAX: LOOP(DO_MAX); break; case OP_BPR: LOOP(DO_BPR); break; } # undef LOOP #ifdef GS_TIMING return time1-time0; #else return 0; #endif }
/* * * \brief Perform complex-valued inverse modulation of the subband * samples stored in rSubband (real part) and iSubband (imaginary * part) and stores the result in timeOut * */ static void inverseModulation (float *qmfReal, float *qmfImag, HANDLE_SBR_QMF_FILTER_BANK synQmf ) { int i, no_synthesis_channels, M; float r1, i1, r2, i2; COUNT_sub_start("inverseModulation"); INDIRECT(1); MOVE(1); no_synthesis_channels = synQmf->no_channels; MULT(1); M = no_synthesis_channels / 2; PTR_INIT(2); /* pointer for qmfReal[], qmfImag[] */ INDIRECT(1); LOOP(1); for (i = synQmf->usb; i < no_synthesis_channels; i++) { MOVE(2); qmfReal[i]=qmfImag[i]=0; } FUNC(2); cosMod (qmfReal, synQmf); FUNC(2); sinMod (qmfImag, synQmf); PTR_INIT(4); /* pointer for qmfReal[], qmfImag[], qmfImag[no_synthesis_channels - 1 - i], qmfReal[no_synthesis_channels - i - 1] */ LOOP(1); for (i = 0; i < M; i++) { MOVE(4); r1 = qmfReal[i]; i2 = qmfImag[no_synthesis_channels - 1 - i]; r2 = qmfReal[no_synthesis_channels - i - 1]; i1 = qmfImag[i]; ADD(4); STORE(4); qmfReal[i] = (r1 - i1); qmfImag[no_synthesis_channels - 1 - i] = -(r1 + i1); qmfReal[no_synthesis_channels - i - 1] = (r2 - i2); qmfImag[i] = -(r2 + i2); } COUNT_sub_end(); }
void trace_back_lpo_po_alignment(int len_x,LPOLetter_T seq_x[], int len_y,LPOLetter_T seq_y[], LPOMove_T **move, LPOLetterRef_T best_x, LPOLetterRef_T best_y, LPOLetterRef_T **x_to_y, LPOLetterRef_T **y_to_x) { int i; LPOLetterRef_T new_x,*x_al=NULL,*y_al=NULL; LPOLetterLink_T *left; CALLOC(x_al,len_x,LPOLetterRef_T); CALLOC(y_al,len_y,LPOLetterRef_T); LOOP (i,len_x) x_al[i]= INVALID_LETTER_POSITION; LOOP (i,len_y) y_al[i]= INVALID_LETTER_POSITION; while (best_x>=0 && best_y>=0) { if (move[best_x][best_y].is_aligned) {/* ALIGNED! MAP best_x <--> best_y */ x_al[best_x]=best_y; y_al[best_y]=best_x; } if (0==move[best_x][best_y].x /* HIT START OF THE ALIGNMENT, SO QUIT */ && 0==move[best_x][best_y].y) break; if ((i=move[best_x][best_y].x)>0) { /* TRACE BACK ON X */ for (left= &seq_x[best_x].left;--i >0;left=left->more); /* USE iTH MOVE*/ new_x = left->ipos; } else new_x=best_x; if ((i=move[best_x][best_y].y)>0) { /* TRACE BACK ON Y */ for (left= &seq_y[best_y].left;--i >0;left=left->more); /* USE iTH MOVE*/ best_y = left->ipos; } best_x=new_x; } if (x_to_y) /* HAND BACK ALIGNMENT RECIPROCAL MAPPINGS */ *x_to_y = x_al; else free(x_al); if (y_to_x) *y_to_x = y_al; else free(y_al); return; }
static void gmStage1(SECTION_INFO * section, int bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const int maxSfb, const int *sideInfoTab) { int mergeStart = 0, mergeEnd; COUNT_sub_start("gmStage1"); MOVE(1); /* counting previous operations */ LOOP(1); do { PTR_INIT(4); /* pointers for section[mergeStart] section[mergeEnd] bitLookUp[mergeStart] bitLookUp[mergeEnd] */ ADD(1); LOOP(1); for (mergeEnd = mergeStart + 1; mergeEnd < maxSfb; mergeEnd++) { ADD(1); BRANCH(1); if (section[mergeStart].codeBook != section[mergeEnd].codeBook) break; ADD(1); STORE(1); section[mergeStart].sfbCnt++; ADD(1); STORE(1); section[mergeStart].sectionBits += section[mergeEnd].sectionBits; FUNC(2); mergeBitLookUp(bitLookUp[mergeStart], bitLookUp[mergeEnd]); } INDIRECT(1); ADD(1); STORE(1); section[mergeStart].sectionBits += sideInfoTab[section[mergeStart].sfbCnt]; MOVE(1); section[mergeEnd - 1].sfbStart = section[mergeStart].sfbStart; MOVE(1); mergeStart = mergeEnd; } while (mergeStart < maxSfb); COUNT_sub_end(); }
/* sum the pe data only for bands where avoid hole is inactive */ static void calcPeNoAH(float *pe, float *constPart, float *nActiveLines, PE_DATA *peData, int ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB], PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], const int nChannels) { int ch, sfb,sfbGrp; COUNT_sub_start("calcPeNoAH"); MOVE(3); *pe = 0.0f; *constPart = 0.0f; *nActiveLines = 0; LOOP(1); for(ch=0; ch<nChannels; ch++) { PSY_OUT_CHANNEL *psyOutChan = &psyOutChannel[ch]; PE_CHANNEL_DATA *peChanData = &peData->peChannelData[ch]; PTR_INIT(2); /* counting previous operations */ INDIRECT(2); LOOP(1); for(sfbGrp = 0;sfbGrp < psyOutChan->sfbCnt;sfbGrp+= psyOutChan->sfbPerGroup){ PTR_INIT(4); /* pointers for ahFlag[ch][sfbGrp+sfb], peChanData->sfbPe[sfbGrp+sfb], peChanData->sfbConstPart[sfbGrp+sfb], peChanData->sfbNActiveLines[sfbGrp+sfb] */ INDIRECT(1); LOOP(1); for (sfb=0; sfb<psyOutChan->maxSfbPerGroup; sfb++) { ADD(1); BRANCH(1); if(ahFlag[ch][sfbGrp+sfb] < AH_ACTIVE) { ADD(3); STORE(3); *pe += peChanData->sfbPe[sfbGrp+sfb]; *constPart += peChanData->sfbConstPart[sfbGrp+sfb]; *nActiveLines += peChanData->sfbNActiveLines[sfbGrp+sfb]; } } } } COUNT_sub_end(); }
/* * * \brief Create QMF filter bank instance * * \return 0 if succesful * */ int createCplxAnalysisQmfBank (HANDLE_SBR_QMF_FILTER_BANK h_sbrQmf, int noCols, int lsb, int usb, int chan) { int L; COUNT_sub_start("createCplxAnalysisQmfBank"); FUNC(2); LOOP(1); PTR_INIT(1); MOVE(1); STORE(sizeof(SBR_QMF_FILTER_BANK)); memset(h_sbrQmf,0,sizeof(SBR_QMF_FILTER_BANK)); MOVE(1); L = NO_ANALYSIS_CHANNELS; PTR_INIT(2); h_sbrQmf->p_filter = sbr_qmf_64_640; h_sbrQmf->pDct4Twiddle = dct4TwiddleTable; #ifndef LP_SBR_ONLY PTR_INIT(5); h_sbrQmf->cos_twiddle = sbr_cos_twiddle_L32; h_sbrQmf->sin_twiddle = sbr_sin_twiddle_L32; h_sbrQmf->alt_sin_twiddle = sbr_alt_sin_twiddle_L32; h_sbrQmf->t_cos = sbr_t_cos_L32; h_sbrQmf->t_sin = sbr_t_sin_L32; #endif MOVE(4); h_sbrQmf->no_channels = L; h_sbrQmf->no_col = noCols; h_sbrQmf->lsb = lsb; h_sbrQmf->usb = usb; PTR_INIT(1); h_sbrQmf->FilterStatesAna = &(sbr_CodecQmfStatesAnalysis[chan*QMF_FILTER_STATE_ANA_SIZE]); FUNC(2); LOOP(1); PTR_INIT(1); MOVE(1); STORE(QMF_FILTER_STATE_ANA_SIZE); memset(h_sbrQmf->FilterStatesAna,0,QMF_FILTER_STATE_ANA_SIZE*sizeof(float)); COUNT_sub_end(); return (0); }
/* * * \brief Perform complex-valued forward modulation of the time domain * data of timeIn and stores the real part of the subband * samples in rSubband, and the imaginary part in iSubband * */ static void sbrForwardModulation (const float *timeIn, float *rSubband, float *iSubband, HANDLE_SBR_QMF_FILTER_BANK anaQmf ) { int i, offset; float real, imag; COUNT_sub_start("sbrForwardModulation"); MOVE(1); offset = 2 * NO_ANALYSIS_CHANNELS; PTR_INIT(1); /* pointer for timeIn[offset - 1 - i] */ LOOP(1); for (i = 0; i < NO_ANALYSIS_CHANNELS; i++) { ADD(2); STORE(2); rSubband[i] = timeIn[i] - timeIn[offset - 1 - i]; iSubband[i] = timeIn[i] + timeIn[offset - 1 - i]; } FUNC(2); cosMod (rSubband, anaQmf); FUNC(2); sinMod (iSubband, anaQmf); PTR_INIT(4); /* pointers for rSubband[i], iSubband[i], anaQmf->t_cos[i], anaQmf->t_sin[i] */ INDIRECT(1); LOOP(1); for (i = 0; i < anaQmf->lsb; i++) { MOVE(2); real = rSubband[i]; imag = iSubband[i]; MULT(1); MAC(1); STORE(1); rSubband[i] = real * anaQmf->t_cos[i] + imag * anaQmf->t_sin[i]; MULT(2); ADD(1); STORE(1); iSubband[i] = imag * anaQmf->t_cos[i] - real * anaQmf->t_sin[i]; } COUNT_sub_end(); }
void* thread_fn(void* arg) { lli slee, start, end; lli loops_ps = loops_per_sec; double lratio = 1.0 - ratio; double wratio = lratio / (1. - lratio); lli loops, i; int syncl = sync_barrier; int local_finish; long long int interval = *((long long int*)arg); while(1) { r_lock(); /* begin reading */ if (syncl) { pthread_barrier_wait(&barrier); // this can't fail according to docs } local_finish = finished; r_unlock(); if (local_finish) { break; } start = GET_TIME(); mysleep(interval); end = GET_TIME(); slee = end - start; loops = (lli)(loops_ps * slee * wratio / 1000000.0); for (i=0; i < loops; i++) { LOOP(); } } return 0; }
static void gmStage0(SECTION_INFO * section, int bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1], const int maxSfb) { int i; COUNT_sub_start("gmStage0"); PTR_INIT(2); /* pointers for section[], bitLookUp[] */ LOOP(1); for (i = 0; i < maxSfb; i++) { ADD(1); BRANCH(1); if (section[i].sectionBits == INVALID_BITCOUNT) { PTR_INIT(1); FUNC(2); STORE(1); section[i].sectionBits = findBestBook(bitLookUp[i], &(section[i].codeBook)); } } COUNT_sub_end(); }
static int findMaxMerge(const int mergeGainLookUp[MAX_SFB_LONG], const SECTION_INFO *section, const int maxSfb, int *maxNdx) { int i, maxMergeGain = 0; COUNT_sub_start("findMaxMerge"); MOVE(1); /* counting previous operations */ PTR_INIT(2); /* pointers for section[], mergeGainLookUp[] */ LOOP(1); for (i = 0; i + section[i].sfbCnt < maxSfb; i += section[i].sfbCnt) { ADD(1); BRANCH(1); if (mergeGainLookUp[i] > maxMergeGain) { MOVE(2); maxMergeGain = mergeGainLookUp[i]; *maxNdx = i; } } COUNT_sub_end(); return (maxMergeGain); }
static int calcSideInfoBits(int sfbCnt, int blockType) { int seg_len_bits = (blockType == SHORT_WINDOW ? 3 : 5); int escape_val = (blockType == SHORT_WINDOW ? 7 : 31); int sideInfoBits, tmp; COUNT_sub_start("calcSideInfoBits"); ADD(2); BRANCH(2); MOVE(2); /* counting previous operations */ MOVE(2); sideInfoBits = CODE_BOOK_BITS; tmp = sfbCnt; LOOP(1); while (tmp >= 0) { ADD(2); sideInfoBits += seg_len_bits; tmp -= escape_val; } COUNT_sub_end(); return (sideInfoBits); }
static int findMinMergeBits(const int *bc1, const int *bc2) { int minBits = INVALID_BITCOUNT, j; COUNT_sub_start("findMinMergeBits"); MOVE(1); /* counting previous operations */ PTR_INIT(2); /* pointers for bc1[], bc2[] */ LOOP(1); for (j = 0; j <= CODE_BOOK_ESC_NDX; j++) { ADD(2); BRANCH(1); if (bc1[j] + bc2[j] < minBits) { MOVE(1); minBits = bc1[j] + bc2[j]; } } COUNT_sub_end(); return (minBits); }
int BCInit(void) { int i; COUNT_sub_start("BCInit"); PTR_INIT(1); /* sideInfoTabLong[] */ LOOP(1); for (i = 0; i <= MAX_SFB_LONG; i++) { FUNC(2); STORE(1); sideInfoTabLong[i] = calcSideInfoBits(i, LONG_WINDOW); } PTR_INIT(1); /* sideInfoTabShort[] */ for (i = 0; i <= MAX_SFB_SHORT; i++) { FUNC(2); STORE(1); sideInfoTabShort[i] = calcSideInfoBits(i, SHORT_WINDOW); } COUNT_sub_end(); return 0; }
/* constants that do not change during successive pe calculations */ static void preparePe(PE_DATA *peData, PSY_OUT_CHANNEL psyOutChannel[MAX_CHANNELS], float sfbFormFactor[MAX_CHANNELS][MAX_GROUPED_SFB], const int nChannels, const float peOffset) { int ch; COUNT_sub_start("preparePe"); LOOP(1); for(ch=0; ch<nChannels; ch++) { PSY_OUT_CHANNEL *psyOutChan = &psyOutChannel[ch]; PTR_INIT(1); /* counting previous operation */ INDIRECT(8); PTR_INIT(1); FUNC(8); prepareSfbPe(&peData->peChannelData[ch], psyOutChan->sfbEnergy, psyOutChan->sfbThreshold, sfbFormFactor[ch], psyOutChan->sfbOffsets, psyOutChan->sfbCnt, psyOutChan->sfbPerGroup, psyOutChan->maxSfbPerGroup); } INDIRECT(1); MOVE(1); peData->offset = peOffset; COUNT_sub_end(); }
/*! \brief Selects the SBR tuning. \return Index ****************************************************************************/ static int getSbrTuningTableIndex(unsigned int bitrate, unsigned int numChannels, unsigned int sampleRate ) { int i, paramSets = sizeof (tuningTable) / sizeof (tuningTable [0]); COUNT_sub_start("getSbrTuningTableIndex"); MOVE(1); /* counting previous operation */ PTR_INIT(1); /* tuningTable[] */ LOOP(1); for (i = 0 ; i < paramSets ; i++) { ADD(1); BRANCH(1); if (numChannels == tuningTable [i].numChannels) { ADD(3); LOGIC(2); BRANCH(1); if ((sampleRate == tuningTable [i].sampleRate) && (bitrate >= tuningTable [i].bitrateFrom) && (bitrate < tuningTable [i].bitrateTo)) { COUNT_sub_end(); return i ; } } } COUNT_sub_end(); return INVALID_TABLE_IDX; }
static int findBestBook(const int *bc, int *book) { int minBits = INVALID_BITCOUNT, j; COUNT_sub_start("findBestBook"); MOVE(1); /* counting previous operations */ PTR_INIT(1); /* pointer for bc[] */ LOOP(1); for (j = 0; j <= CODE_BOOK_ESC_NDX; j++) { ADD(1); BRANCH(1); if (bc[j] < minBits) { MOVE(2); minBits = bc[j]; *book = j; } } COUNT_sub_end(); return (minBits); }
static float AdvanceMAFilter( IIR_FILTER *iirFilter ) { float y; int j; int ptr = iirFilter->ptr; int i = ptr + (BUFFER_SIZE-1); COUNT_sub_start("AdvanceMAFilter"); INDIRECT(1); /* MOVE(1); --> ptr isn't needed */ ADD(1); /* counting previous operations */ INDIRECT(2); MULT(1); y = (iirFilter->coeffIIRa[0] * iirFilter->ring_buf_2[i & (BUFFER_SIZE-1)]); PTR_INIT(3); /* iirFilter->noOffCoeffs iirFilter->coeffIIRa[] iirFilter->ring_buf_2[] */ LOOP(1); for (j=1; j<iirFilter->noOffCoeffs; j++) { i--; MAC(1); y += (iirFilter->coeffIIRa[j] * iirFilter->ring_buf_2[i & (BUFFER_SIZE-1)]); } COUNT_sub_end(); return y; }