⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encodevop.c

📁 adi bf533视频编码程序
💻 C
📖 第 1 页 / 共 5 页
字号:
//			if(j==mNumMacroBlockPerRow-1)
//				get_MB_refwin(mCurrPtr656+(i+1)*MB_row_step*YUV656_BUF_WIDTH,
//									mForwPtrY+i*16*mStepLuma-16,
//	        				  		MB_buffer[iCur_MB],
//	        				  		win_buffer[iCur_MB],
//	        				  		mForwPtrU+i*8*mStepChroma-8,
//	        				  		mForwPtrV+i*8*mStepChroma-8);
//		    else
//				get_MB_refwin(p656+MB_byte_step,
//									pYf-16*mStepLuma,
//	        				  		MB_buffer[iCur_MB],
//	        				  		win_buffer[iCur_MB],
//	        				  		pUf-8*mStepChroma,
//	        				  		pVf-8*mStepChroma);
			if(j==mNumMacroBlockPerRow-1)
				restore_MB_get_MB_refwin(
					MB_buffer[iCur_MB], pPreY, pPreU, pPreV,
					mCurrPtr656+(i+1)*MB_row_step*YUV656_BUF_WIDTH,
    				MB_buffer[iCur_MB],
					mForwPtrY+i*16*mStepLuma-16,
    				mForwPtrU+i*8*mStepChroma-8,
    				mForwPtrV+i*8*mStepChroma-8,
    				pDMARefwinY, pDMARefwinU, pDMARefwinV,
					dma_flags
				);
		    else
				restore_MB_get_MB_refwin(
					MB_buffer[iCur_MB], pPreY, pPreU, pPreV,
					p656+MB_byte_step,
	        		MB_buffer[iCur_MB],
					pYf-16*mStepLuma,
	        		pUf-8*mStepChroma,
	        		pVf-8*mStepChroma,
	        		pDMARefwinY, pDMARefwinU, pDMARefwinV,
					dma_flags
				);
				
			pPreY = pYc;
			pPreU = pUc;
			pPreV = pVc;
			
			MB_preprocess(pCur_MB, 24);
           
             
          // _memdma_refwin_en_c(pYf-16*mStepLuma-16,pYc,pUc,pVc,dma_flag);
//                if(dma_flag&1)
//                       pCur_MB=Current_MB+384;
//                else
//                       pCur_MB=Current_MB;
              
//                memdma1_finish_test();

			/*====================temporal_pre-process 1, added by gary===================*/       
//    			temporal_preprocess(pYc, pYf, pUc, pUf, pVc, pVf);
//				temporal_preprocess(pCur_MB, refwin);
			    
			/*=======================================================================*/       
//                while(*pMDMA_D1_IRQ_STATUS & 0x0008);
            
//            mp4_ME_16x16_C(pCur_MB, refwin,&bestSAD16x16, &mvLuma);
//            mp4_ME_16x16_C(pCur_MB, refwin,&bestSAD, &mvLuma);
            mp4_ME_16x16_C(pCur_MB, pCurRefwinY, &bestSAD, &mvLuma, refwin_Y_step);                        
/*****************************		__070613_2__no_4mv
            if (mME4mv)
                mp4_ME_8x8_C(pCur_MB, refwin,&bestSAD8x8, &mvLuma,mvLuma4);
            else
                bestSAD8x8 = 256 * 256;
*****************************/                    
             
                
//                memdma1_finish_test();
//                 _memdma_refwin_en(pYf-16*mStepLuma-16+16,pYc+16,pUc+8,pVc+8,dma_flag);
//                 dma_flag=dma_flag+1;
		    	            
/*************************			----no 4mv;                
            if (!mME4mv || (bestSAD16x16 - mMEthr4MV < bestSAD8x8)) {
                bestSAD = bestSAD16x16;
                MBcurr->type = IPP_VIDEO_INTER;
                mvPred[0].dx = (Ipp16s)(mvLuma.dx - mvPred[0].dx);
                mvPred[0].dy = (Ipp16s)(mvLuma.dy - mvPred[0].dy);
                mvLuma4[0] = mvLuma4[1] = mvLuma4[2] = mvLuma4[3] = mvLuma;
            } else {
                bestSAD = bestSAD8x8;
                MBcurr->type = IPP_VIDEO_INTER4V;
                Predict3MV(MBcurr, i, j, mvPred, mvLuma4);
                mvPred[0].dx = (Ipp16s)(mvLuma4[0].dx - mvPred[0].dx);
                mvPred[0].dy = (Ipp16s)(mvLuma4[0].dy - mvPred[0].dy);
                mvPred[1].dx = (Ipp16s)(mvLuma4[1].dx - mvPred[1].dx);
                mvPred[1].dy = (Ipp16s)(mvLuma4[1].dy - mvPred[1].dy);
                mvPred[2].dx = (Ipp16s)(mvLuma4[2].dx - mvPred[2].dx);
                mvPred[2].dy = (Ipp16s)(mvLuma4[2].dy - mvPred[2].dy);
                mvPred[3].dx = (Ipp16s)(mvLuma4[3].dx - mvPred[3].dx);
                mvPred[3].dy = (Ipp16s)(mvLuma4[3].dy - mvPred[3].dy);
            }
**************************/

//            MBcurr->type = IPP_VIDEO_INTER;
            type = IPP_VIDEO_INTER;		//0
            
            mvPred.dx = (Ipp16s)(mvLuma.dx - mvPred.dx);
            mvPred.dy = (Ipp16s)(mvLuma.dy - mvPred.dy);
			                
            
            // check pred mv are in fRange
            mvIsInRange = 1;

/**********************                        
            for ( k = 0; k < (MBcurr->type == IPP_VIDEO_INTER ? 1 : 4); k ++) {
                mp4_MV_CheckRange(&mvPred[k], fRangeMin, fRangeMax, fRange);
                if (mvPred[k].dx < fRangeMin || mvPred[k].dx > fRangeMax || mvPred[k].dy < fRangeMin || mvPred[k].dy > fRangeMax)
                    mvIsInRange = 0;
            }
***********************/

//这个函数会改变mv的值,我怀疑这样做会出现错误--gary
//            mp4_MV_CheckRange(&mvPred, fRangeMin, fRangeMax, fRange);
            if (mvPred.dx < fRangeMin || mvPred.dx > fRangeMax || mvPred.dy < fRangeMin || mvPred.dy > fRangeMax)
                mvIsInRange = 0;			
            
			xhMeanAbsDev16x16_8u32s_C1R_MOD(pCur_MB,&dev);
         
            // choose mbtype
            if ((dev < bestSAD - mMEthrIntra) || !mvIsInRange || (i&1==0)) {
                // intra coded
//                MBcurr->mv[0].dx = MBcurr->mv[0].dy = MBcurr->mv[1].dx = MBcurr->mv[1].dy = MBcurr->mv[2].dx = MBcurr->mv[2].dy = MBcurr->mv[3].dx = MBcurr->mv[3].dy = 0;
//                MBcurr->mv.dx = MBcurr->mv.dy = 0;
				refmv[j].dx = refmv[j].dy = 0;
                
//                MBcurr->type = IPP_VIDEO_INTRA;
//                MBcurr->not_coded = 0;
                type = IPP_VIDEO_INTRA;		//3
                not_coded = 0;

//                dcScalerLuma = mp4_GetDCscaler(quant, 0);
//                dcScalerChroma = mp4_GetDCscaler(quant, 4);
                pattern = 0;
                mp4_DCT_Quant_Intra_MPEG4(pCur_MB, 16, 0);
                mp4_DCT_Quant_Intra_MPEG4(pCur_MB+8, 16, 1);
                mp4_DCT_Quant_Intra_MPEG4(pCur_MB+8*16, 16, 2);
                mp4_DCT_Quant_Intra_MPEG4(pCur_MB+8*16+8, 16, 3);
                mp4_DCT_Quant_Intra_MPEG4(pCur_MB+24*18, 8, 4);
                mp4_DCT_Quant_Intra_MPEG4(pCur_MB+24*18+64, 8, 5);
                ac_pred_flag = 0;
                
//				mp4_PredictIntraDCAC(MBcurr, coeffMB+0*64, dcScalerLuma,   0, &predDir[0], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, coeffMB+1*64, dcScalerLuma,   1, &predDir[1], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, coeffMB+2*64, dcScalerLuma,   2, &predDir[2], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, coeffMB+3*64, dcScalerLuma,   3, &predDir[3], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, coeffMB+4*64, dcScalerChroma, 4, &predDir[4], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, coeffMB+5*64, dcScalerChroma, 5, &predDir[5], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, MBDC[1], refYDC[j2-1], refYDC[j2], MBDC, coeffMB+0*64, dcScalerLuma,   0, &predDir[0], ac_pred_flag, &acPredSum0, &acPredSum1);
//				refYDC[j2-1] = MBDC[3];
//				mp4_PredictIntraDCAC(MBcurr, MBDC[3], MBDC[1], 	  MBDC[0], 		MBDC, coeffMB+2*64, dcScalerLuma,   2, &predDir[2], ac_pred_flag, &acPredSum0, &acPredSum1);
//				mp4_PredictIntraDCAC(MBcurr, MBDC[0], refYDC[j2], refYDC[j2+1], MBDC, coeffMB+1*64, dcScalerLuma,   1, &predDir[1], ac_pred_flag, &acPredSum0, &acPredSum1);
//				refYDC[j2] = MBDC[2];
//				mp4_PredictIntraDCAC(MBcurr, MBDC[2], MBDC[0], 	  MBDC[1],		MBDC, coeffMB+3*64, dcScalerLuma,   3, &predDir[3], ac_pred_flag, &acPredSum0, &acPredSum1);
//				tmp_uvdc = MBDC[4];
//				mp4_PredictIntraDCAC(MBcurr, MBDC[4], refUDC[j-1], refUDC[j], 	MBDC, coeffMB+4*64, dcScalerChroma, 4, &predDir[4], ac_pred_flag, &acPredSum0, &acPredSum1);
//				refUDC[j-1] = tmp_uvdc;
//				tmp_uvdc = MBDC[5];
//				mp4_PredictIntraDCAC(MBcurr, MBDC[5], refVDC[j-1], refVDC[j],	MBDC, coeffMB+5*64, dcScalerChroma, 5, &predDir[5], ac_pred_flag, &acPredSum0, &acPredSum1);
//				refVDC[j-1] = tmp_uvdc;
				mp4_PredictIntraDC(MBDC[1], refYDC[j2-1], refYDC[j2], &MBDC[0], coeffMB+0*64, dcScalerLuma,   &predDir[0]);
				refYDC[j2-1] = MBDC[3];
				mp4_PredictIntraDC(MBDC[3], MBDC[1], 	  MBDC[0], 	  &MBDC[2], coeffMB+2*64, dcScalerLuma,   &predDir[2]);
				mp4_PredictIntraDC(MBDC[0], refYDC[j2], refYDC[j2+1], &MBDC[1], coeffMB+1*64, dcScalerLuma,   &predDir[1]);
				refYDC[j2] = MBDC[2];
				mp4_PredictIntraDC(MBDC[2], MBDC[0], 	  MBDC[1],	  &MBDC[3], coeffMB+3*64, dcScalerLuma,   &predDir[3]);
				mp4_PredictIntraDC(leftUDC, refUDC[j-1], refUDC[j],   &MBDC[4], coeffMB+4*64, dcScalerChroma, &predDir[4]);
				refUDC[j-1] = leftUDC;
				leftUDC = MBDC[4];
				
				mp4_PredictIntraDC(leftVDC, refVDC[j-1], refVDC[j],	  &MBDC[5], coeffMB+5*64, dcScalerChroma, &predDir[5]);
				refVDC[j-1] = leftVDC;
				leftVDC = MBDC[5];

				// check pattern after predict AC
//                if (ac_pred_flag)
//                    mp4_CheckPattern(coeffMB, &pattern);

                cbpc = pattern & 3;
                cbpy = pattern >> 2;
                // encode not_coded
                PutBits(0, 1);
                // encode mcbpc
//                EncodeMCBPC_P(MBcurr->type, cbpc);
                EncodeMCBPC_P(type, cbpc);
                
                // encode ac_pred_flag
                PutBits(ac_pred_flag, 1);
                // encode cbpy
//                EncodeCBPY_P(MBcurr->type, cbpy);
                EncodeCBPY_P(type, cbpy);
                
                // Encode blocks
                EncodeBlockIntra_MPEG4(coeffMB + 0*64, use_intra_dc_vlc, 0, cbpy & 8, predDir[0]);
                EncodeBlockIntra_MPEG4(coeffMB + 1*64, use_intra_dc_vlc, 1, cbpy & 4, predDir[1]);
                EncodeBlockIntra_MPEG4(coeffMB + 2*64, use_intra_dc_vlc, 2, cbpy & 2, predDir[2]);
                EncodeBlockIntra_MPEG4(coeffMB + 3*64, use_intra_dc_vlc, 3, cbpy & 1, predDir[3]);
                EncodeBlockIntra_MPEG4(coeffMB + 4*64, use_intra_dc_vlc, 4, cbpc & 2, predDir[4]);
                EncodeBlockIntra_MPEG4(coeffMB + 5*64, use_intra_dc_vlc, 5, cbpc & 1, predDir[5]);
                // restore VOP
//				if (ac_pred_flag) {
//					mp4_RestoreAC(MBcurr, coeffMB+0*64, 0, predDir[0]);
//					mp4_RestoreAC(MBcurr, coeffMB+1*64, 1, predDir[1]);
//					mp4_RestoreAC(MBcurr, coeffMB+2*64, 2, predDir[2]);
//					mp4_RestoreAC(MBcurr, coeffMB+3*64, 3, predDir[3]);
//					mp4_RestoreAC(MBcurr, coeffMB+4*64, 4, predDir[4]);
//					mp4_RestoreAC(MBcurr, coeffMB+5*64, 5, predDir[5]);
//				}

                mp4_Inv_Quant_DCT_Intra_MPEG4(pCur_MB, 16, 0);
                mp4_Inv_Quant_DCT_Intra_MPEG4(pCur_MB+8, 16, 1);
                mp4_Inv_Quant_DCT_Intra_MPEG4(pCur_MB+8*16, 16, 2);
                mp4_Inv_Quant_DCT_Intra_MPEG4(pCur_MB+8*16+8, 16, 3);
                mp4_Inv_Quant_DCT_Intra_MPEG4(pCur_MB+24*18, 8, 4);
                mp4_Inv_Quant_DCT_Intra_MPEG4(pCur_MB+24*18+64, 8, 5);
               
            } else {
                // inter coded
//                MBcurr->dct_dc[0] = MBcurr->dct_dc[1] = MBcurr->dct_dc[2] = MBcurr->dct_dc[3] = MBcurr->dct_dc[4] = MBcurr->dct_dc[5] = mDefDC;
				refYDC[j2-1] = MBDC[3];
				refYDC[j2] = mDefDC;
				refUDC[j-1] = leftUDC;
				refVDC[j-1] = leftVDC;
				MBDC[1]=MBDC[3]=leftUDC=leftVDC=mDefDC;
				

/***********************                                
                if (MBcurr->type == IPP_VIDEO_INTER)
					xhComputeChromaMV_MPEG4(&mvLuma, &mvChroma);
               
                else
                    xhComputeChroma4MV_MPEG4(mvLuma4, &mvChroma, opaqueMB);
************************/                    
				xhComputeChromaMV_MPEG4(&mvLuma, &mvChroma);
                    
                    //pr = pUf + mp4_MC_offs(&mvChroma, mStepChroma);
                    //get_interpolate_uv(pr,mStepChroma,MBy_match_uv,mp4_MC_type(&mvChroma));
                    //pr = pVf + mp4_MC_offs(&mvChroma, mStepChroma); 
                    //get_interpolate_uv(pr,mStepChroma,MBy_match_uv+64,mp4_MC_type(&mvChroma));
                pr = pCurRefwinU+refwin_UV_step*8+8 + mp4_MC_offs(&mvChroma, refwin_UV_step);
                get_interpolate_uv(pr, refwin_UV_step, MBy_match_uv, mp4_MC_type(&mvChroma));
                pr = pCurRefwinV+refwin_UV_step*8+8 + mp4_MC_offs(&mvChroma, refwin_UV_step); 
                get_interpolate_uv(pr, refwin_UV_step, MBy_match_uv+64, mp4_MC_type(&mvChroma));
                    
                    
//                MBcurr->mv[0] = mvLuma4[0];
//				MBcurr->mv[1] = mvLuma4[1]; 
//				MBcurr->mv[2] = mvLuma4[2]; 
//				MBcurr->mv[3] = mvLuma4[3];
//				MBcurr->mv = mvLuma;
				refmv[j] = mvLuma;

/**************************
                //pr = pYf + mp4_MC_offs(&mvLuma4[0], mStepLuma);
                //xhGetDiff8x8_8u16s_C1(pYc, mStepLuma, pr, mStepLuma, coeffMB+0*64, 16, 0, 0, mp4_MC_type(&mvLuma4[0]), VOP.vop_rounding_type);
                GetDiff8x8_8u16s_C1(pCur_MB,16,MBcurr->type == IPP_VIDEO_INTER ? MBy_match_16x16:MBy_match_4x8x8,coeffMB+0*64);
                //pr = pYf + mp4_MC_offs(&mvLuma4[1], mStepLuma) + 8;
                //xhGetDiff8x8_8u16s_C1(pYc+8, mStepLuma, pr, mStepLuma, coeffMB+1*64, 16, 0, 0, mp4_MC_type(&mvLuma4[1]), VOP.vop_rounding_type);
				GetDiff8x8_8u16s_C1(pCur_MB+8,16,MBcurr->type == IPP_VIDEO_INTER?MBy_match_16x16+8:MBy_match_4x8x8+8,coeffMB+1*64);
                //pr = pYf + mp4_MC_offs(&mvLuma4[2], mStepLuma) + 8 * mStepLuma;
                //xhGetDiff8x8_8u16s_C1(pYc+8*mStepLuma, mStepLuma, pr, mStepLuma, coeffMB+2*64, 16, 0, 0, mp4_MC_type(&mvLuma4[2]), VOP.vop_rounding_type);
				GetDiff8x8_8u16s_C1(pCur_MB+8*16,16,MBcurr->type == IPP_VIDEO_INTER?MBy_match_16x16+8*16:MBy_match_4x8x8+8*16,coeffMB+2*64);
                //pr = pYf + mp4_MC_offs(&mvLuma4[3], mStepLuma) + 8 * mStepLuma + 8;
                //xhGetDiff8x8_8u16s_C1(pYc+8*mStepLuma+8, mStepLuma, pr, mStepLuma, coeffMB+3*64, 16, 0, 0, mp4_MC_type(&mvLuma4[3]), VOP.vop_rounding_type);
                GetDiff8x8_8u16s_C1(pCur_MB+8*16+8,16,MBcurr->type == IPP_VIDEO_INTER?MBy_match_16x16+8*16+8:MBy_match_4x8x8+8*16+8,coeffMB+3*64);
				
                //pr = pUf + mp4_MC_offs(&mvChroma, mStepChroma);
                //p_interolate=xhGetDiff8x8_8u16s_C1(pUc, mStepChroma, pr, mStepChroma, coeffMB+4*64, 16, 0, 0, mp4_MC_type(&mvChroma), VOP.vop_rounding_type);
				GetDiff8x8_8u16s_C1(pCur_MB+24*18,8,MBy_match_uv,coeffMB+4*64);
                //for(k=0;k<64;k++)
                  //  if(MBy_match_uv[k]!=p_interolate[k])
                    //      printf("the %d block u is difference",i+22*j);
				
			//	for(k=0;k<64;k++)
			//	    if(resident[k]!=coeffMB[256+k])
			//	      printf("the %d block u resident is difference",i+22*j);
				
				
				
				
			//	pr = pVf + mp4_MC_offs(&mvChroma, mStepChroma);
              //  p_interolate=xhGetDiff8x8_8u16s_C1(pVc, mStepChroma, pr, mStepChroma, coeffMB+5*64, 16, 0, 0, mp4_MC_type(&mvChroma), VOP.vop_rounding_type);
                GetDiff8x8_8u16s_C1(pCur_MB+24*18+64,8,MBy_match_uv+64,coeffMB+5*64);
				//for(k=0;k<64;k++)
                   //if(MBy_match_uv[k+64]!=p_interolate[k])
                    //      printf("the %d block v is difference",i+22*j);
                     
                  //for(k=0;k<64;k++)
				    //if(resident[64+k]!=coeffMB[320+k])
				      //printf("the %d block v resident is difference",i+22*j);
*****************************/
                GetDiff8x8_8u16s_C1(pCur_MB,			16,		MBy_match_16x16,		coeffMB+0*64);
				GetDiff8x8_8u16s_C1(pCur_MB+8,			16,		MBy_match_16x16+8,		coeffMB+1*64);
				GetDiff8x8_8u16s_C1(pCur_MB+8*16,		16,		MBy_match_16x16+8*16,	coeffMB+2*64);
                GetDiff8x8_8u16s_C1(pCur_MB+8*16+8,		16,		MBy_match_16x16+8*16+8,	coeffMB+3*64);
				GetDiff8x8_8u16s_C1(pCur_MB+24*18,		8,		MBy_match_uv,			coeffMB+4*64);
                GetDiff8x8_8u16s_C1(pCur_MB+24*18+64,	8,		MBy_match_uv+64,		coeffMB+5*64);
				      
                pattern = 0;
                mp4_DCT_Quant_Inter_MPEG4(0);
      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -