00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <limits.h>
00016 #include "global.h"
00017 #include "image.h"
00018 #include "macroblock.h"
00019 #include "mc_prediction.h"
00020
00021
00022
00023
00024
00025
00026
00027 static inline void CopyMVBlock16(short ***enc_mv, short ***rdo_mv, int block_x, int block_y, int start, int end)
00028 {
00029 int j;
00030 for (j = start; j < end; j++)
00031 {
00032 memcpy(enc_mv[block_y + j][block_x], rdo_mv[j][0], BLOCK_MULTIPLE * 2 * sizeof(short));
00033 }
00034 }
00035
00036
00037
00038
00039
00040
00041
00042 static inline void ResetMVBlock16(short ***enc_mv, int block_x, int block_y, int start, int end)
00043 {
00044 int j;
00045 for (j = block_y + start; j < block_y + end; j++)
00046 {
00047 memset(enc_mv[j][block_x], 0, BLOCK_MULTIPLE * 2 * sizeof(short));
00048 }
00049 }
00050
00051
00052
00053
00054
00055
00056
00057 static inline void ResetRefBlock16(char **enc_ref, int block_x, int block_y, int start, int end)
00058 {
00059 int j;
00060 for (j = block_y + start; j < block_y + end; j++)
00061 {
00062 memset(&enc_ref[j][block_x], -1, BLOCK_MULTIPLE * sizeof(char));
00063 }
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 static inline void CopyMVBlock8(short ***enc_mv, short ***rdo_mv, int block_x, int start, int end, int offset)
00073 {
00074 int j;
00075 for (j = start; j < end; j++)
00076 {
00077 memcpy(enc_mv[j][block_x], rdo_mv[j][offset], 4 * sizeof(short));
00078 }
00079 }
00080
00081
00082
00083
00084
00085
00086
00087 static inline void ResetMVBlock8(short ***enc_mv, int block_x, int start, int end)
00088 {
00089 int j;
00090
00091 for (j = start; j < end; j++)
00092 {
00093 memset(enc_mv[j][block_x], 0, 4 * sizeof(short));
00094 }
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 static inline void ResetRefBlock8(char **enc_ref, int block_x, int start, int end)
00104 {
00105 int j;
00106 for (j = start; j < end; j++)
00107 {
00108 memset(&enc_ref[j][block_x], -1, 2 * sizeof(char));
00109 }
00110 }
00111
00112
00113
00114
00115
00116
00117
00118 void SetMotionVectorsMBPSlice (Macroblock* currMB, PicMotionParams *motion)
00119 {
00120 Slice *currSlice = currMB->p_slice;
00121 ImageParameters *p_Img = currMB->p_Img;
00122
00123 RD_DATA *rdopt = currSlice->rddata;
00124 short *****all_mv = currSlice->all_mv[LIST_0];
00125 int l0_ref, mode8;
00126 short ***rdo_mv = motion->mv[LIST_0];
00127
00128 if (currSlice->MbaffFrameFlag || (currSlice->UseRDOQuant && currSlice->RDOQ_QP_Num > 1))
00129 {
00130 memcpy(&rdopt->all_mv[LIST_0][0][0][0][0][0], &all_mv[0][0][0][0][0], p_Img->max_num_references * 9 * MB_BLOCK_PARTITIONS * 2 * sizeof(short));
00131 }
00132
00133 if (currMB->mb_type == PSKIP)
00134 {
00135 CopyMVBlock16(rdo_mv, all_mv[0][PSKIP], currMB->block_x, currMB->block_y, 0, 4);
00136 }
00137 else if (currMB->mb_type == P16x16)
00138 {
00139 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x];
00140 CopyMVBlock16(rdo_mv, all_mv[l0_ref][P16x16], currMB->block_x, currMB->block_y, 0, 4);
00141 }
00142 else if (currMB->mb_type == P16x8)
00143 {
00144 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x];
00145 CopyMVBlock16(rdo_mv, all_mv[l0_ref][P16x8], currMB->block_x, currMB->block_y, 0, 2);
00146
00147 l0_ref = motion->ref_idx[LIST_0][currMB->block_y + 2][currMB->block_x];
00148 CopyMVBlock16(rdo_mv, all_mv[l0_ref][P16x8], currMB->block_x, currMB->block_y, 2, 4);
00149 }
00150 else if (currMB->mb_type == P8x16)
00151 {
00152 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x];
00153 CopyMVBlock8(&rdo_mv[currMB->block_y], all_mv[l0_ref][P8x16], currMB->block_x , 0, 4, 0);
00154
00155 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x + 2];
00156 CopyMVBlock8(&rdo_mv[currMB->block_y], all_mv[l0_ref][P8x16], currMB->block_x + 2, 0, 4, 2);
00157 }
00158 else if (currMB->mb_type == P8x8)
00159 {
00160 mode8 = currMB->b8x8[0].mode;
00161 l0_ref = motion->ref_idx[LIST_0][currMB->block_y ][currMB->block_x ];
00162 CopyMVBlock8(&rdo_mv[currMB->block_y], all_mv[l0_ref][mode8], currMB->block_x , 0, 2, 0);
00163
00164 mode8 = currMB->b8x8[1].mode;
00165 l0_ref = motion->ref_idx[LIST_0][currMB->block_y ][currMB->block_x + 2];
00166 CopyMVBlock8(&rdo_mv[currMB->block_y], all_mv[l0_ref][mode8], currMB->block_x + 2, 0, 2, 2);
00167
00168 mode8 = currMB->b8x8[2].mode;
00169 l0_ref = motion->ref_idx[LIST_0][currMB->block_y + 2][currMB->block_x ];
00170 CopyMVBlock8(&rdo_mv[currMB->block_y], all_mv[l0_ref][mode8], currMB->block_x, 2, 4, 0);
00171
00172 mode8 = currMB->b8x8[3].mode;
00173 l0_ref = motion->ref_idx[LIST_0][currMB->block_y + 2][currMB->block_x + 2];
00174 CopyMVBlock8(&rdo_mv[currMB->block_y], all_mv[l0_ref][mode8], currMB->block_x + 2, 2, 4, 2);
00175 }
00176 else
00177 {
00178 ResetMVBlock16 (rdo_mv, currMB->block_x, currMB->block_y, 0, 4);
00179 ResetRefBlock16(motion->ref_idx[LIST_0], currMB->block_x, currMB->block_y, 0, 4);
00180 }
00181 }
00182
00183
00184
00185
00186
00187
00188
00189 static void SetMVBSlice16x8(Slice *currSlice, PicMotionParams *motion, Macroblock* currMB, int pos)
00190 {
00191 int l0_ref, l1_ref;
00192 int pdir = currMB->b8x8[pos].pdir;
00193 if (pdir == LIST_0)
00194 {
00195 l0_ref = motion->ref_idx[LIST_0][currMB->block_y + pos][currMB->block_x];
00196 CopyMVBlock16(motion->mv[LIST_0], currSlice->all_mv [LIST_0][l0_ref][P16x8], currMB->block_x, currMB->block_y, pos, pos + 2);
00197 ResetMVBlock16 (motion->mv[LIST_1], currMB->block_x, currMB->block_y, pos, pos + 2);
00198 ResetRefBlock16(motion->ref_idx[LIST_1], currMB->block_x, currMB->block_y, pos, pos + 2);
00199 }
00200 else if (pdir == LIST_1)
00201 {
00202 ResetMVBlock16 (motion->mv[LIST_0], currMB->block_x, currMB->block_y, pos, pos + 2);
00203 ResetRefBlock16(motion->ref_idx[LIST_0], currMB->block_x, currMB->block_y, pos, pos + 2);
00204 l1_ref = motion->ref_idx[LIST_1][currMB->block_y + pos][currMB->block_x];
00205 CopyMVBlock16 (motion->mv[LIST_1], currSlice->all_mv [LIST_1][l1_ref][P16x8], currMB->block_x, currMB->block_y, pos, pos + 2);
00206 }
00207 else
00208 {
00209 int bipred_me = currMB->b8x8[pos].bipred;
00210 short ******all_mv = bipred_me ? currSlice->bipred_mv[bipred_me - 1]: currSlice->all_mv;
00211 l0_ref = motion->ref_idx[LIST_0][currMB->block_y + pos][currMB->block_x];
00212 CopyMVBlock16 (motion->mv[LIST_0], all_mv [LIST_0][l0_ref][P16x8], currMB->block_x, currMB->block_y, pos, pos + 2);
00213
00214 l1_ref = motion->ref_idx[LIST_1][currMB->block_y + pos][currMB->block_x];
00215 CopyMVBlock16 (motion->mv[LIST_1], all_mv [LIST_1][l1_ref][P16x8], currMB->block_x, currMB->block_y, pos, pos + 2);
00216
00217 if (bipred_me && (currSlice->MbaffFrameFlag || (currSlice->UseRDOQuant && currSlice->RDOQ_QP_Num > 1)))
00218 {
00219 memcpy(currSlice->rddata->all_mv [LIST_0][l0_ref][P16x8][pos][0], all_mv [LIST_0][l0_ref][P16x8][pos][0], 2 * BLOCK_MULTIPLE * 2 * sizeof(short));
00220 memcpy(currSlice->rddata->all_mv [LIST_1][l1_ref][P16x8][pos][0], all_mv [LIST_1][l1_ref][P16x8][pos][0], 2 * BLOCK_MULTIPLE * 2 * sizeof(short));
00221 }
00222 }
00223 }
00224
00225
00226
00227
00228
00229
00230
00231 static void SetMVBSlice8x16(Slice *currSlice, PicMotionParams *motion, Macroblock* currMB, int pos)
00232 {
00233 int l0_ref, l1_ref;
00234 int pdir = currMB->b8x8[pos >> 1].pdir;
00235 if (pdir == LIST_0)
00236 {
00237 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x + pos];
00238 CopyMVBlock8 (&motion->mv[LIST_0][currMB->block_y], currSlice->all_mv [LIST_0][l0_ref][P8x16], currMB->block_x + pos, 0, 4, pos);
00239 ResetMVBlock8(&motion->mv[LIST_1][currMB->block_y], currMB->block_x + pos, 0, 4);
00240 ResetRefBlock8(&motion->ref_idx[LIST_1][currMB->block_y], currMB->block_x + pos, 0, 4);
00241 }
00242 else if (pdir == LIST_1)
00243 {
00244 ResetMVBlock8(&motion->mv[LIST_0][currMB->block_y], currMB->block_x + pos, 0, 4);
00245 ResetRefBlock8(&motion->ref_idx[LIST_0][currMB->block_y], currMB->block_x + pos, 0, 4);
00246 l1_ref = motion->ref_idx[LIST_1][currMB->block_y][currMB->block_x + pos];
00247 CopyMVBlock8 (&motion->mv[LIST_1][currMB->block_y], currSlice->all_mv [LIST_1][l1_ref][P8x16], currMB->block_x + pos, 0, 4, pos);
00248 }
00249 else
00250 {
00251 int bipred_me = currMB->b8x8[pos >> 1].bipred;
00252 short ******all_mv = bipred_me ? currSlice->bipred_mv[bipred_me - 1]: currSlice->all_mv;
00253 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x + pos];
00254 CopyMVBlock8(&motion->mv [LIST_0][currMB->block_y], all_mv [LIST_0][l0_ref][P8x16], currMB->block_x + pos, 0, 4, pos);
00255 l1_ref = motion->ref_idx[LIST_1][currMB->block_y][currMB->block_x + pos];
00256 CopyMVBlock8(&motion->mv [LIST_1][currMB->block_y], all_mv [LIST_1][l1_ref][P8x16], currMB->block_x + pos, 0, 4, pos);
00257
00258 if (bipred_me && (currSlice->MbaffFrameFlag || (currSlice->UseRDOQuant && currSlice->RDOQ_QP_Num > 1)))
00259 {
00260 int j;
00261 for (j = 0; j < BLOCK_MULTIPLE; j++)
00262 {
00263 memcpy(currSlice->rddata->all_mv [LIST_0][l0_ref][P8x16][j][pos], all_mv [LIST_0][l0_ref][P8x16][j][pos], 4 * sizeof(short));
00264 }
00265 for (j = 0; j < BLOCK_MULTIPLE; j++)
00266 {
00267 memcpy(currSlice->rddata->all_mv [LIST_1][l1_ref][P8x16][j][pos], all_mv [LIST_1][l1_ref][P8x16][j][pos], 4 * sizeof(short));
00268 }
00269 }
00270 }
00271 }
00272
00273
00274
00275
00276
00277
00278
00279 static void SetMVBSlice8x8(Slice *currSlice, PicMotionParams *motion, Macroblock* currMB, int pos_y, int pos_x)
00280 {
00281 int l0_ref, l1_ref;
00282 int pos = pos_y + (pos_x >> 1);
00283 int pdir = currMB->b8x8[pos].pdir;
00284 int mode = currMB->b8x8[pos].mode;
00285 int block_y = currMB->block_y + pos_y;
00286 int block_x = currMB->block_x + pos_x;
00287
00288 if (pdir == LIST_0)
00289 {
00290 l0_ref = motion->ref_idx[LIST_0][block_y][block_x];
00291 CopyMVBlock8 (&motion->mv[LIST_0][currMB->block_y], currSlice->all_mv [LIST_0][l0_ref][mode], currMB->block_x + pos_x, pos_y, pos_y + 2, pos_x);
00292 ResetMVBlock8 (&motion->mv[LIST_1][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00293 ResetRefBlock8(&motion->ref_idx[LIST_1][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00294 }
00295 else if (pdir == LIST_1)
00296 {
00297 ResetMVBlock8(&motion->mv[LIST_0][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00298 ResetRefBlock8(&motion->ref_idx[LIST_0][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00299 l1_ref = motion->ref_idx[LIST_1][block_y][block_x];
00300 CopyMVBlock8 (&motion->mv[LIST_1][currMB->block_y], currSlice->all_mv [LIST_1][l1_ref][mode], currMB->block_x + pos_x, pos_y, pos_y + 2, pos_x);
00301 }
00302 else if (pdir == BI_PRED)
00303 {
00304 int bipred_me = currMB->b8x8[pos].bipred;
00305 short ******all_mv = bipred_me ? currSlice->bipred_mv[bipred_me - 1]: currSlice->all_mv;
00306 l0_ref = motion->ref_idx[LIST_0][block_y][block_x];
00307 CopyMVBlock8(&motion->mv [LIST_0][currMB->block_y], all_mv [LIST_0][l0_ref][mode], currMB->block_x + pos_x, pos_y, pos_y + 2, pos_x);
00308
00309 l1_ref = motion->ref_idx[LIST_1][block_y][block_x];
00310 CopyMVBlock8(&motion->mv [LIST_1][currMB->block_y], all_mv [LIST_1][l1_ref][mode], currMB->block_x + pos_x, pos_y, pos_y + 2, pos_x);
00311
00312 if (bipred_me && (currSlice->MbaffFrameFlag || (currSlice->UseRDOQuant && currSlice->RDOQ_QP_Num > 1)))
00313 {
00314 memcpy(currSlice->rddata->all_mv [LIST_0][l0_ref][mode][pos_y ][pos_x], all_mv [LIST_0][l0_ref][mode][pos_y ][pos_x], 4 * sizeof(short));
00315 memcpy(currSlice->rddata->all_mv [LIST_0][l0_ref][mode][pos_y + 1][pos_x], all_mv [LIST_0][l0_ref][mode][pos_y + 1][pos_x], 4 * sizeof(short));
00316 memcpy(currSlice->rddata->all_mv [LIST_1][l1_ref][mode][pos_y ][pos_x], all_mv [LIST_1][l1_ref][mode][pos_y ][pos_x], 4 * sizeof(short));
00317 memcpy(currSlice->rddata->all_mv [LIST_1][l1_ref][mode][pos_y + 1][pos_x], all_mv [LIST_1][l1_ref][mode][pos_y + 1][pos_x], 4 * sizeof(short));
00318 }
00319 }
00320 else
00321 {
00322 ResetMVBlock8(&motion->mv[LIST_0][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00323 ResetRefBlock8(&motion->ref_idx[LIST_0][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00324 ResetMVBlock8(&motion->mv[LIST_1][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00325 ResetRefBlock8(&motion->ref_idx[LIST_1][currMB->block_y], currMB->block_x + pos_x, pos_y, pos_y + 2);
00326 }
00327 }
00328
00329 void SetMotionVectorsMBISlice (Macroblock* currMB, PicMotionParams *motion)
00330 {
00331 }
00332
00333
00334
00335
00336
00337
00338 void SetMotionVectorsMBBSlice (Macroblock* currMB, PicMotionParams *motion)
00339 {
00340 ImageParameters *p_Img = currMB->p_Img;
00341 Slice *currSlice = currMB->p_slice;
00342
00343 int l0_ref, l1_ref;
00344
00345
00346
00347
00348
00349 if (currSlice->MbaffFrameFlag || (currSlice->UseRDOQuant && currSlice->RDOQ_QP_Num > 1))
00350 {
00351 memcpy(&currSlice->rddata->all_mv[LIST_0][0][0][0][0][0], &currSlice->all_mv[LIST_0][0][0][0][0][0], 2 * p_Img->max_num_references * 9 * MB_BLOCK_PARTITIONS * 2 * sizeof(short));
00352 }
00353
00354 if (currMB->mb_type == P16x16)
00355 {
00356 int pdir = currMB->b8x8[0].pdir;
00357 if (pdir == LIST_0)
00358 {
00359 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x];
00360 CopyMVBlock16 (motion->mv[LIST_0], currSlice->all_mv [LIST_0][l0_ref][P16x16], currMB->block_x, currMB->block_y, 0, 4);
00361 ResetMVBlock16(motion->mv[LIST_1], currMB->block_x, currMB->block_y, 0, 4);
00362 }
00363 else if (pdir == LIST_1)
00364 {
00365 l1_ref = motion->ref_idx[LIST_1][currMB->block_y][currMB->block_x];
00366 ResetMVBlock16(motion->mv[LIST_0], currMB->block_x, currMB->block_y, 0, 4);
00367 CopyMVBlock16 (motion->mv[LIST_1], currSlice->all_mv [LIST_1][l1_ref][P16x16], currMB->block_x, currMB->block_y, 0, 4);
00368 }
00369 else
00370 {
00371 int bipred_me = currMB->b8x8[0].bipred;
00372 short ******all_mv = bipred_me ? currSlice->bipred_mv[bipred_me - 1]: currSlice->all_mv;
00373 l0_ref = motion->ref_idx[LIST_0][currMB->block_y][currMB->block_x];
00374 CopyMVBlock16 (motion->mv[LIST_0], all_mv [LIST_0][l0_ref][P16x16], currMB->block_x, currMB->block_y, 0, 4);
00375 l1_ref = motion->ref_idx[LIST_1][currMB->block_y][currMB->block_x];
00376 CopyMVBlock16 (motion->mv[LIST_1], all_mv [LIST_1][l1_ref][P16x16], currMB->block_x, currMB->block_y, 0, 4);
00377
00378
00379 if (bipred_me && (currSlice->MbaffFrameFlag || (currSlice->UseRDOQuant && currSlice->RDOQ_QP_Num > 1)))
00380 {
00381 memcpy(currSlice->rddata->all_mv [LIST_0][l0_ref][P16x16][0][0], all_mv [LIST_0][l0_ref][P16x16][0][0], MB_BLOCK_PARTITIONS * 2 * sizeof(short));
00382 memcpy(currSlice->rddata->all_mv [LIST_1][l1_ref][P16x16][0][0], all_mv [LIST_1][l1_ref][P16x16][0][0], MB_BLOCK_PARTITIONS * 2 * sizeof(short));
00383 }
00384 }
00385 }
00386 else if (currMB->mb_type == P16x8)
00387 {
00388 SetMVBSlice16x8(currSlice, motion, currMB, 0);
00389 SetMVBSlice16x8(currSlice, motion, currMB, 2);
00390 }
00391 else if (currMB->mb_type == P8x16)
00392 {
00393 SetMVBSlice8x16(currSlice, motion, currMB, 0);
00394 SetMVBSlice8x16(currSlice, motion, currMB, 2);
00395 }
00396 else if (currMB->mb_type == P8x8 || currMB->mb_type == BSKIP_DIRECT)
00397 {
00398 SetMVBSlice8x8(currSlice, motion, currMB, 0, 0);
00399 SetMVBSlice8x8(currSlice, motion, currMB, 0, 2);
00400 SetMVBSlice8x8(currSlice, motion, currMB, 2, 0);
00401 SetMVBSlice8x8(currSlice, motion, currMB, 2, 2);
00402 }
00403 else
00404 {
00405 ResetMVBlock16 (motion->mv[LIST_0], currMB->block_x, currMB->block_y, 0, 4);
00406 ResetRefBlock16(motion->ref_idx[LIST_0], currMB->block_x, currMB->block_y, 0, 4);
00407 ResetMVBlock16 (motion->mv[LIST_1], currMB->block_x, currMB->block_y, 0, 4);
00408 ResetRefBlock16(motion->ref_idx[LIST_1], currMB->block_x, currMB->block_y, 0, 4);
00409 }
00410 }
00411
00412
00413
00414
00415
00416
00417
00418 void copy_image_data_16x16(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
00419 {
00420 int j;
00421 for(j=0; j<MB_BLOCK_SIZE; j++)
00422 {
00423 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], MB_BLOCK_SIZE * sizeof (imgpel));
00424 }
00425 }
00426
00427
00428
00429
00430
00431
00432
00433 void copy_image_data_8x8(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
00434 {
00435 int j;
00436 for(j = 0; j < BLOCK_SIZE_8x8; j++)
00437 {
00438 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], BLOCK_SIZE_8x8 * sizeof (imgpel));
00439 }
00440 }
00441
00442
00443
00444
00445
00446
00447
00448 void copy_image_data_4x4(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2)
00449 {
00450 int j;
00451 for(j = 0; j < BLOCK_SIZE; j++)
00452 {
00453 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], BLOCK_SIZE * sizeof (imgpel));
00454 }
00455 }
00456
00457
00458
00459
00460
00461
00462
00463 void copy_image_data(imgpel **imgBuf1, imgpel **imgBuf2, int off1, int off2, int width, int height)
00464 {
00465 int j;
00466 for(j = 0; j < height; j++)
00467 {
00468 memcpy(&imgBuf1[j][off1], &imgBuf2[j][off2], width * sizeof (imgpel));
00469 }
00470 }
00471
00472
00473
00474
00475
00476
00477
00478 void ResetRD8x8Data(ImageParameters *p_Img, RD_8x8DATA *rd_data)
00479 {
00480 int block;
00481 p_Img->giRDOpt_B8OnlyFlag = TRUE;
00482
00483 rd_data->mb_p8x8_cost = 0;
00484 rd_data->cbp8x8 = 0;
00485 rd_data->cbp_blk8x8 = 0;
00486 rd_data->cnt_nonz_8x8 = 0;
00487
00488 for (block = 0; block < 4; block++)
00489 {
00490 rd_data->smb_p8x8_cost[block] = INT_MAX;
00491 rd_data->smb_p8x8_rdcost[block] = 1e20;
00492 rd_data->part[block].mode = -1;
00493 }
00494 }
00495
00496
00497
00498
00499
00500
00501
00502 void SetChromaPredMode(Macroblock *currMB, RD_PARAMS enc_mb, int *mb_available, char chroma_pred_mode_range[2])
00503 {
00504 ImageParameters *p_Img = currMB->p_Img;
00505 InputParameters *p_Inp = currMB->p_Inp;
00506
00507 if ((p_Img->yuv_format != YUV400) && !IS_INDEPENDENT(p_Inp))
00508 {
00509
00510 intra_chroma_prediction(currMB, &mb_available[0], &mb_available[1], &mb_available[2]);
00511
00512 if (p_Inp->FastCrIntraDecision)
00513 {
00514 intra_chroma_RD_decision(currMB, enc_mb);
00515
00516 chroma_pred_mode_range[0] = currMB->c_ipred_mode;
00517 chroma_pred_mode_range[1] = currMB->c_ipred_mode;
00518 }
00519 else
00520 {
00521 chroma_pred_mode_range[0] = DC_PRED_8;
00522 chroma_pred_mode_range[1] = PLANE_8;
00523 }
00524 }
00525 else
00526 {
00527 chroma_pred_mode_range[0] = DC_PRED_8;
00528 chroma_pred_mode_range[1] = DC_PRED_8;
00529 }
00530 }