Professional Documents
Culture Documents
xvidcore-0.9.2
XVID_INIT_PARAM xinit;
XVID_ENC_PARAM xparam;
1 use_assembler xinit.cpu_flags
2xvid_init(NULL, 0, &xinit, NULL)
a.xinit cpu_flagsapi_versioncore_build
b.idct_int32_init()
static short *iclpstatic short iclip[1024]
c.init_VLC_tables()
int32_t RGB_Y_tab[256]int32_t B_U_tab[256]int32_t G_U_tab[256]int32_t
G_V_tab[256] int32_t R_V_tab[256]
e. CPU
3xparam
4xvid_encore(NULL, XVID_ENC_CREATE, &xparam, NULL)
encoder_create((XVID_ENC_PARA *) pParam);
a.pParam
b. Encoder * pEnc
c. pEnc
pEnc->current pEnc->reference MACROBLOCK *mbs
pEnc->current->image, pEnc->reference->image, pEnc->vInterHpEnc->vInterV pEnc->vInterHV
yuv
d.pParam->handle = (void *)pEnc
e.RateControlInit()
5static void *enc_handle = xparam.handle
XVID
xvidcore-0.9.2
1)
SWAP(enc_handle ->current, enc_handle ->reference) enc_handle
->current xframe->image enc_handle ->current image yv12
2) BitstreamInit(&bs, xframe ->bitstream, 0);
3) xframe ->quant enc_handle->current->quant; enc_handle->current->global_flags
XVID_LUMIMASKING adaptive_quantization() enc_handle->current->quant
4)
5)FrameCodeI() FrameCodeP()
6)BitstreamPadAlways(&bs);
7) xstats
8) xframe ->quant=0 RateControlUpdate()
9)inc_frame_num(enc_handle)
XVID
xvidcore-0.9.2
int16_t dct_codes[6*64]
int16_t qcoeff [6*64]
1) I_VOP
2) VOL VOP
BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
BitstreamWriteVopHeader(bs, &pEnc->mbParam, pEnc->current, 1);
3)
a. MACROBLOCK *pMB
b. pMB CodeIntraMB(pEnc, pMB)
xvidcore-0.9.2
int16_t dct_codes[6*64]
int16_t qcoeff [6*64]
1),
image_setedges(pRef, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
pEnc->mbParam.width, pEnc->mbParam.height);
IMAGE *pRef = &pEnc->reference->image
2) I
3)
MBMotionCompensation(pMB, x, y, &pEnc->reference->image,&pEnc->vInterH,&pEnc->vInterV,
&pEnc->vInterHV, &pEnc->current->image,
dct_codes, pEnc->mbParam.width, pEnc->mbParam.height,pEnc->mbParam.edged_width,
pEnc->current->rounding_type);
DCT qcoeff
MBTransQuantInter(&pEnc->mbParam, pEnc->current, pMB, x, y, dct_codes, qcoeff);
b.:
CodeIntraMB(pEnc, pMB);
MBTransQuantIntra(&pEnc->mbParam, pEnc->current, pMB, x, y,dct_codes, qcoeff);
MBPrediction(pEnc->current, x, y, pEnc->mbParam.mb_width, qcoeff);
c.MBSkip() MBCoding()
8) XVID_HINTEDME_GET HintedMEGet(pEnc, 0)
9)return 0 P
xvidcore-0.9.2
1 MACROBLOCK * pMB
2
VECTOR predMV=
get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0);
3 16*16 SAD
16*16 pMB->pmvs[0]
pMB->sad16 =SEARCH16(pRef->y, pRefH->y, pRefV->y, pRefHV->y,
pCurrent, x, y,predMV.x, predMV.y, predMV.x, predMV.y,
current->motion_flags,current->quant,current->fcode,
pParam, pMBs, prevMBs, &pMB->mv16,&pMB->pmvs[0]);
4 pMB->sad16 > MV16_INTER_BIASMV16_INTER_BIAS=512
a. 16*16 SUM(abs(i-Mean))
deviation =dev16(pCurrent->y + x * 16 + y * 16 * pParam->edged_width,pParam->edged_width);
b. deviation < (pMB->sad16 - MV16_INTER_BIAS) 0
MODE_INTRA iIntra iIntra>=iLimit 1 I
5 XVID_INTER4V 4
a. 4 8*8 sad8
sad8 += SEARCH8(pRef->y, pRefH->y, pRefV->y, pRefHV->y,
pCurrent,2 * x, 2 * y, pMB->mv16.x, pMB->mv16.y,
predMV.x, predMV.y, current->motion_flags,current->quant,
current->fcode, pParam,pMBs, prevMBs, &pMB->mvs[0],&pMB->pmvs[0]);
b.if (sad8 < pMB->sad16) MODE_INTER4V pMB->sad8[i]
4
6 MODE_INTER4
xvidcore-0.9.2
dx = (dx&3)?(dx>>1)|1:dx/2;
dy = (dy&3)?(dy>>1)|1:dy/2;
c.( u )
interpolate8x8_switch(refv->u,ref->u,8*i,8*j,dx,dy,edged_width/2, rounding);
refv->u
d.
transfer_8to16sub(&dct_codes[4 * 64],cur->u+8*j*edged_width/2+8*i,
refv->u+8*j*edged_width/2+8*i,edged_width/2);
dct_codes
2else mb->mode == MODE_INTER4V
a.4 dct_codes
compensate8x8_halfpel(...);
b. 4
sum = mb->mvs[0].x+mb->mvs[1].x+mb->mvs[2].x+mb->mvs[3].x;
dx = (sum?SIGN(sum)*(roundtab[ABS(sum)%16]+(ABS(sum)/16)*2):0);
sum = mb->mvs[0].y+mb->mvs[1].y+mb->mvs[2].y+mb->mvs[3].y;
dy = (sum?SIGN(sum)*(roundtab[ABS(sum)%16]+(ABS(sum)/16)*2):0);
c. dct_codes
interpolate8x8_switch(refv->u,ref->u,8*i,8*j,dx,dy,edged_width/2,rounding);
transfer_8to16sub(&dct_codes[4*64],cur->u+8*j*edged_width/2+8*i,
refv->u+8*j*edged_width/2+8*i,edged_width/2);
XVID
xvidcore-0.9.2
VEVTOR pmv[4]; //
int32_t psad[4]; // SAD
currMV Center
Currpmv->x
currMV->x - Center->x;
Currpmv->x
currMV-> x- Center->x;
1
a. iFcode min_dx,max_dx,min_dy,max_dy
get_range(&min_dx, &max_dx, &min_dy, &max_dy, x, y,
16, iWidth, iHeight,iFcode);
b. MotionFlags & PMV_HALFPEL16 0
2 pmv psad
bPredEq = get_pmvdata2(pMBs, iWcount, 0, x, y, 0, pmv, psad)
1 0
3 SAD16
iMinSAD =sad16(cur,get_ref_mv(pRef, pRefH, pRefV, pRefHV, x, y, 16,
currMV,iEdgedWidth),iEdgedWidth, MV_MAX_ERROR)
a.get_ref_mv() currMV
b.sad16() SAD
c.
iMinSAD += calc_delta_16(currMV->x - center_x, currMV->y - center_y,(uint8_t) iFcode, iQuant)
d. SAD
SAD < 2* iQuant
MotionFlags
4 iDiamondSize
5 0 5 SAD
iMinSAD currMV
6 SAD
7
a. MotionFlags iMinSAD currMV
b. MotionFlags & PMV_EXTSEARCH16 0
SAD iMinSAD currMV
8PMVfast16_Terminate_with_Refine PMV_HALFPELREFINE16