📄 mae_fe.c
字号:
cbp_buf[cbp_in][bn].data[0] = 0x0; if (blk_xformsize == 0) { cbp_buf[cbp_in][bn].data[0] = (sb0 | sb1 | sb2 | sb3) ? 0xf : 0x0; } else if (blk_xformsize == 1) { cbp_buf[cbp_in][bn].data[0] = ((sb0 | sb1) & (sb2 | sb3)) ? 0xf : (sb0 | sb1) ? 0x3 : (sb2 | sb3) ? 0xc : 0x0; } else if (blk_xformsize == 2) { cbp_buf[cbp_in][bn].data[0] = ((sb0 | sb2) & (sb1 | sb3)) ? 0xf : (sb0 | sb2) ? 0x5 : (sb1 | sb3) ? 0xa : 0x0; } else { cbp_buf[cbp_in][bn].data[0] = (sb3 << 3) | (sb2 << 2) | (sb1 << 1) | (sb0 << 0); } cbp_buf[cbp_in][bn].data[0] = mae_fe_cfg->codstyl ? cbp_buf[cbp_in][bn].data[0] : 0; cbp_buf[cbp_in][bn].bn = bn; if(bn == (int32) (exp_bc-1)) { cbp_in = !cbp_in; } // Call IDCT routine if(!mae_fe_cfg->codstyl) { // MPEG1/2/4 lee_idct_2d_fixed_point(fixed_point_block, dst_block, bn, exp_bc); } else { // WMV9 //convert block data to back to double for wmv9 xforms if ((blk_xformsize == 0) || (blk_xformsize == 1)) { for(i = 0; i < 8; i++) { for(j = 0; j < 8; j++) { wmv9_block[(i*8)+j] = (int32)floor(fixed_to_double(fixed_point_block[(j*8)+i])); } } } else { for(i = 0; i < 4; i++) { for(j = 0; j < 4; j++) { wmv9_block[(j*8)+(i*2)] = (int32)floor(fixed_to_double(fixed_point_block[(i*8)+j])); wmv9_block[(j*8)+(i*2)+1] = (int32)floor(fixed_to_double(fixed_point_block[(i*8)+j+4])); wmv9_block[((j+4)*8)+(i*2)] = (int32)floor(fixed_to_double(fixed_point_block[((i+4)*8)+j])); wmv9_block[((j+4)*8)+(i*2)+1] = (int32)floor(fixed_to_double(fixed_point_block[((i+4)*8)+j+4])); } } }#ifdef REF_WMV9 for(i = 0; i < 8; i++) { for(j = 0; j < 8; j++) { if((wmv9_block[(i*8)+j] > 32767) || (wmv9_block[(i*8)+j] < -32768)) printf("ERROR: To many bits used for IDCT input! wmv9_block = %08x\n", wmv9_block[(i*8)+j]); } }#endif if ((blk_xformsize == 0) && (blk_mbmode == 0)){ InverseTransform8x8 (wmv9_idct_block, 8, wmv9_block, bn, exp_bc); } else if (blk_xformsize == 0) { InverseTransform8x8 (wmv9_idct_block, 8, wmv9_block, bn, exp_bc); //MAE_IDCT8x8_16_16_WMV3(wmv9_block, 8, wmv9_idct_block, 8, 0, bn, exp_bc); } else if (blk_xformsize == 1) { MAE_IDCT8x4_16_16_WMV3(&wmv9_block[0], 8, &wmv9_idct_block[0], 8, bn, 0); MAE_IDCT8x4_16_16_WMV3(&wmv9_block[4], 8, &wmv9_idct_block[32], 8, bn, 1); tb[tb_in][bn].bn = bn; presat[presat_in][bn].bn = bn; postsat[postsat_in][bn].bn = bn; if(bn == (int32) (exp_bc-1)) { presat_in = !presat_in; } if(bn == (int32) (exp_bc-1)) { postsat_in = !postsat_in; } if(bn == (int)(exp_bc-1)) { tb_in = !tb_in; } } else if (blk_xformsize == 2) { MAE_IDCT4x8_16_16_WMV3(&wmv9_block[0], 8, &wmv9_idct_block[0], 8, bn, 0); MAE_IDCT4x8_16_16_WMV3(&wmv9_block[32], 8, &wmv9_idct_block[4], 8, bn, 1); tb[tb_in][bn].bn = bn; presat[presat_in][bn].bn = bn; postsat[postsat_in][bn].bn = bn; if(bn == (int32) (exp_bc-1)) { presat_in = !presat_in; } if(bn == (int32) (exp_bc-1)) { postsat_in = !postsat_in; } if(bn == (int)(exp_bc-1)) { tb_in = !tb_in; } } else { MAE_IDCT4x4_16_16_WMV3(&wmv9_block[0], 8, &wmv9_idct_block[0], 8, bn, 0); MAE_IDCT4x4_16_16_WMV3(&wmv9_block[4], 8, &wmv9_idct_block[4], 8, bn, 1); MAE_IDCT4x4_16_16_WMV3(&wmv9_block[32], 8, &wmv9_idct_block[32], 8, bn, 2); MAE_IDCT4x4_16_16_WMV3(&wmv9_block[36], 8, &wmv9_idct_block[36], 8, bn, 3); tb[tb_in][bn].bn = bn; presat[presat_in][bn].bn = bn; postsat[postsat_in][bn].bn = bn; if(bn == (int32) (exp_bc-1)) { presat_in = !presat_in; } if(bn == (int32) (exp_bc-1)) { postsat_in = !postsat_in; } if(bn == (int)(exp_bc-1)) { tb_in = !tb_in; } } //convert block data to int32 for(i = 0; i < 8; i++) { for(j = 0; j < 8; j++) { dst_block[(i*8)+j] = (int32)wmv9_idct_block[(i*8)+j]; } } } i = (mb_in->ypos/16*mae_fe_cfg->linesiz/16) + (mb_in->xpos/16); if(blk_xformsize == 0) { embmd[i].m_rgbCodedBlockPattern2[bn] = (sb0 | sb1 | sb2 | sb3); } else if (blk_xformsize == 1) { embmd[i].m_rgbCodedBlockPattern2[bn] = !(sb0 | sb1 | sb2 | sb3) ? 0 : (!(sb0 | sb1) & (sb2 | sb3)) ? 1 : (!(sb2 | sb3) & (sb0 | sb1)) ? 2 : 3; if (!(sb0 | sb1 | sb2 | sb3)) RTL_printf("WARN: WMV9 8x4 transform is not expected to have all 0. Please report to WMV9 team\n"); } else if (blk_xformsize == 2) { embmd[i].m_rgbCodedBlockPattern2[bn] = !(sb0 | sb1 | sb2 | sb3) ? 0 : (!(sb0 | sb2) & (sb1 | sb3)) ? 1 : (!(sb1 | sb3) & (sb0 | sb2)) ? 2 : 3; if (!(sb0 | sb1 | sb2 | sb3)) RTL_printf("WARN: WMV9 4x8 transform is not expected to have all 0. Please report to WMV9 team\n"); } else { embmd[i].m_rgbCodedBlockPattern2[bn] = (sb0 << 3) | (sb1 << 2) | (sb2 << 1) | sb3; } // Set xformmode for Deblocking embmd[i].m_rgcBlockXformMode[bn] = (blk_xformsize == 0) ? MAE_XFORMMODE_8x8 : (blk_xformsize == 1) ? MAE_XFORMMODE_8x4 : (blk_xformsize == 2) ? MAE_XFORMMODE_4x8 : ((mae_fe_cfg->pquant >> S_HACK_ENUM_SHIFT) & 0x1) ? MAE_XFORMMODE_MBSWITCH : MAE_XFORMMODE_4x4; embmd[i].m_chMBMode = (mb_in->mbtype == 0) ? MAE_MB_1MV : (mb_in->mbtype == 2) ? MAE_MB_FIELD : MAE_MB_4MV; #ifndef HAVE_MAE // Get a char ouput. Needed to update the text file for(c=0; c<64; c++) {#ifdef REF_WMV9 // If its an I frame with filters off, then lets dump 8-bits if(nFrameType == IFRAME && !mae_fe_cfg->smooth) { idct_output[c] = MAE_SATURATE8(dst_block[c]); } // Rest are all 16-bits wide else { idct_output_16[c] = (int16)dst_block[c]; }#elif REF_MPEG4 idct_output[c] = (unsigned char)dst_block[c]; // Since the MPEG4 reference code dumps out only positive 8-bit values // for the IDCT output (for Intra frames), we need to clip all negative // values to zero here, so that the intermediate checker is happy!! // ********************************************************************* if (dst_block[c] < 0) idct_output[c] = 0;#elif REF_DIVX idct_output[c] = (unsigned char)dst_block[c]; idct_out16[c] = (short)dst_block[c]; if (dst_block[c] < 0) idct_output[c] = 0;#else // MPEG2 idct_output[c] = (char)dst_block[c]; // Since the MPEG4 reference code dumps out only positive 8-bit values // for the IDCT output (for Intra frames), we need to clip all negative // values to zero here, so that the intermediate checker is happy!! // ********************************************************************* if (dst_block[c] < 0) idct_output[c] = 0;#endif } // Intermediate Checking stuff after IDCT is done with the CModel // ************************************************************** // MPEG4 & DIVX case if (!mae_fe_cfg->codstyl) {#ifndef REF_MPEG2 if (blk_mbmode) //since the reference code is outputing 32-bits for IDCT {#ifdef REF_DIVX MAEBlkChecks.nOutputType = IDCT_DONE_16_BIT; // if the sign bit (MSB) is needed MAEBlkChecks.blk_after_idct_16bit = idct_out16; // output of IDCT in int (16 bits)#else MAEBlkChecks.nOutputType = IDCT_DONE_32_BIT; // if the sign bit (MSB) is needed MAEBlkChecks.blk_after_idct_32bit = dst_block; // output of IDCT in int (32 bits)#endif } else { MAEBlkChecks.nOutputType = IDCT_DONE_8_BIT; // if only the value is needed MAEBlkChecks.blk_after_idct_8bit = idct_output; // output of IDCT in char (8 bit) } #else MAEBlkChecks.nOutputType = IDCT_DONE_32_BIT; MAEBlkChecks.blk_after_idct_32bit = dst_block;#endif // #ifndef REF_MPEG2 } // WMV9 case else {#ifdef REF_WMV9 // If its an I frame with filters off, then lets dump 8-bits if(nFrameType == IFRAME && !mae_fe_cfg->smooth) { MAEBlkChecks.nOutputType = IDCT_DONE_8_BIT; MAEBlkChecks.blk_after_idct_8bit = idct_output; } // Rest are all 16-bits wide else { MAEBlkChecks.nOutputType = IDCT_DONE_16_BIT; MAEBlkChecks.blk_after_idct_16bit = idct_output_16; }#endif } MAEBlkChecks.nStepSize = 0; //everyting is contiguous memset(szFileName, 0, MAX_FILE_SIZE); // if we are not doing pure intra, then we need // to dump the inter file with zeros!! if (!bPureIntra && (nFrameType == PFRAME || nFrameType == BFRAME)) { strcpy(szFileName, FILE_AFTER_INTRA_IDCT); } // check what frame type we are processing else { // check what frame type we are processing if (nFrameType == PFRAME) strcpy(szFileName, FILE_AFTER_INTER_P_IDCT); else if(nFrameType == BFRAME) strcpy(szFileName, FILE_AFTER_INTER_B_IDCT); else if(nFrameType == IFRAME) strcpy(szFileName, FILE_AFTER_INTRA_IDCT); } strcat(szFileName, szFrameNum); strcat(szFileName, MAE_FILE_EXTENSION); // Dump the IDCT output to the file only // if this MB is coded for MPEG1/2/4 // **************************************** if(!mae_fe_cfg->codstyl) { if(mb_in->cbp) InterChecksOnBlock(&MAEBlkChecks, szFileName); } // Do it always for WMV9 // ********************* else {#ifdef REF_WMV9 if(mae_fe_cfg->smooth) MAEBlkChecks.nOverlapSmoothON = TRUE;#endif InterChecksOnBlock(&MAEBlkChecks, szFileName); }#endif RTL_printf("\nIDCT Output block (after scale and clip):%d\n",bn); for(x = 0; x < 8; x++){ RTL_printf("%02x %02x %02x %02x %02x %02x %02x %02x \n", dst_block[(x*8)+0], dst_block[(x*8)+1], dst_block[(x*8)+2], dst_block[(x*8)+3], dst_block[(x*8)+4], dst_block[(x*8)+5], dst_block[(x*8)+6], dst_block[(x*8)+7]); } // Copy the data from the dst_block to the current frame // Select dst_ptr based on Lumma vs. Chroma // There is a dst_ptr & a src_ptr because the current frame passed to the // mcomp function is a copy of the original. This is done because when the dct type (dctt) // specifies interlacing, it is not a direct copy. In other words, the mcomp function // does not put the data in the correct location (and it was not easy to change). Instead // this copy places the data in the correct location. if(bn<4){ //lumma ps_linesize = (mb_in->ps) ? (mae_fe_cfg->linesiz << 1) : mae_fe_cfg->linesiz; linesize = (mb_in->dctt) ? (ps_linesize << 1) : ps_linesize; ypos = mb_in->ypos; xpos = mb_in->xpos; dst_ptr = cur_y_unsat; src_ptr = cur_y_sub; } else { //chroma ps_linesize = (mb_in->ps) ? (mae_fe_cfg->linesiz) : (mae_fe_cfg->linesiz >> 1); linesize = (mb_in->dctt && mae_fe_cfg->bc) ? (ps_linesize << 1) : ps_linesize; ypos = chroma_ypos; xpos = mb_in->xpos >> 1; dst_ptr = ((bn==4) || (bn==6)) ? cur_cb_unsat : cur_cr_unsat; src_ptr = ((bn==4) || (bn==6)) ? cur_cb_sub : cur_cr_sub; } dst_ptr += (ypos * ps_linesize + xpos); src_ptr += (ypos * ps_linesize + xpos); if(mb_in->dctt) { dst_ptr = (bn == 1) ? dst_ptr + 8 : (bn == 2) ? dst_ptr + ps_linesize : (bn == 3) ? dst_ptr + ps_linesize + 8 : ((bn == 6) || (bn == 7)) ? dst_ptr + ps_linesize : dst_ptr; src_ptr = (bn == 1) ? src_ptr + 8 : (bn == 2) ? src_ptr + ps_linesize : (bn == 3) ? src_ptr + ps_linesize + 8 : ((bn == 6) || (bn == 7)) ? src_ptr + ps_linesize : src_ptr; } else { dst_ptr = (bn == 1) ? dst_ptr + 8 : (bn == 2) ? dst_ptr + (8*linesize) : (bn == 3) ? dst_ptr + (8*linesize) + 8 :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -