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