void __print_Buffer(FILE *fOut, PERF_Private *perf, unsigned long ulAddress1, unsigned long ulAddress2, unsigned long ulSize, PERF_MODULETYPE eModule) { /* get debug private structure */ PERF_PRINT_Private *me = perf->cip.pDebug; unsigned long module1 = ((unsigned long) eModule) & PERF_ModuleMask; unsigned long module2 = (((unsigned long) eModule) >> PERF_ModuleBits) & PERF_ModuleMask; int xfering = PERF_IsXfering ((unsigned long) eModule); int sendIx = (PERF_GetSendRecv ((unsigned long) eModule) >> 28) & 3; int sending = PERF_IsSending ((unsigned long) eModule); int frame = PERF_IsFrame ((unsigned long) eModule); int multiple = PERF_IsMultiple((unsigned long) eModule); if (!xfering && sending) module2 = module1; fprintf(fOut, "%s%ld.%06ld%sBuffer%s%s%s%s%s%s%s%s%s0x%lx%s0x%lx", me->prompt, TIME_SECONDS(perf->time), TIME_MICROSECONDS(perf->time), me->info, me->csv ? "," : "(", xfering ? "xfering" : sendRecvTxt[sendIx], me->csv ? "," : " ", frame ? "frame" : "buffer", me->csv ? "," : (xfering || !sending) ? " from=" : "", (xfering || !sending) ? (module1 < PERF_ModuleMax ? PERF_ModuleTypes[module1] : "INVALID") : "", me->csv ? "," : (xfering || sending) ? " to=" : "", (xfering || sending) ? (module2 < PERF_ModuleMax ? PERF_ModuleTypes[module2] : "INVALID") : "", me->csv ? "," : " size=", ulSize, me->csv ? "," : " addr=", ulAddress1); /* print second address if supplied */ if (multiple) { fprintf(fOut, "%s0x%lx", me->csv ? "," : " addr=", ulAddress2); } fprintf(fOut, "%s" __LINE_END__, me->csv ? "" : ")"); print_print_location(perf, fOut, 6 + (multiple ? 1 : 0)); }
static void print_rate_info(FILE *fOut, unsigned long ID, PERF_MODULETYPE modulesAndFlags, unsigned long size, long n) { unsigned long module1 = modulesAndFlags & PERF_ModuleMask; unsigned long module2 = (modulesAndFlags >> PERF_ModuleBits) & PERF_ModuleMask; int xfering = PERF_IsXfering(modulesAndFlags); int sendIx = (PERF_GetSendRecv(modulesAndFlags) >> 28) & 3; int sending = PERF_IsSending(modulesAndFlags); int frame = PERF_IsFrame (modulesAndFlags); fprintf(fOut, "%c%c%c%c %s %ld+ %s[0x%lX]%s%s%s%s", PERF_FOUR_CHARS(ID), xfering ? "xfering" : sendRecvTxt[sendIx], n, frame ? "frames" : "buffers", size, (xfering || !sending) ? " from " : " to ", (module1 < PERF_ModuleMax ? PERF_ModuleTypes[module1] : "INVALID"), xfering ? " to " : "", xfering ? (module2 < PERF_ModuleMax ? PERF_ModuleTypes[module2] : "INVALID") : ""); }
void __rt_Buffer(PERF_Private *perf, unsigned long ulAddress1, unsigned long ulAddress2, unsigned long ulSize, PERF_MODULETYPE eModuleAndFlags) { /* get real-time private structure */ PERF_RT_Private *me = perf->cip.pRT; /* see if we care about this buffer in the rate calculation */ unsigned long module = eModuleAndFlags & PERF_ModuleMask; /* ------------------------ RATE METRICS ------------------------ */ /* change HLMM to LLMM for detailed = 0 and 1 */ if (me->detailed < 2 && module == PERF_ModuleHLMM) { module = PERF_ModuleLLMM; } int rate = (me->detailed == 2) || (me->detailed == 0 && (eModuleAndFlags == me->only_moduleandflags && ulSize >= 8)) || (me->detailed == 1 && ((module == PERF_ModuleHardware || module == PERF_ModuleLLMM))); if (rate && me->dRate && (!me->needSteadyState || me->steadyState)) { /* change encoded filled frame sizes to 0xBEEFED, as they tend to have varying sizes and thus not be counted */ unsigned long sending = PERF_GetXferSendRecv(eModuleAndFlags); unsigned long size = ulSize; if ((me->encoder || me->decoder) && !PERF_IsXfering(sending)) { /* reverse sending direction to common layer or socket node */ if (module >= PERF_ModuleCommonLayer && module <= PERF_ModuleSocketNode) { sending ^= PERF_FlagSending; } if ((me->encoder && (sending == PERF_FlagSending)) || (me->decoder && (sending == PERF_FlagReceived))) { size = size ? 0xBEEFED : 0; } } /* see if we are tracking this buffer size */ int i, j = -1; /* j is one of the lest used indexes */ for (i=0; i < me->nDRate; i++) { if (me->dRate[i].modulesAndFlags == eModuleAndFlags && me->dRate[i].size == size) break; if (j < 0 || me->dRate[i].n < me->dRate[j].n) { j = i; } } /* if we are not yet tracking this buffer, see if we can track it. */ if (i == me->nDRate) { /* we have space to track it */ if (i < me->maxDRate) { me->nDRate++; } /* if we cannot replace another rate, we don't track it */ else if (j < 0 || me->dRate[j].n < 2) { i = me->maxDRate; } else { i = j; } /* start tracking */ if (i < me->maxDRate) { me->dRate[i].modulesAndFlags = eModuleAndFlags; me->dRate[i].size = size; me->dRate[i].xx = me->dRate[i].x = me->dRate[i].n = 0; me->dRate[i].txx = me->dRate[i].tx = me->dRate[i].tn = me->dRate[i].tn0 = 0; me->dRate[i].axx = me->dRate[i].ax = me->dRate[i].an = 0; me->dRate[i].skip = me->needSteadyState ? 0 : 4; TIME_COPY(me->dRate[i].last_timestamp, perf->time); TIME_COPY(me->dRate[i].last_reporting, perf->time); } } else { if (me->dRate[i].skip == 0) { /* see if we passed our granularity */ int steps = TIME_DELTA(perf->time, me->dRate[i].last_reporting); if (steps >= me->granularity) { steps /= me->granularity; /* unless debug bit 4 is set, ignore temporal statistics if we passed the last time by more than a second, and less than the minimul frames were processed in this burst so far, and the last fps was less than 1. */ if (!(me->debug & 4) && (me->dRate[i].tn0 < MIN_FRAMES_FOR_RATE) && (me->dRate[i].tn < me->granularity * steps)) { if (me->debug & 256) { fprintf(me->fRt, "rtPERF: [%ld] IGNORED (steps=%d, tn0=%ld, tn=%ld)\n", TIME_DELTA(me->dRate[i].last_reporting, me->first_time)/1000000, steps, me->dRate[i].tn0, me->dRate[i].tn); } me->dRate[i].txx = me->dRate[i].tx = me->dRate[i].tn = me->dRate[i].tn0 = 0; TIME_INCREASE(me->dRate[i].last_reporting, me->granularity * steps); steps = 0; } else if (me->debug & 256) { fprintf(me->fRt, "rtPERF: [%ld] not-ignored (steps=%d, tn0=%ld, tn=%ld)\n", TIME_DELTA(me->dRate[i].last_reporting, me->first_time)/1000000, steps, me->dRate[i].tn0, me->dRate[i].tn); } /* see if we surpassed our granularity. if yes, calculate temporal statistics */ while (steps) { /* count temporal rate */ count_temporal_rate(perf->ulID, me, me->dRate + i); TIME_INCREASE(me->dRate[i].last_reporting, me->granularity); steps--; } } /* rate is */ unsigned long delta = TIME_DELTA(perf->time, me->dRate[i].last_timestamp); me->dRate[i].x += delta; me->dRate[i].tx += delta; me->dRate[i].xx += delta * (double) delta; me->dRate[i].txx += delta * (double) delta; me->dRate[i].n ++; me->dRate[i].tn ++; me->dRate[i].tn0 ++; } else { me->dRate[i].skip--; if (me->dRate[i].skip == 0) { TIME_COPY(me->dRate[i].last_reporting, perf->time); me->dRate[i].txx = me->dRate[i].tx = me->dRate[i].tn = 0; } } TIME_COPY(me->dRate[i].last_timestamp, perf->time); } } /* ------------------------ SHOT-TO-SHOT METRICS ------------------------ */ if (me->dSTS) { if (eModuleAndFlags == (PERF_FlagSending | PERF_FlagFrame | PERF_ModuleHardware)) { /* queueing buffers to camera */ /* see if resolution has changed */ if (ulSize < me->dSTS->size_min || ulSize > me->dSTS->size_max) { /* report burst rate if we have any */ if (me->debug) { if (me->dSTS->dBurst2.n > 0) { count_delay(me, "Modified burst shot-to-shot", &me->dSTS->dBurst2, 0); } if (me->dSTS->dBurst.n > 0) { count_delay(me, "Raw burst shot-to-shot", &me->dSTS->dBurst, -1); } } me->dSTS->dBurst.n = -1; me->dSTS->dBurst2.n = 0; /* set new size */ me->dSTS->size_min = ulSize > 2048 ? ulSize - 2048 : 0; me->dSTS->size_max = ulSize; /* if more than D1-PAL, we assume it is an image, not a preview */ if (ulSize > 0x119000) { /* new burst mode start */ me->dSTS->capturing = 1; } else { /* preview start */ me->dSTS->capturing = 0; } } } else if (eModuleAndFlags == (PERF_FlagReceived | PERF_FlagFrame | PERF_ModuleHardware)) { /* gotten buffers from camera */ if (me->dSTS->capturing && ulSize >= me->dSTS->size_min && ulSize <= me->dSTS->size_max) { /* see if we have a capture already (we ignore the first) to count into the modified capture */ if (me->dSTS->dBurst.n > 1) { /* count last time delta */ if (me->dSTS->dBurst.n > 2) { delay_add(&me->dSTS->dBurst2, me->dSTS->last_burst); delay_add(&me->dSTS->dABurst2, me->dSTS->last_burst); if (me->debug) { fprintf(me->fRt, "rtPERF: [%ld] Modified burst shot-to-shot[0x%lX]: %.3g s\n", me->dSTS->dBurst2.n, me->dSTS->size_min, 1e-6 * me->dSTS->last_burst); } } me->dSTS->last_burst = TIME_DELTA(perf->time, me->dSTS->dBurst.last_timestamp); } else if (me->dSTS->dBurst.n < 0) { /* if this is the first shot in the burst sequence */ /* calculate single shot-to-shot delay */ if (me->dSTS->dSingle.n >= 0) { if (me->debug) { fprintf(me->fRt, "rtPERF: [#%ld] Single shot-to-shot[0x%lX]: %.3g s\n", me->dSTS->dSingle.n + 1, me->dSTS->size_min, 1e-6 * TIME_DELTA(perf->time, me->dSTS->dSingle.last_timestamp)); } delay_delta(&me->dSTS->dSingle, perf); } } if (me->dSTS->dBurst.n >= 0) { if (me->debug) { fprintf(me->fRt, "rtPERF: [#%ld] Raw burst shot-to-shot[0x%lX]: %.3g s\n", me->dSTS->dBurst.n + 1, me->dSTS->size_min, 1e-6 * TIME_DELTA(perf->time, me->dSTS->dBurst.last_timestamp)); } delay_add(&me->dSTS->dABurst, TIME_DELTA(perf->time, me->dSTS->dBurst.last_timestamp)); } delay_delta(&me->dSTS->dBurst, perf); /* keep last captured image time stamp for single shot-to-shot */ TIME_COPY(me->dSTS->dSingle.last_timestamp, perf->time); if (me->dSTS->dSingle.n < 0) { me->dSTS->dSingle.n = 0; /* captured first time stamp */ } } } } /* ------------------------ UPTIME METRICS ------------------------ */ if (0 && me->dUptime && me->dUptime->measuring) { /* see if we passed our granularity. if yes, calculate uptime */ int steps = TIME_DELTA(perf->time, me->dUptime->last_reporting); if (steps >= me->granularity) { steps /= me->granularity; double uptime, idletime, load = 0; /* calculate MHz load */ get_uptime(&uptime, &idletime); if (uptime > 0 && me->dUptime->success) { me->dUptime->last_idletime = idletime - me->dUptime->last_idletime; me->dUptime->last_uptime = uptime - me->dUptime->last_uptime; if (me->dUptime->last_uptime > 0) { load = 100. * ((me->dUptime->last_uptime - me->dUptime->last_idletime) / me->dUptime->last_uptime); me->dUptime->n += steps; me->dUptime->x += load * steps; me->dUptime->xx += load * load * steps; } } TIME_INCREASE(me->dUptime->last_reporting, steps * me->granularity); if (uptime > 0 && me->dUptime->success) { me->dUptime->last_uptime = uptime; me->dUptime->last_idletime = idletime; if (me->debug) { fprintf(me->fRt, "rtPERF: [%ld] ARM CPU-load is %.3g%%\n", TIME_DELTA(perf->time, me->first_time)/1000000, load); } } else { me->dUptime->success = 0; } } } }