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