00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <math.h>
00013 #include <limits.h>
00014 #include <float.h>
00015
00016 #include "global.h"
00017 #include "rdopt_coding_state.h"
00018 #include "mb_access.h"
00019 #include "intrarefresh.h"
00020 #include "image.h"
00021 #include "transform8x8.h"
00022 #include "ratectl.h"
00023 #include "mode_decision.h"
00024 #include "fmo.h"
00025 #include "me_umhex.h"
00026 #include "me_umhexsmp.h"
00027 #include "macroblock.h"
00028 #include "q_around.h"
00029 #include "vlc.h"
00030 #include "md_common.h"
00031 #include "rdopt.h"
00032
00033
00034 static imgpel temp_img[3][16][16];
00035
00036
00037
00038
00039
00040
00041
00042
00043 void encode_one_macroblock_low (Slice *currSlice, Macroblock *currMB)
00044 {
00045
00046 int block, mode, i=0, j, k, dummy;
00047 char best_pdir;
00048 RD_PARAMS enc_mb;
00049 char best_ref[2] = {0, -1};
00050 int bmcost[5] = {INT_MAX};
00051 double rd_cost = 0, min_rd_cost = 1e30;
00052 int cost = 0;
00053 int min_cost = INT_MAX, cost_direct=0, have_direct=0, i16mode=0;
00054 int intra1 = 0;
00055 int temp_cpb = 0;
00056 int best_transform_flag = 0;
00057 int cost8x8_direct = 0;
00058 short islice = (short) (img->type==I_SLICE);
00059 short bslice = (short) (img->type==B_SLICE);
00060 short pslice = (short) ((img->type==P_SLICE) || (img->type==SP_SLICE));
00061 short intra = (short) (islice || (pslice && img->mb_y==img->mb_y_upd && img->mb_y_upd!=img->mb_y_intra));
00062 int lambda_mf[3];
00063 Macroblock *prevMB = currMB->PrevMB;
00064 Block8x8Info *b8x8info = img->b8x8info;
00065
00066 char **ipredmodes = img->ipredmode;
00067 short *allmvs = params->IntraProfile ? NULL: img->all_mv[0][0][0][0][0];
00068 int ****i4p;
00069 imgpel **mb_pred = img->mb_pred[0];
00070 int is_cavlc = (img->currentSlice->symbol_mode == CAVLC);
00071
00072 int tmp_8x8_flag, tmp_no_mbpart;
00073
00074 short bipred_me, inter_skip = 0;
00075
00076 if (params->AdaptiveRounding)
00077 {
00078 reset_adaptive_rounding();
00079 }
00080
00081 if(params->SearchMode == UM_HEX)
00082 {
00083 UMHEX_decide_intrabk_SAD();
00084 }
00085 else if (params->SearchMode == UM_HEX_SIMPLE)
00086 {
00087 smpUMHEX_decide_intrabk_SAD();
00088 }
00089 if (img->MbaffFrameFlag)
00090 {
00091 reset_mb_nz_coeff(img->current_mb_nr);
00092 }
00093
00094 intra |= RandomIntra (img->current_mb_nr);
00095
00096
00097 init_enc_mb_params(currMB, &enc_mb, intra, bslice);
00098
00099
00100
00101 store_coding_state (currSlice, currMB, cs_cm);
00102
00103 if (!intra)
00104 {
00105
00106 best_mode = 1;
00107 if (bslice)
00108 {
00109 Get_Direct_Motion_Vectors (currMB);
00110 }
00111
00112 if (params->CtxAdptLagrangeMult == 1)
00113 {
00114 get_initial_mb16x16_cost(currMB);
00115 }
00116
00117
00118 for (min_cost=INT_MAX, mode=1; mode<4; mode++)
00119 {
00120 bipred_me = 0;
00121 b8x8info->bipred8x8me[mode][0] = 0;
00122 if (enc_mb.valid[mode] && !inter_skip)
00123 {
00124 for (cost=0, block=0; block<(mode==1?1:2); block++)
00125 {
00126 update_lambda_costs(&enc_mb, lambda_mf);
00127 PartitionMotionSearch (currMB, mode, block, lambda_mf);
00128
00129
00130 j = (block==1 && mode==2 ? 2 : 0);
00131 i = (block==1 && mode==3 ? 2 : 0);
00132
00133
00134 bmcost[LIST_0] = INT_MAX;
00135 list_prediction_cost(currMB, LIST_0, block, mode, &enc_mb, bmcost, best_ref);
00136
00137 if (bslice)
00138 {
00139
00140 bmcost[LIST_1] = INT_MAX;
00141 list_prediction_cost(currMB, LIST_1, block, mode, &enc_mb, bmcost, best_ref);
00142
00143
00144 list_prediction_cost(currMB, BI_PRED, block, mode, &enc_mb, bmcost, best_ref);
00145
00146
00147 if (is_bipred_enabled(mode))
00148 {
00149 list_prediction_cost(currMB, BI_PRED_L0, block, mode, &enc_mb, bmcost, 0);
00150 list_prediction_cost(currMB, BI_PRED_L1, block, mode, &enc_mb, bmcost, 0);
00151 }
00152 else
00153 {
00154 bmcost[BI_PRED_L0] = INT_MAX;
00155 bmcost[BI_PRED_L1] = INT_MAX;
00156 }
00157
00158
00159 determine_prediction_list(mode, bmcost, best_ref, &best_pdir, &cost, &bipred_me);
00160 }
00161 else
00162 {
00163 best_pdir = 0;
00164 cost += bmcost[LIST_0];
00165 }
00166
00167 assign_enc_picture_params(mode, best_pdir, 2 * block, enc_mb.list_offset[LIST_0], best_ref[LIST_0], best_ref[LIST_1], bslice, bipred_me);
00168
00169 set_block8x8_info(b8x8info, mode, block, best_ref, best_pdir, bipred_me);
00170
00171
00172 if (mode>1 && block==0)
00173 SetRefAndMotionVectors (&enc_picture->motion, currMB, block, mode, best_pdir, best_ref[LIST_0], best_ref[LIST_1], bipred_me);
00174 }
00175
00176 currMB->luma_transform_size_8x8_flag = 0;
00177 if (params->Transform8x8Mode)
00178 {
00179 SetModesAndRefframeForBlocks(currMB, mode);
00180 currMB->luma_transform_size_8x8_flag = TransformDecision(currMB, -1, &cost);
00181 }
00182
00183 if ((!inter_skip) && (cost < min_cost))
00184 {
00185 best_mode = (short) mode;
00186 min_cost = cost;
00187 best_transform_flag = currMB->luma_transform_size_8x8_flag;
00188
00189 if (params->CtxAdptLagrangeMult == 1)
00190 {
00191 adjust_mb16x16_cost(cost);
00192 }
00193 }
00194 }
00195 }
00196
00197 if ((!inter_skip) && enc_mb.valid[P8x8])
00198 {
00199 giRDOpt_B8OnlyFlag = 1;
00200
00201 tr8x8.mb_p8x8_cost = INT_MAX;
00202 tr4x4.mb_p8x8_cost = INT_MAX;
00203
00204 store_coding_state (currSlice, currMB, cs_mb);
00205
00206 currMB->all_blk_8x8 = -1;
00207
00208 if (params->Transform8x8Mode)
00209 {
00210 tr8x8.mb_p8x8_cost = 0;
00211
00212
00213
00214
00215 for (cost_direct=cbp8x8=cbp_blk8x8=cnt_nonz_8x8=0, block = 0; block < 4; block++)
00216 {
00217 submacroblock_mode_decision_low(currSlice, &enc_mb, &tr8x8, currMB, cofAC8x8ts[block],
00218 &have_direct, bslice, block, &cost_direct, &cost, &cost8x8_direct, 1, is_cavlc);
00219 set_subblock8x8_info(b8x8info, P8x8, block, &tr8x8);
00220 }
00221
00222
00223 cbp8_8x8ts = cbp8x8;
00224 cbp_blk8_8x8ts = cbp_blk8x8;
00225 cnt_nonz8_8x8ts = cnt_nonz_8x8;
00226 currMB->luma_transform_size_8x8_flag = 0;
00227
00228
00229
00230 }
00231
00232
00233 if (params->Transform8x8Mode != 2)
00234 {
00235 tr4x4.mb_p8x8_cost = 0;
00236
00237
00238
00239
00240 for (cost_direct=cbp8x8=cbp_blk8x8=cnt_nonz_8x8=0, block=0; block<4; block++)
00241 {
00242 submacroblock_mode_decision_low(currSlice, &enc_mb, &tr4x4, currMB, coefAC8x8[block],
00243 &have_direct, bslice, block, &cost_direct, &cost, &cost8x8_direct, 0, is_cavlc);
00244 set_subblock8x8_info(b8x8info, P8x8, block, &tr4x4);
00245 }
00246
00247
00248 }
00249
00250
00251 reset_coding_state (currSlice, currMB, cs_mb);
00252
00253
00254
00255 if (params->RCEnable)
00256 rc_store_diff(img->opix_x, img->opix_y, mb_pred);
00257
00258
00259 if (tr4x4.mb_p8x8_cost < min_cost || tr8x8.mb_p8x8_cost < min_cost)
00260 {
00261 best_mode = P8x8;
00262
00263
00264
00265
00266 if (params->Transform8x8Mode == 2)
00267 {
00268 min_cost = tr8x8.mb_p8x8_cost;
00269 currMB->luma_transform_size_8x8_flag=1;
00270 }
00271 else if (params->Transform8x8Mode)
00272 {
00273 if (tr8x8.mb_p8x8_cost < tr4x4.mb_p8x8_cost)
00274 {
00275 min_cost = tr8x8.mb_p8x8_cost;
00276 currMB->luma_transform_size_8x8_flag=1;
00277 }
00278 else if(tr4x4.mb_p8x8_cost < tr8x8.mb_p8x8_cost)
00279 {
00280 min_cost = tr4x4.mb_p8x8_cost;
00281 currMB->luma_transform_size_8x8_flag=0;
00282 }
00283 else
00284 {
00285 if (GetBestTransformP8x8() == 0)
00286 {
00287 min_cost = tr4x4.mb_p8x8_cost;
00288 currMB->luma_transform_size_8x8_flag=0;
00289 }
00290 else
00291 {
00292 min_cost = tr8x8.mb_p8x8_cost;
00293 currMB->luma_transform_size_8x8_flag=1;
00294 }
00295 }
00296 }
00297 else
00298 {
00299 min_cost = tr4x4.mb_p8x8_cost;
00300 currMB->luma_transform_size_8x8_flag=0;
00301 }
00302 }
00303 giRDOpt_B8OnlyFlag = 0;
00304 }
00305 else
00306 {
00307 tr4x4.mb_p8x8_cost = INT_MAX;
00308 }
00309
00310
00311 if(pslice)
00312 FindSkipModeMotionVector (currMB);
00313 }
00314 else
00315 {
00316 min_cost = INT_MAX;
00317 }
00318
00319
00320
00321
00322 tmp_8x8_flag = currMB->luma_transform_size_8x8_flag;
00323 tmp_no_mbpart = currMB->NoMbPartLessThan8x8Flag;
00324 if ((img->yuv_format != YUV400) && (img->yuv_format != YUV444))
00325
00326 IntraChromaPrediction(currMB, NULL, NULL, NULL);
00327
00328 if (enc_mb.valid[0] && bslice)
00329 {
00330 if(have_direct)
00331 {
00332 switch(params->Transform8x8Mode)
00333 {
00334 case 1:
00335 cost = ((cost8x8_direct < cost_direct) || !(enc_mb.valid[5] && enc_mb.valid[6] && enc_mb.valid[7]))
00336 ? cost8x8_direct : cost_direct;
00337 break;
00338 case 2:
00339 cost = cost8x8_direct;
00340 break;
00341 default:
00342 cost = cost_direct;
00343 break;
00344 }
00345 }
00346 else
00347 {
00348 cost = GetDirectCostMB (currMB, bslice);
00349 }
00350 if (cost!=INT_MAX)
00351 {
00352 cost -= (int)floor(16*enc_mb.lambda_md+0.4999);
00353 }
00354
00355 if (cost <= min_cost)
00356 {
00357 if(active_sps->direct_8x8_inference_flag && params->Transform8x8Mode)
00358 {
00359 if(params->Transform8x8Mode==2)
00360 currMB->luma_transform_size_8x8_flag=1;
00361 else
00362 {
00363 if(cost8x8_direct < cost_direct)
00364 currMB->luma_transform_size_8x8_flag=1;
00365 else
00366 currMB->luma_transform_size_8x8_flag=0;
00367 }
00368 }
00369 else
00370 currMB->luma_transform_size_8x8_flag=0;
00371
00372
00373 if (params->RCEnable)
00374 rc_store_diff(img->opix_x, img->opix_y, mb_pred);
00375
00376 min_cost = cost;
00377 best_mode = 0;
00378 tmp_8x8_flag = currMB->luma_transform_size_8x8_flag;
00379 }
00380 else
00381 {
00382 currMB->luma_transform_size_8x8_flag = tmp_8x8_flag;
00383 currMB->NoMbPartLessThan8x8Flag = tmp_no_mbpart;
00384 }
00385 }
00386
00387 min_rd_cost = (double) min_cost;
00388
00389 if (enc_mb.valid[I8MB])
00390 {
00391 currMB->luma_transform_size_8x8_flag = 1;
00392
00393 currMB->mb_type = currMB->ar_mode = I8MB;
00394 temp_cpb = Mode_Decision_for_Intra8x8Macroblock (currSlice, currMB, enc_mb.lambda_md, &rd_cost);
00395
00396
00397 if (rd_cost <= min_rd_cost)
00398 {
00399 currMB->cbp = temp_cpb;
00400 if (img->P444_joined)
00401 {
00402 curr_cbp[0] = cmp_cbp[1];
00403 curr_cbp[1] = cmp_cbp[2];
00404 }
00405
00406 if(enc_mb.valid[I4MB])
00407 {
00408
00409 if (params->Transform8x8Mode != 2)
00410 {
00411 i4p=cofAC; cofAC=img->cofAC; img->cofAC=i4p;
00412 }
00413 }
00414
00415 for(j=0; j<MB_BLOCK_SIZE; j++)
00416 {
00417 memcpy(temp_img[0][j], &enc_picture->imgY[img->pix_y + j][img->pix_x], MB_BLOCK_SIZE * sizeof (imgpel));
00418 }
00419
00420 if (img->P444_joined)
00421 {
00422 for(j=0; j<MB_BLOCK_SIZE; j++)
00423 {
00424 memcpy(temp_img[1][j], &enc_picture->imgUV[0][img->pix_y + j][img->pix_x], MB_BLOCK_SIZE * sizeof (imgpel));
00425 memcpy(temp_img[2][j], &enc_picture->imgUV[1][img->pix_y + j][img->pix_x], MB_BLOCK_SIZE * sizeof (imgpel));
00426 }
00427 }
00428
00429
00430 if (params->RCEnable)
00431 rc_store_diff(img->opix_x, img->opix_y, mb_pred);
00432
00433 min_rd_cost = rd_cost;
00434 best_mode = I8MB;
00435 tmp_8x8_flag = currMB->luma_transform_size_8x8_flag;
00436 }
00437 else
00438 {
00439 currMB->luma_transform_size_8x8_flag = tmp_8x8_flag;
00440 if (img->P444_joined)
00441 {
00442 cmp_cbp[1] = curr_cbp[0];
00443 cmp_cbp[2] = curr_cbp[1];
00444 currMB->cbp |= cmp_cbp[1];
00445 currMB->cbp |= cmp_cbp[2];
00446 cmp_cbp[1] = currMB->cbp;
00447 cmp_cbp[2] = currMB->cbp;
00448 }
00449 }
00450 }
00451
00452 if (enc_mb.valid[I4MB])
00453 {
00454 currMB->luma_transform_size_8x8_flag = 0;
00455 currMB->mb_type = currMB->ar_mode = I4MB;
00456 temp_cpb = Mode_Decision_for_Intra4x4Macroblock (currSlice, currMB, enc_mb.lambda_md, &rd_cost, is_cavlc);
00457
00458 if (rd_cost <= min_rd_cost)
00459 {
00460 currMB->cbp = temp_cpb;
00461
00462
00463 if (params->RCEnable)
00464 rc_store_diff(img->opix_x, img->opix_y, mb_pred);
00465
00466 min_rd_cost = rd_cost;
00467 best_mode = I4MB;
00468 tmp_8x8_flag = currMB->luma_transform_size_8x8_flag;
00469
00470
00471
00472
00473 }
00474 else
00475 {
00476 currMB->luma_transform_size_8x8_flag = tmp_8x8_flag;
00477 if (img->P444_joined)
00478 {
00479 cmp_cbp[1] = curr_cbp[0];
00480 cmp_cbp[2] = curr_cbp[1];
00481 currMB->cbp |= cmp_cbp[1];
00482 currMB->cbp |= cmp_cbp[2];
00483 cmp_cbp[1] = currMB->cbp;
00484 cmp_cbp[2] = currMB->cbp;
00485 }
00486
00487 i4p=cofAC; cofAC=img->cofAC; img->cofAC=i4p;
00488 }
00489 }
00490 if (enc_mb.valid[I16MB])
00491 {
00492 currMB->luma_transform_size_8x8_flag = 0;
00493 intrapred_16x16 (currMB, PLANE_Y);
00494 if (img->P444_joined)
00495 {
00496 select_plane(PLANE_U);
00497 intrapred_16x16 (currMB, PLANE_U);
00498 select_plane(PLANE_V);
00499 intrapred_16x16 (currMB, PLANE_V);
00500 select_plane(PLANE_Y);
00501 }
00502
00503 rd_cost = find_sad_16x16 (currMB, &i16mode);
00504
00505 if (rd_cost < min_rd_cost)
00506 {
00507
00508 if (params->RCEnable)
00509 rc_store_diff(img->opix_x,img->opix_y,img->mpr_16x16[0][i16mode]);
00510
00511 best_mode = I16MB;
00512 min_rd_cost = rd_cost;
00513 currMB->cbp = pDCT_16x16 (currMB, PLANE_Y, i16mode, is_cavlc);
00514
00515
00516
00517
00518
00519 if (img->P444_joined)
00520 {
00521 select_plane(PLANE_U);
00522 cmp_cbp[1] = pDCT_16x16(currMB, PLANE_U, i16mode, is_cavlc);
00523 select_plane(PLANE_V);
00524 cmp_cbp[2] = pDCT_16x16(currMB, PLANE_V, i16mode, is_cavlc);
00525
00526 select_plane(PLANE_Y);
00527 currMB->cbp |= cmp_cbp[1];
00528 currMB->cbp |= cmp_cbp[2];
00529 cmp_cbp[1] = currMB->cbp;
00530 cmp_cbp[2] = currMB->cbp;
00531 }
00532
00533 }
00534 else
00535 {
00536 currMB->luma_transform_size_8x8_flag = tmp_8x8_flag;
00537 currMB->NoMbPartLessThan8x8Flag = tmp_no_mbpart;
00538 }
00539 }
00540
00541 intra1 = IS_INTRA(currMB);
00542
00543
00544
00545 {
00546
00547 SetModesAndRefframeForBlocks (currMB, best_mode);
00548
00549 if (best_mode==P8x8)
00550 {
00551 if (currMB->luma_transform_size_8x8_flag && (cbp8_8x8ts == 0) && params->Transform8x8Mode != 2)
00552 currMB->luma_transform_size_8x8_flag = 0;
00553
00554 SetCoeffAndReconstruction8x8 (currMB);
00555
00556 memset(currMB->intra_pred_modes, DC_PRED, MB_BLOCK_PARTITIONS * sizeof(char));
00557 for (k=0, j = img->block_y; j < img->block_y + BLOCK_MULTIPLE; j++)
00558 memset(&ipredmodes[j][img->block_x], DC_PRED, BLOCK_MULTIPLE * sizeof(char));
00559 }
00560 else
00561 {
00562
00563 if (best_mode == I8MB)
00564 {
00565 memcpy(currMB->intra_pred_modes,currMB->intra_pred_modes8x8, MB_BLOCK_PARTITIONS * sizeof(char));
00566 for(j = img->block_y; j < img->block_y + BLOCK_MULTIPLE; j++)
00567 memcpy(&img->ipredmode[j][img->block_x],&img->ipredmode8x8[j][img->block_x], BLOCK_MULTIPLE * sizeof(char));
00568
00569
00570 for(j=0; j<MB_BLOCK_SIZE; j++)
00571 {
00572 memcpy(&enc_picture->imgY[img->pix_y + j][img->pix_x],temp_img[0][j], MB_BLOCK_SIZE * sizeof(imgpel));
00573 }
00574 if (img->P444_joined)
00575 {
00576 for(j=0; j<MB_BLOCK_SIZE; j++)
00577 {
00578 memcpy(&enc_picture->imgUV[0][img->pix_y + j][img->pix_x],temp_img[1][j], MB_BLOCK_SIZE * sizeof(imgpel));
00579 memcpy(&enc_picture->imgUV[1][img->pix_y + j][img->pix_x],temp_img[2][j], MB_BLOCK_SIZE * sizeof(imgpel));
00580 }
00581 }
00582 }
00583
00584 if ((best_mode!=I4MB)&&(best_mode != I8MB))
00585 {
00586 memset(currMB->intra_pred_modes,DC_PRED, MB_BLOCK_PARTITIONS * sizeof(char));
00587 for(j = img->block_y; j < img->block_y + BLOCK_MULTIPLE; j++)
00588 memset(&ipredmodes[j][img->block_x],DC_PRED, BLOCK_MULTIPLE * sizeof(char));
00589 currMB->ar_mode = best_mode;
00590
00591 if (best_mode!=I16MB)
00592 {
00593 if((best_mode>=1) && (best_mode<=3))
00594 currMB->luma_transform_size_8x8_flag = best_transform_flag;
00595 LumaResidualCoding (currMB, is_cavlc);
00596
00597 if (img->P444_joined)
00598 {
00599 if((currMB->cbp==0 && cmp_cbp[1] == 0 && cmp_cbp[2] == 0) &&(best_mode==0))
00600 currMB->luma_transform_size_8x8_flag = 0;
00601 }
00602 else if((currMB->cbp==0)&&(best_mode==0))
00603 currMB->luma_transform_size_8x8_flag = 0;
00604
00605
00606 if (params->RCEnable)
00607 rc_store_diff(img->opix_x,img->opix_y,mb_pred);
00608 }
00609 }
00610 }
00611
00612 if (((currMB->cbp&15) == 0) && currMB->mb_type != I4MB && currMB->mb_type != I8MB)
00613 currMB->luma_transform_size_8x8_flag = 0;
00614
00615
00616 if ((img->yuv_format != YUV400) && (img->yuv_format != YUV444))
00617 IntraChromaPrediction(currMB, NULL, NULL, NULL);
00618
00619 img->i16offset = 0;
00620 dummy = 0;
00621
00622 if ((img->yuv_format != YUV400) && (img->yuv_format != YUV444))
00623 ChromaResidualCoding (currMB, is_cavlc);
00624
00625 if (best_mode==I16MB)
00626 {
00627 img->i16offset = I16Offset (currMB->cbp, i16mode);
00628 }
00629
00630 SetMotionVectorsMB (img, &enc_picture->motion, currMB);
00631
00632
00633 if(img->P444_joined)
00634 {
00635 if ((pslice) && best_mode==1 && currMB->cbp==0 && cmp_cbp[1] == 0 && cmp_cbp[2] == 0 &&
00636 enc_picture->motion.ref_idx[LIST_0][img->block_y][img->block_x] == 0 &&
00637 enc_picture->motion.mv [LIST_0][img->block_y][img->block_x][0] == allmvs[0] &&
00638 enc_picture->motion.mv [LIST_0][img->block_y][img->block_x][1] == allmvs[1])
00639 {
00640 currMB->mb_type = currMB->b8mode[0] = currMB->b8mode[1] = currMB->b8mode[2] = currMB->b8mode[3] = 0;
00641 currMB->luma_transform_size_8x8_flag = 0;
00642 }
00643 }
00644 else if ((pslice) && best_mode==1 && currMB->cbp==0 &&
00645 enc_picture->motion.ref_idx[LIST_0][img->block_y][img->block_x] == 0 &&
00646 enc_picture->motion.mv [LIST_0][img->block_y][img->block_x][0] == allmvs[0] &&
00647 enc_picture->motion.mv [LIST_0][img->block_y][img->block_x][1] == allmvs[1])
00648 {
00649 currMB->mb_type = currMB->b8mode[0] = currMB->b8mode[1] = currMB->b8mode[2] = currMB->b8mode[3] = 0;
00650 currMB->luma_transform_size_8x8_flag = 0;
00651 }
00652
00653 if (img->MbaffFrameFlag || (params->UseRDOQuant && params->RDOQ_QP_Num > 1))
00654 set_mbaff_parameters(currMB);
00655 }
00656
00657
00658 if(params->RCEnable && params->RCUpdateMode <= MAX_RC_MODE)
00659 rc_store_mad(currMB);
00660 update_qp_cbp(currMB, best_mode);
00661
00662 rdopt->min_rdcost = min_rd_cost;
00663 rdopt->min_dcost = min_rd_cost;
00664
00665 if ( (img->MbaffFrameFlag)
00666 && (img->current_mb_nr%2)
00667 && (currMB->mb_type ? 0:((bslice) ? !currMB->cbp:1))
00668 && (prevMB->mb_type ? 0:((bslice) ? !prevMB->cbp:1))
00669 && !(field_flag_inference(currMB) == enc_mb.curr_mb_field))
00670 {
00671 rdopt->min_rdcost = 1e30;
00672 }
00673
00674
00675 if (params->RestrictRef)
00676 update_refresh_map(intra, intra1, currMB);
00677
00678 if(params->SearchMode == UM_HEX)
00679 {
00680 UMHEX_skip_intrabk_SAD(best_mode, listXsize[enc_mb.list_offset[LIST_0]]);
00681 }
00682 else if(params->SearchMode == UM_HEX_SIMPLE)
00683 {
00684 smpUMHEX_skip_intrabk_SAD(best_mode, listXsize[enc_mb.list_offset[LIST_0]]);
00685 }
00686
00687
00688 if(params->UseConstrainedIntraPred && (img->type==P_SLICE || img->type==B_SLICE))
00689 {
00690 img->intra_block[img->current_mb_nr] = IS_INTRA(currMB);
00691 }
00692
00693
00694 if (img->AdaptiveRounding)
00695 {
00696 update_offset_params(currMB, best_mode, currMB->luma_transform_size_8x8_flag);
00697 }
00698 }
00699