Commit 5baf510f authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review
Browse files

Merge "Adding has_second_ref function."

parents 039b0c4c d8286dd5
...@@ -161,10 +161,14 @@ typedef struct { ...@@ -161,10 +161,14 @@ typedef struct {
union b_mode_info bmi[4]; union b_mode_info bmi[4];
} MODE_INFO; } MODE_INFO;
static int is_inter_block(const MB_MODE_INFO *mbmi) { static INLINE int is_inter_block(const MB_MODE_INFO *mbmi) {
return mbmi->ref_frame[0] > INTRA_FRAME; return mbmi->ref_frame[0] > INTRA_FRAME;
} }
static INLINE int has_second_ref(const MB_MODE_INFO *mbmi) {
return mbmi->ref_frame[1] > INTRA_FRAME;
}
enum mv_precision { enum mv_precision {
MV_PRECISION_Q3, MV_PRECISION_Q3,
MV_PRECISION_Q4 MV_PRECISION_Q4
......
...@@ -216,52 +216,53 @@ unsigned char vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) { ...@@ -216,52 +216,53 @@ unsigned char vp9_get_pred_context_single_ref_p1(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)
pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME); pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME);
else else
pred_context = 1 + (edge_mbmi->ref_frame[0] == LAST_FRAME || pred_context = 1 + (edge_mbmi->ref_frame[0] == LAST_FRAME ||
edge_mbmi->ref_frame[1] == LAST_FRAME); edge_mbmi->ref_frame[1] == LAST_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)) {
pred_context = 2 * (above_mbmi->ref_frame[0] == LAST_FRAME) + pred_context = 2 * (above_mbmi->ref_frame[0] == LAST_FRAME) +
2 * (left_mbmi->ref_frame[0] == LAST_FRAME); 2 * (left_mbmi->ref_frame[0] == LAST_FRAME);
} else if (above_mbmi->ref_frame[1] > INTRA_FRAME && } else if (has_second_ref(above_mbmi) && has_second_ref(left_mbmi)) {
left_mbmi->ref_frame[1] > INTRA_FRAME) { pred_context = 1 + (above_mbmi->ref_frame[0] == LAST_FRAME ||
pred_context = 1 + (above_mbmi->ref_frame[0] == LAST_FRAME || above_mbmi->ref_frame[1] == LAST_FRAME ||
above_mbmi->ref_frame[1] == LAST_FRAME || left_mbmi->ref_frame[0] == LAST_FRAME ||
left_mbmi->ref_frame[0] == LAST_FRAME || left_mbmi->ref_frame[1] == LAST_FRAME);
left_mbmi->ref_frame[1] == LAST_FRAME); } else {
} else { const MV_REFERENCE_FRAME rfs = !has_second_ref(above_mbmi) ?
MV_REFERENCE_FRAME rfs = above_mbmi->ref_frame[1] <= INTRA_FRAME ? above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0];
above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0]; const MV_REFERENCE_FRAME crf1 = has_second_ref(above_mbmi) ?
MV_REFERENCE_FRAME crf1 = above_mbmi->ref_frame[1] > INTRA_FRAME ? above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0];
above_mbmi->ref_frame[0] : left_mbmi->ref_frame[0]; const MV_REFERENCE_FRAME crf2 = has_second_ref(above_mbmi) ?
MV_REFERENCE_FRAME crf2 = above_mbmi->ref_frame[1] > INTRA_FRAME ? above_mbmi->ref_frame[1] : left_mbmi->ref_frame[1];
above_mbmi->ref_frame[1] : left_mbmi->ref_frame[1];
if (rfs == LAST_FRAME)
if (rfs == LAST_FRAME) pred_context = 3 + (crf1 == LAST_FRAME || crf2 == LAST_FRAME);
pred_context = 3 + (crf1 == LAST_FRAME || crf2 == LAST_FRAME); else
else pred_context = crf1 == LAST_FRAME || crf2 == LAST_FRAME;
pred_context = crf1 == LAST_FRAME || crf2 == LAST_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 (!is_inter_block(edge_mbmi)) { // intra
if (edge_mbmi->ref_frame[0] == INTRA_FRAME)
pred_context = 2; pred_context = 2;
else if (edge_mbmi->ref_frame[1] <= INTRA_FRAME) } else { // inter
pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME); if (!has_second_ref(edge_mbmi))
else pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME);
pred_context = 1 + (edge_mbmi->ref_frame[0] == LAST_FRAME || else
edge_mbmi->ref_frame[1] == LAST_FRAME); pred_context = 1 + (edge_mbmi->ref_frame[0] == LAST_FRAME ||
} else { // no edges available (2) edge_mbmi->ref_frame[1] == LAST_FRAME);
}
} else { // no edges available
pred_context = 2; pred_context = 2;
} }
assert(pred_context >= 0 && pred_context < REF_CONTEXTS); assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context; return pred_context;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment