00001
00017 #include "global.h"
00018 #include "intra8x8_pred.h"
00019 #include "mb_access.h"
00020 #include "image.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #define P_Z (PredPel[0])
00039 #define P_A (PredPel[1])
00040 #define P_B (PredPel[2])
00041 #define P_C (PredPel[3])
00042 #define P_D (PredPel[4])
00043 #define P_E (PredPel[5])
00044 #define P_F (PredPel[6])
00045 #define P_G (PredPel[7])
00046 #define P_H (PredPel[8])
00047 #define P_I (PredPel[9])
00048 #define P_J (PredPel[10])
00049 #define P_K (PredPel[11])
00050 #define P_L (PredPel[12])
00051 #define P_M (PredPel[13])
00052 #define P_N (PredPel[14])
00053 #define P_O (PredPel[15])
00054 #define P_P (PredPel[16])
00055 #define P_Q (PredPel[17])
00056 #define P_R (PredPel[18])
00057 #define P_S (PredPel[19])
00058 #define P_T (PredPel[20])
00059 #define P_U (PredPel[21])
00060 #define P_V (PredPel[22])
00061 #define P_W (PredPel[23])
00062 #define P_X (PredPel[24])
00063
00070 static inline void LowPassForIntra8x8Pred(imgpel *PredPel, int block_up_left, int block_up, int block_left)
00071 {
00072 int i;
00073 static imgpel LoopArray[25];
00074
00075 memcpy(&LoopArray[0], &PredPel[0], 25 * sizeof(imgpel));
00076
00077 if(block_up_left)
00078 {
00079 if(block_up && block_left)
00080 {
00081 LoopArray[0] = (imgpel) ((P_Q + (P_Z<<1) + P_A + 2)>>2);
00082 }
00083 else
00084 {
00085 if(block_up)
00086 LoopArray[0] = (imgpel) ((P_Z + (P_Z<<1) + P_A + 2)>>2);
00087 else if (block_left)
00088 LoopArray[0] = (imgpel) ((P_Z + (P_Z<<1) + P_Q + 2)>>2);
00089 }
00090 }
00091
00092 if(block_up)
00093 {
00094 if(block_up_left)
00095 {
00096 LoopArray[1] = (imgpel) ((PredPel[0] + (PredPel[1]<<1) + PredPel[2] + 2)>>2);
00097 }
00098 else
00099 LoopArray[1] = (imgpel) ((PredPel[1] + (PredPel[1]<<1) + PredPel[2] + 2)>>2);
00100
00101
00102 for(i = 2; i <16; i++)
00103 {
00104 LoopArray[i] = (imgpel) ((PredPel[i-1] + (PredPel[i]<<1) + PredPel[i+1] + 2)>>2);
00105 }
00106 LoopArray[16] = (imgpel) ((P_P + (P_P<<1) + P_O + 2)>>2);
00107 }
00108
00109 if(block_left)
00110 {
00111 if(block_up_left)
00112 LoopArray[17] = (imgpel) ((P_Z + (P_Q<<1) + P_R + 2)>>2);
00113 else
00114 LoopArray[17] = (imgpel) ((P_Q + (P_Q<<1) + P_R + 2)>>2);
00115
00116 for(i = 18; i <24; i++)
00117 {
00118 LoopArray[i] = (imgpel) ((PredPel[i-1] + (PredPel[i]<<1) + PredPel[i+1] + 2)>>2);
00119 }
00120 LoopArray[24] = (imgpel) ((P_W + (P_X<<1) + P_X + 2) >> 2);
00121 }
00122
00123 memcpy(&PredPel[0], &LoopArray[0], 25 * sizeof(imgpel));
00124 }
00125
00132 static inline void LowPassForIntra8x8PredHor(imgpel *PredPel, int block_up_left, int block_up, int block_left)
00133 {
00134 int i;
00135 static imgpel LoopArray[25];
00136
00137 memcpy(&LoopArray[0], &PredPel[0], 25 * sizeof(imgpel));
00138
00139 if(block_up_left)
00140 {
00141 if(block_up && block_left)
00142 {
00143 LoopArray[0] = (imgpel) ((P_Q + (P_Z<<1) + P_A + 2)>>2);
00144 }
00145 else
00146 {
00147 if(block_up)
00148 LoopArray[0] = (imgpel) ((P_Z + (P_Z<<1) + P_A + 2)>>2);
00149 else if (block_left)
00150 LoopArray[0] = (imgpel) ((P_Z + (P_Z<<1) + P_Q + 2)>>2);
00151 }
00152 }
00153
00154 if(block_up)
00155 {
00156 if(block_up_left)
00157 {
00158 LoopArray[1] = (imgpel) ((PredPel[0] + (PredPel[1]<<1) + PredPel[2] + 2)>>2);
00159 }
00160 else
00161 LoopArray[1] = (imgpel) ((PredPel[1] + (PredPel[1]<<1) + PredPel[2] + 2)>>2);
00162
00163
00164 for(i = 2; i <16; i++)
00165 {
00166 LoopArray[i] = (imgpel) ((PredPel[i-1] + (PredPel[i]<<1) + PredPel[i+1] + 2)>>2);
00167 }
00168 LoopArray[16] = (imgpel) ((P_P + (P_P<<1) + P_O + 2)>>2);
00169 }
00170
00171
00172 memcpy(&PredPel[0], &LoopArray[0], 17 * sizeof(imgpel));
00173 }
00174
00181 static inline void LowPassForIntra8x8PredVer(imgpel *PredPel, int block_up_left, int block_up, int block_left)
00182 {
00183
00184
00185 int i;
00186 static imgpel LoopArray[25];
00187
00188 memcpy(&LoopArray[0], &PredPel[0], 25 * sizeof(imgpel));
00189
00190 if(block_up_left)
00191 {
00192 if(block_up && block_left)
00193 {
00194 LoopArray[0] = (imgpel) ((P_Q + (P_Z<<1) + P_A + 2)>>2);
00195 }
00196 else
00197 {
00198 if(block_up)
00199 LoopArray[0] = (imgpel) ((P_Z + (P_Z<<1) + P_A + 2)>>2);
00200 else if (block_left)
00201 LoopArray[0] = (imgpel) ((P_Z + (P_Z<<1) + P_Q + 2)>>2);
00202 }
00203 }
00204
00205 if(block_left)
00206 {
00207 if(block_up_left)
00208 LoopArray[17] = (imgpel) ((P_Z + (P_Q<<1) + P_R + 2)>>2);
00209 else
00210 LoopArray[17] = (imgpel) ((P_Q + (P_Q<<1) + P_R + 2)>>2);
00211
00212 for(i = 18; i <24; i++)
00213 {
00214 LoopArray[i] = (imgpel) ((PredPel[i-1] + (PredPel[i]<<1) + PredPel[i+1] + 2)>>2);
00215 }
00216 LoopArray[24] = (imgpel) ((P_W + (P_X<<1) + P_X + 2) >> 2);
00217 }
00218
00219 memcpy(&PredPel[0], &LoopArray[0], 25 * sizeof(imgpel));
00220 }
00221
00232 static inline int intra8x8_dc_pred(Macroblock *currMB,
00233 ColorPlane pl,
00234 int ioff,
00235 int joff)
00236 {
00237 int i,j;
00238 int s0 = 0;
00239 imgpel PredPel[25];
00240 Slice *currSlice = currMB->p_Slice;
00241 ImageParameters *p_Img = currMB->p_Img;
00242
00243 StorablePicture *dec_picture = p_Img->dec_picture;
00244 imgpel **imgY = (pl) ? dec_picture->imgUV[pl - 1] : dec_picture->imgY;
00245
00246 PixelPos pix_a[8];
00247 PixelPos pix_b, pix_c, pix_d;
00248
00249 int block_available_up;
00250 int block_available_left;
00251 int block_available_up_left;
00252 int block_available_up_right;
00253
00254
00255 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
00256 int *mb_size = p_Img->mb_size[IS_LUMA];
00257
00258 for (i=0;i<8;i++)
00259 {
00260 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
00261 }
00262
00263 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
00264 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
00265 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
00266
00267 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
00268
00269 if (p_Img->active_pps->constrained_intra_pred_flag)
00270 {
00271 for (i=0, block_available_left=1; i<8;i++)
00272 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
00273 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
00274 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
00275 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
00276 }
00277 else
00278 {
00279 block_available_left = pix_a[0].available;
00280 block_available_up = pix_b.available;
00281 block_available_up_right = pix_c.available;
00282 block_available_up_left = pix_d.available;
00283 }
00284
00285
00286 if (block_available_up)
00287 {
00288 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
00289 P_A = pred_pels[0];
00290 P_B = pred_pels[1];
00291 P_C = pred_pels[2];
00292 P_D = pred_pels[3];
00293 P_E = pred_pels[4];
00294 P_F = pred_pels[5];
00295 P_G = pred_pels[6];
00296 P_H = pred_pels[7];
00297 }
00298 else
00299 {
00300 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
00301 }
00302
00303 if (block_available_up_right)
00304 {
00305 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
00306 P_I = pred_pels[0];
00307 P_J = pred_pels[1];
00308 P_K = pred_pels[2];
00309 P_L = pred_pels[3];
00310 P_M = pred_pels[4];
00311 P_N = pred_pels[5];
00312 P_O = pred_pels[6];
00313 P_P = pred_pels[7];
00314
00315 }
00316 else
00317 {
00318 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
00319 }
00320
00321 if (block_available_left)
00322 {
00323 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
00324 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
00325 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
00326 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
00327 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
00328 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
00329 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
00330 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
00331 }
00332 else
00333 {
00334 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
00335 }
00336
00337 if (block_available_up_left)
00338 {
00339 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
00340 }
00341 else
00342 {
00343 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
00344 }
00345
00346 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
00347
00348 if (block_available_up && block_available_left)
00349 {
00350
00351 s0 = (P_A + P_B + P_C + P_D + P_E + P_F + P_G + P_H + P_Q + P_R + P_S + P_T + P_U + P_V + P_W + P_X + 8) >> 4;
00352 }
00353 else if (!block_available_up && block_available_left)
00354 {
00355
00356 s0 = (P_Q + P_R + P_S + P_T + P_U + P_V + P_W + P_X + 4) >> 3;
00357 }
00358 else if (block_available_up && !block_available_left)
00359 {
00360
00361 s0 = (P_A + P_B + P_C + P_D + P_E + P_F + P_G + P_H + 4) >> 3;
00362 }
00363 else
00364 {
00365
00366 s0 = p_Img->dc_pred_value_comp[pl];
00367 }
00368
00369 for(j = joff; j < joff + BLOCK_SIZE_8x8; j++)
00370 for(i = ioff; i < ioff + BLOCK_SIZE_8x8; i++)
00371 mpr[j][i] = (imgpel) s0;
00372
00373 return DECODING_OK;
00374 }
00375
00386 static inline int intra8x8_vert_pred(Macroblock *currMB,
00387 ColorPlane pl,
00388 int ioff,
00389 int joff)
00390 {
00391 Slice *currSlice = currMB->p_Slice;
00392 ImageParameters *p_Img = currMB->p_Img;
00393
00394 int i;
00395 imgpel PredPel[25];
00396 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
00397
00398 PixelPos pix_a[8];
00399 PixelPos pix_b, pix_c, pix_d;
00400
00401 int block_available_up;
00402 int block_available_left;
00403 int block_available_up_left;
00404 int block_available_up_right;
00405
00406
00407 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
00408 int *mb_size = p_Img->mb_size[IS_LUMA];
00409
00410 for (i=0;i<8;i++)
00411 {
00412 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
00413 }
00414
00415 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
00416 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
00417 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
00418
00419 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
00420
00421 if (p_Img->active_pps->constrained_intra_pred_flag)
00422 {
00423 for (i=0, block_available_left=1; i<8;i++)
00424 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
00425 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
00426 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
00427 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
00428 }
00429 else
00430 {
00431 block_available_left = pix_a[0].available;
00432 block_available_up = pix_b.available;
00433 block_available_up_right = pix_c.available;
00434 block_available_up_left = pix_d.available;
00435 }
00436
00437 if (!block_available_up)
00438 printf ("warning: Intra_8x8_Vertical prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
00439
00440
00441 if (block_available_up)
00442 {
00443 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
00444 P_A = *(pred_pels ++);
00445 P_B = *(pred_pels ++);
00446 P_C = *(pred_pels ++);
00447 P_D = *(pred_pels ++);
00448 P_E = *(pred_pels ++);
00449 P_F = *(pred_pels ++);
00450 P_G = *(pred_pels ++);
00451 P_H = *pred_pels;
00452 }
00453 else
00454 {
00455 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
00456 }
00457
00458 if (block_available_up_right)
00459 {
00460 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
00461 P_I = *(pred_pels ++);
00462 P_J = *(pred_pels ++);
00463 P_K = *(pred_pels ++);
00464 P_L = *(pred_pels ++);
00465 P_M = *(pred_pels ++);
00466 P_N = *(pred_pels ++);
00467 P_O = *(pred_pels ++);
00468 P_P = *pred_pels;
00469 }
00470 else
00471 {
00472 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
00473 }
00474
00475 if (block_available_up_left)
00476 {
00477 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
00478 }
00479 else
00480 {
00481 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
00482 }
00483
00484 LowPassForIntra8x8PredHor(&(P_Z), block_available_up_left, block_available_up, block_available_left);
00485
00486 for (i=joff; i < joff + BLOCK_SIZE_8x8; i++)
00487 {
00488 memcpy(&mpr[i][ioff], (&P_A), BLOCK_SIZE_8x8 * sizeof(imgpel));
00489 }
00490
00491 return DECODING_OK;
00492 }
00493
00504 static inline int intra8x8_hor_pred(Macroblock *currMB,
00505 ColorPlane pl,
00506 int ioff,
00507 int joff)
00508 {
00509 Slice *currSlice = currMB->p_Slice;
00510 ImageParameters *p_Img = currMB->p_Img;
00511
00512
00513 int i,j;
00514 imgpel PredPel[25];
00515 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
00516
00517 PixelPos pix_a[8];
00518 PixelPos pix_b, pix_c, pix_d;
00519
00520 int block_available_up;
00521 int block_available_left;
00522 int block_available_up_left;
00523 int block_available_up_right;
00524
00525 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
00526 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
00527 int jpos;
00528 imgpel **mpr = currSlice->mb_pred[pl];
00529 int *mb_size = p_Img->mb_size[IS_LUMA];
00530
00531 for (i=0;i<8;i++)
00532 {
00533 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
00534 }
00535
00536 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
00537 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
00538 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
00539
00540 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
00541
00542 if (p_Img->active_pps->constrained_intra_pred_flag)
00543 {
00544 for (i=0, block_available_left=1; i<8;i++)
00545 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
00546 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
00547 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
00548 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
00549 }
00550 else
00551 {
00552 block_available_left = pix_a[0].available;
00553 block_available_up = pix_b.available;
00554 block_available_up_right = pix_c.available;
00555 block_available_up_left = pix_d.available;
00556 }
00557
00558 if (!block_available_left)
00559 printf ("warning: Intra_8x8_Horizontal prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
00560
00561
00562 if (block_available_left)
00563 {
00564 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
00565 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
00566 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
00567 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
00568 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
00569 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
00570 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
00571 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
00572 }
00573 else
00574 {
00575 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
00576 }
00577
00578 if (block_available_up_left)
00579 {
00580 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
00581 }
00582 else
00583 {
00584 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
00585 }
00586
00587 LowPassForIntra8x8PredVer(&(P_Z), block_available_up_left, block_available_up, block_available_left);
00588
00589 for (j=0; j < BLOCK_SIZE_8x8; j++)
00590 {
00591 jpos = j + joff;
00592 mpr[jpos][ipos0] =
00593 mpr[jpos][ipos1] =
00594 mpr[jpos][ipos2] =
00595 mpr[jpos][ipos3] =
00596 mpr[jpos][ipos4] =
00597 mpr[jpos][ipos5] =
00598 mpr[jpos][ipos6] =
00599 mpr[jpos][ipos7] = (imgpel) (&P_Q)[j];
00600 }
00601
00602 return DECODING_OK;
00603 }
00604
00615 static inline int intra8x8_diag_down_right_pred(Macroblock *currMB,
00616 ColorPlane pl,
00617 int ioff,
00618 int joff)
00619 {
00620 Slice *currSlice = currMB->p_Slice;
00621 ImageParameters *p_Img = currMB->p_Img;
00622
00623
00624 int i;
00625 imgpel PredPel[25];
00626 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
00627
00628 PixelPos pix_a[8];
00629 PixelPos pix_b, pix_c, pix_d;
00630
00631 int block_available_up;
00632 int block_available_left;
00633 int block_available_up_left;
00634 int block_available_up_right;
00635
00636 int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
00637 int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
00638 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
00639 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
00640
00641 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
00642 int *mb_size = p_Img->mb_size[IS_LUMA];
00643
00644 for (i=0;i<8;i++)
00645 {
00646 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
00647 }
00648
00649 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
00650 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
00651 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
00652
00653 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
00654
00655 if (p_Img->active_pps->constrained_intra_pred_flag)
00656 {
00657 for (i=0, block_available_left=1; i<8;i++)
00658 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
00659 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
00660 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
00661 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
00662 }
00663 else
00664 {
00665 block_available_left = pix_a[0].available;
00666 block_available_up = pix_b.available;
00667 block_available_up_right = pix_c.available;
00668 block_available_up_left = pix_d.available;
00669 }
00670
00671 if ((!block_available_up)||(!block_available_left)||(!block_available_up_left))
00672 printf ("warning: Intra_8x8_Diagonal_Down_Right prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
00673
00674
00675 if (block_available_up)
00676 {
00677 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
00678 P_A = pred_pels[0];
00679 P_B = pred_pels[1];
00680 P_C = pred_pels[2];
00681 P_D = pred_pels[3];
00682 P_E = pred_pels[4];
00683 P_F = pred_pels[5];
00684 P_G = pred_pels[6];
00685 P_H = pred_pels[7];
00686 }
00687 else
00688 {
00689 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
00690 }
00691
00692 if (block_available_up_right)
00693 {
00694 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
00695 P_I = pred_pels[0];
00696 P_J = pred_pels[1];
00697 P_K = pred_pels[2];
00698 P_L = pred_pels[3];
00699 P_M = pred_pels[4];
00700 P_N = pred_pels[5];
00701 P_O = pred_pels[6];
00702 P_P = pred_pels[7];
00703
00704 }
00705 else
00706 {
00707 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
00708 }
00709
00710 if (block_available_left)
00711 {
00712 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
00713 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
00714 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
00715 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
00716 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
00717 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
00718 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
00719 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
00720 }
00721 else
00722 {
00723 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
00724 }
00725
00726 if (block_available_up_left)
00727 {
00728 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
00729 }
00730 else
00731 {
00732 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
00733 }
00734
00735 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
00736
00737
00738 mpr[jpos7][ipos0] = (imgpel) ((P_X + P_V + 2*(P_W) + 2) >> 2);
00739 mpr[jpos6][ipos0] =
00740 mpr[jpos7][ipos1] = (imgpel) ((P_W + P_U + 2*(P_V) + 2) >> 2);
00741 mpr[jpos5][ipos0] =
00742 mpr[jpos6][ipos1] =
00743 mpr[jpos7][ipos2] = (imgpel) ((P_V + P_T + 2*(P_U) + 2) >> 2);
00744 mpr[jpos4][ipos0] =
00745 mpr[jpos5][ipos1] =
00746 mpr[jpos6][ipos2] =
00747 mpr[jpos7][ipos3] = (imgpel) ((P_U + P_S + 2*(P_T) + 2) >> 2);
00748 mpr[jpos3][ipos0] =
00749 mpr[jpos4][ipos1] =
00750 mpr[jpos5][ipos2] =
00751 mpr[jpos6][ipos3] =
00752 mpr[jpos7][ipos4] = (imgpel) ((P_T + P_R + 2*(P_S) + 2) >> 2);
00753 mpr[jpos2][ipos0] =
00754 mpr[jpos3][ipos1] =
00755 mpr[jpos4][ipos2] =
00756 mpr[jpos5][ipos3] =
00757 mpr[jpos6][ipos4] =
00758 mpr[jpos7][ipos5] = (imgpel) ((P_S + P_Q + 2*(P_R) + 2) >> 2);
00759 mpr[jpos1][ipos0] =
00760 mpr[jpos2][ipos1] =
00761 mpr[jpos3][ipos2] =
00762 mpr[jpos4][ipos3] =
00763 mpr[jpos5][ipos4] =
00764 mpr[jpos6][ipos5] =
00765 mpr[jpos7][ipos6] = (imgpel) ((P_R + P_Z + 2*(P_Q) + 2) >> 2);
00766 mpr[jpos0][ipos0] =
00767 mpr[jpos1][ipos1] =
00768 mpr[jpos2][ipos2] =
00769 mpr[jpos3][ipos3] =
00770 mpr[jpos4][ipos4] =
00771 mpr[jpos5][ipos5] =
00772 mpr[jpos6][ipos6] =
00773 mpr[jpos7][ipos7] = (imgpel) ((P_Q + P_A + 2*(P_Z) + 2) >> 2);
00774 mpr[jpos0][ipos1] =
00775 mpr[jpos1][ipos2] =
00776 mpr[jpos2][ipos3] =
00777 mpr[jpos3][ipos4] =
00778 mpr[jpos4][ipos5] =
00779 mpr[jpos5][ipos6] =
00780 mpr[jpos6][ipos7] = (imgpel) ((P_Z + P_B + 2*(P_A) + 2) >> 2);
00781 mpr[jpos0][ipos2] =
00782 mpr[jpos1][ipos3] =
00783 mpr[jpos2][ipos4] =
00784 mpr[jpos3][ipos5] =
00785 mpr[jpos4][ipos6] =
00786 mpr[jpos5][ipos7] = (imgpel) ((P_A + P_C + 2*(P_B) + 2) >> 2);
00787 mpr[jpos0][ipos3] =
00788 mpr[jpos1][ipos4] =
00789 mpr[jpos2][ipos5] =
00790 mpr[jpos3][ipos6] =
00791 mpr[jpos4][ipos7] = (imgpel) ((P_B + P_D + 2*(P_C) + 2) >> 2);
00792 mpr[jpos0][ipos4] =
00793 mpr[jpos1][ipos5] =
00794 mpr[jpos2][ipos6] =
00795 mpr[jpos3][ipos7] = (imgpel) ((P_C + P_E + 2*(P_D) + 2) >> 2);
00796 mpr[jpos0][ipos5] =
00797 mpr[jpos1][ipos6] =
00798 mpr[jpos2][ipos7] = (imgpel) ((P_D + P_F + 2*(P_E) + 2) >> 2);
00799 mpr[jpos0][ipos6] =
00800 mpr[jpos1][ipos7] = (imgpel) ((P_E + P_G + 2*(P_F) + 2) >> 2);
00801 mpr[jpos0][ipos7] = (imgpel) ((P_F + P_H + 2*(P_G) + 2) >> 2);
00802
00803 return DECODING_OK;
00804 }
00805
00816 static inline int intra8x8_diag_down_left_pred(Macroblock *currMB,
00817 ColorPlane pl,
00818 int ioff,
00819 int joff)
00820 {
00821 Slice *currSlice = currMB->p_Slice;
00822 ImageParameters *p_Img = currMB->p_Img;
00823
00824 int i;
00825 imgpel PredPel[25];
00826 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
00827
00828 PixelPos pix_a[8];
00829 PixelPos pix_b, pix_c, pix_d;
00830
00831 int block_available_up;
00832 int block_available_left;
00833 int block_available_up_left;
00834 int block_available_up_right;
00835
00836 int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
00837 int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
00838 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
00839 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
00840
00841 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
00842 int *mb_size = p_Img->mb_size[IS_LUMA];
00843
00844 for (i=0;i<8;i++)
00845 {
00846 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
00847 }
00848
00849 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
00850 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
00851 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
00852
00853 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
00854
00855 if (p_Img->active_pps->constrained_intra_pred_flag)
00856 {
00857 for (i=0, block_available_left=1; i<8;i++)
00858 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
00859 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
00860 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
00861 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
00862 }
00863 else
00864 {
00865 block_available_left = pix_a[0].available;
00866 block_available_up = pix_b.available;
00867 block_available_up_right = pix_c.available;
00868 block_available_up_left = pix_d.available;
00869 }
00870
00871 if (!block_available_up)
00872 printf ("warning: Intra_8x8_Diagonal_Down_Left prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
00873
00874
00875 if (block_available_up)
00876 {
00877 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
00878 P_A = pred_pels[0];
00879 P_B = pred_pels[1];
00880 P_C = pred_pels[2];
00881 P_D = pred_pels[3];
00882 P_E = pred_pels[4];
00883 P_F = pred_pels[5];
00884 P_G = pred_pels[6];
00885 P_H = pred_pels[7];
00886 }
00887 else
00888 {
00889 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
00890 }
00891
00892 if (block_available_up_right)
00893 {
00894 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
00895 P_I = pred_pels[0];
00896 P_J = pred_pels[1];
00897 P_K = pred_pels[2];
00898 P_L = pred_pels[3];
00899 P_M = pred_pels[4];
00900 P_N = pred_pels[5];
00901 P_O = pred_pels[6];
00902 P_P = pred_pels[7];
00903
00904 }
00905 else
00906 {
00907 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
00908 }
00909
00910 if (block_available_left)
00911 {
00912 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
00913 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
00914 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
00915 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
00916 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
00917 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
00918 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
00919 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
00920 }
00921 else
00922 {
00923 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
00924 }
00925
00926 if (block_available_up_left)
00927 {
00928 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
00929 }
00930 else
00931 {
00932 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
00933 }
00934
00935 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
00936
00937
00938 mpr[jpos0][ipos0] = (imgpel) ((P_A + P_C + 2*(P_B) + 2) >> 2);
00939 mpr[jpos1][ipos0] =
00940 mpr[jpos0][ipos1] = (imgpel) ((P_B + P_D + 2*(P_C) + 2) >> 2);
00941 mpr[jpos2][ipos0] =
00942 mpr[jpos1][ipos1] =
00943 mpr[jpos0][ipos2] = (imgpel) ((P_C + P_E + 2*(P_D) + 2) >> 2);
00944 mpr[jpos3][ipos0] =
00945 mpr[jpos2][ipos1] =
00946 mpr[jpos1][ipos2] =
00947 mpr[jpos0][ipos3] = (imgpel) ((P_D + P_F + 2*(P_E) + 2) >> 2);
00948 mpr[jpos4][ipos0] =
00949 mpr[jpos3][ipos1] =
00950 mpr[jpos2][ipos2] =
00951 mpr[jpos1][ipos3] =
00952 mpr[jpos0][ipos4] = (imgpel) ((P_E + P_G + 2*(P_F) + 2) >> 2);
00953 mpr[jpos5][ipos0] =
00954 mpr[jpos4][ipos1] =
00955 mpr[jpos3][ipos2] =
00956 mpr[jpos2][ipos3] =
00957 mpr[jpos1][ipos4] =
00958 mpr[jpos0][ipos5] = (imgpel) ((P_F + P_H + 2*(P_G) + 2) >> 2);
00959 mpr[jpos6][ipos0] =
00960 mpr[jpos5][ipos1] =
00961 mpr[jpos4][ipos2] =
00962 mpr[jpos3][ipos3] =
00963 mpr[jpos2][ipos4] =
00964 mpr[jpos1][ipos5] =
00965 mpr[jpos0][ipos6] = (imgpel) ((P_G + P_I + 2*(P_H) + 2) >> 2);
00966 mpr[jpos7][ipos0] =
00967 mpr[jpos6][ipos1] =
00968 mpr[jpos5][ipos2] =
00969 mpr[jpos4][ipos3] =
00970 mpr[jpos3][ipos4] =
00971 mpr[jpos2][ipos5] =
00972 mpr[jpos1][ipos6] =
00973 mpr[jpos0][ipos7] = (imgpel) ((P_H + P_J + 2*(P_I) + 2) >> 2);
00974 mpr[jpos7][ipos1] =
00975 mpr[jpos6][ipos2] =
00976 mpr[jpos5][ipos3] =
00977 mpr[jpos4][ipos4] =
00978 mpr[jpos3][ipos5] =
00979 mpr[jpos2][ipos6] =
00980 mpr[jpos1][ipos7] = (imgpel) ((P_I + P_K + 2*(P_J) + 2) >> 2);
00981 mpr[jpos7][ipos2] =
00982 mpr[jpos6][ipos3] =
00983 mpr[jpos5][ipos4] =
00984 mpr[jpos4][ipos5] =
00985 mpr[jpos3][ipos6] =
00986 mpr[jpos2][ipos7] = (imgpel) ((P_J + P_L + 2*(P_K) + 2) >> 2);
00987 mpr[jpos7][ipos3] =
00988 mpr[jpos6][ipos4] =
00989 mpr[jpos5][ipos5] =
00990 mpr[jpos4][ipos6] =
00991 mpr[jpos3][ipos7] = (imgpel) ((P_K + P_M + 2*(P_L) + 2) >> 2);
00992 mpr[jpos7][ipos4] =
00993 mpr[jpos6][ipos5] =
00994 mpr[jpos5][ipos6] =
00995 mpr[jpos4][ipos7] = (imgpel) ((P_L + P_N + 2*(P_M) + 2) >> 2);
00996 mpr[jpos7][ipos5] =
00997 mpr[jpos6][ipos6] =
00998 mpr[jpos5][ipos7] = (imgpel) ((P_M + P_O + 2*(P_N) + 2) >> 2);
00999 mpr[jpos7][ipos6] =
01000 mpr[jpos6][ipos7] = (imgpel) ((P_N + P_P + 2*(P_O) + 2) >> 2);
01001 mpr[jpos7][ipos7] = (imgpel) ((P_O + 3*(P_P) + 2) >> 2);
01002
01003 return DECODING_OK;
01004 }
01005
01016 static inline int intra8x8_vert_right_pred(Macroblock *currMB,
01017 ColorPlane pl,
01018 int ioff,
01019 int joff)
01020 {
01021 Slice *currSlice = currMB->p_Slice;
01022 ImageParameters *p_Img = currMB->p_Img;
01023
01024 int i;
01025 imgpel PredPel[25];
01026 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
01027
01028 PixelPos pix_a[8];
01029 PixelPos pix_b, pix_c, pix_d;
01030
01031 int block_available_up;
01032 int block_available_left;
01033 int block_available_up_left;
01034 int block_available_up_right;
01035 int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
01036 int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
01037 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
01038 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
01039 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
01040 int *mb_size = p_Img->mb_size[IS_LUMA];
01041
01042 for (i=0;i<8;i++)
01043 {
01044 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
01045 }
01046
01047 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
01048 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
01049 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
01050
01051 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
01052
01053 if (p_Img->active_pps->constrained_intra_pred_flag)
01054 {
01055 for (i=0, block_available_left=1; i<8;i++)
01056 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
01057 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
01058 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
01059 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
01060 }
01061 else
01062 {
01063 block_available_left = pix_a[0].available;
01064 block_available_up = pix_b.available;
01065 block_available_up_right = pix_c.available;
01066 block_available_up_left = pix_d.available;
01067 }
01068
01069 if ((!block_available_up)||(!block_available_left)||(!block_available_up_left))
01070 printf ("warning: Intra_8x8_Vertical_Right prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
01071
01072
01073 if (block_available_up)
01074 {
01075 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
01076 P_A = pred_pels[0];
01077 P_B = pred_pels[1];
01078 P_C = pred_pels[2];
01079 P_D = pred_pels[3];
01080 P_E = pred_pels[4];
01081 P_F = pred_pels[5];
01082 P_G = pred_pels[6];
01083 P_H = pred_pels[7];
01084 }
01085 else
01086 {
01087 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
01088 }
01089
01090 if (block_available_up_right)
01091 {
01092 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
01093 P_I = pred_pels[0];
01094 P_J = pred_pels[1];
01095 P_K = pred_pels[2];
01096 P_L = pred_pels[3];
01097 P_M = pred_pels[4];
01098 P_N = pred_pels[5];
01099 P_O = pred_pels[6];
01100 P_P = pred_pels[7];
01101
01102 }
01103 else
01104 {
01105 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
01106 }
01107
01108 if (block_available_left)
01109 {
01110 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
01111 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
01112 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
01113 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
01114 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
01115 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
01116 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
01117 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
01118 }
01119 else
01120 {
01121 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
01122 }
01123
01124 if (block_available_up_left)
01125 {
01126 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
01127 }
01128 else
01129 {
01130 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
01131 }
01132
01133 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
01134
01135 mpr[jpos0][ipos0] =
01136 mpr[jpos2][ipos1] =
01137 mpr[jpos4][ipos2] =
01138 mpr[jpos6][ipos3] = (imgpel) ((P_Z + P_A + 1) >> 1);
01139 mpr[jpos0][ipos1] =
01140 mpr[jpos2][ipos2] =
01141 mpr[jpos4][ipos3] =
01142 mpr[jpos6][ipos4] = (imgpel) ((P_A + P_B + 1) >> 1);
01143 mpr[jpos0][ipos2] =
01144 mpr[jpos2][ipos3] =
01145 mpr[jpos4][ipos4] =
01146 mpr[jpos6][ipos5] = (imgpel) ((P_B + P_C + 1) >> 1);
01147 mpr[jpos0][ipos3] =
01148 mpr[jpos2][ipos4] =
01149 mpr[jpos4][ipos5] =
01150 mpr[jpos6][ipos6] = (imgpel) ((P_C + P_D + 1) >> 1);
01151 mpr[jpos0][ipos4] =
01152 mpr[jpos2][ipos5] =
01153 mpr[jpos4][ipos6] =
01154 mpr[jpos6][ipos7] = (imgpel) ((P_D + P_E + 1) >> 1);
01155 mpr[jpos0][ipos5] =
01156 mpr[jpos2][ipos6] =
01157 mpr[jpos4][ipos7] = (imgpel) ((P_E + P_F + 1) >> 1);
01158 mpr[jpos0][ipos6] =
01159 mpr[jpos2][ipos7] = (imgpel) ((P_F + P_G + 1) >> 1);
01160 mpr[jpos0][ipos7] = (imgpel) ((P_G + P_H + 1) >> 1);
01161 mpr[jpos1][ipos0] =
01162 mpr[jpos3][ipos1] =
01163 mpr[jpos5][ipos2] =
01164 mpr[jpos7][ipos3] = (imgpel) ((P_Q + P_A + 2*P_Z + 2) >> 2);
01165 mpr[jpos1][ipos1] =
01166 mpr[jpos3][ipos2] =
01167 mpr[jpos5][ipos3] =
01168 mpr[jpos7][ipos4] = (imgpel) ((P_Z + P_B + 2*P_A + 2) >> 2);
01169 mpr[jpos1][ipos2] =
01170 mpr[jpos3][ipos3] =
01171 mpr[jpos5][ipos4] =
01172 mpr[jpos7][ipos5] = (imgpel) ((P_A + P_C + 2*P_B + 2) >> 2);
01173 mpr[jpos1][ipos3] =
01174 mpr[jpos3][ipos4] =
01175 mpr[jpos5][ipos5] =
01176 mpr[jpos7][ipos6] = (imgpel) ((P_B + P_D + 2*P_C + 2) >> 2);
01177 mpr[jpos1][ipos4] =
01178 mpr[jpos3][ipos5] =
01179 mpr[jpos5][ipos6] =
01180 mpr[jpos7][ipos7] = (imgpel) ((P_C + P_E + 2*P_D + 2) >> 2);
01181 mpr[jpos1][ipos5] =
01182 mpr[jpos3][ipos6] =
01183 mpr[jpos5][ipos7] = (imgpel) ((P_D + P_F + 2*P_E + 2) >> 2);
01184 mpr[jpos1][ipos6] =
01185 mpr[jpos3][ipos7] = (imgpel) ((P_E + P_G + 2*P_F + 2) >> 2);
01186 mpr[jpos1][ipos7] = (imgpel) ((P_F + P_H + 2*P_G + 2) >> 2);
01187 mpr[jpos2][ipos0] =
01188 mpr[jpos4][ipos1] =
01189 mpr[jpos6][ipos2] = (imgpel) ((P_R + P_Z + 2*P_Q + 2) >> 2);
01190 mpr[jpos3][ipos0] =
01191 mpr[jpos5][ipos1] =
01192 mpr[jpos7][ipos2] = (imgpel) ((P_S + P_Q + 2*P_R + 2) >> 2);
01193 mpr[jpos4][ipos0] =
01194 mpr[jpos6][ipos1] = (imgpel) ((P_T + P_R + 2*P_S + 2) >> 2);
01195 mpr[jpos5][ipos0] =
01196 mpr[jpos7][ipos1] = (imgpel) ((P_U + P_S + 2*P_T + 2) >> 2);
01197 mpr[jpos6][ipos0] = (imgpel) ((P_V + P_T + 2*P_U + 2) >> 2);
01198 mpr[jpos7][ipos0] = (imgpel) ((P_W + P_U + 2*P_V + 2) >> 2);
01199
01200 return DECODING_OK;
01201 }
01202
01203
01214 static inline int intra8x8_vert_left_pred(Macroblock *currMB,
01215 ColorPlane pl,
01216 int ioff,
01217 int joff)
01218 {
01219 Slice *currSlice = currMB->p_Slice;
01220 ImageParameters *p_Img = currMB->p_Img;
01221
01222 int i;
01223 imgpel PredPel[25];
01224 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
01225
01226 PixelPos pix_a[8];
01227 PixelPos pix_b, pix_c, pix_d;
01228
01229 int block_available_up;
01230 int block_available_left;
01231 int block_available_up_left;
01232 int block_available_up_right;
01233
01234 int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
01235 int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
01236 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
01237 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
01238 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
01239 int *mb_size = p_Img->mb_size[IS_LUMA];
01240
01241 for (i=0;i<8;i++)
01242 {
01243 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
01244 }
01245
01246 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
01247 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
01248 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
01249
01250 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
01251
01252 if (p_Img->active_pps->constrained_intra_pred_flag)
01253 {
01254 for (i=0, block_available_left=1; i<8;i++)
01255 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
01256 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
01257 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
01258 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
01259 }
01260 else
01261 {
01262 block_available_left = pix_a[0].available;
01263 block_available_up = pix_b.available;
01264 block_available_up_right = pix_c.available;
01265 block_available_up_left = pix_d.available;
01266 }
01267
01268 if (!block_available_up)
01269 printf ("warning: Intra_4x4_Vertical_Left prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
01270
01271
01272 if (block_available_up)
01273 {
01274 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
01275 P_A = pred_pels[0];
01276 P_B = pred_pels[1];
01277 P_C = pred_pels[2];
01278 P_D = pred_pels[3];
01279 P_E = pred_pels[4];
01280 P_F = pred_pels[5];
01281 P_G = pred_pels[6];
01282 P_H = pred_pels[7];
01283 }
01284 else
01285 {
01286 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
01287 }
01288
01289 if (block_available_up_right)
01290 {
01291 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
01292 P_I = pred_pels[0];
01293 P_J = pred_pels[1];
01294 P_K = pred_pels[2];
01295 P_L = pred_pels[3];
01296 P_M = pred_pels[4];
01297 P_N = pred_pels[5];
01298 P_O = pred_pels[6];
01299 P_P = pred_pels[7];
01300
01301 }
01302 else
01303 {
01304 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
01305 }
01306
01307 if (block_available_left)
01308 {
01309 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
01310 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
01311 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
01312 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
01313 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
01314 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
01315 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
01316 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
01317 }
01318 else
01319 {
01320 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
01321 }
01322
01323 if (block_available_up_left)
01324 {
01325 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
01326 }
01327 else
01328 {
01329 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
01330 }
01331
01332 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
01333
01334 mpr[jpos0][ipos0] = (imgpel) ((P_A + P_B + 1) >> 1);
01335 mpr[jpos0][ipos1] =
01336 mpr[jpos2][ipos0] = (imgpel) ((P_B + P_C + 1) >> 1);
01337 mpr[jpos0][ipos2] =
01338 mpr[jpos2][ipos1] =
01339 mpr[jpos4][ipos0] = (imgpel) ((P_C + P_D + 1) >> 1);
01340 mpr[jpos0][ipos3] =
01341 mpr[jpos2][ipos2] =
01342 mpr[jpos4][ipos1] =
01343 mpr[jpos6][ipos0] = (imgpel) ((P_D + P_E + 1) >> 1);
01344 mpr[jpos0][ipos4] =
01345 mpr[jpos2][ipos3] =
01346 mpr[jpos4][ipos2] =
01347 mpr[jpos6][ipos1] = (imgpel) ((P_E + P_F + 1) >> 1);
01348 mpr[jpos0][ipos5] =
01349 mpr[jpos2][ipos4] =
01350 mpr[jpos4][ipos3] =
01351 mpr[jpos6][ipos2] = (imgpel) ((P_F + P_G + 1) >> 1);
01352 mpr[jpos0][ipos6] =
01353 mpr[jpos2][ipos5] =
01354 mpr[jpos4][ipos4] =
01355 mpr[jpos6][ipos3] = (imgpel) ((P_G + P_H + 1) >> 1);
01356 mpr[jpos0][ipos7] =
01357 mpr[jpos2][ipos6] =
01358 mpr[jpos4][ipos5] =
01359 mpr[jpos6][ipos4] = (imgpel) ((P_H + P_I + 1) >> 1);
01360 mpr[jpos2][ipos7] =
01361 mpr[jpos4][ipos6] =
01362 mpr[jpos6][ipos5] = (imgpel) ((P_I + P_J + 1) >> 1);
01363 mpr[jpos4][ipos7] =
01364 mpr[jpos6][ipos6] = (imgpel) ((P_J + P_K + 1) >> 1);
01365 mpr[jpos6][ipos7] = (imgpel) ((P_K + P_L + 1) >> 1);
01366 mpr[jpos1][ipos0] = (imgpel) ((P_A + P_C + 2*P_B + 2) >> 2);
01367 mpr[jpos1][ipos1] =
01368 mpr[jpos3][ipos0] = (imgpel) ((P_B + P_D + 2*P_C + 2) >> 2);
01369 mpr[jpos1][ipos2] =
01370 mpr[jpos3][ipos1] =
01371 mpr[jpos5][ipos0] = (imgpel) ((P_C + P_E + 2*P_D + 2) >> 2);
01372 mpr[jpos1][ipos3] =
01373 mpr[jpos3][ipos2] =
01374 mpr[jpos5][ipos1] =
01375 mpr[jpos7][ipos0] = (imgpel) ((P_D + P_F + 2*P_E + 2) >> 2);
01376 mpr[jpos1][ipos4] =
01377 mpr[jpos3][ipos3] =
01378 mpr[jpos5][ipos2] =
01379 mpr[jpos7][ipos1] = (imgpel) ((P_E + P_G + 2*P_F + 2) >> 2);
01380 mpr[jpos1][ipos5] =
01381 mpr[jpos3][ipos4] =
01382 mpr[jpos5][ipos3] =
01383 mpr[jpos7][ipos2] = (imgpel) ((P_F + P_H + 2*P_G + 2) >> 2);
01384 mpr[jpos1][ipos6] =
01385 mpr[jpos3][ipos5] =
01386 mpr[jpos5][ipos4] =
01387 mpr[jpos7][ipos3] = (imgpel) ((P_G + P_I + 2*P_H + 2) >> 2);
01388 mpr[jpos1][ipos7] =
01389 mpr[jpos3][ipos6] =
01390 mpr[jpos5][ipos5] =
01391 mpr[jpos7][ipos4] = (imgpel) ((P_H + P_J + 2*P_I + 2) >> 2);
01392 mpr[jpos3][ipos7] =
01393 mpr[jpos5][ipos6] =
01394 mpr[jpos7][ipos5] = (imgpel) ((P_I + P_K + 2*P_J + 2) >> 2);
01395 mpr[jpos5][ipos7] =
01396 mpr[jpos7][ipos6] = (imgpel) ((P_J + P_L + 2*P_K + 2) >> 2);
01397 mpr[jpos7][ipos7] = (imgpel) ((P_K + P_M + 2*P_L + 2) >> 2);
01398
01399 return DECODING_OK;
01400 }
01401
01412 static inline int intra8x8_hor_up_pred(Macroblock *currMB,
01413 ColorPlane pl,
01414 int ioff,
01415 int joff)
01416 {
01417 Slice *currSlice = currMB->p_Slice;
01418 ImageParameters *p_Img = currMB->p_Img;
01419
01420 int i;
01421 imgpel PredPel[25];
01422 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
01423
01424 PixelPos pix_a[8];
01425 PixelPos pix_b, pix_c, pix_d;
01426
01427 int block_available_up;
01428 int block_available_left;
01429 int block_available_up_left;
01430 int block_available_up_right;
01431 int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
01432 int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
01433 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
01434 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
01435
01436 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
01437 int *mb_size = p_Img->mb_size[IS_LUMA];
01438
01439 for (i=0;i<8;i++)
01440 {
01441 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
01442 }
01443
01444 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
01445 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
01446 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
01447
01448 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
01449
01450 if (p_Img->active_pps->constrained_intra_pred_flag)
01451 {
01452 for (i=0, block_available_left=1; i<8;i++)
01453 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
01454 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
01455 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
01456 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
01457 }
01458 else
01459 {
01460 block_available_left = pix_a[0].available;
01461 block_available_up = pix_b.available;
01462 block_available_up_right = pix_c.available;
01463 block_available_up_left = pix_d.available;
01464 }
01465
01466 if (!block_available_left)
01467 printf ("warning: Intra_8x8_Horizontal_Up prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
01468
01469
01470 if (block_available_up)
01471 {
01472 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
01473 P_A = pred_pels[0];
01474 P_B = pred_pels[1];
01475 P_C = pred_pels[2];
01476 P_D = pred_pels[3];
01477 P_E = pred_pels[4];
01478 P_F = pred_pels[5];
01479 P_G = pred_pels[6];
01480 P_H = pred_pels[7];
01481 }
01482 else
01483 {
01484 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
01485 }
01486
01487 if (block_available_up_right)
01488 {
01489 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
01490 P_I = pred_pels[0];
01491 P_J = pred_pels[1];
01492 P_K = pred_pels[2];
01493 P_L = pred_pels[3];
01494 P_M = pred_pels[4];
01495 P_N = pred_pels[5];
01496 P_O = pred_pels[6];
01497 P_P = pred_pels[7];
01498
01499 }
01500 else
01501 {
01502 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
01503 }
01504
01505 if (block_available_left)
01506 {
01507 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
01508 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
01509 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
01510 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
01511 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
01512 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
01513 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
01514 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
01515 }
01516 else
01517 {
01518 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
01519 }
01520
01521 if (block_available_up_left)
01522 {
01523 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
01524 }
01525 else
01526 {
01527 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
01528 }
01529
01530 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
01531
01532 mpr[jpos0][ipos0] = (imgpel) ((P_Q + P_R + 1) >> 1);
01533 mpr[jpos1][ipos0] =
01534 mpr[jpos0][ipos2] = (imgpel) ((P_R + P_S + 1) >> 1);
01535 mpr[jpos2][ipos0] =
01536 mpr[jpos1][ipos2] =
01537 mpr[jpos0][ipos4] = (imgpel) ((P_S + P_T + 1) >> 1);
01538 mpr[jpos3][ipos0] =
01539 mpr[jpos2][ipos2] =
01540 mpr[jpos1][ipos4] =
01541 mpr[jpos0][ipos6] = (imgpel) ((P_T + P_U + 1) >> 1);
01542 mpr[jpos4][ipos0] =
01543 mpr[jpos3][ipos2] =
01544 mpr[jpos2][ipos4] =
01545 mpr[jpos1][ipos6] = (imgpel) ((P_U + P_V + 1) >> 1);
01546 mpr[jpos5][ipos0] =
01547 mpr[jpos4][ipos2] =
01548 mpr[jpos3][ipos4] =
01549 mpr[jpos2][ipos6] = (imgpel) ((P_V + P_W + 1) >> 1);
01550 mpr[jpos6][ipos0] =
01551 mpr[jpos5][ipos2] =
01552 mpr[jpos4][ipos4] =
01553 mpr[jpos3][ipos6] = (imgpel) ((P_W + P_X + 1) >> 1);
01554 mpr[jpos4][ipos6] =
01555 mpr[jpos4][ipos7] =
01556 mpr[jpos5][ipos4] =
01557 mpr[jpos5][ipos5] =
01558 mpr[jpos5][ipos6] =
01559 mpr[jpos5][ipos7] =
01560 mpr[jpos6][ipos2] =
01561 mpr[jpos6][ipos3] =
01562 mpr[jpos6][ipos4] =
01563 mpr[jpos6][ipos5] =
01564 mpr[jpos6][ipos6] =
01565 mpr[jpos6][ipos7] =
01566 mpr[jpos7][ipos0] =
01567 mpr[jpos7][ipos1] =
01568 mpr[jpos7][ipos2] =
01569 mpr[jpos7][ipos3] =
01570 mpr[jpos7][ipos4] =
01571 mpr[jpos7][ipos5] =
01572 mpr[jpos7][ipos6] =
01573 mpr[jpos7][ipos7] = (imgpel) P_X;
01574 mpr[jpos6][ipos1] =
01575 mpr[jpos5][ipos3] =
01576 mpr[jpos4][ipos5] =
01577 mpr[jpos3][ipos7] = (imgpel) ((P_W + 3*P_X + 2) >> 2);
01578 mpr[jpos5][ipos1] =
01579 mpr[jpos4][ipos3] =
01580 mpr[jpos3][ipos5] =
01581 mpr[jpos2][ipos7] = (imgpel) ((P_X + P_V + 2*P_W + 2) >> 2);
01582 mpr[jpos4][ipos1] =
01583 mpr[jpos3][ipos3] =
01584 mpr[jpos2][ipos5] =
01585 mpr[jpos1][ipos7] = (imgpel) ((P_W + P_U + 2*P_V + 2) >> 2);
01586 mpr[jpos3][ipos1] =
01587 mpr[jpos2][ipos3] =
01588 mpr[jpos1][ipos5] =
01589 mpr[jpos0][ipos7] = (imgpel) ((P_V + P_T + 2*P_U + 2) >> 2);
01590 mpr[jpos2][ipos1] =
01591 mpr[jpos1][ipos3] =
01592 mpr[jpos0][ipos5] = (imgpel) ((P_U + P_S + 2*P_T + 2) >> 2);
01593 mpr[jpos1][ipos1] =
01594 mpr[jpos0][ipos3] = (imgpel) ((P_T + P_R + 2*P_S + 2) >> 2);
01595 mpr[jpos0][ipos1] = (imgpel) ((P_S + P_Q + 2*P_R + 2) >> 2);
01596
01597 return DECODING_OK;
01598 }
01599
01610 static inline int intra8x8_hor_down_pred(Macroblock *currMB,
01611 ColorPlane pl,
01612 int ioff,
01613 int joff)
01614 {
01615 Slice *currSlice = currMB->p_Slice;
01616 ImageParameters *p_Img = currMB->p_Img;
01617
01618 int i;
01619 imgpel PredPel[25];
01620 imgpel **imgY = (pl) ? p_Img->dec_picture->imgUV[pl - 1] : p_Img->dec_picture->imgY;
01621
01622 PixelPos pix_a[8];
01623 PixelPos pix_b, pix_c, pix_d;
01624
01625 int block_available_up;
01626 int block_available_left;
01627 int block_available_up_left;
01628 int block_available_up_right;
01629 int jpos0 = joff , jpos1 = joff + 1, jpos2 = joff + 2, jpos3 = joff + 3;
01630 int jpos4 = joff + 4, jpos5 = joff + 5, jpos6 = joff + 6, jpos7 = joff + 7;
01631 int ipos0 = ioff , ipos1 = ioff + 1, ipos2 = ioff + 2, ipos3 = ioff + 3;
01632 int ipos4 = ioff + 4, ipos5 = ioff + 5, ipos6 = ioff + 6, ipos7 = ioff + 7;
01633
01634 imgpel *pred_pels, **mpr = currSlice->mb_pred[pl];
01635 int *mb_size = p_Img->mb_size[IS_LUMA];
01636
01637 for (i=0;i<8;i++)
01638 {
01639 p_Img->getNeighbour(currMB, ioff - 1, joff + i, mb_size, &pix_a[i]);
01640 }
01641
01642 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
01643 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
01644 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
01645
01646 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
01647
01648 if (p_Img->active_pps->constrained_intra_pred_flag)
01649 {
01650 for (i=0, block_available_left=1; i<8;i++)
01651 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
01652 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
01653 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
01654 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
01655 }
01656 else
01657 {
01658 block_available_left = pix_a[0].available;
01659 block_available_up = pix_b.available;
01660 block_available_up_right = pix_c.available;
01661 block_available_up_left = pix_d.available;
01662 }
01663
01664 if ((!block_available_up)||(!block_available_left)||(!block_available_up_left))
01665 printf ("warning: Intra_8x8_Horizontal_Down prediction mode not allowed at mb %d\n", (int) p_Img->current_mb_nr);
01666
01667
01668 if (block_available_up)
01669 {
01670 pred_pels = &imgY[pix_b.pos_y][pix_b.pos_x];
01671 P_A = pred_pels[0];
01672 P_B = pred_pels[1];
01673 P_C = pred_pels[2];
01674 P_D = pred_pels[3];
01675 P_E = pred_pels[4];
01676 P_F = pred_pels[5];
01677 P_G = pred_pels[6];
01678 P_H = pred_pels[7];
01679 }
01680 else
01681 {
01682 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = (imgpel) p_Img->dc_pred_value_comp[pl];
01683 }
01684
01685 if (block_available_up_right)
01686 {
01687 pred_pels = &imgY[pix_c.pos_y][pix_c.pos_x];
01688 P_I = pred_pels[0];
01689 P_J = pred_pels[1];
01690 P_K = pred_pels[2];
01691 P_L = pred_pels[3];
01692 P_M = pred_pels[4];
01693 P_N = pred_pels[5];
01694 P_O = pred_pels[6];
01695 P_P = pred_pels[7];
01696
01697 }
01698 else
01699 {
01700 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
01701 }
01702
01703 if (block_available_left)
01704 {
01705 P_Q = imgY[pix_a[0].pos_y][pix_a[0].pos_x];
01706 P_R = imgY[pix_a[1].pos_y][pix_a[1].pos_x];
01707 P_S = imgY[pix_a[2].pos_y][pix_a[2].pos_x];
01708 P_T = imgY[pix_a[3].pos_y][pix_a[3].pos_x];
01709 P_U = imgY[pix_a[4].pos_y][pix_a[4].pos_x];
01710 P_V = imgY[pix_a[5].pos_y][pix_a[5].pos_x];
01711 P_W = imgY[pix_a[6].pos_y][pix_a[6].pos_x];
01712 P_X = imgY[pix_a[7].pos_y][pix_a[7].pos_x];
01713 }
01714 else
01715 {
01716 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = (imgpel) p_Img->dc_pred_value_comp[pl];
01717 }
01718
01719 if (block_available_up_left)
01720 {
01721 P_Z = imgY[pix_d.pos_y][pix_d.pos_x];
01722 }
01723 else
01724 {
01725 P_Z = (imgpel) p_Img->dc_pred_value_comp[pl];
01726 }
01727
01728 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
01729
01730 mpr[jpos0][ipos0] =
01731 mpr[jpos1][ipos2] =
01732 mpr[jpos2][ipos4] =
01733 mpr[jpos3][ipos6] = (imgpel) ((P_Q + P_Z + 1) >> 1);
01734 mpr[jpos1][ipos0] =
01735 mpr[jpos2][ipos2] =
01736 mpr[jpos3][ipos4] =
01737 mpr[jpos4][ipos6] = (imgpel) ((P_R + P_Q + 1) >> 1);
01738 mpr[jpos2][ipos0] =
01739 mpr[jpos3][ipos2] =
01740 mpr[jpos4][ipos4] =
01741 mpr[jpos5][ipos6] = (imgpel) ((P_S + P_R + 1) >> 1);
01742 mpr[jpos3][ipos0] =
01743 mpr[jpos4][ipos2] =
01744 mpr[jpos5][ipos4] =
01745 mpr[jpos6][ipos6] = (imgpel) ((P_T + P_S + 1) >> 1);
01746 mpr[jpos4][ipos0] =
01747 mpr[jpos5][ipos2] =
01748 mpr[jpos6][ipos4] =
01749 mpr[jpos7][ipos6] = (imgpel) ((P_U + P_T + 1) >> 1);
01750 mpr[jpos5][ipos0] =
01751 mpr[jpos6][ipos2] =
01752 mpr[jpos7][ipos4] = (imgpel) ((P_V + P_U + 1) >> 1);
01753 mpr[jpos6][ipos0] =
01754 mpr[jpos7][ipos2] = (imgpel) ((P_W + P_V + 1) >> 1);
01755 mpr[jpos7][ipos0] = (imgpel) ((P_X + P_W + 1) >> 1);
01756 mpr[jpos0][ipos1] =
01757 mpr[jpos1][ipos3] =
01758 mpr[jpos2][ipos5] =
01759 mpr[jpos3][ipos7] = (imgpel) ((P_Q + P_A + 2*P_Z + 2) >> 2);
01760 mpr[jpos1][ipos1] =
01761 mpr[jpos2][ipos3] =
01762 mpr[jpos3][ipos5] =
01763 mpr[jpos4][ipos7] = (imgpel) ((P_Z + P_R + 2*P_Q + 2) >> 2);
01764 mpr[jpos2][ipos1] =
01765 mpr[jpos3][ipos3] =
01766 mpr[jpos4][ipos5] =
01767 mpr[jpos5][ipos7] = (imgpel) ((P_Q + P_S + 2*P_R + 2) >> 2);
01768 mpr[jpos3][ipos1] =
01769 mpr[jpos4][ipos3] =
01770 mpr[jpos5][ipos5] =
01771 mpr[jpos6][ipos7] = (imgpel) ((P_R + P_T + 2*P_S + 2) >> 2);
01772 mpr[jpos4][ipos1] =
01773 mpr[jpos5][ipos3] =
01774 mpr[jpos6][ipos5] =
01775 mpr[jpos7][ipos7] = (imgpel) ((P_S + P_U + 2*P_T + 2) >> 2);
01776 mpr[jpos5][ipos1] =
01777 mpr[jpos6][ipos3] =
01778 mpr[jpos7][ipos5] = (imgpel) ((P_T + P_V + 2*P_U + 2) >> 2);
01779 mpr[jpos6][ipos1] =
01780 mpr[jpos7][ipos3] = (imgpel) ((P_U + P_W + 2*P_V + 2) >> 2);
01781 mpr[jpos7][ipos1] = (imgpel) ((P_V + P_X + 2*P_W + 2) >> 2);
01782 mpr[jpos0][ipos2] =
01783 mpr[jpos1][ipos4] =
01784 mpr[jpos2][ipos6] = (imgpel) ((P_Z + P_B + 2*P_A + 2) >> 2);
01785 mpr[jpos0][ipos3] =
01786 mpr[jpos1][ipos5] =
01787 mpr[jpos2][ipos7] = (imgpel) ((P_A + P_C + 2*P_B + 2) >> 2);
01788 mpr[jpos0][ipos4] =
01789 mpr[jpos1][ipos6] = (imgpel) ((P_B + P_D + 2*P_C + 2) >> 2);
01790 mpr[jpos0][ipos5] =
01791 mpr[jpos1][ipos7] = (imgpel) ((P_C + P_E + 2*P_D + 2) >> 2);
01792 mpr[jpos0][ipos6] = (imgpel) ((P_D + P_F + 2*P_E + 2) >> 2);
01793 mpr[jpos0][ipos7] = (imgpel) ((P_E + P_G + 2*P_F + 2) >> 2);
01794
01795 return DECODING_OK;
01796 }
01797
01812 int intrapred8x8(Macroblock *currMB,
01813 ColorPlane pl,
01814 int ioff,
01815 int joff)
01816
01817 {
01818 ImageParameters *p_Img = currMB->p_Img;
01819 int block_x = (currMB->block_x) + (ioff >> 2);
01820 int block_y = (currMB->block_y) + (joff >> 2);
01821 byte predmode = p_Img->ipredmode[block_y][block_x];
01822
01823 p_Img->ipmode_DPCM = predmode;
01824
01825 switch (predmode)
01826 {
01827 case DC_PRED:
01828 return (intra8x8_dc_pred(currMB, pl, ioff, joff));
01829 break;
01830 case VERT_PRED:
01831 return (intra8x8_vert_pred(currMB, pl, ioff, joff));
01832 break;
01833 case HOR_PRED:
01834 return (intra8x8_hor_pred(currMB, pl, ioff, joff));
01835 break;
01836 case DIAG_DOWN_RIGHT_PRED:
01837 return (intra8x8_diag_down_right_pred(currMB, pl, ioff, joff));
01838 break;
01839 case DIAG_DOWN_LEFT_PRED:
01840 return (intra8x8_diag_down_left_pred(currMB, pl, ioff, joff));
01841 break;
01842 case VERT_RIGHT_PRED:
01843 return (intra8x8_vert_right_pred(currMB, pl, ioff, joff));
01844 break;
01845 case VERT_LEFT_PRED:
01846 return (intra8x8_vert_left_pred(currMB, pl, ioff, joff));
01847 break;
01848 case HOR_UP_PRED:
01849 return (intra8x8_hor_up_pred(currMB, pl, ioff, joff));
01850 break;
01851 case HOR_DOWN_PRED:
01852 return (intra8x8_hor_down_pred(currMB, pl, ioff, joff));
01853 default:
01854 printf("Error: illegal intra_8x8 prediction mode: %d\n", (int) predmode);
01855 return SEARCH_SYNC;
01856 break;
01857 }
01858
01859 return DECODING_OK;
01860 }
01861
01862