Merge "Using has_second_ref function to simplify the code."

This commit is contained in:
Dmitry Kovalev 2013-08-22 01:39:14 -07:00 committed by Gerrit Code Review
commit 96a1a59d21

View File

@ -282,12 +282,11 @@ unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
// left of the entries correpsonding to real macroblocks. // left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0. // The prediction flags in these dummy entries are initialised to 0.
if (above_in_image && left_in_image) { // both edges available if (above_in_image && left_in_image) { // both edges available
if (above_intra && left_intra) { if (above_intra && left_intra) { // intra/intra
pred_context = 2; pred_context = 2;
} else if (above_intra || left_intra) { } else if (above_intra || left_intra) { // intra/inter or inter/intra
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi; const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) {
if (edge_mbmi->ref_frame[1] <= INTRA_FRAME) {
if (edge_mbmi->ref_frame[0] == LAST_FRAME) if (edge_mbmi->ref_frame[0] == LAST_FRAME)
pred_context = 3; pred_context = 3;
else else
@ -296,54 +295,53 @@ unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME || pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME ||
edge_mbmi->ref_frame[1] == GOLDEN_FRAME); edge_mbmi->ref_frame[1] == GOLDEN_FRAME);
} }
} else if (above_mbmi->ref_frame[1] <= INTRA_FRAME && } else { // inter/inter
left_mbmi->ref_frame[1] <= INTRA_FRAME) { if (!has_second_ref(above_mbmi) && !has_second_ref(left_mbmi)) {
if (above_mbmi->ref_frame[0] == LAST_FRAME && if (above_mbmi->ref_frame[0] == LAST_FRAME &&
left_mbmi->ref_frame[0] == LAST_FRAME) { left_mbmi->ref_frame[0] == LAST_FRAME) {
pred_context = 3; pred_context = 3;
} else if (above_mbmi->ref_frame[0] == LAST_FRAME || } else if (above_mbmi->ref_frame[0] == LAST_FRAME ||
left_mbmi->ref_frame[0] == LAST_FRAME) { left_mbmi->ref_frame[0] == LAST_FRAME) {
const MB_MODE_INFO *edge_mbmi = above_mbmi->ref_frame[0] == LAST_FRAME ? const MB_MODE_INFO *edge_mbmi =
left_mbmi : above_mbmi; above_mbmi->ref_frame[0] == LAST_FRAME ? left_mbmi : above_mbmi;
pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME); pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME);
} else {
pred_context = 2 * (above_mbmi->ref_frame[0] == GOLDEN_FRAME) +
2 * (left_mbmi->ref_frame[0] == GOLDEN_FRAME);
}
} else if (has_second_ref(above_mbmi) && has_second_ref(left_mbmi)) {
if (above_mbmi->ref_frame[0] == left_mbmi->ref_frame[0] &&
above_mbmi->ref_frame[1] == left_mbmi->ref_frame[1])
pred_context = 3 * (above_mbmi->ref_frame[0] == GOLDEN_FRAME ||
above_mbmi->ref_frame[1] == GOLDEN_FRAME ||
left_mbmi->ref_frame[0] == GOLDEN_FRAME ||
left_mbmi->ref_frame[1] == GOLDEN_FRAME);
else
pred_context = 2;
} else { } else {
pred_context = 2 * (above_mbmi->ref_frame[0] == GOLDEN_FRAME) + const MV_REFERENCE_FRAME rfs = !has_second_ref(above_mbmi) ?
2 * (left_mbmi->ref_frame[0] == GOLDEN_FRAME); above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0];
} const MV_REFERENCE_FRAME crf1 = has_second_ref(above_mbmi) ?
} else if (above_mbmi->ref_frame[1] > INTRA_FRAME && above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0];
left_mbmi->ref_frame[1] > INTRA_FRAME) { const MV_REFERENCE_FRAME crf2 = has_second_ref(above_mbmi) ?
if (above_mbmi->ref_frame[0] == left_mbmi->ref_frame[0] && above_mbmi->ref_frame[1] : left_mbmi->ref_frame[1];
above_mbmi->ref_frame[1] == left_mbmi->ref_frame[1])
pred_context = 3 * (above_mbmi->ref_frame[0] == GOLDEN_FRAME ||
above_mbmi->ref_frame[1] == GOLDEN_FRAME ||
left_mbmi->ref_frame[0] == GOLDEN_FRAME ||
left_mbmi->ref_frame[1] == GOLDEN_FRAME);
else
pred_context = 2;
} else {
MV_REFERENCE_FRAME rfs = above_mbmi->ref_frame[1] <= INTRA_FRAME ?
above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0];
MV_REFERENCE_FRAME crf1 = above_mbmi->ref_frame[1] > INTRA_FRAME ?
above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0];
MV_REFERENCE_FRAME crf2 = above_mbmi->ref_frame[1] > INTRA_FRAME ?
above_mbmi->ref_frame[1] : left_mbmi->ref_frame[1];
if (rfs == GOLDEN_FRAME) if (rfs == GOLDEN_FRAME)
pred_context = 3 + (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME); pred_context = 3 + (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME);
else if (rfs == ALTREF_FRAME) else if (rfs == ALTREF_FRAME)
pred_context = crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME; pred_context = crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME;
else else
pred_context = 1 + 2 * (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME); pred_context = 1 + 2 * (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME);
}
} }
} else if (above_in_image || left_in_image) { // one edge available } else if (above_in_image || left_in_image) { // one edge available
const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi; const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
if (edge_mbmi->ref_frame[0] == INTRA_FRAME || if (!is_inter_block(edge_mbmi) ||
(edge_mbmi->ref_frame[0] == LAST_FRAME && (edge_mbmi->ref_frame[0] == LAST_FRAME && !has_second_ref(edge_mbmi)))
edge_mbmi->ref_frame[1] <= INTRA_FRAME))
pred_context = 2; pred_context = 2;
else if (edge_mbmi->ref_frame[1] <= INTRA_FRAME) else if (!has_second_ref(edge_mbmi))
pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME); pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME);
else else
pred_context = 3 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME || pred_context = 3 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME ||