📄 main.c
字号:
#endif hAACDecoder = (HAACDecoder *)AACInitDecoder(); if (!hAACDecoder) { printf(" *** Error initializing decoder ***\n"); Usage(); return -1; } DebugMemCheckEndPoint(); /* initialize timing code */ InitTimer(); peakMHz = 0; lastDiffTime = 0; audioFrameSecs = 0; /* init after decoding first frame */ bytesLeft = 0; outOfData = 0; eofReached = 0; readPtr = readBuf; err = 0; skipFrames = SKIP_FRAMES; playStatus = Play; nFramesTNSOn = 0; nFramesTNSOff = 0; totalDecTimeTNSOn = 0; totalDecTimeTNSOff = 0; do { /* somewhat arbitrary trigger to refill buffer - should always be enough for a full frame */ if (bytesLeft < AAC_MAX_NCHANS * AAC_MAINBUF_SIZE && !eofReached) { nRead = FillReadBuffer(readBuf, readPtr, READBUF_SIZE, bytesLeft, infile); bytesLeft += nRead; readPtr = readBuf; if (nRead == 0) eofReached = 1; } startTime = ReadTimer(); /* decode one AAC frame */ err = AACDecode(hAACDecoder, &readPtr, &bytesLeft, outBuf); endTime = ReadTimer(); diffTime = CalcTimeDifference(startTime, endTime); if (err) { /* error occurred */ switch (err) { case ERR_AAC_INDATA_UNDERFLOW: /* need to provide more data on next call to AACDecode() (if possible) */ if (eofReached || bytesLeft == READBUF_SIZE) outOfData = 1; break; default: outOfData = 1; break; } } if (outOfData) break; /* no error */ AACGetLastFrameInfo(hAACDecoder, &aacFrameInfo); if (firstWrite) { if (outputWAV) { WriteWAVHeader(outfile, &aacFrameInfo); } firstWrite = 0; } if (skipFrames == 0 && outfile) { if (bigEndian && outputWAV && aacFrameInfo.bitsPerSample == 16) { int lSizeBytes = aacFrameInfo.outputSamps * aacFrameInfo.bitsPerSample / 8; swap16((unsigned char*) outBuf, (unsigned long) lSizeBytes); } fwrite(outBuf, aacFrameInfo.bitsPerSample / 8, aacFrameInfo.outputSamps, outfile); } if (skipFrames != 0) skipFrames--; playStatus = PollHardware(); switch (playStatus) { case Stop: case Quit: printf("Warning - Processing aborted"); break; case Play: break; } if (!audioFrameSecs) audioFrameSecs = ((float)aacFrameInfo.outputSamps) / ((float)aacFrameInfo.sampRateOut * aacFrameInfo.nChans); currMHz = ARMULATE_MUL_FACT * (1.0f / audioFrameSecs) * diffTime / 1e6f; peakMHz = (currMHz > peakMHz ? currMHz : peakMHz); if (aacFrameInfo.tnsUsed) { nFramesTNSOn++; totalDecTimeTNSOn += diffTime; } else { nFramesTNSOff++; totalDecTimeTNSOff += diffTime; }#if defined (__arm) && defined (__ARMCC_VERSION) printf("frame %5d [%10u - %10u = %6u tks] .. ", nFramesTNSOn + nFramesTNSOff, startTime, endTime, diffTime); printf("curr MHz = %5.2f, peak MHz = %5.2f, delta tks = %#d (T=%c)\r", currMHz, peakMHz, diffTime - lastDiffTime, aacFrameInfo.tnsUsed ? '*' : ' '); fflush(stdout);#endif if (nFramesTNSOn + nFramesTNSOff == MAX_FRAMES) break; } while (playStatus == Play);#if defined (__arm) && defined (__ARMCC_VERSION) logfile = stdout;#elif defined (_WIN32) && defined (_WIN32_WCE) logfile = fopen("\\Temp\\testwrap.log", "wb");#else logfile = 0;#endif if (logfile) { audioSecs = (float)nFramesTNSOff * audioFrameSecs; if (nFramesTNSOff) { fprintf(logfile, "\n\nTNS OFF: Total clock ticks = %13.0f, MHz usage = %5.2f, nFrames = %4d\n", totalDecTimeTNSOff, ARMULATE_MUL_FACT * (1.0f / audioSecs) * totalDecTimeTNSOff / 1e6f, nFramesTNSOff); } else { fprintf(logfile, "\n\nTNS OFF: no frames\n"); } audioSecs = (float)nFramesTNSOn * audioFrameSecs; if (nFramesTNSOn) { fprintf(logfile, "TNS ON: Total clock ticks = %13.0f, MHz usage = %5.2f, nFrames = %4d\n\n", totalDecTimeTNSOn, ARMULATE_MUL_FACT * (1.0f / audioSecs) * totalDecTimeTNSOn / 1e6f, nFramesTNSOn); } else { fprintf(logfile, "TNS ON: no frames\n\n"); } fprintf(logfile, "nFrames total = %d, output samps = %d, sampRate = %d, nChans = %d\n", nFramesTNSOn + nFramesTNSOff, aacFrameInfo.outputSamps, aacFrameInfo.sampRateOut, aacFrameInfo.nChans); if (logfile != stdout) fclose(logfile); } audioSecs = 0; FreeTimer(); if (err != ERR_AAC_NONE && err != ERR_AAC_INDATA_UNDERFLOW) printf("Error - %d", err); printf("\n"); AACFreeDecoder(hAACDecoder);#ifdef HELIX_CONFIG_AAC_GENERATE_TRIGTABS_FLOAT AACFreeTrigtabsFloat();#endif /* close files */ fclose(infile); if (outfile) { fclose(outfile); if (outputWAV) { UpdateWAVHeader(outfileName); } } DebugMemCheckFree(); return 0;}#if defined (_WIN32) && defined (_WIN32_WCE)#include <windows.h>#include <aygshell.h> /* PocketPC shell functions */#include <nled.h> /* LED on WinCE only */HXBOOL NLedGetDeviceInfo(int nID, void *pOutput); HXBOOL NLedSetDevice(int nID, void *pOutput);static void StartLED(void){ int numLeds; struct NLED_COUNT_INFO nLedCountInfo; struct NLED_SETTINGS_INFO nLedSettingsInfo; numLeds = 0; if( NLedGetDeviceInfo(NLED_COUNT_INFO_ID, &nLedCountInfo) ) numLeds = (int)nLedCountInfo.cLeds; /* 0 = off, 1 = on, 2 = blink */ if (numLeds >= 1) { nLedSettingsInfo.LedNum = 0; nLedSettingsInfo.OffOnBlink = 1; NLedSetDevice(NLED_SETTINGS_INFO_ID, &nLedSettingsInfo); }}static void StopLED(void){ int numLeds; struct NLED_COUNT_INFO nLedCountInfo; struct NLED_SETTINGS_INFO nLedSettingsInfo; numLeds = 0; if( NLedGetDeviceInfo(NLED_COUNT_INFO_ID, &nLedCountInfo) ) numLeds = (int)nLedCountInfo.cLeds; /* 0 = off, 1 = on, 2 = blink */ if (numLeds >= 1) { nLedSettingsInfo.LedNum = 0; nLedSettingsInfo.OffOnBlink = 0; NLedSetDevice(NLED_SETTINGS_INFO_ID, &nLedSettingsInfo); }}//#define STEST#ifdef STEST#define NUM_FILES 10static const char *stestName[NUM_FILES] = { "aero128_44s_adts", "aero64_22m_adts", "al_sbr_gh_44_2", "AL05_24000", "al18_48000", "al19_11025", "btrav128_44s_adif", "L4_11025", "star32p_44m_adts", "star48p_44s_adts",};#else#define NUM_FILES 1#endif#define LOG_TOTAL_TIMEint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd){ int i; char infileName[256], outfileName[256]; char *testArgs[3];#ifdef LOG_TOTAL_TIME int startTime, endTime, diffTime; FILE *logFile;#endif for (i = 0; i < NUM_FILES; i++) {#ifdef STEST strcpy(infileName, "\\Temp\\smoke\\"); strcat(infileName, stestName[i]); strcat(infileName, ".aac"); strcpy(outfileName, "\\ipaq file store\\"); strcat(outfileName, stestName[i]); strcat(outfileName, ".pcm");#else strcpy(infileName, "\\Temp\\file.aac"); strcpy(outfileName, "nul");#endif testArgs[0] = "testwrap.exe"; testArgs[1] = infileName; testArgs[2] = outfileName;#ifdef LOG_TOTAL_TIME startTime = GetTickCount();#endif StartLED(); main(3, testArgs); StopLED();#ifdef LOG_TOTAL_TIME endTime = GetTickCount(); diffTime = endTime - startTime; logFile = fopen("\\Temp\\totaltime.log", "wb"); if (logFile) { fprintf(logFile, "startTime = %10d, endTime = %10d, diffTime = %10d mSecs\n", startTime, endTime, diffTime); fclose(logFile); }#endif } return 0;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -