📄 md_high.c
字号:
cbp_blk8_8x8ts = cbp_blk8x8;
cnt_nonz8_8x8ts = cnt_nonz_8x8;
currMB->luma_transform_size_8x8_flag = 0; //switch to 4x4 transform size
//--- re-set coding state (as it was before 8x8 block coding) ---
//reset_coding_state (cs_mb);
}// if (input->Transform8x8Mode)
if (input->Transform8x8Mode != 2)
{
tr4x4.cost8x8 = 0;
//=================================================================
// Check 8x8, 8x4, 4x8 and 4x4 partitions with transform size 4x4
//=================================================================
//===== LOOP OVER 8x8 SUB-PARTITIONS (Motion Estimation & Mode Decision) =====
for (cost_direct=cbp8x8=cbp_blk8x8=cnt_nonz_8x8=0, block=0; block<4; block++)
{
submacroblock_mode_decision(enc_mb, &tr4x4, currMB, cofAC8x8[block],
&have_direct, bslice, block, &cost_direct, &cost, &cost8x8_direct, 0);
best8x8mode [block] = tr4x4.part8x8mode [block];
best8x8pdir [P8x8][block] = tr4x4.part8x8pdir [block];
best8x8l0ref[P8x8][block] = tr4x4.part8x8l0ref[block];
best8x8l1ref[P8x8][block] = tr4x4.part8x8l1ref[block];
}
//--- re-set coding state (as it was before 8x8 block coding) ---
// reset_coding_state (cs_mb);
}// if (input->Transform8x8Mode != 2)
//--- re-set coding state (as it was before 8x8 block coding) ---
reset_coding_state (cs_mb);
// This is not enabled yet since mpr has reverse order.
if (input->RCEnable)
rc_store_diff(img->opix_x,img->opix_y,img->mpr);
//check cost for P8x8 for non-rdopt mode
giRDOpt_B8OnlyFlag = 0;
}
else // if (enc_mb.valid[P8x8])
{
tr4x4.cost8x8 = INT_MAX;
}
// Find a motion vector for the Skip mode
if(pslice)
FindSkipModeMotionVector ();
}
else // if (!intra)
{
min_cost = INT_MAX;
}
//========= C H O O S E B E S T M A C R O B L O C K M O D E =========
//-------------------------------------------------------------------------
if (input->BiPredMotionEstimation)
img->bi_pred_me[1] =0;
if ((img->yuv_format != YUV400) && !IS_INDEPENDENT(input))
{
// precompute all new chroma intra prediction modes
IntraChromaPrediction(&mb_available_up, &mb_available_left, &mb_available_up_left);
if (input->FastCrIntraDecision)
{
IntraChromaRDDecision(enc_mb);
min_chroma_pred_mode = (short) currMB->c_ipred_mode;
max_chroma_pred_mode = (short) currMB->c_ipred_mode;
}
else
{
min_chroma_pred_mode = DC_PRED_8;
max_chroma_pred_mode = PLANE_8;
}
}
else
{
min_chroma_pred_mode = DC_PRED_8;
max_chroma_pred_mode = DC_PRED_8;
}
for (currMB->c_ipred_mode=min_chroma_pred_mode; currMB->c_ipred_mode<=max_chroma_pred_mode; currMB->c_ipred_mode++)
{
// bypass if c_ipred_mode is not allowed
if ( (img->yuv_format != YUV400) &&
( ((!intra || !input->IntraDisableInterOnly) && input->ChromaIntraDisable == 1 && currMB->c_ipred_mode!=DC_PRED_8)
|| (currMB->c_ipred_mode == VERT_PRED_8 && !mb_available_up)
|| (currMB->c_ipred_mode == HOR_PRED_8 && !mb_available_left)
|| (currMB->c_ipred_mode == PLANE_8 && (!mb_available_left || !mb_available_up || !mb_available_up_left))))
continue;
//===== GET BEST MACROBLOCK MODE =====
for (ctr16x16=0, index=0; index < max_index; index++)
{
mode = mb_mode_table[index];
if (img->yuv_format != YUV400)
{
mode = mb_mode_table[index];
i16mode = 0;
}
//--- for INTER16x16 check all prediction directions ---
if (mode==1 && bslice)
{
best8x8pdir[1][0] = best8x8pdir[1][1] = best8x8pdir[1][2] = best8x8pdir[1][3] = (char) ctr16x16;
if ( (bslice) && (input->BiPredMotionEstimation)
&& (ctr16x16 == 2 && img->bi_pred_me[mode] < 2 && mode == 1))
ctr16x16--;
if (ctr16x16 < 2)
index--;
ctr16x16++;
}
// Skip intra modes in inter slices if best inter mode is
// a MB partition and cbp is 0.
if (input->SkipIntraInInterSlices && !intra && mode >= I16MB
&& best_mode <=3 && currMB->cbp == 0)
continue;
// check if weights are in valid range for biprediction.
if (bslice && active_pps->weighted_bipred_idc == 1 && mode < P8x8)
{
int cur_blk, cur_comp;
int weight_sum;
Boolean invalid_mode = FALSE;
for (cur_blk = 0; cur_blk < 4; cur_blk ++)
{
if (best8x8pdir[mode][cur_blk] == 2)
{
for (cur_comp = 0; cur_comp < (active_sps->chroma_format_idc == YUV400 ? 1 : 3) ; cur_comp ++)
{
weight_sum =
wbp_weight[0][(int) best8x8l0ref[mode][cur_blk]][(int) best8x8l1ref[mode][cur_blk]][cur_comp] +
wbp_weight[1][(int) best8x8l0ref[mode][cur_blk]][(int) best8x8l1ref[mode][cur_blk]][cur_comp];
if (weight_sum < -128 || weight_sum > 127)
{
invalid_mode = TRUE;
break;
}
}
if (invalid_mode == TRUE)
break;
}
}
if (invalid_mode == TRUE)
{
if ((input->BiPredMotionEstimation) && ctr16x16 == 2
&& img->bi_pred_me[mode] < 2 && mode == 1)
img->bi_pred_me[mode] = (short) (img->bi_pred_me[mode] + 1);
continue;
}
}
if (enc_mb.valid[mode])
compute_mode_RD_cost(mode, currMB, enc_mb, &min_rdcost, &min_dcost, &min_rate, i16mode, bslice, &inter_skip);
if ((input->BiPredMotionEstimation) && (bslice) && ctr16x16 == 2
&& img->bi_pred_me[mode] < 2 && mode == 1 && best8x8pdir[1][0] == 2)
img->bi_pred_me[mode] = (short) (img->bi_pred_me[mode] + 1);
}// for (ctr16x16=0, index=0; index<max_index; index++)
}// for (currMB->c_ipred_mode=DC_PRED_8; currMB->c_ipred_mode<=max_chroma_pred_mode; currMB->c_ipred_mode++)
#ifdef BEST_NZ_COEFF
for (j=0;j<4;j++)
for (i=0; i<(4+img->num_blk8x8_uv); i++)
img->nz_coeff[img->current_mb_nr][j][i] = gaaiMBAFF_NZCoeff[j][i];
#endif
intra1 = IS_INTRA(currMB);
//===== S E T F I N A L M A C R O B L O C K P A R A M E T E R S ======
//---------------------------------------------------------------------------
if (((cbp!=0 || best_mode==I16MB) && (best_mode!=IPCM) ))
currMB->prev_cbp = 1;
else if ((cbp==0 && !input->RCEnable) || (best_mode==IPCM))
{
currMB->delta_qp = 0;
currMB->qp = currMB->prev_qp;
set_chroma_qp(currMB);
img->qp = currMB->qp;
currMB->prev_cbp = 0;
}
set_stored_macroblock_parameters ();
// Rate control
if(input->RCEnable)
update_rc(currMB, best_mode);
handle_qp(currMB, best_mode);
rdopt->min_rdcost = min_rdcost;
if ( (img->MbaffFrameFlag)
&& (img->current_mb_nr%2)
&& (currMB->mb_type ? 0:((bslice) ? !currMB->cbp:1)) // bottom is skip
&& (prevMB->mb_type ? 0:((bslice) ? !prevMB->cbp:1))
&& !(field_flag_inference() == enc_mb.curr_mb_field)) // top is skip
{
rdopt->min_rdcost = 1e30; // don't allow coding of a MB pair as skip if wrong inference
}
//===== Decide if this MB will restrict the reference frames =====
if (input->RestrictRef)
update_refresh_map(intra, intra1, currMB);
if(input->SearchMode == UM_HEX)
{
UMHEX_skip_intrabk_SAD(best_mode, listXsize[enc_mb.list_offset[LIST_0]]);
}
else if(input->SearchMode == UM_HEX_SIMPLE)
{
smpUMHEX_skip_intrabk_SAD(best_mode, listXsize[enc_mb.list_offset[LIST_0]]);
}
//--- constrain intra prediction ---
if(input->UseConstrainedIntraPred && (img->type==P_SLICE || img->type==B_SLICE))
{
img->intra_block[img->current_mb_nr] = IS_INTRA(currMB);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -