00001
00023 #include "global.h"
00024 #include "image.h"
00025 #include "mb_access.h"
00026 #include "loopfilter.h"
00027
00028 byte mixedModeEdgeFlag, fieldModeFilteringFlag;
00029
00030 static int64 **list0_refPicIdArr, **list1_refPicIdArr;
00031 static short ***list0_mv, ***list1_mv;
00032 static char **list0_refIdxArr, **list1_refIdxArr;
00033 static Macroblock *MbP;
00034 static imgpel *SrcPtrP, *SrcPtrQ;
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 static const byte ALPHA_TABLE[52] = {0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,4,4,5,6, 7,8,9,10,12,13,15,17, 20,22,25,28,32,36,40,45, 50,56,63,71,80,90,101,113, 127,144,162,182,203,226,255,255} ;
00047 static const byte BETA_TABLE[52] = {0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,2,2,2,3, 3,3,3, 4, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9,10,10, 11,11,12,12,13,13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18} ;
00048 static const byte CLIP_TAB[52][5] =
00049 {
00050 { 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},
00051 { 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},{ 0, 0, 0, 0, 0},
00052 { 0, 0, 0, 0, 0},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 0, 1, 1},{ 0, 0, 1, 1, 1},{ 0, 0, 1, 1, 1},{ 0, 1, 1, 1, 1},
00053 { 0, 1, 1, 1, 1},{ 0, 1, 1, 1, 1},{ 0, 1, 1, 1, 1},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 1, 2, 2},{ 0, 1, 2, 3, 3},
00054 { 0, 1, 2, 3, 3},{ 0, 2, 2, 3, 3},{ 0, 2, 2, 4, 4},{ 0, 2, 3, 4, 4},{ 0, 2, 3, 4, 4},{ 0, 3, 3, 5, 5},{ 0, 3, 4, 6, 6},{ 0, 3, 4, 6, 6},
00055 { 0, 4, 5, 7, 7},{ 0, 4, 5, 8, 8},{ 0, 4, 6, 9, 9},{ 0, 5, 7,10,10},{ 0, 6, 8,11,11},{ 0, 6, 8,13,13},{ 0, 7,10,14,14},{ 0, 8,11,16,16},
00056 { 0, 9,12,18,18},{ 0,10,13,20,20},{ 0,11,15,23,23},{ 0,13,17,25,25}
00057 } ;
00058
00059 static const char chroma_edge[2][4][4] =
00060 { { {-4, 0, 0, 0},
00061 {-4,-4,-4, 4},
00062 {-4, 4, 4, 8},
00063 {-4,-4,-4, 12}},
00064
00065 { {-4, 0, 0, 0},
00066 {-4,-4, 4, 4},
00067 {-4, 4, 8, 8},
00068 {-4,-4, 12, 12}}};
00069
00070 static const int pelnum_cr[2][4] = {{0,8,16,16}, {0,8, 8,16}};
00071
00072 void (*GetStrength) (byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir,int edge, int mvlimit,StorablePicture *p);
00073 void GetStrengthNormal (byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir,int edge, int mvlimit,StorablePicture *p);
00074 void GetStrengthMBAff (byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir,int edge, int mvlimit,StorablePicture *p);
00075 void (*EdgeLoopLuma) (ColorPlane pl, imgpel** Img, byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir, int edge, StorablePicture *p);
00076 void EdgeLoopLumaNormal(ColorPlane pl, imgpel** Img, byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir, int edge, StorablePicture *p);
00077 void EdgeLoopLumaMBAff (ColorPlane pl, imgpel** Img, byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir, int edge, StorablePicture *p);
00078 void (*EdgeLoopChroma)(imgpel** Img, byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir, int edge, int uv, StorablePicture *p);
00079 void EdgeLoopChromaNormal(imgpel** Img, byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir, int edge, int uv, StorablePicture *p);
00080 void EdgeLoopChromaMBAff(imgpel** Img, byte Strength[16],ImageParameters *img, Macroblock *MbQ, int dir, int edge, int uv, StorablePicture *p);
00081 void DeblockMb(ImageParameters *img, StorablePicture *p, int MbQAddr);
00082 int compute_deblock_strength(char **list0_refIdxArr, char **list1_refIdxArr, int64 **list0_refPicIdArr, int64 **list1_refPicIdArr,
00083 short ***list0_mv, short ***list1_mv, int blk_y, int blk_x, int blk_y2, int blk_x2, int mvlimit);
00084
00091 void DeblockPicture(ImageParameters *img, StorablePicture *p)
00092 {
00093 unsigned i;
00094
00095 if (p->MbaffFrameFlag == 1)
00096 {
00097 GetStrength = GetStrengthMBAff;
00098 EdgeLoopLuma = EdgeLoopLumaMBAff;
00099 EdgeLoopChroma = EdgeLoopChromaMBAff;
00100 }
00101 else
00102 {
00103 GetStrength = GetStrengthNormal;
00104 EdgeLoopLuma = EdgeLoopLumaNormal;
00105 EdgeLoopChroma = EdgeLoopChromaNormal;
00106 }
00107
00108 for (i = 0; i < p->PicSizeInMbs; i++)
00109 {
00110 DeblockMb( img, p, i ) ;
00111 }
00112 }
00113
00114
00122 void DeblockMb(ImageParameters *img, StorablePicture *p, int MbQAddr)
00123 {
00124 int EdgeCondition;
00125 int dir, edge;
00126 byte Strength[16];
00127 int mb_x, mb_y;
00128
00129 int filterNon8x8LumaEdgesFlag[4] = {1,1,1,1};
00130 int filterLeftMbEdgeFlag;
00131 int filterTopMbEdgeFlag;
00132 int fieldModeMbFlag;
00133 int mvlimit = 4;
00134 int i, StrengthSum;
00135 Macroblock *MbQ = &(img->mb_data[MbQAddr]) ;
00136 imgpel **imgY = p->imgY;
00137 imgpel ***imgUV = p->imgUV;
00138
00139 int edge_cr;
00140
00141
00142 if (MbQ->DFDisableIdc==1)
00143 {
00144 img->DeblockCall = 0;
00145 return;
00146 }
00147
00148 img->DeblockCall = 1;
00149 get_mb_pos (MbQAddr, img->mb_size[IS_LUMA], &mb_x, &mb_y);
00150
00151 filterLeftMbEdgeFlag = (mb_x != 0);
00152 filterTopMbEdgeFlag = (mb_y != 0);
00153
00154 if (MbQ->mb_type == I8MB)
00155 assert(MbQ->luma_transform_size_8x8_flag);
00156
00157 filterNon8x8LumaEdgesFlag[1] =
00158 filterNon8x8LumaEdgesFlag[3] = !(MbQ->luma_transform_size_8x8_flag);
00159
00160 if (p->MbaffFrameFlag && mb_y == MB_BLOCK_SIZE && MbQ->mb_field)
00161 filterTopMbEdgeFlag = 0;
00162
00163 fieldModeMbFlag = (p->structure!=FRAME) || (p->MbaffFrameFlag && MbQ->mb_field);
00164 if (fieldModeMbFlag)
00165 mvlimit = 2;
00166
00167 if (MbQ->DFDisableIdc==2)
00168 {
00169
00170 filterLeftMbEdgeFlag = MbQ->mbAvailA;
00171
00172 filterTopMbEdgeFlag = (p->MbaffFrameFlag && !MbQ->mb_field && (MbQAddr & 0x01)) ? 1 : MbQ->mbAvailB;
00173 }
00174 img->current_mb_nr = MbQAddr;
00175 CheckAvailabilityOfNeighbors(MbQ);
00176
00177 for( dir = 0 ; dir < 2 ; dir++ )
00178 {
00179 EdgeCondition = (dir && filterTopMbEdgeFlag) || (!dir && filterLeftMbEdgeFlag);
00180 for( edge=0; edge<4 ; edge++ )
00181 {
00182 if( edge || EdgeCondition )
00183 {
00184 edge_cr = chroma_edge[dir][edge][p->chroma_format_idc];
00185
00186 GetStrength(Strength, img, MbQ, dir, edge << 2, mvlimit, p);
00187 StrengthSum = Strength[0];
00188 for (i = 1; i < MB_BLOCK_SIZE && StrengthSum == 0 ; i++)
00189 {
00190 StrengthSum += (int) Strength[i];
00191 }
00192
00193 if( StrengthSum )
00194 {
00195 if (filterNon8x8LumaEdgesFlag[edge])
00196 {
00197 EdgeLoopLuma( PLANE_Y, imgY, Strength, img, MbQ, dir, edge << 2, p) ;
00198 if( active_sps->chroma_format_idc==YUV444 && !IS_INDEPENDENT(img) )
00199 {
00200 EdgeLoopLuma(PLANE_U, imgUV[0], Strength, img, MbQ, dir, edge << 2, p);
00201 EdgeLoopLuma(PLANE_V, imgUV[1], Strength, img, MbQ, dir, edge << 2, p);
00202 }
00203 }
00204 if (active_sps->chroma_format_idc==YUV420 || active_sps->chroma_format_idc==YUV422)
00205 {
00206 if( (imgUV != NULL) && (edge_cr >= 0))
00207 {
00208 EdgeLoopChroma( imgUV[0], Strength, img, MbQ, dir, edge_cr, 0, p);
00209 EdgeLoopChroma( imgUV[1], Strength, img, MbQ, dir, edge_cr, 1, p);
00210 }
00211 }
00212 }
00213
00214 if (dir && !edge && !MbQ->mb_field && mixedModeEdgeFlag)
00215 {
00216
00217 img->DeblockCall = 2;
00218 GetStrength(Strength, img, MbQ, dir, MB_BLOCK_SIZE, mvlimit, p);
00219
00220 {
00221 if (filterNon8x8LumaEdgesFlag[edge])
00222 {
00223 EdgeLoopLuma(PLANE_Y, imgY, Strength, img, MbQ, dir, MB_BLOCK_SIZE, p) ;
00224 if( active_sps->chroma_format_idc==YUV444 && !IS_INDEPENDENT(img) )
00225 {
00226 EdgeLoopLuma(PLANE_U, imgUV[0], Strength, img, MbQ, dir, MB_BLOCK_SIZE, p) ;
00227 EdgeLoopLuma(PLANE_V, imgUV[1], Strength, img, MbQ, dir, MB_BLOCK_SIZE, p) ;
00228 }
00229 }
00230 if (active_sps->chroma_format_idc==YUV420 || active_sps->chroma_format_idc==YUV422)
00231 {
00232 if( (imgUV != NULL) && (edge_cr >= 0))
00233 {
00234 EdgeLoopChroma( imgUV[0], Strength, img, MbQ, dir, MB_BLOCK_SIZE, 0, p) ;
00235 EdgeLoopChroma( imgUV[1], Strength, img, MbQ, dir, MB_BLOCK_SIZE, 1, p) ;
00236 }
00237 }
00238 }
00239 img->DeblockCall = 1;
00240 }
00241 }
00242 }
00243 }
00244
00245 img->DeblockCall = 0;
00246 }
00247
00255 #define ANY_INTRA (MbP->mb_type==I4MB||MbP->mb_type==I8MB||MbP->mb_type==I16MB||MbP->mb_type==IPCM||MbQ->mb_type==I4MB||MbQ->mb_type==I8MB||MbQ->mb_type==I16MB||MbQ->mb_type==IPCM)
00256
00257 void GetStrengthNormal(byte Strength[MB_BLOCK_SIZE], ImageParameters *img, Macroblock *MbQ, int dir, int edge, int mvlimit, StorablePicture *p)
00258 {
00259 static int64 ref_p0,ref_p1,ref_q0,ref_q1;
00260 static int blkP, blkQ, idx;
00261 static int blk_x, blk_x2, blk_y, blk_y2 ;
00262 static int xQ, yQ;
00263 static int mb_x, mb_y;
00264 static PixelPos pixP, pixMB;
00265 static byte StrValue;
00266
00267 if ((p->slice_type==SP_SLICE)||(p->slice_type==SI_SLICE) )
00268 {
00269
00270 StrValue = (edge == 0 && (((p->structure==FRAME)) || ((p->structure != FRAME) && !dir))) ? 4 : 3;
00271 memset(&Strength[0], (byte) StrValue, MB_BLOCK_SIZE * sizeof(byte));
00272 }
00273 else
00274 {
00275 xQ = dir ? 0 : edge - 1;
00276 yQ = dir ? (edge < 16 ? edge - 1: 0) : 0;
00277
00278 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_LUMA], &pixMB);
00279 pixP = pixMB;
00280 MbP = &(img->mb_data[pixP.mb_addr]);
00281
00282 if (!ANY_INTRA)
00283 {
00284 PicMotionParams *motion = &p->motion;
00285 list0_refPicIdArr = motion->ref_pic_id[LIST_0];
00286 list1_refPicIdArr = motion->ref_pic_id[LIST_1];
00287 list0_mv = motion->mv[LIST_0];
00288 list1_mv = motion->mv[LIST_1];
00289 list0_refIdxArr = motion->ref_idx[LIST_0];
00290 list1_refIdxArr = motion->ref_idx[LIST_1];
00291
00292 get_mb_block_pos (MbQ->mbAddrX, &mb_x, &mb_y);
00293 mb_x <<= 2;
00294 mb_y <<= 2;
00295
00296 yQ += dir;
00297 xQ += (1 - dir);
00298
00299 for( idx = 0 ; idx < MB_BLOCK_SIZE ; idx += BLOCK_SIZE )
00300 {
00301 if (dir)
00302 {
00303 xQ = idx;
00304 pixP.x = pixMB.x + idx;
00305 pixP.pos_x = pixMB.pos_x + idx;
00306 }
00307 else
00308 {
00309 yQ = idx;
00310 pixP.y = pixMB.y + idx;
00311 pixP.pos_y = pixMB.pos_y + idx;
00312 }
00313
00314 blkQ = (yQ & 0xFFFC) + (xQ >> 2);
00315 blkP = (pixP.y & 0xFFFC) + (pixP.x >> 2);
00316
00317 if( ((MbQ->cbp_blk[0] & ((int64)1 << blkQ )) != 0) || ((MbP->cbp_blk[0] & ((int64)1 << blkP)) != 0) )
00318 StrValue = 2;
00319 else
00320 {
00321
00322
00323
00324 blk_y = mb_y + (blkQ >> 2);
00325 blk_x = mb_x + (blkQ & 3);
00326 blk_y2 = pixP.pos_y >> 2;
00327 blk_x2 = pixP.pos_x >> 2;
00328
00329 ref_p0 = list0_refIdxArr[blk_y ][blk_x ] < 0 ? INT64_MIN : list0_refPicIdArr[blk_y ][blk_x ];
00330 ref_q0 = list0_refIdxArr[blk_y2][blk_x2] < 0 ? INT64_MIN : list0_refPicIdArr[blk_y2][blk_x2];
00331 ref_p1 = list1_refIdxArr[blk_y ][blk_x ] < 0 ? INT64_MIN : list1_refPicIdArr[blk_y ][blk_x ];
00332 ref_q1 = list1_refIdxArr[blk_y2][blk_x2] < 0 ? INT64_MIN : list1_refPicIdArr[blk_y2][blk_x2];
00333 if ( ((ref_p0==ref_q0) && (ref_p1==ref_q1)) || ((ref_p0==ref_q1) && (ref_p1==ref_q0)))
00334 {
00335
00336 if (ref_p0 != ref_p1)
00337 {
00338
00339 if (ref_p0 == ref_q0)
00340 {
00341 if (ref_p0 == INT64_MIN)
00342 {
00343 StrValue = (byte) (
00344 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00345 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit));
00346 }
00347 else if (ref_p1 == INT64_MIN)
00348 {
00349 StrValue = (byte) (
00350 (iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00351 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit));
00352 }
00353 else
00354 {
00355 StrValue = (byte) (
00356 (iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00357 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00358 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00359 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit));
00360 }
00361 }
00362 else
00363 {
00364 StrValue = (byte) (
00365 (iabs( list0_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00366 (iabs( list0_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00367 (iabs( list1_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00368 (iabs( list1_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit));
00369 }
00370 }
00371 else
00372 {
00373 StrValue = (byte) (
00374 ((iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00375 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit ) |
00376 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00377 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit))
00378 &&
00379 ((iabs( list0_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00380 (iabs( list0_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00381 (iabs( list1_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00382 (iabs( list1_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit)));
00383 }
00384 }
00385 else
00386 {
00387 StrValue = 1;
00388 }
00389 }
00390 memset(&Strength[idx], (byte) StrValue, BLOCK_SIZE * sizeof(byte));
00391 }
00392 }
00393 else
00394 {
00395
00396 StrValue = (edge == 0 && ((((p->structure==FRAME))) || ((p->structure != FRAME) && !dir))) ? 4 : 3;
00397 memset(&Strength[0], (byte) StrValue, MB_BLOCK_SIZE * sizeof(byte));
00398 }
00399 }
00400 }
00401
00408 void GetStrengthMBAff(byte Strength[16], ImageParameters *img, Macroblock *MbQ, int dir, int edge, int mvlimit, StorablePicture *p)
00409 {
00410 int blkP, blkQ, idx;
00411 int blk_x, blk_x2, blk_y, blk_y2 ;
00412 int64 ref_p0,ref_p1,ref_q0,ref_q1;
00413 int xQ, yQ;
00414 int mb_x, mb_y;
00415
00416 PixelPos pixP;
00417 int dir_m1 = (1 - dir);
00418
00419 PicMotionParams *motion = &p->motion;
00420 list0_mv = motion->mv[LIST_0];
00421 list1_mv = motion->mv[LIST_1];
00422 list0_refIdxArr = motion->ref_idx[LIST_0];
00423 list1_refIdxArr = motion->ref_idx[LIST_1];
00424 list0_refPicIdArr = motion->ref_pic_id[LIST_0];
00425 list1_refPicIdArr = motion->ref_pic_id[LIST_1];
00426
00427 for( idx=0 ; idx<16 ; idx++ )
00428 {
00429 xQ = dir ? idx : edge;
00430 yQ = dir ? (edge < MB_BLOCK_SIZE ? edge : 1) : idx;
00431 getNeighbour(MbQ, xQ - dir_m1, yQ - dir, img->mb_size[IS_LUMA], &pixP);
00432 blkQ = (yQ & 0xFFFC) + (xQ >> 2);
00433 blkP = (pixP.y & 0xFFFC) + (pixP.x >> 2);
00434
00435
00436 MbP = &(img->mb_data[pixP.mb_addr]);
00437 mixedModeEdgeFlag = (byte) (MbQ->mb_field != MbP->mb_field);
00438
00439 if ((p->slice_type==SP_SLICE)||(p->slice_type==SI_SLICE) )
00440 {
00441 Strength[idx] = (edge == 0 && (((!p->MbaffFrameFlag && (p->structure==FRAME)) ||
00442 (p->MbaffFrameFlag && !MbP->mb_field && !MbQ->mb_field)) ||
00443 ((p->MbaffFrameFlag || (p->structure != FRAME)) && !dir))) ? 4 : 3;
00444 }
00445 else
00446 {
00447
00448 Strength[idx] = (edge == 0 && (((!p->MbaffFrameFlag && (p->structure==FRAME)) ||
00449 (p->MbaffFrameFlag && !MbP->mb_field && !MbQ->mb_field)) ||
00450 ((p->MbaffFrameFlag || (p->structure!=FRAME)) && !dir))) ? 4 : 3;
00451
00452 if( !(MbP->mb_type==I4MB || MbP->mb_type==I16MB || MbP->mb_type==I8MB || MbP->mb_type==IPCM)
00453 && !(MbQ->mb_type==I4MB || MbQ->mb_type==I16MB || MbQ->mb_type==I8MB || MbQ->mb_type==IPCM) )
00454 {
00455 if( ((MbQ->cbp_blk[0] & ((int64)1 << blkQ )) != 0) || ((MbP->cbp_blk[0] & ((int64)1 << blkP)) != 0) )
00456 Strength[idx] = 2 ;
00457 else
00458 {
00459
00460
00461
00462 if (mixedModeEdgeFlag)
00463 {
00464 (Strength[idx] = 1);
00465 }
00466 else
00467 {
00468 get_mb_block_pos (MbQ->mbAddrX, &mb_x, &mb_y);
00469 blk_y = (mb_y<<2) + (blkQ >> 2) ;
00470 blk_x = (mb_x<<2) + (blkQ & 3) ;
00471 blk_y2 = pixP.pos_y >> 2;
00472 blk_x2 = pixP.pos_x >> 2;
00473 {
00474 ref_p0 = list0_refIdxArr[blk_y ][blk_x ] < 0 ? INT64_MIN : list0_refPicIdArr[blk_y ][blk_x];
00475 ref_q0 = list0_refIdxArr[blk_y2][blk_x2] < 0 ? INT64_MIN : list0_refPicIdArr[blk_y2][blk_x2];
00476 ref_p1 = list1_refIdxArr[blk_y ][blk_x ] < 0 ? INT64_MIN : list1_refPicIdArr[blk_y ][blk_x];
00477 ref_q1 = list1_refIdxArr[blk_y2][blk_x2]<0 ? INT64_MIN : list1_refPicIdArr[blk_y2][blk_x2];
00478 if ( ((ref_p0==ref_q0) && (ref_p1==ref_q1)) ||
00479 ((ref_p0==ref_q1) && (ref_p1==ref_q0)))
00480 {
00481 Strength[idx]=0;
00482
00483 if (ref_p0 != ref_p1)
00484 {
00485
00486 if (ref_p0==ref_q0)
00487 {
00488 Strength[idx] = (byte) (
00489 (iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00490 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00491 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00492 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit));
00493 }
00494 else
00495 {
00496 Strength[idx] = (byte) (
00497 (iabs( list0_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00498 (iabs( list0_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00499 (iabs( list1_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00500 (iabs( list1_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit));
00501 }
00502 }
00503 else
00504 {
00505
00506 Strength[idx] = (byte) (
00507 ((iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00508 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit ) |
00509 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00510 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit))
00511 &&
00512 ((iabs( list0_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
00513 (iabs( list0_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00514 (iabs( list1_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00515 (iabs( list1_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit)));
00516 }
00517 }
00518 else
00519 {
00520 Strength[idx] = 1;
00521 }
00522 }
00523 }
00524 }
00525 }
00526 }
00527 }
00528 }
00529
00536 void EdgeLoopLumaNormal(ColorPlane pl, imgpel** Img, byte Strength[16], ImageParameters *img, Macroblock *MbQ,
00537 int dir, int edge, StorablePicture *p)
00538 {
00539 static imgpel L2, L1, L0, R0, R1, R2, L3, R3;
00540 static PixelPos pixP, pixQ, pixMB1, pixMB2;
00541 static int C0, tc0, dif, RL0;
00542 static int pel, ap, aq, Strng;
00543 static int Alpha, Beta, small_gap;
00544 static int indexA, indexB;
00545 static int QP;
00546 static const byte* ClipTab;
00547 static int inc_dim, inc_dim3;
00548 int xQ = dir ? 0 : edge - 1;
00549 int yQ = dir ? (edge < MB_BLOCK_SIZE ? edge - 1: 0) : 0;
00550
00551 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_LUMA], &pixMB1);
00552
00553 if (pixMB1.available || (MbQ->DFDisableIdc== 0))
00554 {
00555 int AlphaC0Offset = MbQ->DFAlphaC0Offset;
00556 int BetaOffset = MbQ->DFBetaOffset;
00557 int dirM1 = (dir - 1);
00558 int bitdepth_scale = pl ? img->bitdepth_scale[IS_CHROMA] : img->bitdepth_scale[IS_LUMA];
00559 int max_imgpel_value = img->max_imgpel_value_comp[pl];
00560 int width = p->size_x;
00561 pixP = pixMB1;
00562 MbP = &(img->mb_data[pixP.mb_addr]);
00563 inc_dim = dir ? width : 1;
00564 inc_dim3 = inc_dim * 3;
00565
00566 yQ += dir;
00567 xQ -= dirM1;
00568 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_LUMA], &pixMB2);
00569 pixQ = pixMB2;
00570
00571
00572 QP = pl? ((MbP->qpc[pl-1] + MbQ->qpc[pl-1] + 1) >> 1) : (MbP->qp + MbQ->qp + 1) >> 1;
00573
00574 indexA = iClip3(0, MAX_QP, QP + AlphaC0Offset);
00575 indexB = iClip3(0, MAX_QP, QP + BetaOffset);
00576
00577 Alpha = ALPHA_TABLE[indexA] * bitdepth_scale;
00578 Beta = BETA_TABLE [indexB] * bitdepth_scale;
00579 ClipTab = CLIP_TAB[indexA];
00580
00581 for( pel = 0 ; pel < MB_BLOCK_SIZE ; pel++ )
00582 {
00583 if( (Strng = *(Strength++)) != 0)
00584 {
00585 SrcPtrQ = &(Img[pixQ.pos_y][pixQ.pos_x]);
00586 SrcPtrP = &(Img[pixP.pos_y][pixP.pos_x]);
00587
00588 L3 = *(SrcPtrP -= inc_dim3);
00589 L2 = *(SrcPtrP += inc_dim);
00590 L1 = *(SrcPtrP += inc_dim);
00591 L0 = *(SrcPtrP += inc_dim);
00592 R0 = *SrcPtrQ;
00593 R1 = *(SrcPtrQ += inc_dim);
00594 R2 = *(SrcPtrQ += inc_dim);
00595 R3 = *(SrcPtrQ += inc_dim);
00596
00597 if( iabs( R0 - L0 ) < Alpha )
00598 {
00599 if ((iabs( R0 - R1) < Beta) && (iabs(L0 - L1) < Beta))
00600 {
00601 if(Strng == 4 )
00602 {
00603 RL0 = L0 + R0;
00604 small_gap = (iabs( R0 - L0 ) < ((Alpha >> 2) + 2));
00605 aq = ( iabs( R0 - R2) < Beta ) & small_gap;
00606 ap = ( iabs( L0 - L2) < Beta ) & small_gap;
00607
00608 if (ap)
00609 {
00610 *SrcPtrP = (imgpel) (( R1 + ((L1 + RL0) << 1) + L2 + 4) >> 3);
00611 *(SrcPtrP -= inc_dim) = (imgpel) (( L2 + L1 + RL0 + 2) >> 2);
00612 *(SrcPtrP - inc_dim) = (imgpel) ((((L3 + L2) <<1) + L2 + L1 + RL0 + 4) >> 3);
00613 }
00614 else
00615 {
00616 *SrcPtrP = (imgpel) (((L1 << 1) + L0 + R1 + 2) >> 2) ;
00617 }
00618
00619 if (aq)
00620 {
00621 *(SrcPtrQ -= inc_dim3) = (imgpel) (( L1 + ((R1 + RL0) << 1) + R2 + 4) >> 3);
00622 *(SrcPtrQ += inc_dim ) = (imgpel) (( R2 + R0 + L0 + R1 + 2) >> 2);
00623 *(SrcPtrQ + inc_dim ) = (imgpel) ((((R3 + R2) <<1) + R2 + R1 + RL0 + 4) >> 3);
00624 }
00625 else
00626 {
00627 *(SrcPtrQ - inc_dim3) = (imgpel) (((R1 << 1) + R0 + L1 + 2) >> 2);
00628 }
00629 }
00630 else
00631 {
00632 RL0 = (L0 + R0 + 1) >> 1;
00633 aq = (iabs(R0 - R2) < Beta);
00634 ap = (iabs(L0 - L2) < Beta);
00635
00636 C0 = ClipTab[ Strng ] * bitdepth_scale;
00637 tc0 = (C0 + ap + aq) ;
00638 dif = iClip3( -tc0, tc0, (((R0 - L0) << 2) + (L1 - R1) + 4) >> 3 );
00639
00640 if( ap )
00641 *(SrcPtrP - inc_dim) += iClip3( -C0, C0, (L2 + RL0 - (L1<<1)) >> 1 );
00642
00643 *SrcPtrP = (imgpel) iClip1(max_imgpel_value, L0 + dif);
00644 *(SrcPtrQ -= inc_dim3) = (imgpel) iClip1(max_imgpel_value, R0 - dif);
00645
00646 if( aq )
00647 *(SrcPtrQ + inc_dim) += iClip3( -C0, C0, (R2 + RL0 - (R1<<1)) >> 1 );
00648 }
00649 }
00650 }
00651 }
00652 pixP.pos_x += dir;
00653 pixQ.pos_x += dir;
00654 pixP.pos_y -= dirM1;
00655 pixQ.pos_y -= dirM1;
00656 }
00657 }
00658 }
00659
00666 void EdgeLoopLumaMBAff(ColorPlane pl, imgpel** Img, byte Strength[16], ImageParameters *img, Macroblock *MbQ,
00667 int dir, int edge, StorablePicture *p)
00668 {
00669 int width = p->size_x;
00670 int pel, ap = 0, aq = 0, Strng ;
00671 int incP, incQ;
00672 int C0, tc0, dif;
00673 imgpel L2 = 0, L1, L0, R0, R1, R2 = 0, L3, R3;
00674 int RL0;
00675 int Alpha = 0, Beta = 0 ;
00676 const byte* ClipTab = NULL;
00677 int small_gap;
00678 int indexA, indexB;
00679 int PelNum = pl? pelnum_cr[dir][p->chroma_format_idc] : MB_BLOCK_SIZE;
00680
00681 int QP;
00682 int xQ, yQ;
00683
00684 PixelPos pixP, pixQ;
00685 int dir_m1 = (1 - dir);
00686 int bitdepth_scale = pl? img->bitdepth_scale[IS_CHROMA] : img->bitdepth_scale[IS_LUMA];
00687 int max_imgpel_value = img->max_imgpel_value_comp[pl];
00688
00689 int AlphaC0Offset = MbQ->DFAlphaC0Offset;
00690 int BetaOffset = MbQ->DFBetaOffset;
00691
00692
00693 for( pel = 0 ; pel < PelNum ; pel++ )
00694 {
00695 xQ = dir ? pel : edge;
00696 yQ = dir ? (edge < 16 ? edge : 1) : pel;
00697 getNeighbour(MbQ, xQ - (dir_m1), yQ - dir, img->mb_size[IS_LUMA], &pixP);
00698
00699 if (pixP.available || (MbQ->DFDisableIdc== 0))
00700 {
00701 if( (Strng = Strength[pel]) != 0)
00702 {
00703 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_LUMA], &pixQ);
00704
00705 MbP = &(img->mb_data[pixP.mb_addr]);
00706 fieldModeFilteringFlag = (byte) (MbQ->mb_field || MbP->mb_field);
00707
00708 incQ = dir ? ((fieldModeFilteringFlag && !MbQ->mb_field) ? 2 * width : width) : 1;
00709 incP = dir ? ((fieldModeFilteringFlag && !MbP->mb_field) ? 2 * width : width) : 1;
00710 SrcPtrQ = &(Img[pixQ.pos_y][pixQ.pos_x]);
00711 SrcPtrP = &(Img[pixP.pos_y][pixP.pos_x]);
00712
00713
00714 QP = pl? ((MbP->qpc[pl-1] + MbQ->qpc[pl-1] + 1) >> 1) : (MbP->qp + MbQ->qp + 1) >> 1;
00715
00716 indexA = iClip3(0, MAX_QP, QP + AlphaC0Offset);
00717 indexB = iClip3(0, MAX_QP, QP + BetaOffset);
00718
00719 Alpha = ALPHA_TABLE[indexA] * bitdepth_scale;
00720 Beta = BETA_TABLE [indexB] * bitdepth_scale;
00721 ClipTab = CLIP_TAB[indexA];
00722
00723 L3 = SrcPtrP[-incP*3];
00724 L2 = SrcPtrP[-incP*2];
00725 L1 = SrcPtrP[-incP];
00726 L0 = SrcPtrP[0] ;
00727 R0 = SrcPtrQ[0] ;
00728 R1 = SrcPtrQ[ incQ];
00729 R2 = SrcPtrQ[ incQ*2];
00730 R3 = SrcPtrQ[ incQ*3];
00731
00732 if( iabs( R0 - L0 ) < Alpha )
00733 {
00734 if ((iabs( R0 - R1) < Beta ) && (iabs(L0 - L1) < Beta ))
00735 {
00736 if(Strng == 4 )
00737 {
00738 RL0 = L0 + R0;
00739 small_gap = (iabs( R0 - L0 ) < ((Alpha >> 2) + 2));
00740 aq = ( iabs( R0 - R2) < Beta ) & small_gap;
00741 ap = ( iabs( L0 - L2) < Beta ) & small_gap;
00742
00743 if (ap)
00744 {
00745 SrcPtrP[-incP * 2] = (imgpel) ((((L3 + L2) << 1) + L2 + L1 + RL0 + 4) >> 3);
00746 SrcPtrP[-incP ] = (imgpel) (( L2 + L1 + L0 + R0 + 2) >> 2);
00747 SrcPtrP[ 0 ] = (imgpel) (( R1 + ((L1 + RL0) << 1) + L2 + 4) >> 3);
00748 }
00749 else
00750 {
00751 SrcPtrP[ 0 ] = (imgpel) (((L1 << 1) + L0 + R1 + 2) >> 2) ;
00752 }
00753
00754 if (aq)
00755 {
00756 SrcPtrQ[ 0 ] = (imgpel) (( L1 + ((R1 + RL0) << 1) + R2 + 4) >> 3);
00757 SrcPtrQ[ incQ ] = (imgpel) (( R2 + R0 + R1 + L0 + 2) >> 2);
00758 SrcPtrQ[ incQ * 2 ] = (imgpel) ((((R3 + R2) << 1) + R2 + R1 + RL0 + 4) >> 3);
00759 }
00760 else
00761 {
00762 SrcPtrQ[ 0 ] = (imgpel) (((R1 << 1) + R0 + L1 + 2) >> 2);
00763 }
00764 }
00765 else
00766 {
00767 RL0 = (L0 + R0 + 1) >> 1;
00768 aq = (iabs( R0 - R2) < Beta);
00769 ap = (iabs( L0 - L2) < Beta);
00770
00771 C0 = ClipTab[ Strng ] * bitdepth_scale;
00772 tc0 = (C0 + ap + aq) ;
00773 dif = iClip3( -tc0, tc0, (((R0 - L0) << 2) + (L1 - R1) + 4) >> 3) ;
00774
00775 if( ap )
00776 *(SrcPtrP - incP) += iClip3( -C0, C0, ( L2 + RL0 - (L1 << 1)) >> 1 ) ;
00777
00778 *SrcPtrP = (imgpel) iClip1 (max_imgpel_value, L0 + dif) ;
00779 *SrcPtrQ = (imgpel) iClip1 (max_imgpel_value, R0 - dif) ;
00780
00781 if( aq )
00782 *(SrcPtrQ + incQ) += iClip3( -C0, C0, ( R2 + RL0 - (R1 << 1)) >> 1 ) ;
00783 }
00784 }
00785 }
00786 }
00787 }
00788 }
00789 }
00790
00797 void EdgeLoopChromaNormal(imgpel** Img, byte Strength[16], ImageParameters *img, Macroblock *MbQ,
00798 int dir, int edge, int uv, StorablePicture *p)
00799 {
00800 static int pel, Strng ;
00801 static int inc_dim;
00802 static int tc0, dif;
00803 static imgpel L1, L0, R0, R1;
00804 static int Alpha, Beta;
00805 static const byte* ClipTab;
00806 static int indexA, indexB;
00807 static int StrengthIdx;
00808 static PixelPos pixP, pixQ, pixMB1, pixMB2;
00809 static int QP;
00810 int PelNum = pelnum_cr[dir][p->chroma_format_idc];
00811
00812 int bitdepth_scale = img->bitdepth_scale[IS_CHROMA];
00813 int max_imgpel_value = img->max_imgpel_value_comp[uv + 1];
00814
00815 int xQ = dir ? 0 : edge - 1;
00816 int yQ = dir ? (edge < 16 ? edge - 1: 0) : 0;
00817
00818 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_CHROMA], &pixMB1);
00819
00820 if (pixMB1.available || (MbQ->DFDisableIdc == 0))
00821 {
00822 int AlphaC0Offset = MbQ->DFAlphaC0Offset;
00823 int BetaOffset = MbQ->DFBetaOffset;
00824 int width = p->size_x_cr;
00825 int dirM1 = dir - 1;
00826 pixP = pixMB1;
00827 MbP = &(img->mb_data[pixP.mb_addr]);
00828 yQ += dir;
00829 xQ -= dirM1;
00830 inc_dim = dir ? width : 1;
00831
00832 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_CHROMA], &pixMB2);
00833 pixQ = pixMB2;
00834
00835
00836 QP = (MbP->qpc[uv] + MbQ->qpc[uv] + 1) >> 1;
00837
00838 indexA = iClip3(0, MAX_QP, QP + AlphaC0Offset);
00839 indexB = iClip3(0, MAX_QP, QP + BetaOffset);
00840
00841 Alpha = ALPHA_TABLE[indexA] * bitdepth_scale;
00842 Beta = BETA_TABLE [indexB] * bitdepth_scale;
00843 ClipTab = CLIP_TAB[indexA];
00844
00845 for( pel = 0 ; pel < PelNum ; pel++ )
00846 {
00847 StrengthIdx = (PelNum == 8) ? (((pel >> 1) << 2) + (pel & 0x01)) : pel;
00848
00849 if( (Strng = Strength[StrengthIdx]) != 0)
00850 {
00851 SrcPtrP = &(Img[pixP.pos_y][pixP.pos_x]);
00852 L1 = *(SrcPtrP - inc_dim);
00853 L0 = *SrcPtrP;
00854 SrcPtrQ = &(Img[pixQ.pos_y][pixQ.pos_x]);
00855 R0 = *SrcPtrQ;
00856 R1 = *(SrcPtrQ + inc_dim);
00857
00858 if (( iabs( R0 - L0 ) < Alpha ) && ( iabs(R0 - R1) < Beta ) && ( iabs(L0 - L1) < Beta ) )
00859 {
00860 if( Strng == 4 )
00861 {
00862 *SrcPtrP = (imgpel) ( ((L1 << 1) + L0 + R1 + 2) >> 2 );
00863 *SrcPtrQ = (imgpel) ( ((R1 << 1) + R0 + L1 + 2) >> 2 );
00864 }
00865 else
00866 {
00867 tc0 = ClipTab[ Strng ] * bitdepth_scale + 1;
00868 dif = iClip3( -tc0, tc0, ( ((R0 - L0) << 2) + (L1 - R1) + 4) >> 3 );
00869
00870 *SrcPtrP = (imgpel) iClip1 ( max_imgpel_value, L0 + dif) ;
00871 *SrcPtrQ = (imgpel) iClip1 ( max_imgpel_value, R0 - dif) ;
00872 }
00873 }
00874 }
00875 pixP.pos_x += dir;
00876 pixQ.pos_x += dir;
00877 pixP.pos_y -= dirM1;
00878 pixQ.pos_y -= dirM1;
00879 }
00880 }
00881 }
00882
00889 void EdgeLoopChromaMBAff(imgpel** Img, byte Strength[16], ImageParameters *img, Macroblock *MbQ,
00890 int dir, int edge, int uv, StorablePicture *p)
00891 {
00892 int pel, Strng ;
00893 int incP, incQ;
00894 int C0, tc0, dif;
00895 imgpel L1, L0, R0, R1;
00896 int Alpha = 0, Beta = 0;
00897 const byte* ClipTab = NULL;
00898 int indexA, indexB;
00899 int PelNum = pelnum_cr[dir][p->chroma_format_idc];
00900 int StrengthIdx;
00901 int QP;
00902 int xQ, yQ;
00903 PixelPos pixP, pixQ;
00904 int dir_m1 = 1 - dir;
00905 int bitdepth_scale = img->bitdepth_scale[IS_CHROMA];
00906 int max_imgpel_value = img->max_imgpel_value_comp[uv + 1];
00907
00908 int AlphaC0Offset = MbQ->DFAlphaC0Offset;
00909 int BetaOffset = MbQ->DFBetaOffset;
00910 int width = p->size_x_cr;
00911
00912 for( pel = 0 ; pel < PelNum ; pel++ )
00913 {
00914 xQ = dir ? pel : edge;
00915 yQ = dir ? (edge < 16? edge : 1) : pel;
00916 getNeighbour(MbQ, xQ, yQ, img->mb_size[IS_CHROMA], &pixQ);
00917 getNeighbour(MbQ, xQ - (dir_m1), yQ - dir, img->mb_size[IS_CHROMA], &pixP);
00918 MbP = &(img->mb_data[pixP.mb_addr]);
00919 StrengthIdx = (PelNum == 8) ? ((MbQ->mb_field && !MbP->mb_field) ? pel << 1 :((pel >> 1) << 2) + (pel & 0x01)) : pel;
00920
00921 if (pixP.available || (MbQ->DFDisableIdc == 0))
00922 {
00923 if( (Strng = Strength[StrengthIdx]) != 0)
00924 {
00925 fieldModeFilteringFlag = (byte) (MbQ->mb_field || MbP->mb_field);
00926 incQ = dir ? ((fieldModeFilteringFlag && !MbQ->mb_field) ? 2 * width : width) : 1;
00927 incP = dir ? ((fieldModeFilteringFlag && !MbP->mb_field) ? 2 * width : width) : 1;
00928 SrcPtrQ = &(Img[pixQ.pos_y][pixQ.pos_x]);
00929 SrcPtrP = &(Img[pixP.pos_y][pixP.pos_x]);
00930
00931
00932 QP = (MbP->qpc[uv] + MbQ->qpc[uv] + 1) >> 1;
00933
00934 indexA = iClip3(0, MAX_QP, QP + AlphaC0Offset);
00935 indexB = iClip3(0, MAX_QP, QP + BetaOffset);
00936
00937 Alpha = ALPHA_TABLE[indexA] * bitdepth_scale;
00938 Beta = BETA_TABLE [indexB] * bitdepth_scale;
00939 ClipTab = CLIP_TAB[indexA];
00940
00941 L1 = SrcPtrP[-incP];
00942 L0 = SrcPtrP[0] ;
00943 R0 = SrcPtrQ[0] ;
00944 R1 = SrcPtrQ[ incQ];
00945
00946 if( iabs( R0 - L0 ) < Alpha )
00947 {
00948 if( ((iabs( R0 - R1) - Beta ) & (iabs(L0 - L1) - Beta )) < 0 )
00949 {
00950 if( Strng == 4 )
00951 {
00952 SrcPtrQ[0] = (imgpel) ( ((R1 << 1) + R0 + L1 + 2) >> 2 );
00953 SrcPtrP[0] = (imgpel) ( ((L1 << 1) + L0 + R1 + 2) >> 2 );
00954 }
00955 else
00956 {
00957 C0 = ClipTab[ Strng ] * bitdepth_scale;
00958 tc0 = (C0 + 1);
00959 dif = iClip3( -tc0, tc0, ( ((R0 - L0) << 2) + (L1 - R1) + 4) >> 3 );
00960
00961 SrcPtrP[0] = (imgpel) iClip1 ( max_imgpel_value, L0 + dif );
00962 SrcPtrQ[0] = (imgpel) iClip1 ( max_imgpel_value, R0 - dif );
00963 }
00964 }
00965 }
00966 }
00967 }
00968 }
00969 }
00970
00971 int compute_deblock_strength(char **list0_refIdxArr,
00972 char **list1_refIdxArr,
00973 int64 **list0_refPicIdArr,
00974 int64 **list1_refPicIdArr,
00975 short ***list0_mv,
00976 short ***list1_mv,
00977 int blk_y, int blk_x,
00978 int blk_y2, int blk_x2,
00979 int mvlimit)
00980 {
00981 static int64 ref_p0, ref_q0, ref_p1, ref_q1;
00982 static byte StrValue;
00983
00984 ref_p0 = list0_refIdxArr[blk_y] [blk_x] <0 ? INT64_MIN : list0_refPicIdArr[blk_y] [blk_x];
00985 ref_q0 = list0_refIdxArr[blk_y2][blk_x2]<0 ? INT64_MIN : list0_refPicIdArr[blk_y2][blk_x2];
00986 ref_p1 = list1_refIdxArr[blk_y] [blk_x] <0 ? INT64_MIN : list1_refPicIdArr[blk_y] [blk_x];
00987 ref_q1 = list1_refIdxArr[blk_y2][blk_x2]<0 ? INT64_MIN : list1_refPicIdArr[blk_y2][blk_x2];
00988 if ( ((ref_p0==ref_q0) && (ref_p1==ref_q1)) || ((ref_p0==ref_q1) && (ref_p1==ref_q0)))
00989 {
00990
00991 if (ref_p0 != ref_p1)
00992 {
00993
00994 if (ref_p0 == ref_q0)
00995 {
00996 StrValue = (byte) (
00997 (iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
00998 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit) |
00999 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
01000 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit));
01001 }
01002 else
01003 {
01004 StrValue = (byte) (
01005 (iabs( list0_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
01006 (iabs( list0_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit) |
01007 (iabs( list1_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
01008 (iabs( list1_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit));
01009 }
01010 }
01011 else
01012 {
01013
01014 StrValue = (byte) (
01015 ((iabs( list0_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
01016 (iabs( list0_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit ) |
01017 (iabs( list1_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
01018 (iabs( list1_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit))
01019 &&
01020 ((iabs( list0_mv[blk_y][blk_x][0] - list1_mv[blk_y2][blk_x2][0]) >= 4) |
01021 (iabs( list0_mv[blk_y][blk_x][1] - list1_mv[blk_y2][blk_x2][1]) >= mvlimit) |
01022 (iabs( list1_mv[blk_y][blk_x][0] - list0_mv[blk_y2][blk_x2][0]) >= 4) |
01023 (iabs( list1_mv[blk_y][blk_x][1] - list0_mv[blk_y2][blk_x2][1]) >= mvlimit)));
01024 }
01025 }
01026 else
01027 {
01028 StrValue = 1;
01029 }
01030 return StrValue;
01031 }
01032