📄 mae_pass_thru.c
字号:
CachedFILE pFile; int inner, outer; void *pOutput; char *szFrameNumAndExt = NULL; if(nFileUpdates & NO_DUMP_ALL) { if ( (nFileUpdates & DUMP_FINAL) && (strstr(xFileName, "Final")) ) { // go ahead and print // this is a special case for printing ONLY the final output } else { return; } } //read, write & append pFile = FileCacheGet(xFileName); //pFile = fopen (xFileName,"a+"); if (pCheckBlk->nOutputType == IQUANT_DONE) { pOutput = (short *)pCheckBlk->blk_after_iquant; } else if (pCheckBlk->nOutputType == IDCT_DONE_8_BIT) { pOutput = (unsigned char *)pCheckBlk->blk_after_idct_8bit; } else if (pCheckBlk->nOutputType == IDCT_DONE_32_BIT) { pOutput = (int *)pCheckBlk->blk_after_idct_32bit; } else if (pCheckBlk->nOutputType == MOTION_COMP_DONE) { pOutput = (unsigned char *)pCheckBlk->blk_after_mcomp; } if (pFile) { // Is this Inter frame coded as Intra. If so, dump // out some minimal info & return if (pCheckBlk->nBlkType == Y1_LUMA_BLOCK && (pCheckBlk->nIntraWithinInter == INTER_CODED_AS_INTRA || pCheckBlk->nIntraWithinInter == MACROBLOCK_SKIPPED)) { // Write the MB number only while processing the Y0 block // Also, dump out that this is a special MB if (pCheckBlk->nIntraWithinInter == INTER_CODED_AS_INTRA) { fprintf(pFile, "$MacroBlock #%d: INTER_CODED_AS_INTRA ", pCheckBlk->nMB); // Get the frame number & the extension of the Intra frame (If // the file name is IQUANTInter2.mae, extract 2.mae). This will // then get appended to "IQUANTIntra". Do the same to the IDCT // file as well. // ************************************************************ // Check for the letter P in IQUANTInterPn.xxx (or IDCTInterPn.xxx) // & return a pointer to the rest of the string szFrameNumAndExt = strchr(xFileName, 'P'); if (pCheckBlk->nOutputType == IQUANT_DONE) { if (szFrameNumAndExt) fprintf(pFile, "[Check out IQUANTIntra%s as well]:NO_DATA:\n", (szFrameNumAndExt+1));// strncpy(szFrameNumAndExt, xFileName + sizeof(FILE_AFTER_INTER_P_IQUANT) - 1, // sizeof(FILE_AFTER_INTRA_IQUANT));// fprintf(pFile, "[Check out IQUANTIntra%s as well]:\n", szFrameNumAndExt); } else { if (szFrameNumAndExt) fprintf(pFile, "[Check out IDCTIntra%s as well]:NO_DATA:\n", (szFrameNumAndExt+1));// strncpy(szFrameNumAndExt, xFileName + sizeof(FILE_AFTER_INTER_P_IDCT) - 1, // sizeof(FILE_AFTER_INTRA_IDCT));// fprintf(pFile, "[Check out IDCTIntra%s as well]:\n", szFrameNumAndExt); } } else if (pCheckBlk->nIntraWithinInter == MACROBLOCK_SKIPPED) { fprintf(pFile, "$MacroBlock #%d: MACROBLOCK_SKIPPED (No IQUANT & IDCT):NO_DATA:\n", pCheckBlk->nMB); } FileCacheDone(pFile); //fclose (pFile); return; } // Handle only IQUANT & IDCT output here // ************************************** // Write the block type switch(pCheckBlk->nBlkType) { case Y1_LUMA_BLOCK: default: // Write the MB number only while processing the Y0 block fprintf(pFile, "$MacroBlock #%d:\n", pCheckBlk->nMB); fprintf(pFile, "$Y0 Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case Y2_LUMA_BLOCK: fprintf(pFile, "$Y1 Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case Y3_LUMA_BLOCK: fprintf(pFile, "$Y2 Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case Y4_LUMA_BLOCK: fprintf(pFile, "$Y3 Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case U_CHROMA_BLOCK: fprintf(pFile, "$U Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case U2_CHROMA_BLOCK: fprintf(pFile, "$U2 Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case V_CHROMA_BLOCK: fprintf(pFile, "$V Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; case V2_CHROMA_BLOCK: fprintf(pFile, "$V2 Block: Coded = %s\n", (pCheckBlk->bBlockCoded == 0 ? "NO" : "YES")); break; } // Process just 1 block for all kinds of output // ******************************************** // Is IQUANT done? if ( (pCheckBlk->nOutputType == IQUANT_DONE) && (strstr (xFileName, "mae")) ) { int *pOut = (int *)pOutput; for (inner=0; inner<BLOCK_SIZE; inner++) { fprintf(pFile, "%08x:%08x:%08x:%08x:%08x:%08x:%08x:%08x:\n",*pOut, *(pOut + 1), *(pOut + 2), *(pOut + 3), *(pOut + 4), *(pOut + 5), *(pOut + 6), *(pOut + 7)); pOut += 8; } } else if ( (pCheckBlk->nOutputType == IQUANT_DONE) && (strstr (xFileName, "ref")) ) { short int *pOut = (short int *)pOutput; for (outer=0; outer<BLOCK_SIZE; outer++) { fprintf(pFile, "%08x:%08x:%08x:%08x:%08x:%08x:%08x:%08x:\n",*pOut >> 4, *(pOut + 1) >> 4, *(pOut + 2) >> 4, *(pOut + 3) >> 4, *(pOut + 4) >> 4, *(pOut + 5) >> 4, *(pOut + 6) >> 4, *(pOut + 7) >> 4); pOut += 8; } } // 8-bit IDCT output values else if ( (pCheckBlk->nOutputType == IDCT_DONE_8_BIT) || (pCheckBlk->nOutputType == MOTION_COMP_DONE) ) { unsigned char *pOrg = (unsigned char *)pOutput; unsigned char *pOut = pOrg; for (inner=0; inner<BLOCK_SIZE; inner++) { // The Reference code doesn't store the output of IDCT contiguously!! // Use the StepSize only if its positive!! // ****************************************************************** if (pCheckBlk->nStepSize) (unsigned char *)pOutput = (unsigned char *)(pOrg + (inner*pCheckBlk->nStepSize)); fprintf(pFile, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\n",*pOut, *(pOut + 1), *(pOut + 2), *(pOut + 3), *(pOut + 4), *(pOut + 5), *(pOut + 6), *(pOut + 7)); if (pCheckBlk->nStepSize) pOut += pCheckBlk->nStepSize; else pOut += 8; } } // 32-bit IDCT output values else if (pCheckBlk->nOutputType == IDCT_DONE_32_BIT) { int *pOrg = (int *)pOutput; int *pOut = pOrg; for (inner=0; inner<BLOCK_SIZE; inner++) { // The Reference code doesn't store the output of IDCT contiguously!! // Use the StepSize only if its positive!! // ****************************************************************** if (pCheckBlk->nStepSize) (int *)pOutput = (int *)(pOrg + (inner*pCheckBlk->nStepSize)); fprintf(pFile, "%08x:%08x:%08x:%08x:%08x:%08x:%08x:%08x:\n",*pOut, *(pOut + 1), *(pOut + 2), *(pOut + 3), *(pOut + 4), *(pOut + 5), *(pOut + 6), *(pOut + 7)); pOut += 8; } } FileCacheDone(pFile); //fclose (pFile); }}// ***************************************************************************//// Function: InterChecksAfterMC////// Parameters: pINTERMEDITATE_MB_CHECKERS pIntraCheckers -- // pointer to INTERMEDITATE_MB_CHECKERS struct// char *xFileName -- file name to write data into// int nMBType -- needed to point to the correct block//// Return Value: VOID//// Notes: After Motion Compensation is performed, the output// is bundled in a single Macro Block (unlike IQUANT // IDCT wherein each block's output is separate).//// ***************************************************************************void InterChecksAfterMC(pINTERMEDITATE_MB_CHECKERS pCheckMB, char *xFileName, int nMBType){ CachedFILE pFile; int i, inner; unsigned char *pYOut, *pCbOut, *pCrOut; char szMBType[10] = {0}, szMBMode[15] = {0}; if(nFileUpdates & NO_DUMP_ALL) return; //read, write & append pFile = FileCacheGet(xFileName); //pFile = fopen (xFileName, "a+"); if (!pFile) return; // Write the MB number only while processing the Y0 block //if (pCheckMB->nSkipped == MACROBLOCK_SKIPPED) // fprintf(pFile, "$MacroBlock #%d: SKIPPED: ", pCheckMB->nMB); //else fprintf(pFile, "$MacroBlock #%d: ", pCheckMB->nMB); pYOut = pCheckMB->cur_y_frame; pCbOut = pCheckMB->cur_cb_frame; pCrOut = pCheckMB->cur_cr_frame; for (i=0; i<Y4_LUMA_BLOCK; i++) { if (i+1 == Y1_LUMA_BLOCK) { // Write the MBType if (nMBType == MBT_16x16) strcpy(szMBType, "MBT_16x16"); else if (nMBType == MBT_16x8) strcpy(szMBType, "MBT_16x8"); else if (nMBType == MBT_8x8) strcpy(szMBType, "MBT_8x8"); fprintf(pFile, "MBType=%s: ", szMBType); // Write the MBMode if (pCheckMB->nMBMode == MBM_FORWARD) strcpy(szMBMode, "Forward Only"); else if (pCheckMB->nMBMode == MBM_BACKWARD) strcpy(szMBMode, "Backward Only"); else if (pCheckMB->nMBMode == MBM_BIDIRECTIONAL) strcpy(szMBMode, "Bi-Directional"); fprintf(pFile, "MBMode=%s: \n", szMBMode); if (pCheckMB->nMBMode == MBM_BIDIRECTIONAL) { if (pCheckMB->nRefType == FORWARD_REFERENCES) fprintf(pFile, "$Y0 Block (FORWARD_REFERENCES):\n"); else if (pCheckMB->nRefType == BACKWARD_REFERENCES) fprintf(pFile, "$Y0 Block (BACKWARD_REFERENCES):\n"); } else fprintf(pFile, "$Y0 Block:\n"); } else fprintf(pFile, "$Y%d Block:\n", i); for (inner=0; inner<BLOCK_SIZE; inner++) { fprintf(pFile, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\n", *pYOut, *(pYOut+1), *(pYOut+2), *(pYOut+3), *(pYOut+4), *(pYOut+5), *(pYOut+6), *(pYOut+7) ); if (pCheckMB->nWidthLuma) pYOut = pYOut + pCheckMB->nWidthLuma; else pYOut = pYOut + 8; } } // Process the cb0 block fprintf(pFile, "$U Block:\n"); for (inner=0; inner<BLOCK_SIZE; inner++) { fprintf(pFile, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\n", *pCbOut, *(pCbOut+1), *(pCbOut+2), *(pCbOut+3), *(pCbOut+4), *(pCbOut+5), *(pCbOut+6), *(pCbOut+7) ); if (pCheckMB->nWidthLuma) pCbOut = pCbOut + pCheckMB->nWidthChroma; else pCbOut = pCbOut + 8; } if (pCheckMB->nChromaFormat == 1) { // 422 // Process the cb1 block fprintf(pFile, "$U2 Block:\n"); pCbOut = pCheckMB->cur_cb_frame + 64; for (inner=0; inner<BLOCK_SIZE; inner++) { fprintf(pFile, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\n", *pCbOut, *(pCbOut+1), *(pCbOut+2), *(pCbOut+3), *(pCbOut+4), *(pCbOut+5), *(pCbOut+6), *(pCbOut+7) ); if (pCheckMB->nWidthLuma) pCbOut = pCbOut + pCheckMB->nWidthChroma; else pCbOut = pCbOut + 8; } } // Process the cr block fprintf(pFile, "$V Block:\n"); for (inner=0; inner<BLOCK_SIZE; inner++) { fprintf(pFile, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\n", *pCrOut, *(pCrOut+1), *(pCrOut+2), *(pCrOut+3), *(pCrOut+4), *(pCrOut+5), *(pCrOut+6), *(pCrOut+7) ); if (pCheckMB->nWidthLuma) pCrOut = pCrOut + pCheckMB->nWidthChroma; else pCrOut = pCrOut + 8; } if (pCheckMB->nChromaFormat == 1) { // 422 // Process the cr1 block fprintf(pFile, "$V2 Block:\n"); pCrOut = pCheckMB->cur_cr_frame + 64; for (inner=0; inner<BLOCK_SIZE; inner++) { fprintf(pFile, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\n", *pCrOut, *(pCrOut+1), *(pCrOut+2), *(pCrOut+3), *(pCrOut+4), *(pCrOut+5), *(pCrOut+6), *(pCrOut+7) );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -