📄 recongob.c
字号:
upperDCLumaBlockCache[2*mb->x][0], upperLumaBlockCache[2*mb->x], // DC and AC pred for row upperDCLumaBlockCache[2*mb->x],upperLumaBlockCache[2*mb->x], // DC and AC store for row leftDCLumaBlockCache[3][0], leftLumaBlockCache[3], // DC and AC pred for column leftDCLumaBlockCache[2], leftLumaBlockCache[2], // DC and AC store for column predtype, fixedDC, mb->x==0, FALSE); // can only be on left boundary //printf("Luma block 4 \n"); Idct2AdvancedIntra( mb->block[3].sym, mb->block[3].nsym, pixel0 + 8 + 8 * pic->y.hoffset, pic->y.hoffset, recon_tab, upperDCLumaBlockCache[2*mb->x+1][0], upperLumaBlockCache[2*mb->x+1], // DC and AC pred for row upperDCLumaBlockCache[2*mb->x+1],upperLumaBlockCache[2*mb->x+1], // DC and AC store for row leftDCLumaBlockCache[2][0], leftLumaBlockCache[2], // DC and AC pred for column leftDCLumaBlockCache[3], leftLumaBlockCache[3], // DC and AC store for column predtype, fixedDC, FALSE, FALSE); // can't be on left or upper boundary if (pic->color) { // Assuming same offset for Cr and Cb col = 8 * mb->x; row = 8 * mb->y; offset = col + row * pic->cb.hoffset; pixel0 = pic->cb.ptr + offset; //printf("CB block \n"); Idct2AdvancedIntra( mb->block[4].sym, mb->block[4].nsym, pixel0, pic->cb.hoffset, recon_tab, upperDCCbBlockCache[mb->x][0], upperCbBlockCache[mb->x], // DC and AC pred for row upperDCCbBlockCache[mb->x],upperCbBlockCache[mb->x], // DC and AC store for row leftDCCbBlockCache[0], leftCbBlockCache[0], // DC and AC pred for column leftDCCbBlockCache, leftCbBlockCache[0], // DC and AC store for column predtype, fixedDC, mb->x==0, mb->y==0); // what boundaries are we on? pixel0 = pic->cr.ptr + offset; //printf("CR block \n"); Idct2AdvancedIntra( mb->block[5].sym, mb->block[5].nsym, pixel0, pic->cr.hoffset, recon_tab, upperDCCrBlockCache[mb->x][0], upperCrBlockCache[mb->x], // DC and AC pred for row upperDCCrBlockCache[mb->x],upperCrBlockCache[mb->x], // DC and AC store for row leftDCCrBlockCache[0], leftCrBlockCache[0], // DC and AC pred for column leftDCCrBlockCache, leftCrBlockCache[0], // DC and AC store for column predtype, fixedDC, mb->x==0, mb->y==0); // what boundaries are we on? } return;}#endif// ReconInterextern void ReconInter( MACROBLOCK_DESCR * mb, PICTURE * pic, int clean ){ int row, col, offset ; PIXEL * pixel0; S16 * recon_tab; recon_tab = Recon[mb->quant - QUANT_MIN]; col = 16 * mb->x; row = 16 * mb->y;/* { int isym; printf("ReconInter: x = %d y = %d\n", col, row); printf("nsym = %d %d %d %d %d %d \n", mb->block[0].nsym, mb->block[1].nsym, mb->block[2].nsym, mb->block[3].nsym, mb->block[4].nsym, mb->block[5].nsym); printf("Symbol number to print: "); scanf("%d", &isym); while (isym > 0) { printf("Luma 1: "); printsym( *(mb->block[0].sym + isym - 1) ); printf("\n"); printf("Luma 2: "); printsym( *(mb->block[1].sym + isym - 1) ); printf("\n"); printf("Luma 3: "); printsym( *(mb->block[2].sym + isym - 1) ); printf("\n"); printf("Luma 4: "); printsym( *(mb->block[3].sym + isym - 1) ); printf("\n"); printf("Symbol number to print: "); scanf("%d", &isym); } } */ pixel0 = pic->y.ptr + col + row * pic->y.hoffset;// #define DB_DUMP_MACROBLOCK#ifdef DB_DUMP_MACROBLOCK { static char foo[256]; /* Flawfinder: ignore */ static char dump=0; int dbi,dbj; if(dump) { SafeSprintf(foo, 256, "Reference Block (from ReconInter) (%d, %d)\n", mb->x, mb->y); OutputDebugString(foo); for(dbi=0;dbi<16;dbi++) { foo[0] = '\0'; for(dbj=0;dbj<16;dbj++) { SafeSprintf(foo+strlen(foo), 256-strlen(foo), "%d ", pixel0[dbi*pic->y.hoffset + dbj]); } SafeStrCat(foo, "\n", 256); OutputDebugString(foo); } } }#endif if (mb->block[0].nsym > 0) { //printf("Luma block 1 \n"); Idct2Sum( mb->block[0].sym, mb->block[0].nsym, pixel0, pic->y.hoffset, recon_tab, clean); } if (mb->block[1].nsym > 0) { //printf("Luma block 2 \n"); Idct2Sum( mb->block[1].sym, mb->block[1].nsym, pixel0 + 8, pic->y.hoffset, recon_tab, clean); } if (mb->block[2].nsym > 0) { //printf("Luma block 3 \n"); Idct2Sum( mb->block[2].sym, mb->block[2].nsym, pixel0 + 8 * pic->y.hoffset, pic->y.hoffset, recon_tab, clean); } if (mb->block[3].nsym > 0) { //printf("Luma block 4 \n"); Idct2Sum( mb->block[3].sym, mb->block[3].nsym, pixel0 + 8 + 8 * pic->y.hoffset, pic->y.hoffset, recon_tab, clean); } if (pic->color && (mb->block[4].nsym > 0 || mb->block[5].nsym > 0)) { // Assuming same offset for Cr and Cb col = 8 * mb->x; row = 8 * mb->y; offset = col + row * pic->cb.hoffset; if (mb->block[4].nsym > 0) { pixel0 = pic->cb.ptr + offset; //printf("CB block \n"); Idct2Sum( mb->block[4].sym, mb->block[4].nsym, pixel0, pic->cb.hoffset, recon_tab, clean); } if (mb->block[5].nsym > 0) { pixel0 = pic->cr.ptr + offset; //printf("CR block \n"); Idct2Sum( mb->block[5].sym, mb->block[5].nsym, pixel0, pic->cr.hoffset, recon_tab, clean); } }//#define DB_DUMP_MACROBLOCK#ifdef DB_DUMP_MACROBLOCK { static char foo[256]; /* Flawfinder: ignore */ static char dump=0; int dbi,dbj; if(dump) { pixel0 = pic->y.ptr + col + row * pic->y.hoffset; SafeSprintf(foo, 256, "Reconstructed Macroblock (%d, %d)\n", mb->x, mb->y); OutputDebugString(foo); for(dbi=0;dbi<16;dbi++) { foo[0] = '\0'; for(dbj=0;dbj<16;dbj++) { SafeSprintf(foo+strlen(foo), 256-strlen(foo), "%d ", pixel0[dbi*pic->y.hoffset + dbj]); } SafeStrCat(foo, "\n", 256); OutputDebugString(foo); } } }#endif return;}// reconBframe - Reconstruct B-frame prediction error and add to predictionstatic void reconBframe( MACROBLOCK_DESCR * mb, PICTURE * Bpic ){ int i; U8 saveQuant, saveCbp; SYMBOL *saveSym[6]; int saveNsym[6]; if (BFRAME_HAS_CBP(mb)) { // Set quant, cbp, and block[] to hold values for B-frame saveQuant = mb->quant; mb->quant = mb->Bquant; saveCbp = mb->cbp; mb->cbp = mb->cbpB; for (i = 0; i < 6; ++i) { saveSym[i] = mb->block[i].sym; mb->block[i].sym = mb->Bblock[i].sym; saveNsym[i] = mb->block[i].nsym; mb->block[i].nsym = mb->Bblock[i].nsym; } // Do reconstruction ReconInter( mb, Bpic, CLEAN ); // Restore parameters (if needed for statistics) mb->quant = saveQuant; mb->cbp = saveCbp; for (i = 0; i < 6; ++i) { mb->block[i].sym = saveSym[i]; mb->block[i].nsym = saveNsym[i]; } }}// gray_mb - fill macroblock with gray (value 128); assumes that pic is word-alignedstatic void gray_mb( MACROBLOCK_DESCR * mb, PICTURE * pic ){ fill_mb( mb, pic, GRAY );}// fill_mb - fill macroblock with constant color; assumes that pic is word-alignedstatic void fill_mb( MACROBLOCK_DESCR * mb, PICTURE * pic, PIXEL value ){ int row, col, i; union { // Write words to speed up routine PIXEL * pix; U32 * word; } pixel; U32 * dest; U32 dValue; dValue = value | (value << 8) | (value << 16) | (value << 24); col = 16 * mb->x; row = 16 * mb->y;#ifdef DO_H263_PLUS if (col >= pic->y.nhor || row >= pic->y.nvert) return; // Inactive part of Macroblock#endif pixel.pix = pic->y.ptr + col + row * pic->y.hoffset; for (i = 0; i < 16; i++) { for (dest = pixel.word; dest < pixel.word + 16/4; dest++) { *dest = dValue; } pixel.pix += pic->y.hoffset; } if (pic->color) { col = 8 * mb->x; row = 8 * mb->y; pixel.pix = pic->cb.ptr + col + row * pic->cb.hoffset; for (i = 0; i < 8; i++) { for (dest = pixel.word; dest < pixel.word + 8/4; dest++) { *dest = dValue; } pixel.pix += pic->cb.hoffset; } pixel.pix = pic->cr.ptr + col + row * pic->cr.hoffset; for (i = 0; i < 8; i++) { for (dest = pixel.word; dest < pixel.word + 8/4; dest++) { *dest = dValue; } pixel.pix += pic->cr.hoffset; } } return;}#ifdef DO_H263_PLUS///////////////////////////////////////////////////////////////////////////////////////////////////// Functions for reconstruction in Reduced-resolution Update mode //////////////////////////////////////////////////////////////////////////////////////////////////////// ReducedResMvComponent - Translate Reduced-res. motion vector component to representation// with one fractional bit. The input value is "rounded" half a pixel towards zero, e.g.,// input values: -2 -1 0 1 2 are// translated to: -1.5 -0.5 0 0.5 1.5,extern S8 ReducedResMvComponent( S8 x ){ if (x > 0) { x = 2 * x - 1; } else if (x < 0) { x = 2 * x + 1; } return x;}// MotionComp32x32 - perform motion compensation for Reduced-res. Update modeextern void MotionComp32x32( MACROBLOCK_DESCR * mb, // Describes block to be motion-compensated PICTURE * prevPic, // Describes previous picture used to form MC PICTURE * pic // Output picture where MC block is placed ){ int blk; // Save MTYPE and x/y position int saveType = mb->mtype; int saveX = mb->x; int saveY = mb->y; int saveMvX = mb->mv_x; int saveMvY = mb->mv_y; mb->mtype = MTYPE263_INTER; if (saveType != MTYPE263_INTER4V) { // Use same motion vector for all four quadrants for (blk = 0; blk < 4; ++blk) { mb->blkMvX[blk] = mb->mv_x;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -