00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "global.h"
00015 #include "image.h"
00016 #include "mb_access.h"
00017 #include "intra8x8.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #define P_Z (PredPel[0])
00036 #define P_A (PredPel[1])
00037 #define P_B (PredPel[2])
00038 #define P_C (PredPel[3])
00039 #define P_D (PredPel[4])
00040 #define P_E (PredPel[5])
00041 #define P_F (PredPel[6])
00042 #define P_G (PredPel[7])
00043 #define P_H (PredPel[8])
00044 #define P_I (PredPel[9])
00045 #define P_J (PredPel[10])
00046 #define P_K (PredPel[11])
00047 #define P_L (PredPel[12])
00048 #define P_M (PredPel[13])
00049 #define P_N (PredPel[14])
00050 #define P_O (PredPel[15])
00051 #define P_P (PredPel[16])
00052 #define P_Q (PredPel[17])
00053 #define P_R (PredPel[18])
00054 #define P_S (PredPel[19])
00055 #define P_T (PredPel[20])
00056 #define P_U (PredPel[21])
00057 #define P_V (PredPel[22])
00058 #define P_W (PredPel[23])
00059 #define P_X (PredPel[24])
00060
00061
00062
00063
00064
00065
00066
00067 void LowPassForIntra8x8Pred(imgpel *PredPel, int block_up_left, int block_up, int block_left)
00068 {
00069 int i;
00070 imgpel LoopArray[25];
00071
00072 memcpy(LoopArray,PredPel, 25 * sizeof(imgpel));
00073
00074 if(block_up)
00075 {
00076 if(block_up_left)
00077 {
00078 LoopArray[1] = (imgpel) ((PredPel[0] + (PredPel[1]<<1) + PredPel[2] + 2) >> 2);
00079 }
00080 else
00081 LoopArray[1] = (imgpel) ((PredPel[1] + (PredPel[1]<<1) + PredPel[2] + 2) >> 2);
00082
00083
00084 for(i = 2; i <16; i++)
00085 {
00086 LoopArray[i] = (imgpel) ((PredPel[i-1] + (PredPel[i]<<1) + PredPel[i+1] + 2) >> 2);
00087 }
00088 LoopArray[16] = (imgpel) ((PredPel[15] + PredPel[16] + (PredPel[16]<<1) + 2) >> 2);
00089 }
00090
00091 if(block_up_left)
00092 {
00093 if(block_up && block_left)
00094 {
00095 LoopArray[0] = (imgpel) (((PredPel[0] << 1) + PredPel[1] + PredPel[17] + 2) >> 2);
00096 }
00097 else
00098 {
00099 if(block_up)
00100 LoopArray[0] = (imgpel) ((PredPel[0] + (PredPel[0] << 1) + PredPel[1] + 2) >> 2);
00101 else
00102 if(block_left)
00103 LoopArray[0] = (imgpel) ((PredPel[0] + (PredPel[0] << 1) + PredPel[17] + 2) >> 2);
00104 }
00105 }
00106
00107 if(block_left)
00108 {
00109 if(block_up_left)
00110 LoopArray[17] = (imgpel) ((PredPel[0] + (PredPel[17] << 1) + PredPel[18] + 2) >> 2);
00111 else
00112 LoopArray[17] = (imgpel) ((PredPel[17] + (PredPel[17] << 1) + PredPel[18] + 2) >> 2);
00113
00114 for(i = 18; i <24; i++)
00115 {
00116 LoopArray[i] = (imgpel) ((PredPel[i-1] + (PredPel[i]<<1) + PredPel[i+1] + 2) >> 2);
00117 }
00118 LoopArray[24] = (imgpel) ((PredPel[23] + (PredPel[24] << 1) + PredPel[24] + 2) >> 2);
00119 }
00120
00121 memcpy(PredPel, LoopArray, 25 * sizeof(imgpel));
00122 }
00123
00124
00125
00126
00127
00128
00129
00130 static inline void get_i8x8_vertical(imgpel **cur_pred, imgpel *PredPel)
00131 {
00132 int j;
00133 for (j=0; j < BLOCK_SIZE_8x8; j++)
00134 memcpy(cur_pred[j], &P_A, BLOCK_SIZE_8x8 * sizeof(imgpel));
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144 static inline void get_i8x8_horizontal(imgpel **cur_pred, imgpel *PredPel)
00145 {
00146 int i;
00147 for (i=0; i < BLOCK_SIZE_8x8; i++)
00148 {
00149 cur_pred[i][0] =
00150 cur_pred[i][1] =
00151 cur_pred[i][2] =
00152 cur_pred[i][3] =
00153 cur_pred[i][4] =
00154 cur_pred[i][5] =
00155 cur_pred[i][6] =
00156 cur_pred[i][7] = (imgpel) (&P_Q)[i];
00157 }
00158 }
00159
00160
00161
00162
00163
00164
00165
00166 static inline void get_i8x8_dc(imgpel **cur_pred, imgpel *PredPel, int left_available, int up_available)
00167 {
00168 int i, j, s0 = 0;
00169 if (up_available && left_available)
00170 {
00171
00172 s0 = rshift_rnd_sf((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), 4);
00173 }
00174 else if (!up_available && left_available)
00175 {
00176
00177 s0 = rshift_rnd_sf((P_Q + P_R + P_S + P_T + P_U + P_V + P_W + P_X), 3);
00178 }
00179 else if (up_available && !left_available)
00180 {
00181
00182 s0 = rshift_rnd_sf((P_A + P_B + P_C + P_D + P_E + P_F + P_G + P_H), 3);
00183 }
00184 else
00185 {
00186
00187 s0 = P_A;
00188 }
00189
00190
00191 for (i=0; i < BLOCK_SIZE_8x8; i++)
00192 {
00193 cur_pred[0][i] = (imgpel) s0;
00194 }
00195
00196 for (j=0; j < BLOCK_SIZE_8x8 - 1; j++)
00197 {
00198 memcpy (cur_pred[j + 1], cur_pred[j], BLOCK_SIZE_8x8 * sizeof(imgpel));
00199 }
00200 }
00201
00202
00203
00204
00205
00206
00207
00208 static inline void get_i8x8_downleft(imgpel **cur_pred, imgpel *PredPel)
00209 {
00210 cur_pred[0][0] = (imgpel) ((P_A + P_C + ((P_B) << 1) + 2) >> 2);
00211 cur_pred[0][1] =
00212 cur_pred[1][0] = (imgpel) ((P_B + P_D + ((P_C) << 1) + 2) >> 2);
00213 cur_pred[0][2] =
00214 cur_pred[1][1] =
00215 cur_pred[2][0] = (imgpel) ((P_C + P_E + ((P_D) << 1) + 2) >> 2);
00216 cur_pred[0][3] =
00217 cur_pred[1][2] =
00218 cur_pred[2][1] =
00219 cur_pred[3][0] = (imgpel) ((P_D + P_F + ((P_E) << 1) + 2) >> 2);
00220 cur_pred[0][4] =
00221 cur_pred[1][3] =
00222 cur_pred[2][2] =
00223 cur_pred[3][1] =
00224 cur_pred[4][0] = (imgpel) ((P_E + P_G + ((P_F) << 1) + 2) >> 2);
00225 cur_pred[0][5] =
00226 cur_pred[1][4] =
00227 cur_pred[2][3] =
00228 cur_pred[3][2] =
00229 cur_pred[4][1] =
00230 cur_pred[5][0] = (imgpel) ((P_F + P_H + ((P_G) << 1) + 2) >> 2);
00231 cur_pred[0][6] =
00232 cur_pred[1][5] =
00233 cur_pred[2][4] =
00234 cur_pred[3][3] =
00235 cur_pred[4][2] =
00236 cur_pred[5][1] =
00237 cur_pred[6][0] = (imgpel) ((P_G + P_I + ((P_H) << 1) + 2) >> 2);
00238 cur_pred[0][7] =
00239 cur_pred[1][6] =
00240 cur_pred[2][5] =
00241 cur_pred[3][4] =
00242 cur_pred[4][3] =
00243 cur_pred[5][2] =
00244 cur_pred[6][1] =
00245 cur_pred[7][0] = (imgpel) ((P_H + P_J + ((P_I) << 1) + 2) >> 2);
00246 cur_pred[1][7] =
00247 cur_pred[2][6] =
00248 cur_pred[3][5] =
00249 cur_pred[4][4] =
00250 cur_pred[5][3] =
00251 cur_pred[6][2] =
00252 cur_pred[7][1] = (imgpel) ((P_I + P_K + ((P_J) << 1) + 2) >> 2);
00253 cur_pred[2][7] =
00254 cur_pred[3][6] =
00255 cur_pred[4][5] =
00256 cur_pred[5][4] =
00257 cur_pred[6][3] =
00258 cur_pred[7][2] = (imgpel) ((P_J + P_L + (P_K << 1) + 2) >> 2);
00259 cur_pred[3][7] =
00260 cur_pred[4][6] =
00261 cur_pred[5][5] =
00262 cur_pred[6][4] =
00263 cur_pred[7][3] = (imgpel) ((P_K + P_M + (P_L << 1) + 2) >> 2);
00264 cur_pred[4][7] =
00265 cur_pred[5][6] =
00266 cur_pred[6][5] =
00267 cur_pred[7][4] = (imgpel) ((P_L + P_N + (P_M << 1) + 2) >> 2);
00268 cur_pred[5][7] =
00269 cur_pred[6][6] =
00270 cur_pred[7][5] = (imgpel) ((P_M + P_O + (P_N << 1) + 2) >> 2);
00271 cur_pred[6][7] =
00272 cur_pred[7][6] = (imgpel) ((P_N + P_P + (P_O << 1) + 2) >> 2);
00273 cur_pred[7][7] = (imgpel) ((P_O + P_P + (P_P << 1) + 2) >> 2);
00274 }
00275
00276
00277
00278
00279
00280
00281
00282 static inline void get_i8x8_downright(imgpel **cur_pred, imgpel *PredPel)
00283 {
00284 cur_pred[7][0] = (imgpel) ((P_X + P_V + (P_W << 1) + 2) >> 2);
00285 cur_pred[6][0] =
00286 cur_pred[7][1] = (imgpel) ((P_W + P_U + (P_V << 1) + 2) >> 2);
00287 cur_pred[5][0] =
00288 cur_pred[6][1] =
00289 cur_pred[7][2] = (imgpel) ((P_V + P_T + (P_U << 1) + 2) >> 2);
00290 cur_pred[4][0] =
00291 cur_pred[5][1] =
00292 cur_pred[6][2] =
00293 cur_pred[7][3] = (imgpel) ((P_U + P_S + (P_T << 1) + 2) >> 2);
00294 cur_pred[3][0] =
00295 cur_pred[4][1] =
00296 cur_pred[5][2] =
00297 cur_pred[6][3] =
00298 cur_pred[7][4] = (imgpel) ((P_T + P_R + (P_S << 1) + 2) >> 2);
00299 cur_pred[2][0] =
00300 cur_pred[3][1] =
00301 cur_pred[4][2] =
00302 cur_pred[5][3] =
00303 cur_pred[6][4] =
00304 cur_pred[7][5] = (imgpel) ((P_S + P_Q + (P_R << 1) + 2) >> 2);
00305 cur_pred[1][0] =
00306 cur_pred[2][1] =
00307 cur_pred[3][2] =
00308 cur_pred[4][3] =
00309 cur_pred[5][4] =
00310 cur_pred[6][5] =
00311 cur_pred[7][6] = (imgpel) ((P_R + P_Z + (P_Q << 1) + 2) >> 2);
00312 cur_pred[0][0] =
00313 cur_pred[1][1] =
00314 cur_pred[2][2] =
00315 cur_pred[3][3] =
00316 cur_pred[4][4] =
00317 cur_pred[5][5] =
00318 cur_pred[6][6] =
00319 cur_pred[7][7] = (imgpel) ((P_Q + P_A + (P_Z << 1) + 2) >> 2);
00320 cur_pred[0][1] =
00321 cur_pred[1][2] =
00322 cur_pred[2][3] =
00323 cur_pred[3][4] =
00324 cur_pred[4][5] =
00325 cur_pred[5][6] =
00326 cur_pred[6][7] = (imgpel) ((P_Z + P_B + (P_A << 1) + 2) >> 2);
00327 cur_pred[0][2] =
00328 cur_pred[1][3] =
00329 cur_pred[2][4] =
00330 cur_pred[3][5] =
00331 cur_pred[4][6] =
00332 cur_pred[5][7] = (imgpel) ((P_A + P_C + (P_B << 1) + 2) >> 2);
00333 cur_pred[0][3] =
00334 cur_pred[1][4] =
00335 cur_pred[2][5] =
00336 cur_pred[3][6] =
00337 cur_pred[4][7] = (imgpel) ((P_B + P_D + (P_C << 1) + 2) >> 2);
00338 cur_pred[0][4] =
00339 cur_pred[1][5] =
00340 cur_pred[2][6] =
00341 cur_pred[3][7] = (imgpel) ((P_C + P_E + (P_D << 1) + 2) >> 2);
00342 cur_pred[0][5] =
00343 cur_pred[1][6] =
00344 cur_pred[2][7] = (imgpel) ((P_D + P_F + (P_E << 1) + 2) >> 2);
00345 cur_pred[0][6] =
00346 cur_pred[1][7] = (imgpel) ((P_E + P_G + (P_F << 1) + 2) >> 2);
00347 cur_pred[0][7] = (imgpel) ((P_F + P_H + (P_G << 1) + 2) >> 2);
00348 }
00349
00350
00351
00352
00353
00354
00355
00356
00357 static inline void get_i8x8_vertleft(imgpel **cur_pred, imgpel *PredPel)
00358 {
00359 cur_pred[0][0] = (imgpel) ((P_A + P_B + 1) >> 1);
00360 cur_pred[0][1] =
00361 cur_pred[2][0] = (imgpel) ((P_B + P_C + 1) >> 1);
00362 cur_pred[0][2] =
00363 cur_pred[2][1] =
00364 cur_pred[4][0] = (imgpel) ((P_C + P_D + 1) >> 1);
00365 cur_pred[0][3] =
00366 cur_pred[2][2] =
00367 cur_pred[4][1] =
00368 cur_pred[6][0] = (imgpel) ((P_D + P_E + 1) >> 1);
00369 cur_pred[0][4] =
00370 cur_pred[2][3] =
00371 cur_pred[4][2] =
00372 cur_pred[6][1] = (imgpel) ((P_E + P_F + 1) >> 1);
00373 cur_pred[0][5] =
00374 cur_pred[2][4] =
00375 cur_pred[4][3] =
00376 cur_pred[6][2] = (imgpel) ((P_F + P_G + 1) >> 1);
00377 cur_pred[0][6] =
00378 cur_pred[2][5] =
00379 cur_pred[4][4] =
00380 cur_pred[6][3] = (imgpel) ((P_G + P_H + 1) >> 1);
00381 cur_pred[0][7] =
00382 cur_pred[2][6] =
00383 cur_pred[4][5] =
00384 cur_pred[6][4] = (imgpel) ((P_H + P_I + 1) >> 1);
00385 cur_pred[2][7] =
00386 cur_pred[4][6] =
00387 cur_pred[6][5] = (imgpel) ((P_I + P_J + 1) >> 1);
00388 cur_pred[4][7] =
00389 cur_pred[6][6] = (imgpel) ((P_J + P_K + 1) >> 1);
00390 cur_pred[6][7] = (imgpel) ((P_K + P_L + 1) >> 1);
00391 cur_pred[1][0] = (imgpel) ((P_A + P_C + 2*P_B + 2) >> 2);
00392 cur_pred[1][1] =
00393 cur_pred[3][0] = (imgpel) ((P_B + P_D + 2*P_C + 2) >> 2);
00394 cur_pred[1][2] =
00395 cur_pred[3][1] =
00396 cur_pred[5][0] = (imgpel) ((P_C + P_E + 2*P_D + 2) >> 2);
00397 cur_pred[1][3] =
00398 cur_pred[3][2] =
00399 cur_pred[5][1] =
00400 cur_pred[7][0] = (imgpel) ((P_D + P_F + 2*P_E + 2) >> 2);
00401 cur_pred[1][4] =
00402 cur_pred[3][3] =
00403 cur_pred[5][2] =
00404 cur_pred[7][1] = (imgpel) ((P_E + P_G + 2*P_F + 2) >> 2);
00405 cur_pred[1][5] =
00406 cur_pred[3][4] =
00407 cur_pred[5][3] =
00408 cur_pred[7][2] = (imgpel) ((P_F + P_H + 2*P_G + 2) >> 2);
00409 cur_pred[1][6] =
00410 cur_pred[3][5] =
00411 cur_pred[5][4] =
00412 cur_pred[7][3] = (imgpel) ((P_G + P_I + 2*P_H + 2) >> 2);
00413 cur_pred[1][7] =
00414 cur_pred[3][6] =
00415 cur_pred[5][5] =
00416 cur_pred[7][4] = (imgpel) ((P_H + P_J + 2*P_I + 2) >> 2);
00417 cur_pred[3][7] =
00418 cur_pred[5][6] =
00419 cur_pred[7][5] = (imgpel) ((P_I + P_K + 2*P_J + 2) >> 2);
00420 cur_pred[5][7] =
00421 cur_pred[7][6] = (imgpel) ((P_J + P_L + 2*P_K + 2) >> 2);
00422 cur_pred[7][7] = (imgpel) ((P_K + P_M + 2*P_L + 2) >> 2);
00423 }
00424
00425
00426
00427
00428
00429
00430
00431 static inline void get_i8x8_vertright(imgpel **cur_pred, imgpel *PredPel)
00432 {
00433 cur_pred[0][0] =
00434 cur_pred[2][1] =
00435 cur_pred[4][2] =
00436 cur_pred[6][3] = (imgpel) ((P_Z + P_A + 1) >> 1);
00437 cur_pred[0][1] =
00438 cur_pred[2][2] =
00439 cur_pred[4][3] =
00440 cur_pred[6][4] = (imgpel) ((P_A + P_B + 1) >> 1);
00441 cur_pred[0][2] =
00442 cur_pred[2][3] =
00443 cur_pred[4][4] =
00444 cur_pred[6][5] = (imgpel) ((P_B + P_C + 1) >> 1);
00445 cur_pred[0][3] =
00446 cur_pred[2][4] =
00447 cur_pred[4][5] =
00448 cur_pred[6][6] = (imgpel) ((P_C + P_D + 1) >> 1);
00449 cur_pred[0][4] =
00450 cur_pred[2][5] =
00451 cur_pred[4][6] =
00452 cur_pred[6][7] = (imgpel) ((P_D + P_E + 1) >> 1);
00453 cur_pred[0][5] =
00454 cur_pred[2][6] =
00455 cur_pred[4][7] = (imgpel) ((P_E + P_F + 1) >> 1);
00456 cur_pred[0][6] =
00457 cur_pred[2][7] = (imgpel) ((P_F + P_G + 1) >> 1);
00458 cur_pred[0][7] = (imgpel) ((P_G + P_H + 1) >> 1);
00459 cur_pred[1][0] =
00460 cur_pred[3][1] =
00461 cur_pred[5][2] =
00462 cur_pred[7][3] = (imgpel) ((P_Q + P_A + (P_Z << 1) + 2) >> 2);
00463 cur_pred[1][1] =
00464 cur_pred[3][2] =
00465 cur_pred[5][3] =
00466 cur_pred[7][4] = (imgpel) ((P_Z + P_B + (P_A << 1) + 2) >> 2);
00467 cur_pred[1][2] =
00468 cur_pred[3][3] =
00469 cur_pred[5][4] =
00470 cur_pred[7][5] = (imgpel) ((P_A + P_C + (P_B << 1) + 2) >> 2);
00471 cur_pred[1][3] =
00472 cur_pred[3][4] =
00473 cur_pred[5][5] =
00474 cur_pred[7][6] = (imgpel) ((P_B + P_D + (P_C << 1) + 2) >> 2);
00475 cur_pred[1][4] =
00476 cur_pred[3][5] =
00477 cur_pred[5][6] =
00478 cur_pred[7][7] = (imgpel) ((P_C + P_E + (P_D << 1) + 2) >> 2);
00479 cur_pred[1][5] =
00480 cur_pred[3][6] =
00481 cur_pred[5][7] = (imgpel) ((P_D + P_F + (P_E << 1) + 2) >> 2);
00482 cur_pred[1][6] =
00483 cur_pred[3][7] = (imgpel) ((P_E + P_G + (P_F << 1) + 2) >> 2);
00484 cur_pred[1][7] = (imgpel) ((P_F + P_H + (P_G << 1) + 2) >> 2);
00485 cur_pred[2][0] =
00486 cur_pred[4][1] =
00487 cur_pred[6][2] = (imgpel) ((P_R + P_Z + (P_Q << 1) + 2) >> 2);
00488 cur_pred[3][0] =
00489 cur_pred[5][1] =
00490 cur_pred[7][2] = (imgpel) ((P_S + P_Q + (P_R << 1) + 2) >> 2);
00491 cur_pred[4][0] =
00492 cur_pred[6][1] = (imgpel) ((P_T + P_R + (P_S << 1) + 2) >> 2);
00493 cur_pred[5][0] =
00494 cur_pred[7][1] = (imgpel) ((P_U + P_S + (P_T << 1) + 2) >> 2);
00495 cur_pred[6][0] = (imgpel) ((P_V + P_T + (P_U << 1) + 2) >> 2);
00496 cur_pred[7][0] = (imgpel) ((P_W + P_U + (P_V << 1) + 2) >> 2);
00497 }
00498
00499
00500
00501
00502
00503
00504
00505 static inline void get_i8x8_hordown(imgpel **cur_pred, imgpel *PredPel)
00506 {
00507 cur_pred[0][0] =
00508 cur_pred[1][2] =
00509 cur_pred[2][4] =
00510 cur_pred[3][6] = (imgpel) ((P_Q + P_Z + 1) >> 1);
00511 cur_pred[1][0] =
00512 cur_pred[2][2] =
00513 cur_pred[3][4] =
00514 cur_pred[4][6] = (imgpel) ((P_R + P_Q + 1) >> 1);
00515 cur_pred[2][0] =
00516 cur_pred[3][2] =
00517 cur_pred[4][4] =
00518 cur_pred[5][6] = (imgpel) ((P_S + P_R + 1) >> 1);
00519 cur_pred[3][0] =
00520 cur_pred[4][2] =
00521 cur_pred[5][4] =
00522 cur_pred[6][6] = (imgpel) ((P_T + P_S + 1) >> 1);
00523 cur_pred[4][0] =
00524 cur_pred[5][2] =
00525 cur_pred[6][4] =
00526 cur_pred[7][6] = (imgpel) ((P_U + P_T + 1) >> 1);
00527 cur_pred[5][0] =
00528 cur_pred[6][2] =
00529 cur_pred[7][4] = (imgpel) ((P_V + P_U + 1) >> 1);
00530 cur_pred[6][0] =
00531 cur_pred[7][2] = (imgpel) ((P_W + P_V + 1) >> 1);
00532 cur_pred[7][0] = (imgpel) ((P_X + P_W + 1) >> 1);
00533 cur_pred[0][1] =
00534 cur_pred[1][3] =
00535 cur_pred[2][5] =
00536 cur_pred[3][7] = (imgpel) ((P_Q + P_A + (P_Z << 1) + 2) >> 2);
00537 cur_pred[1][1] =
00538 cur_pred[2][3] =
00539 cur_pred[3][5] =
00540 cur_pred[4][7] = (imgpel) ((P_Z + P_R + (P_Q << 1) + 2) >> 2);
00541 cur_pred[2][1] =
00542 cur_pred[3][3] =
00543 cur_pred[4][5] =
00544 cur_pred[5][7] = (imgpel) ((P_Q + P_S + (P_R << 1) + 2) >> 2);
00545 cur_pred[3][1] =
00546 cur_pred[4][3] =
00547 cur_pred[5][5] =
00548 cur_pred[6][7] = (imgpel) ((P_R + P_T + (P_S << 1) + 2) >> 2);
00549 cur_pred[4][1] =
00550 cur_pred[5][3] =
00551 cur_pred[6][5] =
00552 cur_pred[7][7] = (imgpel) ((P_S + P_U + (P_T << 1) + 2) >> 2);
00553 cur_pred[5][1] =
00554 cur_pred[6][3] =
00555 cur_pred[7][5] = (imgpel) ((P_T + P_V + (P_U << 1) + 2) >> 2);
00556 cur_pred[6][1] =
00557 cur_pred[7][3] = (imgpel) ((P_U + P_W + (P_V << 1) + 2) >> 2);
00558 cur_pred[7][1] = (imgpel) ((P_V + P_X + (P_W << 1) + 2) >> 2);
00559 cur_pred[0][2] =
00560 cur_pred[1][4] =
00561 cur_pred[2][6] = (imgpel) ((P_Z + P_B + (P_A << 1) + 2) >> 2);
00562 cur_pred[0][3] =
00563 cur_pred[1][5] =
00564 cur_pred[2][7] = (imgpel) ((P_A + P_C + (P_B << 1) + 2) >> 2);
00565 cur_pred[0][4] =
00566 cur_pred[1][6] = (imgpel) ((P_B + P_D + (P_C << 1) + 2) >> 2);
00567 cur_pred[0][5] =
00568 cur_pred[1][7] = (imgpel) ((P_C + P_E + (P_D << 1) + 2) >> 2);
00569 cur_pred[0][6] = (imgpel) ((P_D + P_F + (P_E << 1) + 2) >> 2);
00570 cur_pred[0][7] = (imgpel) ((P_E + P_G + (P_F << 1) + 2) >> 2);
00571 }
00572
00573
00574
00575
00576
00577
00578
00579
00580 static inline void get_i8x8_horup(imgpel **cur_pred, imgpel *PredPel)
00581 {
00582 cur_pred[0][0] = (imgpel) ((P_Q + P_R + 1) >> 1);
00583 cur_pred[1][0] =
00584 cur_pred[0][2] = (imgpel) ((P_R + P_S + 1) >> 1);
00585 cur_pred[2][0] =
00586 cur_pred[1][2] =
00587 cur_pred[0][4] = (imgpel) ((P_S + P_T + 1) >> 1);
00588 cur_pred[3][0] =
00589 cur_pred[2][2] =
00590 cur_pred[1][4] =
00591 cur_pred[0][6] = (imgpel) ((P_T + P_U + 1) >> 1);
00592 cur_pred[4][0] =
00593 cur_pred[3][2] =
00594 cur_pred[2][4] =
00595 cur_pred[1][6] = (imgpel) ((P_U + P_V + 1) >> 1);
00596 cur_pred[5][0] =
00597 cur_pred[4][2] =
00598 cur_pred[3][4] =
00599 cur_pred[2][6] = (imgpel) ((P_V + P_W + 1) >> 1);
00600 cur_pred[6][0] =
00601 cur_pred[5][2] =
00602 cur_pred[4][4] =
00603 cur_pred[3][6] = (imgpel) ((P_W + P_X + 1) >> 1);
00604 cur_pred[4][6] =
00605 cur_pred[4][7] =
00606 cur_pred[5][4] =
00607 cur_pred[5][5] =
00608 cur_pred[5][6] =
00609 cur_pred[5][7] =
00610 cur_pred[6][2] =
00611 cur_pred[6][3] =
00612 cur_pred[6][4] =
00613 cur_pred[6][5] =
00614 cur_pred[6][6] =
00615 cur_pred[6][7] =
00616 cur_pred[7][0] =
00617 cur_pred[7][1] =
00618 cur_pred[7][2] =
00619 cur_pred[7][3] =
00620 cur_pred[7][4] =
00621 cur_pred[7][5] =
00622 cur_pred[7][6] =
00623 cur_pred[7][7] = (imgpel) P_X;
00624 cur_pred[6][1] =
00625 cur_pred[5][3] =
00626 cur_pred[4][5] =
00627 cur_pred[3][7] = (imgpel) ((P_W + P_X + (P_X << 1) + 2) >> 2);
00628 cur_pred[5][1] =
00629 cur_pred[4][3] =
00630 cur_pred[3][5] =
00631 cur_pred[2][7] = (imgpel) ((P_X + P_V + (P_W << 1) + 2) >> 2);
00632 cur_pred[4][1] =
00633 cur_pred[3][3] =
00634 cur_pred[2][5] =
00635 cur_pred[1][7] = (imgpel) ((P_W + P_U + (P_V << 1) + 2) >> 2);
00636 cur_pred[3][1] =
00637 cur_pred[2][3] =
00638 cur_pred[1][5] =
00639 cur_pred[0][7] = (imgpel) ((P_V + P_T + (P_U << 1) + 2) >> 2);
00640 cur_pred[2][1] =
00641 cur_pred[1][3] =
00642 cur_pred[0][5] = (imgpel) ((P_U + P_S + (P_T << 1) + 2) >> 2);
00643 cur_pred[1][1] =
00644 cur_pred[0][3] = (imgpel) ((P_T + P_R + (P_S << 1) + 2) >> 2);
00645 cur_pred[0][1] = (imgpel) ((P_S + P_Q + (P_R << 1) + 2) >> 2);
00646 }
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665 void set_intrapred_8x8(Macroblock *currMB, ColorPlane pl, int img_x,int img_y, int *left_available, int *up_available, int *all_available)
00666 {
00667 ImageParameters *p_Img = currMB->p_Img;
00668 InputParameters *p_Inp = currMB->p_Inp;
00669
00670 int i;
00671 imgpel *PredPel = currMB->intra8x8_pred[pl];
00672 imgpel **img_enc = p_Img->enc_picture->p_curr_img;
00673 imgpel *img_pel;
00674 int *mb_size = p_Img->mb_size[IS_LUMA];
00675
00676 int ioff = (img_x & 15);
00677 int joff = (img_y & 15);
00678
00679 PixelPos pix_a[8];
00680 PixelPos pix_b, pix_c, pix_d;
00681
00682 int block_available_up;
00683 int block_available_left;
00684 int block_available_up_left;
00685 int block_available_up_right;
00686
00687 for (i=0;i<8;i++)
00688 {
00689 p_Img->getNeighbour(currMB, ioff - 1, joff + i , mb_size, &pix_a[i]);
00690 }
00691
00692 p_Img->getNeighbour(currMB, ioff , joff - 1, mb_size, &pix_b);
00693 p_Img->getNeighbour(currMB, ioff + 8, joff - 1, mb_size, &pix_c);
00694 p_Img->getNeighbour(currMB, ioff - 1, joff - 1, mb_size, &pix_d);
00695
00696 pix_c.available = pix_c.available &&!(ioff == 8 && joff == 8);
00697
00698 if (p_Inp->UseConstrainedIntraPred)
00699 {
00700 for (i=0, block_available_left=1; i<8;i++)
00701 block_available_left &= pix_a[i].available ? p_Img->intra_block[pix_a[i].mb_addr]: 0;
00702
00703 block_available_up = pix_b.available ? p_Img->intra_block [pix_b.mb_addr] : 0;
00704 block_available_up_right = pix_c.available ? p_Img->intra_block [pix_c.mb_addr] : 0;
00705 block_available_up_left = pix_d.available ? p_Img->intra_block [pix_d.mb_addr] : 0;
00706 }
00707 else
00708 {
00709 block_available_left = pix_a[0].available;
00710 block_available_up = pix_b.available;
00711 block_available_up_right = pix_c.available;
00712 block_available_up_left = pix_d.available;
00713 }
00714
00715 *left_available = block_available_left;
00716 *up_available = block_available_up;
00717 *all_available = block_available_up && block_available_left && block_available_up_left;
00718
00719
00720 if (block_available_up)
00721 {
00722 img_pel = &img_enc[pix_b.pos_y][pix_b.pos_x];
00723 P_A = *(img_pel++);
00724 P_B = *(img_pel++);
00725 P_C = *(img_pel++);
00726 P_D = *(img_pel++);
00727 P_E = *(img_pel++);
00728 P_F = *(img_pel++);
00729 P_G = *(img_pel++);
00730 P_H = *(img_pel);
00731 }
00732 else
00733 {
00734 P_A = P_B = P_C = P_D = P_E = P_F = P_G = P_H = p_Img->dc_pred_value;
00735 }
00736
00737 if (block_available_up_right)
00738 {
00739 img_pel = &img_enc[pix_c.pos_y][pix_c.pos_x];
00740 P_I = *(img_pel++);
00741 P_J = *(img_pel++);
00742 P_K = *(img_pel++);
00743 P_L = *(img_pel++);
00744 P_M = *(img_pel++);
00745 P_N = *(img_pel++);
00746 P_O = *(img_pel++);
00747 P_P = *(img_pel);
00748
00749 }
00750 else
00751 {
00752 P_I = P_J = P_K = P_L = P_M = P_N = P_O = P_P = P_H;
00753 }
00754
00755 if (block_available_left)
00756 {
00757 P_Q = img_enc[pix_a[0].pos_y][pix_a[0].pos_x];
00758 P_R = img_enc[pix_a[1].pos_y][pix_a[1].pos_x];
00759 P_S = img_enc[pix_a[2].pos_y][pix_a[2].pos_x];
00760 P_T = img_enc[pix_a[3].pos_y][pix_a[3].pos_x];
00761 P_U = img_enc[pix_a[4].pos_y][pix_a[4].pos_x];
00762 P_V = img_enc[pix_a[5].pos_y][pix_a[5].pos_x];
00763 P_W = img_enc[pix_a[6].pos_y][pix_a[6].pos_x];
00764 P_X = img_enc[pix_a[7].pos_y][pix_a[7].pos_x];
00765 }
00766 else
00767 {
00768 P_Q = P_R = P_S = P_T = P_U = P_V = P_W = P_X = p_Img->dc_pred_value;
00769 }
00770
00771 if (block_available_up_left)
00772 {
00773 P_Z = img_enc[pix_d.pos_y][pix_d.pos_x];
00774 }
00775 else
00776 {
00777 P_Z = p_Img->dc_pred_value;
00778 }
00779
00780 LowPassForIntra8x8Pred(&(P_Z), block_available_up_left, block_available_up, block_available_left);
00781 }
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795 void get_intrapred_8x8(Macroblock *currMB, ColorPlane pl, int i8x8_mode, int left_available, int up_available)
00796 {
00797 imgpel *PredPel = currMB->intra8x8_pred[pl];
00798 Slice *currSlice = currMB->p_slice;
00799 imgpel ***curr_mpr_8x8 = currSlice->mpr_8x8[pl];
00800
00801 switch (i8x8_mode)
00802 {
00803 case VERT_PRED :
00804 get_i8x8_vertical(curr_mpr_8x8[VERT_PRED], PredPel);
00805 break;
00806 case HOR_PRED :
00807 get_i8x8_horizontal(curr_mpr_8x8[HOR_PRED], PredPel);
00808 break;
00809 case DC_PRED :
00810 get_i8x8_dc(curr_mpr_8x8[DC_PRED], PredPel, left_available, up_available);
00811 break;
00812 case DIAG_DOWN_LEFT_PRED :
00813 get_i8x8_downleft(curr_mpr_8x8[DIAG_DOWN_LEFT_PRED], PredPel);
00814 break;
00815 case DIAG_DOWN_RIGHT_PRED :
00816 get_i8x8_downright(curr_mpr_8x8[DIAG_DOWN_RIGHT_PRED], PredPel);
00817 break;
00818 case VERT_RIGHT_PRED :
00819 get_i8x8_vertright(curr_mpr_8x8[VERT_RIGHT_PRED], PredPel);
00820 break;
00821 case HOR_DOWN_PRED :
00822 get_i8x8_hordown(curr_mpr_8x8[HOR_DOWN_PRED], PredPel);
00823 break;
00824 case VERT_LEFT_PRED :
00825 get_i8x8_vertleft(curr_mpr_8x8[VERT_LEFT_PRED], PredPel);
00826 break;
00827 case HOR_UP_PRED :
00828 get_i8x8_horup(curr_mpr_8x8[HOR_UP_PRED], PredPel);
00829 break;
00830 default:
00831 printf("invalid prediction mode \n");
00832 break;
00833 }
00834 }