Merge "Added another reference frame LAST4_FRAME" into nextgen

This commit is contained in:
Zoe Liu 2015-09-24 15:58:22 +00:00 committed by Gerrit Code Review
commit a9900eb2b1
19 changed files with 1558 additions and 35 deletions

1
configure vendored
View File

@ -308,6 +308,7 @@ EXPERIMENT_LIST="
sr_mode sr_mode
multi_ref multi_ref
last3_ref last3_ref
last4_ref
" "
CONFIG_LIST=" CONFIG_LIST="
external_build external_build

View File

@ -67,14 +67,25 @@ extern "C" {
#define REF_CONTEXTS 5 #define REF_CONTEXTS 5
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
#define SINGLE_REFS 6
#define COMP_REFS 5
#else // CONFIG_LAST4_REF
#define SINGLE_REFS 5 #define SINGLE_REFS 5
#define COMP_REFS 4 #define COMP_REFS 4
#else #endif // CONFIG_LAST4_REF
#else // LAST3_REF
#define SINGLE_REFS 4 #define SINGLE_REFS 4
#define COMP_REFS 3 #define COMP_REFS 3
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else
#else // CONFIG_MULTI_REF
#define SINGLE_REFS 3 #define SINGLE_REFS 3
#define COMP_REFS 2 #define COMP_REFS 2
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -222,14 +233,21 @@ typedef enum {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
LAST2_FRAME = 2, LAST2_FRAME = 2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
LAST3_FRAME = 3,
LAST4_FRAME = 4,
GOLDEN_FRAME = 5,
ALTREF_FRAME = 6,
#else // CONFIG_LAST4_REF
LAST3_FRAME = 3, LAST3_FRAME = 3,
GOLDEN_FRAME = 4, GOLDEN_FRAME = 4,
ALTREF_FRAME = 5, ALTREF_FRAME = 5,
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
GOLDEN_FRAME = 3, GOLDEN_FRAME = 3,
ALTREF_FRAME = 4, ALTREF_FRAME = 4,
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
GOLDEN_FRAME = 2, GOLDEN_FRAME = 2,
ALTREF_FRAME = 3, ALTREF_FRAME = 3,
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF

View File

@ -420,19 +420,27 @@ static const vp9_prob default_single_ref_probs[REF_CONTEXTS][SINGLE_REFS - 1] =
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
// TODO(zoeliu): To adjust the initial prob values. // TODO(zoeliu): To adjust the initial prob values.
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
{ 33, 16, 16, 16, 16 },
{ 77, 74, 74, 74, 74 },
{ 142, 142, 142, 142, 142 },
{ 172, 170, 170, 170, 170 },
{ 238, 247, 247, 247, 247 }
#else // CONFIG_LAST4_REF
{ 33, 16, 16, 16 }, { 33, 16, 16, 16 },
{ 77, 74, 74, 74 }, { 77, 74, 74, 74 },
{ 142, 142, 142, 142 }, { 142, 142, 142, 142 },
{ 172, 170, 170, 170 }, { 172, 170, 170, 170 },
{ 238, 247, 247, 247 } { 238, 247, 247, 247 }
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
{ 33, 16, 16 }, { 33, 16, 16 },
{ 77, 74, 74 }, { 77, 74, 74 },
{ 142, 142, 142 }, { 142, 142, 142 },
{ 172, 170, 170 }, { 172, 170, 170 },
{ 238, 247, 247 } { 238, 247, 247 }
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
{ 33, 16 }, { 33, 16 },
{ 77, 74 }, { 77, 74 },
{ 142, 142 }, { 142, 142 },
@ -445,19 +453,27 @@ static const vp9_prob default_comp_ref_probs[REF_CONTEXTS][COMP_REFS - 1] = {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
// TODO(zoeliu): To adjust the initial prob values. // TODO(zoeliu): To adjust the initial prob values.
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
{ 33, 16, 16, 16 },
{ 77, 74, 74, 74 },
{ 142, 142, 142, 142 },
{ 172, 170, 170, 170 },
{ 238, 247, 247, 247 }
#else // CONFIG_LAST4_REF
{ 33, 16, 16 }, { 33, 16, 16 },
{ 77, 74, 74 }, { 77, 74, 74 },
{ 142, 142, 142 }, { 142, 142, 142 },
{ 172, 170, 170 }, { 172, 170, 170 },
{ 238, 247, 247 } { 238, 247, 247 }
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
{ 33, 16 }, { 33, 16 },
{ 77, 74 }, { 77, 74 },
{ 142, 142 }, { 142, 142 },
{ 172, 170 }, { 172, 170 },
{ 238, 247 } { 238, 247 }
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
{ 50 }, { 126 }, { 123 }, { 221 }, { 226 } { 50 }, { 126 }, { 123 }, { 221 }, { 226 }
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
}; };
@ -1333,6 +1349,9 @@ static void set_default_lf_deltas(struct loopfilter *lf) {
lf->ref_deltas[LAST2_FRAME] = lf->ref_deltas[LAST_FRAME]; lf->ref_deltas[LAST2_FRAME] = lf->ref_deltas[LAST_FRAME];
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
lf->ref_deltas[LAST3_FRAME] = lf->ref_deltas[LAST_FRAME]; lf->ref_deltas[LAST3_FRAME] = lf->ref_deltas[LAST_FRAME];
#if CONFIG_LAST4_REF
lf->ref_deltas[LAST4_FRAME] = lf->ref_deltas[LAST_FRAME];
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
lf->ref_deltas[GOLDEN_FRAME] = -1; lf->ref_deltas[GOLDEN_FRAME] = -1;

View File

@ -198,13 +198,19 @@ typedef enum {
VP9_LAST2_FLAG = 1 << 1, VP9_LAST2_FLAG = 1 << 1,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
VP9_LAST3_FLAG = 1 << 2, VP9_LAST3_FLAG = 1 << 2,
#if CONFIG_LAST4_REF
VP9_LAST4_FLAG = 1 << 3,
VP9_GOLD_FLAG = 1 << 4,
VP9_ALT_FLAG = 1 << 5,
#else // CONFIG_LAST4_REF
VP9_GOLD_FLAG = 1 << 3, VP9_GOLD_FLAG = 1 << 3,
VP9_ALT_FLAG = 1 << 4, VP9_ALT_FLAG = 1 << 4,
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
VP9_GOLD_FLAG = 1 << 2, VP9_GOLD_FLAG = 1 << 2,
VP9_ALT_FLAG = 1 << 3, VP9_ALT_FLAG = 1 << 3,
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
VP9_GOLD_FLAG = 1 << 1, VP9_GOLD_FLAG = 1 << 1,
VP9_ALT_FLAG = 1 << 2, VP9_ALT_FLAG = 1 << 2,
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF

View File

@ -28,11 +28,15 @@ extern "C" {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
#define MAX_REF_LF_DELTAS 7
#else // CONFIG_LAST4_REF
#define MAX_REF_LF_DELTAS 6 #define MAX_REF_LF_DELTAS 6
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
#define MAX_REF_LF_DELTAS 5 #define MAX_REF_LF_DELTAS 5
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
#define MAX_REF_LF_DELTAS 4 #define MAX_REF_LF_DELTAS 4
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -112,7 +116,10 @@ struct loopfilter {
uint8_t mode_ref_delta_enabled; uint8_t mode_ref_delta_enabled;
uint8_t mode_ref_delta_update; uint8_t mode_ref_delta_update;
// 0 = Intra, Last, Last2(CONFIG_MULTI_REF), GF, ARF // 0 = Intra, Last, Last2(CONFIG_MULTI_REF),
// Last3(CONFIG_LAST3_REF),
// Last4(CONFIG_LAST4_REF),
// GF, ARF
signed char ref_deltas[MAX_REF_LF_DELTAS]; signed char ref_deltas[MAX_REF_LF_DELTAS];
signed char last_ref_deltas[MAX_REF_LF_DELTAS]; signed char last_ref_deltas[MAX_REF_LF_DELTAS];

View File

@ -32,11 +32,15 @@ extern "C" {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
#define REFS_PER_FRAME 6
#else // CONFIG_LAST4_REF
#define REFS_PER_FRAME 5 #define REFS_PER_FRAME 5
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
#define REFS_PER_FRAME 4 #define REFS_PER_FRAME 4
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
#define REFS_PER_FRAME 3 #define REFS_PER_FRAME 3
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -135,7 +139,11 @@ typedef struct VP9Common {
FRAME_TYPE frame_type; FRAME_TYPE frame_type;
#if CONFIG_MULTI_REF && CONFIG_LAST3_REF #if CONFIG_MULTI_REF && CONFIG_LAST3_REF
// frame type for the frame before the last // frame type for the frame before the last
FRAME_TYPE frame_before_last_type; FRAME_TYPE last2_frame_type;
#if CONFIG_LAST4_REF
// frame type for the frame two frames before the last
FRAME_TYPE last3_frame_type;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF #endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF
int show_frame; int show_frame;
@ -199,11 +207,15 @@ typedef struct VP9Common {
MV_REFERENCE_FRAME comp_fixed_ref; MV_REFERENCE_FRAME comp_fixed_ref;
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
MV_REFERENCE_FRAME comp_var_ref[5];
#else // CONFIG_LAST4_REF
MV_REFERENCE_FRAME comp_var_ref[4]; MV_REFERENCE_FRAME comp_var_ref[4];
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
MV_REFERENCE_FRAME comp_var_ref[3]; MV_REFERENCE_FRAME comp_var_ref[3];
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
MV_REFERENCE_FRAME comp_var_ref[2]; MV_REFERENCE_FRAME comp_var_ref[2];
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
REFERENCE_MODE reference_mode; REFERENCE_MODE reference_mode;

View File

@ -119,6 +119,417 @@ int vp9_get_reference_mode_context(const VP9_COMMON *cm,
#define CHECK_GOLDEN_OR_LAST3(ref_frame) \ #define CHECK_GOLDEN_OR_LAST3(ref_frame) \
((ref_frame == GOLDEN_FRAME) || (ref_frame == LAST3_FRAME)) ((ref_frame == GOLDEN_FRAME) || (ref_frame == LAST3_FRAME))
#if CONFIG_LAST4_REF
#define CHECK_GOLDEN_LAST3_LAST4(ref_frame) \
((ref_frame == GOLDEN_FRAME) || (ref_frame == LAST3_FRAME) || \
(ref_frame == LAST4_FRAME))
// TODO(zoeliu): Would like to create a master function.
// Returns a context number for the given MB prediction signal
// Signal the first reference frame for a compound mode is either
// GOLDEN/LAST3/LAST4, or LAST/LAST2.
//
// NOTE(zoeliu): The probability of ref_frame[0] is either
// GOLDEN_FRAME/LAST3_FRAME/LAST4_FRAME.
int vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int above_in_image = above_mbmi != NULL;
const int left_in_image = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int var_ref_idx = !fix_ref_idx;
if (above_in_image && left_in_image) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra (2)
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) // single pred (1/3)
pred_context = 1 +
2 * (!CHECK_GOLDEN_LAST3_LAST4(edge_mbmi->ref_frame[0]));
else // comp pred (1/3)
pred_context = 1 +
2 * (!CHECK_GOLDEN_LAST3_LAST4(edge_mbmi->ref_frame[var_ref_idx]));
} else { // inter/inter
const int l_sg = !has_second_ref(left_mbmi);
const int a_sg = !has_second_ref(above_mbmi);
const MV_REFERENCE_FRAME vrfa = a_sg ? above_mbmi->ref_frame[0]
: above_mbmi->ref_frame[var_ref_idx];
const MV_REFERENCE_FRAME vrfl = l_sg ? left_mbmi->ref_frame[0]
: left_mbmi->ref_frame[var_ref_idx];
if (vrfa == vrfl && CHECK_GOLDEN_LAST3_LAST4(vrfa)) {
pred_context = 0;
} else if (l_sg && a_sg) { // single/single
if ((vrfa == ALTREF_FRAME && CHECK_LAST_OR_LAST2(vrfl)) ||
(vrfl == ALTREF_FRAME && CHECK_LAST_OR_LAST2(vrfa))) {
pred_context = 4;
} else if (vrfa == vrfl || (CHECK_LAST_OR_LAST2(vrfa) &&
CHECK_LAST_OR_LAST2(vrfl))) {
pred_context = 3;
} else { // Either vrfa or vrfl is GOLDEN / LAST3 / LAST4
// NOTE(zoeliu): Following assert may be removed once confirmed.
assert(CHECK_GOLDEN_LAST3_LAST4(vrfa) ||
CHECK_GOLDEN_LAST3_LAST4(vrfl));
pred_context = 1;
}
} else if (l_sg || a_sg) { // single/comp
const MV_REFERENCE_FRAME vrfc = l_sg ? vrfa : vrfl;
const MV_REFERENCE_FRAME rfs = a_sg ? vrfa : vrfl;
if (CHECK_GOLDEN_LAST3_LAST4(vrfc) && !CHECK_GOLDEN_LAST3_LAST4(rfs))
pred_context = 1;
else if (CHECK_GOLDEN_LAST3_LAST4(rfs) &&
!CHECK_GOLDEN_LAST3_LAST4(vrfc))
pred_context = 2;
else
pred_context = 4;
} else { // comp/comp
if ((CHECK_LAST_OR_LAST2(vrfa) && CHECK_LAST_OR_LAST2(vrfl))) {
pred_context = 4;
} else {
// NOTE(zoeliu): Following assert may be removed once confirmed.
assert(CHECK_GOLDEN_LAST3_LAST4(vrfa) ||
CHECK_GOLDEN_LAST3_LAST4(vrfl));
pred_context = 2;
}
}
}
} else if (above_in_image || left_in_image) { // one edge available
const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi)) {
pred_context = 2;
} else {
if (has_second_ref(edge_mbmi))
pred_context =
4 * (!CHECK_GOLDEN_LAST3_LAST4(edge_mbmi->ref_frame[var_ref_idx]));
else
pred_context = 3 * (!CHECK_GOLDEN_LAST3_LAST4(edge_mbmi->ref_frame[0]));
}
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
// Returns a context number for the given MB prediction signal
// Signal the first reference frame for a compound mode is LAST,
// conditioning on that it is known either LAST/LAST2.
//
// NOTE(zoeliu): The probability of ref_frame[0] is LAST_FRAME,
// conditioning on it is either LAST_FRAME or LAST2_FRAME.
int vp9_get_pred_context_comp_ref_p1(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int above_in_image = above_mbmi != NULL;
const int left_in_image = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int var_ref_idx = !fix_ref_idx;
if (above_in_image && left_in_image) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra (2)
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) // single pred (1/3)
pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] != LAST_FRAME);
else // comp pred (1/3)
pred_context = 1 + 2 * (edge_mbmi->ref_frame[var_ref_idx]
!= LAST_FRAME);
} else { // inter/inter
const int l_sg = !has_second_ref(left_mbmi);
const int a_sg = !has_second_ref(above_mbmi);
const MV_REFERENCE_FRAME vrfa = a_sg ? above_mbmi->ref_frame[0]
: above_mbmi->ref_frame[var_ref_idx];
const MV_REFERENCE_FRAME vrfl = l_sg ? left_mbmi->ref_frame[0]
: left_mbmi->ref_frame[var_ref_idx];
if (vrfa == vrfl && vrfa == LAST_FRAME)
pred_context = 0;
else if (l_sg && a_sg) { // single/single
if (vrfa == LAST_FRAME || vrfl == LAST_FRAME)
pred_context = 1;
else if (CHECK_GOLDEN_LAST3_LAST4(vrfa) ||
CHECK_GOLDEN_LAST3_LAST4(vrfl))
pred_context = 2 + (vrfa != vrfl);
else if (vrfa == vrfl)
pred_context = 3;
else
pred_context = 4;
} else if (l_sg || a_sg) { // single/comp
const MV_REFERENCE_FRAME vrfc = l_sg ? vrfa : vrfl;
const MV_REFERENCE_FRAME rfs = a_sg ? vrfa : vrfl;
if (vrfc == LAST_FRAME && rfs != LAST_FRAME)
pred_context = 1;
else if (rfs == LAST_FRAME && vrfc != LAST_FRAME)
pred_context = 2;
else
pred_context = 3 +
(vrfc == LAST2_FRAME || CHECK_GOLDEN_LAST3_LAST4(rfs));
} else { // comp/comp
if (vrfa == LAST_FRAME || vrfl == LAST_FRAME)
pred_context = 2;
else
pred_context = 3 + (CHECK_GOLDEN_LAST3_LAST4(vrfa) ||
CHECK_GOLDEN_LAST3_LAST4(vrfl));
}
}
} else if (above_in_image || left_in_image) { // one edge available
const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi)) {
pred_context = 2;
} else {
if (has_second_ref(edge_mbmi)) {
pred_context = 4 * (edge_mbmi->ref_frame[var_ref_idx] != LAST_FRAME);
} else {
if (edge_mbmi->ref_frame[0] == LAST_FRAME)
pred_context = 0;
else
pred_context = 2 + CHECK_GOLDEN_LAST3_LAST4(edge_mbmi->ref_frame[0]);
}
}
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
#define CHECK_LAST3_OR_LAST4(ref_frame) \
((ref_frame == LAST3_FRAME) || (ref_frame == LAST4_FRAME))
// Returns a context number for the given MB prediction signal
// Signal the first reference frame for a compound mode is GOLDEN,
// conditioning on that it is known either GOLDEN/LAST3/LAST4.
//
// NOTE(zoeliu): The probability of ref_frame[0] is GOLDEN_FRAME,
// conditioning on it is either GOLDEN / LAST3 / LAST4.
int vp9_get_pred_context_comp_ref_p2(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int above_in_image = above_mbmi != NULL;
const int left_in_image = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int var_ref_idx = !fix_ref_idx;
if (above_in_image && left_in_image) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra (2)
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) // single pred (1/3)
pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] != GOLDEN_FRAME);
else // comp pred (1/3)
pred_context = 1 +
2 * (edge_mbmi->ref_frame[var_ref_idx] != GOLDEN_FRAME);
} else { // inter/inter
const int l_sg = !has_second_ref(left_mbmi);
const int a_sg = !has_second_ref(above_mbmi);
const MV_REFERENCE_FRAME vrfa = a_sg ? above_mbmi->ref_frame[0]
: above_mbmi->ref_frame[var_ref_idx];
const MV_REFERENCE_FRAME vrfl = l_sg ? left_mbmi->ref_frame[0]
: left_mbmi->ref_frame[var_ref_idx];
if (vrfa == vrfl && vrfa == GOLDEN_FRAME)
pred_context = 0;
else if (l_sg && a_sg) { // single/single
if (vrfa == GOLDEN_FRAME || vrfl == GOLDEN_FRAME)
pred_context = 1;
else if (CHECK_LAST_OR_LAST2(vrfa) || CHECK_LAST_OR_LAST2(vrfl))
pred_context = 2 + (vrfa != vrfl);
else if (vrfa == vrfl)
pred_context = 3;
else
pred_context = 4;
} else if (l_sg || a_sg) { // single/comp
const MV_REFERENCE_FRAME vrfc = l_sg ? vrfa : vrfl;
const MV_REFERENCE_FRAME rfs = a_sg ? vrfa : vrfl;
if (vrfc == GOLDEN_FRAME && rfs != GOLDEN_FRAME)
pred_context = 1;
else if (rfs == GOLDEN_FRAME && vrfc != GOLDEN_FRAME)
pred_context = 2;
else
pred_context = 3 +
(CHECK_LAST3_OR_LAST4(vrfc) || CHECK_LAST_OR_LAST2(rfs));
} else { // comp/comp
if (vrfa == GOLDEN_FRAME || vrfl == GOLDEN_FRAME)
pred_context = 2;
else
pred_context = 3 +
(CHECK_LAST_OR_LAST2(vrfa) || CHECK_LAST_OR_LAST2(vrfl));
}
}
} else if (above_in_image || left_in_image) { // one edge available
const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi)) {
pred_context = 2;
} else {
if (has_second_ref(edge_mbmi)) {
pred_context = 4 * (edge_mbmi->ref_frame[var_ref_idx] != GOLDEN_FRAME);
} else {
if (edge_mbmi->ref_frame[0] == GOLDEN_FRAME)
pred_context = 0;
else
pred_context = 2 + CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]);
}
}
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
#define CHECK_LAST_LAST2_GOLDEN(ref_frame) \
((ref_frame == LAST_FRAME) || (ref_frame == LAST2_FRAME) || \
(ref_frame == GOLDEN_FRAME))
// Returns a context number for the given MB prediction signal
// Signal the first reference frame for a compound mode is LAST3,
// conditioning on that it is known either LAST3/LAST4.
//
// NOTE(zoeliu): The probability of ref_frame[0] is LAST3_FRAME,
// conditioning on it is either LAST3 / LAST4.
int vp9_get_pred_context_comp_ref_p3(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int above_in_image = above_mbmi != NULL;
const int left_in_image = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int var_ref_idx = !fix_ref_idx;
if (above_in_image && left_in_image) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra (2)
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) // single pred (1/3)
pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] != LAST3_FRAME);
else // comp pred (1/3)
pred_context = 1 +
2 * (edge_mbmi->ref_frame[var_ref_idx] != LAST3_FRAME);
} else { // inter/inter
const int l_sg = !has_second_ref(left_mbmi);
const int a_sg = !has_second_ref(above_mbmi);
const MV_REFERENCE_FRAME vrfa = a_sg ? above_mbmi->ref_frame[0]
: above_mbmi->ref_frame[var_ref_idx];
const MV_REFERENCE_FRAME vrfl = l_sg ? left_mbmi->ref_frame[0]
: left_mbmi->ref_frame[var_ref_idx];
if (vrfa == vrfl && vrfa == LAST3_FRAME)
pred_context = 0;
else if (l_sg && a_sg) { // single/single
if (vrfa == LAST3_FRAME || vrfl == LAST3_FRAME)
pred_context = 1;
else if (CHECK_LAST_LAST2_GOLDEN(vrfa) || CHECK_LAST_LAST2_GOLDEN(vrfl))
pred_context = 2 + (vrfa != vrfl);
else if (vrfa == vrfl)
pred_context = 3;
else
pred_context = 4;
} else if (l_sg || a_sg) { // single/comp
const MV_REFERENCE_FRAME vrfc = l_sg ? vrfa : vrfl;
const MV_REFERENCE_FRAME rfs = a_sg ? vrfa : vrfl;
if (vrfc == LAST3_FRAME && rfs != LAST3_FRAME)
pred_context = 1;
else if (rfs == LAST3_FRAME && vrfc != LAST3_FRAME)
pred_context = 2;
else
pred_context = 3 +
(vrfc == LAST4_FRAME || CHECK_LAST_LAST2_GOLDEN(rfs));
} else { // comp/comp
if (vrfa == LAST3_FRAME || vrfl == LAST3_FRAME)
pred_context = 2;
else
pred_context = 3 +
(CHECK_LAST_LAST2_GOLDEN(vrfa) || CHECK_LAST_LAST2_GOLDEN(vrfl));
}
}
} else if (above_in_image || left_in_image) { // one edge available
const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi)) {
pred_context = 2;
} else {
if (has_second_ref(edge_mbmi)) {
pred_context = 4 * (edge_mbmi->ref_frame[var_ref_idx] != LAST3_FRAME);
} else {
if (edge_mbmi->ref_frame[0] == LAST3_FRAME)
pred_context = 0;
else
pred_context = 2 + CHECK_LAST_LAST2_GOLDEN(edge_mbmi->ref_frame[0]);
}
}
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
#else // CONFIG_LAST4_REF
// Returns a context number for the given MB prediction signal // Returns a context number for the given MB prediction signal
// Signal the first reference frame for a compound mode is GOLDEN. // Signal the first reference frame for a compound mode is GOLDEN.
// //
@ -411,6 +822,8 @@ int vp9_get_pred_context_comp_ref_p2(const VP9_COMMON *cm,
return pred_context; return pred_context;
} }
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
// Returns a context number for the given MB prediction signal // Returns a context number for the given MB prediction signal
@ -693,6 +1106,473 @@ int vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
((ref_frame == LAST_FRAME) || (ref_frame == LAST2_FRAME) || \ ((ref_frame == LAST_FRAME) || (ref_frame == LAST2_FRAME) || \
(ref_frame == LAST3_FRAME)) (ref_frame == LAST3_FRAME))
#if CONFIG_LAST4_REF
#define CHECK_GOLDEN_OR_ALTREF(ref_frame) \
((ref_frame == GOLDEN_FRAME) || (ref_frame == ALTREF_FRAME))
// For the bit to signal whether the single reference is a ALTREF_FRAME
// or a GOLDEN_FRAME.
//
// NOTE(zoeliu): The probability of ref_frame[0] is ALTREF/GOLDEN.
int vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int has_above = above_mbmi != NULL;
const int has_left = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi))
pred_context = 4 * (!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]));
else
pred_context = 1 + (!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]) ||
!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[1]));
} else { // inter/inter
const int above_has_second = has_second_ref(above_mbmi);
const int left_has_second = has_second_ref(left_mbmi);
const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
if (above_has_second && left_has_second) {
pred_context = 1 + (!CHECK_GOLDEN_OR_ALTREF(above0) ||
!CHECK_GOLDEN_OR_ALTREF(above1) ||
!CHECK_GOLDEN_OR_ALTREF(left0) ||
!CHECK_GOLDEN_OR_ALTREF(left1));
} else if (above_has_second || left_has_second) {
const MV_REFERENCE_FRAME rfs = !above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf1 = above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf2 = above_has_second ? above1 : left1;
if (!CHECK_GOLDEN_OR_ALTREF(rfs))
pred_context = 3 + (!CHECK_GOLDEN_OR_ALTREF(crf1) ||
!CHECK_GOLDEN_OR_ALTREF(crf2));
else
pred_context = !CHECK_GOLDEN_OR_ALTREF(crf1) ||
!CHECK_GOLDEN_OR_ALTREF(crf2);
} else {
pred_context = 2 * (!CHECK_GOLDEN_OR_ALTREF(above0)) +
2 * (!CHECK_GOLDEN_OR_ALTREF(left0));
}
}
} else if (has_above || has_left) { // one edge available
const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi)) { // intra
pred_context = 2;
} else { // inter
if (!has_second_ref(edge_mbmi))
pred_context = 4 * (!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]));
else
pred_context = 1 + (!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]) ||
!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[1]));
}
} else { // no edges available
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
// For the bit to signal whether the single reference is ALTREF_FRAME or
// GOLDEN_FRAME, knowing that it shall be either of these 2 choices.
//
// NOTE(zoeliu): The probability of ref_frame[0] is ALTREF_FRAME, conditioning
// on it is either ALTREF_FRAME/GOLDEN_FRAME.
int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int has_above = above_mbmi != NULL;
const int has_left = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) {
if (!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]))
pred_context = 3;
else
pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME);
} else {
pred_context = 1 + 2 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME ||
edge_mbmi->ref_frame[1] == GOLDEN_FRAME);
}
} else { // inter/inter
const int above_has_second = has_second_ref(above_mbmi);
const int left_has_second = has_second_ref(left_mbmi);
const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
if (above_has_second && left_has_second) {
if (above0 == left0 && above1 == left1)
pred_context = 3 * (above0 == GOLDEN_FRAME ||
above1 == GOLDEN_FRAME ||
left0 == GOLDEN_FRAME ||
left1 == GOLDEN_FRAME);
else
pred_context = 2;
} else if (above_has_second || left_has_second) {
const MV_REFERENCE_FRAME rfs = !above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf1 = above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf2 = above_has_second ? above1 : left1;
if (rfs == GOLDEN_FRAME)
pred_context = 3 + (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME);
else if (rfs == ALTREF_FRAME)
pred_context = (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME);
else
pred_context = 1 + 2 * (crf1 == GOLDEN_FRAME || crf2 == GOLDEN_FRAME);
} else {
if (!CHECK_GOLDEN_OR_ALTREF(above0) && !CHECK_GOLDEN_OR_ALTREF(left0)) {
pred_context = 2 + (above0 == left0);
} else if (!CHECK_GOLDEN_OR_ALTREF(above0) ||
!CHECK_GOLDEN_OR_ALTREF(left0)) {
const MV_REFERENCE_FRAME edge0 =
!CHECK_GOLDEN_OR_ALTREF(above0) ? left0 : above0;
pred_context = 4 * (edge0 == GOLDEN_FRAME);
} else {
pred_context = 2 * (above0 == GOLDEN_FRAME) +
2 * (left0 == GOLDEN_FRAME);
}
}
}
} else if (has_above || has_left) { // one edge available
const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi) ||
(!CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]) &&
!has_second_ref(edge_mbmi)))
pred_context = 2;
else if (!has_second_ref(edge_mbmi))
pred_context = 4 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME);
else
pred_context = 3 * (edge_mbmi->ref_frame[0] == GOLDEN_FRAME ||
edge_mbmi->ref_frame[1] == GOLDEN_FRAME);
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
// For the bit to signal whether the single reference is LAST3/LAST4 or
// LAST2/LAST, knowing that it shall be either of these 2 choices.
//
// NOTE(zoeliu): The probability of ref_frame[0] is LAST3/LAST4, conditioning
// on it is either LAST3/LAST4/LAST2/LAST.
int vp9_get_pred_context_single_ref_p3(const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int has_above = above_mbmi != NULL;
const int has_left = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) {
if (CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]))
pred_context = 3;
else
pred_context = 4 * CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]);
} else {
pred_context = 1 +
2 * (CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]) ||
CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[1]));
}
} else { // inter/inter
const int above_has_second = has_second_ref(above_mbmi);
const int left_has_second = has_second_ref(left_mbmi);
const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
if (above_has_second && left_has_second) {
if (above0 == left0 && above1 == left1)
pred_context = 3 * (CHECK_LAST_OR_LAST2(above0) ||
CHECK_LAST_OR_LAST2(above1) ||
CHECK_LAST_OR_LAST2(left0) ||
CHECK_LAST_OR_LAST2(left1));
else
pred_context = 2;
} else if (above_has_second || left_has_second) {
const MV_REFERENCE_FRAME rfs = !above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf1 = above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf2 = above_has_second ? above1 : left1;
if (CHECK_LAST_OR_LAST2(rfs))
pred_context = 3 + (CHECK_LAST_OR_LAST2(crf1) ||
CHECK_LAST_OR_LAST2(crf2));
else if (rfs == LAST3_FRAME || rfs == LAST4_FRAME)
pred_context = (CHECK_LAST_OR_LAST2(crf1) ||
CHECK_LAST_OR_LAST2(crf2));
else
pred_context = 1 + 2 * (CHECK_LAST_OR_LAST2(crf1) ||
CHECK_LAST_OR_LAST2(crf2));
} else {
if (CHECK_GOLDEN_OR_ALTREF(above0) && CHECK_GOLDEN_OR_ALTREF(left0)) {
pred_context = 2 + (above0 == left0);
} else if (CHECK_GOLDEN_OR_ALTREF(above0) ||
CHECK_GOLDEN_OR_ALTREF(left0)) {
const MV_REFERENCE_FRAME edge0 =
CHECK_GOLDEN_OR_ALTREF(above0) ? left0 : above0;
pred_context = 4 * CHECK_LAST_OR_LAST2(edge0);
} else {
pred_context = 2 * CHECK_LAST_OR_LAST2(above0) +
2 * CHECK_LAST_OR_LAST2(left0);
}
}
}
} else if (has_above || has_left) { // one edge available
const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi) ||
(CHECK_GOLDEN_OR_ALTREF(edge_mbmi->ref_frame[0]) &&
!has_second_ref(edge_mbmi)))
pred_context = 2;
else if (!has_second_ref(edge_mbmi))
pred_context = 4 * (CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]));
else
pred_context = 3 * (CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]) ||
CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[1]));
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
// For the bit to signal whether the single reference is LAST2_FRAME or
// LAST_FRAME, knowing that it shall be either of these 2 choices.
//
// NOTE(zoeliu): The probability of ref_frame[0] is LAST2_FRAME, conditioning
// on it is either LAST2_FRAME/LAST_FRAME.
int vp9_get_pred_context_single_ref_p4(const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int has_above = above_mbmi != NULL;
const int has_left = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) {
if (!CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]))
pred_context = 3;
else
pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME);
} else {
pred_context = 1 +
2 * (edge_mbmi->ref_frame[0] == LAST_FRAME ||
edge_mbmi->ref_frame[1] == LAST_FRAME);
}
} else { // inter/inter
const int above_has_second = has_second_ref(above_mbmi);
const int left_has_second = has_second_ref(left_mbmi);
const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
if (above_has_second && left_has_second) {
if (above0 == left0 && above1 == left1)
pred_context = 3 * (above0 == LAST_FRAME || above1 == LAST_FRAME ||
left0 == LAST_FRAME || left1 == LAST_FRAME);
else
pred_context = 2;
} else if (above_has_second || left_has_second) {
const MV_REFERENCE_FRAME rfs = !above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf1 = above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf2 = above_has_second ? above1 : left1;
if (rfs == LAST_FRAME)
pred_context = 3 + (crf1 == LAST_FRAME || crf2 == LAST_FRAME);
else if (rfs == LAST2_FRAME)
pred_context = (crf1 == LAST_FRAME || crf2 == LAST_FRAME);
else
pred_context = 1 + 2 * (crf1 == LAST_FRAME || crf2 == LAST_FRAME);
} else {
if (!CHECK_LAST_OR_LAST2(above0) &&
!CHECK_LAST_OR_LAST2(left0)) {
pred_context = 2 + (above0 == left0);
} else if (!CHECK_LAST_OR_LAST2(above0) ||
!CHECK_LAST_OR_LAST2(left0)) {
const MV_REFERENCE_FRAME edge0 =
!CHECK_LAST_OR_LAST2(above0) ? left0 : above0;
pred_context = 4 * (edge0 == LAST_FRAME);
} else {
pred_context = 2 * (above0 == LAST_FRAME) + 2 * (left0 == LAST_FRAME);
}
}
}
} else if (has_above || has_left) { // one edge available
const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi) ||
(!CHECK_LAST_OR_LAST2(edge_mbmi->ref_frame[0]) &&
!has_second_ref(edge_mbmi)))
pred_context = 2;
else if (!has_second_ref(edge_mbmi))
pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST_FRAME);
else
pred_context = 3 * (edge_mbmi->ref_frame[0] == LAST_FRAME ||
edge_mbmi->ref_frame[1] == LAST_FRAME);
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
// For the bit to signal whether the single reference is LAST4_FRAME or
// LAST3_FRAME, knowing that it shall be either of these 2 choices.
//
// NOTE(zoeliu): The probability of ref_frame[0] is LAST4_FRAME, conditioning
// on it is either LAST4_FRAME/LAST3_FRAME.
int vp9_get_pred_context_single_ref_p5(const MACROBLOCKD *xd) {
int pred_context;
const MB_MODE_INFO *const above_mbmi = get_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_mbmi(get_left_mi(xd));
const int has_above = above_mbmi != NULL;
const int has_left = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
if (above_intra && left_intra) { // intra/intra
pred_context = 2;
} else if (above_intra || left_intra) { // intra/inter or inter/intra
const MB_MODE_INFO *edge_mbmi = above_intra ? left_mbmi : above_mbmi;
if (!has_second_ref(edge_mbmi)) {
if (!CHECK_LAST3_OR_LAST4(edge_mbmi->ref_frame[0]))
pred_context = 3;
else
pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST3_FRAME);
} else {
pred_context = 1 +
2 * (edge_mbmi->ref_frame[0] == LAST3_FRAME ||
edge_mbmi->ref_frame[1] == LAST3_FRAME);
}
} else { // inter/inter
const int above_has_second = has_second_ref(above_mbmi);
const int left_has_second = has_second_ref(left_mbmi);
const MV_REFERENCE_FRAME above0 = above_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME above1 = above_mbmi->ref_frame[1];
const MV_REFERENCE_FRAME left0 = left_mbmi->ref_frame[0];
const MV_REFERENCE_FRAME left1 = left_mbmi->ref_frame[1];
if (above_has_second && left_has_second) {
if (above0 == left0 && above1 == left1)
pred_context = 3 * (above0 == LAST3_FRAME || above1 == LAST3_FRAME ||
left0 == LAST3_FRAME || left1 == LAST3_FRAME);
else
pred_context = 2;
} else if (above_has_second || left_has_second) {
const MV_REFERENCE_FRAME rfs = !above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf1 = above_has_second ? above0 : left0;
const MV_REFERENCE_FRAME crf2 = above_has_second ? above1 : left1;
if (rfs == LAST3_FRAME)
pred_context = 3 + (crf1 == LAST3_FRAME || crf2 == LAST3_FRAME);
else if (rfs == LAST4_FRAME)
pred_context = (crf1 == LAST3_FRAME || crf2 == LAST3_FRAME);
else
pred_context = 1 + 2 * (crf1 == LAST3_FRAME || crf2 == LAST3_FRAME);
} else {
if (!CHECK_LAST3_OR_LAST4(above0) &&
!CHECK_LAST3_OR_LAST4(left0)) {
pred_context = 2 + (above0 == left0);
} else if (!CHECK_LAST3_OR_LAST4(above0) ||
!CHECK_LAST3_OR_LAST4(left0)) {
const MV_REFERENCE_FRAME edge0 =
!CHECK_LAST3_OR_LAST4(above0) ? left0 : above0;
pred_context = 4 * (edge0 == LAST3_FRAME);
} else {
pred_context = 2 * (above0 == LAST3_FRAME) +
2 * (left0 == LAST3_FRAME);
}
}
}
} else if (has_above || has_left) { // one edge available
const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
if (!is_inter_block(edge_mbmi) ||
(!CHECK_LAST3_OR_LAST4(edge_mbmi->ref_frame[0]) &&
!has_second_ref(edge_mbmi)))
pred_context = 2;
else if (!has_second_ref(edge_mbmi))
pred_context = 4 * (edge_mbmi->ref_frame[0] == LAST3_FRAME);
else
pred_context = 3 * (edge_mbmi->ref_frame[0] == LAST3_FRAME ||
edge_mbmi->ref_frame[1] == LAST3_FRAME);
} else { // no edges available (2)
pred_context = 2;
}
assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
return pred_context;
}
#else // CONFIG_LAST4_REF
// For the bit to signal whether the single reference is a LAST_FRAME/ // For the bit to signal whether the single reference is a LAST_FRAME/
// LAST2_FRAME/LAST3_FRAME, or not. // LAST2_FRAME/LAST3_FRAME, or not.
// //
@ -1064,6 +1944,8 @@ int vp9_get_pred_context_single_ref_p4(const MACROBLOCKD *xd) {
return pred_context; return pred_context;
} }
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
// For the bit to signal whether the single reference is a LAST_FRAME/ // For the bit to signal whether the single reference is a LAST_FRAME/

View File

@ -149,6 +149,17 @@ static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p2(const VP9_COMMON *cm,
const int pred_context = vp9_get_pred_context_comp_ref_p2(cm, xd); const int pred_context = vp9_get_pred_context_comp_ref_p2(cm, xd);
return cm->fc.comp_ref_probs[pred_context][2]; return cm->fc.comp_ref_probs[pred_context][2];
} }
#if CONFIG_LAST4_REF
int vp9_get_pred_context_comp_ref_p3(const VP9_COMMON *cm,
const MACROBLOCKD *xd);
static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p3(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = vp9_get_pred_context_comp_ref_p3(cm, xd);
return cm->fc.comp_ref_probs[pred_context][3];
}
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -181,6 +192,15 @@ static INLINE vp9_prob vp9_get_pred_prob_single_ref_p4(const VP9_COMMON *cm,
const MACROBLOCKD *xd) { const MACROBLOCKD *xd) {
return cm->fc.single_ref_probs[vp9_get_pred_context_single_ref_p4(xd)][3]; return cm->fc.single_ref_probs[vp9_get_pred_context_single_ref_p4(xd)][3];
} }
#if CONFIG_LAST4_REF
int vp9_get_pred_context_single_ref_p5(const MACROBLOCKD *xd);
static INLINE vp9_prob vp9_get_pred_prob_single_ref_p5(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
return cm->fc.single_ref_probs[vp9_get_pred_context_single_ref_p5(xd)][4];
}
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF

View File

@ -63,11 +63,16 @@ static void setup_compound_reference_mode(VP9_COMMON *cm) {
cm->comp_var_ref[1] = LAST2_FRAME; cm->comp_var_ref[1] = LAST2_FRAME;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cm->comp_var_ref[2] = LAST3_FRAME; cm->comp_var_ref[2] = LAST3_FRAME;
#if CONFIG_LAST4_REF
cm->comp_var_ref[3] = LAST4_FRAME;
cm->comp_var_ref[4] = GOLDEN_FRAME;
#else // CONFIG_LAST4_REF
cm->comp_var_ref[3] = GOLDEN_FRAME; cm->comp_var_ref[3] = GOLDEN_FRAME;
#else #endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF
cm->comp_var_ref[2] = GOLDEN_FRAME; cm->comp_var_ref[2] = GOLDEN_FRAME;
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else #else // CONFIG_MULTI_REF
cm->comp_var_ref[1] = GOLDEN_FRAME; cm->comp_var_ref[1] = GOLDEN_FRAME;
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
} else if (cm->ref_frame_sign_bias[LAST_FRAME] == } else if (cm->ref_frame_sign_bias[LAST_FRAME] ==
@ -3103,7 +3108,10 @@ static size_t read_uncompressed_header(VP9Decoder *pbi,
int i; int i;
#if CONFIG_MULTI_REF && CONFIG_LAST3_REF #if CONFIG_MULTI_REF && CONFIG_LAST3_REF
cm->frame_before_last_type = cm->last_frame_type; #if CONFIG_LAST4_REF
cm->last3_frame_type = cm->last2_frame_type;
#endif // CONFIG_LAST4_REF
cm->last2_frame_type = cm->last_frame_type;
#endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF #endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF
cm->last_frame_type = cm->frame_type; cm->last_frame_type = cm->frame_type;

View File

@ -791,7 +791,21 @@ static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (!cm->frame_parallel_decoding_mode) if (!cm->frame_parallel_decoding_mode)
++counts->comp_ref[ctx2][2][bit2]; ++counts->comp_ref[ctx2][2][bit2];
#if CONFIG_LAST4_REF
if (!bit2) {
const int ctx3 = vp9_get_pred_context_comp_ref_p3(cm, xd);
const int bit3 = vp9_read(r, fc->comp_ref_probs[ctx3][3]);
if (!cm->frame_parallel_decoding_mode)
++counts->comp_ref[ctx3][3][bit3];
ref_frame[!idx] = cm->comp_var_ref[bit3 ? 2 : 3];
} else {
ref_frame[!idx] = cm->comp_var_ref[4];
}
#else // CONFIG_LAST4_REF
ref_frame[!idx] = cm->comp_var_ref[bit2 ? 3 : 2]; ref_frame[!idx] = cm->comp_var_ref[bit2 ? 3 : 2];
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
ref_frame[!idx] = cm->comp_var_ref[2]; ref_frame[!idx] = cm->comp_var_ref[2];
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
@ -824,7 +838,17 @@ static void read_ref_frames(VP9_COMMON *const cm, MACROBLOCKD *const xd,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
if (bit2) { if (bit2) {
#if CONFIG_LAST4_REF
const int ctx4 = vp9_get_pred_context_single_ref_p5(xd);
const int bit4 = vp9_read(r, fc->single_ref_probs[ctx4][4]);
if (!cm->frame_parallel_decoding_mode)
++counts->single_ref[ctx4][4][bit4];
ref_frame[0] = bit4 ? LAST4_FRAME : LAST3_FRAME;
#else // CONFIG_LAST4_REF
ref_frame[0] = LAST3_FRAME; ref_frame[0] = LAST3_FRAME;
#endif // CONFIG_LAST4_REF
} else { } else {
const int ctx3 = vp9_get_pred_context_single_ref_p4(xd); const int ctx3 = vp9_get_pred_context_single_ref_p4(xd);
const int bit3 = vp9_read(r, fc->single_ref_probs[ctx3][3]); const int bit3 = vp9_read(r, fc->single_ref_probs[ctx3][3]);

View File

@ -161,10 +161,19 @@ vpx_codec_err_t vp9_set_reference_dec(VP9_COMMON *cm,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
} else if (ref_frame_flag == VP9_LAST3_FLAG) { } else if (ref_frame_flag == VP9_LAST3_FLAG) {
ref_buf = &cm->frame_refs[2]; ref_buf = &cm->frame_refs[2];
#if CONFIG_LAST4_REF
} else if (ref_frame_flag == VP9_LAST4_FLAG) {
ref_buf = &cm->frame_refs[3];
} else if (ref_frame_flag == VP9_GOLD_FLAG) {
ref_buf = &cm->frame_refs[4];
} else if (ref_frame_flag == VP9_ALT_FLAG) {
ref_buf = &cm->frame_refs[5];
#else // CONFIG_LAST4_REF
} else if (ref_frame_flag == VP9_GOLD_FLAG) { } else if (ref_frame_flag == VP9_GOLD_FLAG) {
ref_buf = &cm->frame_refs[3]; ref_buf = &cm->frame_refs[3];
} else if (ref_frame_flag == VP9_ALT_FLAG) { } else if (ref_frame_flag == VP9_ALT_FLAG) {
ref_buf = &cm->frame_refs[4]; ref_buf = &cm->frame_refs[4];
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
} else if (ref_frame_flag == VP9_GOLD_FLAG) { } else if (ref_frame_flag == VP9_GOLD_FLAG) {
ref_buf = &cm->frame_refs[2]; ref_buf = &cm->frame_refs[2];
@ -232,7 +241,12 @@ static void swap_frame_buffers(VP9Decoder *pbi) {
// all the frames in the frame buffer (cm->frame_bufs) get refreshed. // all the frames in the frame buffer (cm->frame_bufs) get refreshed.
if ((mask & 1) && if ((mask & 1) &&
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
(cm->frame_type == KEY_FRAME ||
(ref_index != 1 && ref_index != 2 && ref_index != 3))
#else // CONFIG_LAST4_REF
(cm->frame_type == KEY_FRAME || (ref_index != 1 && ref_index != 2)) (cm->frame_type == KEY_FRAME || (ref_index != 1 && ref_index != 2))
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
(cm->frame_type == KEY_FRAME || ref_index != 1) (cm->frame_type == KEY_FRAME || ref_index != 1)
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
@ -257,6 +271,26 @@ static void swap_frame_buffers(VP9Decoder *pbi) {
const int ref_index_last3 = ref_index_last2 + 1; const int ref_index_last3 = ref_index_last2 + 1;
const int old_buf_idx_last3 = cm->ref_frame_map[ref_index_last3]; const int old_buf_idx_last3 = cm->ref_frame_map[ref_index_last3];
#if CONFIG_LAST4_REF
if (mask & 8) {
// If current is LAST_FRAME, and LAST2, LAST3 and LAST4 all need to
// get refreshed as well, then LAST4_FRAME should get handled first
// followed by the handling of LAST3_FRAME and then LAST2_FRAME.
const int ref_index_last4 = ref_index_last3 + 1;
const int old_buf_idx_last4 = cm->ref_frame_map[ref_index_last4];
ref_cnt_fb(cm->frame_bufs,
&cm->ref_frame_map[ref_index_last4],
cm->ref_frame_map[ref_index_last3]);
if (old_buf_idx_last4 >= 0 &&
cm->frame_bufs[old_buf_idx_last4].ref_count == 0) {
cm->release_fb_cb(
cm->cb_priv,
&cm->frame_bufs[old_buf_idx_last4].raw_frame_buffer);
}
}
#endif // CONFIG_LAST4_REF
ref_cnt_fb(cm->frame_bufs, ref_cnt_fb(cm->frame_bufs,
&cm->ref_frame_map[ref_index_last3], &cm->ref_frame_map[ref_index_last3],
cm->ref_frame_map[ref_index_last2]); cm->ref_frame_map[ref_index_last2]);

View File

@ -496,8 +496,14 @@ static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
if (is_compound) { if (is_compound) {
#if CONFIG_MULTI_REF && CONFIG_LAST3_REF #if CONFIG_MULTI_REF && CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
const int bit = (mbmi->ref_frame[0] == GOLDEN_FRAME ||
mbmi->ref_frame[0] == LAST3_FRAME ||
mbmi->ref_frame[0] == LAST4_FRAME);
#else // CONFIG_LAST4_REF
const int bit = (mbmi->ref_frame[0] == GOLDEN_FRAME || const int bit = (mbmi->ref_frame[0] == GOLDEN_FRAME ||
mbmi->ref_frame[0] == LAST3_FRAME); mbmi->ref_frame[0] == LAST3_FRAME);
#endif // CONFIG_LAST4_REF
#else #else
const int bit = mbmi->ref_frame[0] == GOLDEN_FRAME; const int bit = mbmi->ref_frame[0] == GOLDEN_FRAME;
#endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF #endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF
@ -511,6 +517,13 @@ static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
} else { } else {
const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME; const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME;
vp9_write(w, bit2, vp9_get_pred_prob_comp_ref_p2(cm, xd)); vp9_write(w, bit2, vp9_get_pred_prob_comp_ref_p2(cm, xd));
#if CONFIG_LAST4_REF
if (!bit2) {
const int bit3 = mbmi->ref_frame[0] == LAST3_FRAME;
vp9_write(w, bit3, vp9_get_pred_prob_comp_ref_p3(cm, xd));
}
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
} }
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -525,7 +538,12 @@ static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
vp9_write(w, bit1, vp9_get_pred_prob_single_ref_p2(cm, xd)); vp9_write(w, bit1, vp9_get_pred_prob_single_ref_p2(cm, xd));
} else { } else {
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
const int bit2 = (mbmi->ref_frame[0] == LAST3_FRAME ||
mbmi->ref_frame[0] == LAST4_FRAME);
#else // CONFIG_LAST4_REF
const int bit2 = mbmi->ref_frame[0] == LAST3_FRAME; const int bit2 = mbmi->ref_frame[0] == LAST3_FRAME;
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
const int bit2 = mbmi->ref_frame[0] != LAST_FRAME; const int bit2 = mbmi->ref_frame[0] != LAST_FRAME;
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
@ -535,6 +553,11 @@ static void write_ref_frames(const VP9_COMMON *cm, const MACROBLOCKD *xd,
if (!bit2) { if (!bit2) {
const int bit3 = mbmi->ref_frame[0] != LAST_FRAME; const int bit3 = mbmi->ref_frame[0] != LAST_FRAME;
vp9_write(w, bit3, vp9_get_pred_prob_single_ref_p4(cm, xd)); vp9_write(w, bit3, vp9_get_pred_prob_single_ref_p4(cm, xd));
#if CONFIG_LAST4_REF
} else {
const int bit4 = mbmi->ref_frame[0] != LAST3_FRAME;
vp9_write(w, bit4, vp9_get_pred_prob_single_ref_p5(cm, xd));
#endif // CONFIG_LAST4_REF
} }
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
} }
@ -2185,6 +2208,9 @@ static int get_refresh_mask(VP9_COMP *cpi) {
(cpi->refresh_last2_frame << cpi->lst2_fb_idx) | (cpi->refresh_last2_frame << cpi->lst2_fb_idx) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(cpi->refresh_last3_frame << cpi->lst3_fb_idx) | (cpi->refresh_last3_frame << cpi->lst3_fb_idx) |
#if CONFIG_LAST4_REF
(cpi->refresh_last4_frame << cpi->lst4_fb_idx) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(cpi->refresh_golden_frame << cpi->alt_fb_idx); (cpi->refresh_golden_frame << cpi->alt_fb_idx);
@ -2199,6 +2225,9 @@ static int get_refresh_mask(VP9_COMP *cpi) {
(cpi->refresh_last2_frame << cpi->lst2_fb_idx) | (cpi->refresh_last2_frame << cpi->lst2_fb_idx) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(cpi->refresh_last3_frame << cpi->lst3_fb_idx) | (cpi->refresh_last3_frame << cpi->lst3_fb_idx) |
#if CONFIG_LAST4_REF
(cpi->refresh_last4_frame << cpi->lst4_fb_idx) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(cpi->refresh_golden_frame << cpi->gld_fb_idx) | (cpi->refresh_golden_frame << cpi->gld_fb_idx) |
@ -2409,6 +2438,9 @@ static void write_uncompressed_header(VP9_COMP *cpi,
(cm->frame_type == KEY_FRAME || cpi->refresh_last_frame) ? 1 : 0; (cm->frame_type == KEY_FRAME || cpi->refresh_last_frame) ? 1 : 0;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->refresh_last3_frame = cpi->refresh_last2_frame ? 1 : 0; cpi->refresh_last3_frame = cpi->refresh_last2_frame ? 1 : 0;
#if CONFIG_LAST4_REF
cpi->refresh_last4_frame = cpi->refresh_last3_frame ? 1 : 0;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF

View File

@ -402,6 +402,10 @@ void vp9_denoiser_update_frame_info(VP9_DENOISER *denoiser,
if (refresh_last_frame) { if (refresh_last_frame) {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
copy_frame(denoiser->running_avg_y[LAST4_FRAME],
denoiser->running_avg_y[LAST3_FRAME]);
#endif // CONFIG_LAST4_REF
copy_frame(denoiser->running_avg_y[LAST3_FRAME], copy_frame(denoiser->running_avg_y[LAST3_FRAME],
denoiser->running_avg_y[LAST2_FRAME]); denoiser->running_avg_y[LAST2_FRAME]);
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF

View File

@ -1523,7 +1523,12 @@ static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) {
if (has_second_ref(mbmi)) { if (has_second_ref(mbmi)) {
#if CONFIG_MULTI_REF && CONFIG_LAST3_REF #if CONFIG_MULTI_REF && CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
const int bit = (ref0 == GOLDEN_FRAME || ref0 == LAST3_FRAME ||
ref0 == LAST4_FRAME);
#else // CONFIG_LAST4_REF
const int bit = (ref0 == GOLDEN_FRAME || ref0 == LAST3_FRAME); const int bit = (ref0 == GOLDEN_FRAME || ref0 == LAST3_FRAME);
#endif // CONFIG_LAST4_REF
counts->comp_ref[vp9_get_pred_context_comp_ref_p(cm, xd)][0][bit]++; counts->comp_ref[vp9_get_pred_context_comp_ref_p(cm, xd)][0][bit]++;
if (!bit) { if (!bit) {
counts->comp_ref[vp9_get_pred_context_comp_ref_p1(cm, xd)][1] counts->comp_ref[vp9_get_pred_context_comp_ref_p1(cm, xd)][1]
@ -1531,6 +1536,12 @@ static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) {
} else { } else {
counts->comp_ref[vp9_get_pred_context_comp_ref_p2(cm, xd)][2] counts->comp_ref[vp9_get_pred_context_comp_ref_p2(cm, xd)][2]
[ref0 == GOLDEN_FRAME]++; [ref0 == GOLDEN_FRAME]++;
#if CONFIG_LAST4_REF
if (ref0 != GOLDEN_FRAME) {
counts->comp_ref[vp9_get_pred_context_comp_ref_p3(cm, xd)][3]
[ref0 == LAST3_FRAME]++;
}
#endif // CONFIG_LAST4_REF
} }
#else // CONFIG_MULTI_REF && CONFIG_LAST3_REF #else // CONFIG_MULTI_REF && CONFIG_LAST3_REF
counts->comp_ref[vp9_get_pred_context_comp_ref_p(cm, xd)][0] counts->comp_ref[vp9_get_pred_context_comp_ref_p(cm, xd)][0]
@ -1551,11 +1562,17 @@ static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) {
[ref0 != GOLDEN_FRAME]++; [ref0 != GOLDEN_FRAME]++;
} else { } else {
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
const int bit1 = !(ref0 == LAST2_FRAME || ref0 == LAST_FRAME);
counts->single_ref[vp9_get_pred_context_single_ref_p3(xd)][2] counts->single_ref[vp9_get_pred_context_single_ref_p3(xd)][2]
[ref0 == LAST3_FRAME]++; [bit1]++;
if (ref0 != LAST3_FRAME) { if (!bit1) {
counts->single_ref[vp9_get_pred_context_single_ref_p4(xd)][3] counts->single_ref[vp9_get_pred_context_single_ref_p4(xd)][3]
[ref0 != LAST_FRAME]++; [ref0 != LAST_FRAME]++;
#if CONFIG_LAST4_REF
} else {
counts->single_ref[vp9_get_pred_context_single_ref_p5(xd)][4]
[ref0 != LAST3_FRAME]++;
#endif // CONFIG_LAST4_REF
} }
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
counts->single_ref[vp9_get_pred_context_single_ref_p3(xd)][2] counts->single_ref[vp9_get_pred_context_single_ref_p3(xd)][2]
@ -3892,19 +3909,18 @@ static int check_dual_ref_flags(VP9_COMP *cpi) {
if (vp9_segfeature_active(&cpi->common.seg, 1, SEG_LVL_REF_FRAME)) { if (vp9_segfeature_active(&cpi->common.seg, 1, SEG_LVL_REF_FRAME)) {
return 0; return 0;
} else { } else {
return (!!(ref_flags & VP9_GOLD_FLAG) +
!!(ref_flags & VP9_LAST_FLAG) +
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
!!(ref_flags & VP9_LAST2_FLAG) +
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG) + !!(ref_flags & VP9_LAST3_FLAG) +
!!(ref_flags & VP9_ALT_FLAG) + !!(ref_flags & VP9_LAST2_FLAG) + #if CONFIG_LAST4_REF
!!(ref_flags & VP9_LAST3_FLAG)) >= 2; !!(ref_flags & VP9_LAST4_FLAG) +
#else // CONFIG_LAST3_REF #endif // CONFIG_LAST4_REF
return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG) +
!!(ref_flags & VP9_ALT_FLAG) + !!(ref_flags & VP9_LAST2_FLAG)) >= 2;
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#else // CONFIG_MULTI_REF
return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG) +
!!(ref_flags & VP9_ALT_FLAG)) >= 2;
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
!!(ref_flags & VP9_ALT_FLAG)) >= 2;
} }
} }
@ -4326,7 +4342,12 @@ void vp9_encode_frame(VP9_COMP *cpi) {
cm->comp_var_ref[1] = LAST2_FRAME; cm->comp_var_ref[1] = LAST2_FRAME;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cm->comp_var_ref[2] = LAST3_FRAME; cm->comp_var_ref[2] = LAST3_FRAME;
#if CONFIG_LAST4_REF
cm->comp_var_ref[3] = LAST4_FRAME;
cm->comp_var_ref[4] = GOLDEN_FRAME;
#else // CONFIG_LAST4_REF
cm->comp_var_ref[3] = GOLDEN_FRAME; cm->comp_var_ref[3] = GOLDEN_FRAME;
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
cm->comp_var_ref[2] = GOLDEN_FRAME; cm->comp_var_ref[2] = GOLDEN_FRAME;
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF

View File

@ -583,8 +583,16 @@ static void init_buffer_indices(VP9_COMP *cpi) {
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->lst3_fb_idx = 2; cpi->lst3_fb_idx = 2;
#if CONFIG_LAST4_REF
cpi->lst4_fb_idx = 3;
cpi->gld_fb_idx = 4;
cpi->alt_fb_idx = 5;
#else // CONFIG_LAST4_REF
cpi->gld_fb_idx = 3; cpi->gld_fb_idx = 3;
cpi->alt_fb_idx = 4; cpi->alt_fb_idx = 4;
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
cpi->gld_fb_idx = 2; cpi->gld_fb_idx = 2;
cpi->alt_fb_idx = 3; cpi->alt_fb_idx = 3;
@ -1487,6 +1495,9 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
cpi->refresh_last2_frame = 0; cpi->refresh_last2_frame = 0;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->refresh_last3_frame = 0; cpi->refresh_last3_frame = 0;
#if CONFIG_LAST4_REF
cpi->refresh_last4_frame = 0;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
cm->refresh_frame_context = 1; cm->refresh_frame_context = 1;
@ -2265,6 +2276,9 @@ void vp9_update_reference(VP9_COMP *cpi, int ref_frame_flags) {
cpi->ext_refresh_last2_frame = (ref_frame_flags & VP9_LAST2_FLAG) != 0; cpi->ext_refresh_last2_frame = (ref_frame_flags & VP9_LAST2_FLAG) != 0;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->ext_refresh_last3_frame = (ref_frame_flags & VP9_LAST3_FLAG) != 0; cpi->ext_refresh_last3_frame = (ref_frame_flags & VP9_LAST3_FLAG) != 0;
#if CONFIG_LAST4_REF
cpi->ext_refresh_last4_frame = (ref_frame_flags & VP9_LAST4_FLAG) != 0;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
cpi->ext_refresh_frame_flags_pending = 1; cpi->ext_refresh_frame_flags_pending = 1;
@ -2281,6 +2295,10 @@ static YV12_BUFFER_CONFIG *get_vp9_ref_frame_buffer(VP9_COMP *cpi,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
else if (ref_frame_flag == VP9_LAST3_FLAG) else if (ref_frame_flag == VP9_LAST3_FLAG)
ref_frame = LAST3_FRAME; ref_frame = LAST3_FRAME;
#if CONFIG_LAST4_REF
else if (ref_frame_flag == VP9_LAST4_FLAG)
ref_frame = LAST4_FRAME;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
else if (ref_frame_flag == VP9_GOLD_FLAG) else if (ref_frame_flag == VP9_GOLD_FLAG)
@ -2608,6 +2626,19 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
if (cpi->refresh_last2_frame) { if (cpi->refresh_last2_frame) {
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
if (cpi->refresh_last3_frame) { if (cpi->refresh_last3_frame) {
#if CONFIG_LAST4_REF
if (cpi->refresh_last4_frame) {
if (cm->frame_type == KEY_FRAME)
ref_cnt_fb(cm->frame_bufs,
&cm->ref_frame_map[cpi->lst4_fb_idx],
cm->new_fb_idx);
else
ref_cnt_fb(cm->frame_bufs,
&cm->ref_frame_map[cpi->lst4_fb_idx],
cm->ref_frame_map[cpi->lst3_fb_idx]);
}
#endif // CONFIG_LAST4_REF
if (cm->frame_type == KEY_FRAME) if (cm->frame_type == KEY_FRAME)
ref_cnt_fb(cm->frame_bufs, ref_cnt_fb(cm->frame_bufs,
&cm->ref_frame_map[cpi->lst3_fb_idx], &cm->ref_frame_map[cpi->lst3_fb_idx],
@ -2637,6 +2668,19 @@ void vp9_update_reference_frames(VP9_COMP *cpi) {
if (cpi->refresh_last2_frame) { if (cpi->refresh_last2_frame) {
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
if (cpi->refresh_last3_frame) { if (cpi->refresh_last3_frame) {
#if CONFIG_LAST4_REF
if (cpi->refresh_last4_frame) {
if (cm->frame_type == KEY_FRAME)
vpx_memcpy(cpi->interp_filter_selected[LAST4_FRAME],
cpi->interp_filter_selected[0],
sizeof(cpi->interp_filter_selected[0]));
else
vpx_memcpy(cpi->interp_filter_selected[LAST4_FRAME],
cpi->interp_filter_selected[LAST3_FRAME],
sizeof(cpi->interp_filter_selected[LAST3_FRAME]));
}
#endif // CONFIG_LAST4_REF
if (cm->frame_type == KEY_FRAME) if (cm->frame_type == KEY_FRAME)
vpx_memcpy(cpi->interp_filter_selected[LAST3_FRAME], vpx_memcpy(cpi->interp_filter_selected[LAST3_FRAME],
cpi->interp_filter_selected[0], cpi->interp_filter_selected[0],
@ -2717,6 +2761,9 @@ void vp9_scale_references(VP9_COMP *cpi) {
VP9_LAST2_FLAG, VP9_LAST2_FLAG,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
VP9_LAST3_FLAG, VP9_LAST3_FLAG,
#if CONFIG_LAST4_REF
VP9_LAST4_FLAG,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
VP9_GOLD_FLAG, VP9_GOLD_FLAG,
@ -3124,6 +3171,14 @@ static int get_ref_frame_flags(const VP9_COMP *cpi) {
const int last3_is_last2 = map[cpi->lst3_fb_idx] == map[cpi->lst2_fb_idx]; const int last3_is_last2 = map[cpi->lst3_fb_idx] == map[cpi->lst2_fb_idx];
const int gld_is_last3 = map[cpi->gld_fb_idx] == map[cpi->lst3_fb_idx]; const int gld_is_last3 = map[cpi->gld_fb_idx] == map[cpi->lst3_fb_idx];
const int alt_is_last3 = map[cpi->alt_fb_idx] == map[cpi->lst3_fb_idx]; const int alt_is_last3 = map[cpi->alt_fb_idx] == map[cpi->lst3_fb_idx];
#if CONFIG_LAST4_REF
const int last4_is_last = map[cpi->lst4_fb_idx] == map[cpi->lst_fb_idx];
const int last4_is_last2 = map[cpi->lst4_fb_idx] == map[cpi->lst2_fb_idx];
const int last4_is_last3 = map[cpi->lst4_fb_idx] == map[cpi->lst3_fb_idx];
const int gld_is_last4 = map[cpi->gld_fb_idx] == map[cpi->lst4_fb_idx];
const int alt_is_last4 = map[cpi->alt_fb_idx] == map[cpi->lst4_fb_idx];
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -3132,6 +3187,9 @@ static int get_ref_frame_flags(const VP9_COMP *cpi) {
flags |= VP9_LAST2_FLAG; flags |= VP9_LAST2_FLAG;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
flags |= VP9_LAST3_FLAG; flags |= VP9_LAST3_FLAG;
#if CONFIG_LAST4_REF
flags |= VP9_LAST4_FLAG;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -3150,6 +3208,18 @@ static int get_ref_frame_flags(const VP9_COMP *cpi) {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
if (last4_is_last || last4_is_last2 || last4_is_last3)
flags &= ~VP9_LAST4_FLAG;
if (gld_is_last4)
flags &= ~VP9_GOLD_FLAG;
if (alt_is_last4)
flags &= ~VP9_ALT_FLAG;
#endif // CONFIG_LAST4_REF
if (last3_is_last || last3_is_last2) if (last3_is_last || last3_is_last2)
flags &= ~VP9_LAST3_FLAG; flags &= ~VP9_LAST3_FLAG;
@ -3188,6 +3258,9 @@ static void set_ext_overrides(VP9_COMP *cpi) {
cpi->refresh_last2_frame = cpi->ext_refresh_last2_frame; cpi->refresh_last2_frame = cpi->ext_refresh_last2_frame;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->refresh_last3_frame = cpi->ext_refresh_last3_frame; cpi->refresh_last3_frame = cpi->ext_refresh_last3_frame;
#if CONFIG_LAST4_REF
cpi->refresh_last4_frame = cpi->ext_refresh_last4_frame;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
cpi->refresh_golden_frame = cpi->ext_refresh_golden_frame; cpi->refresh_golden_frame = cpi->ext_refresh_golden_frame;
@ -3295,6 +3368,11 @@ int setup_interp_filter_search_mask(VP9_COMP *cpi) {
(ref_total[LAST3_FRAME] == 0 || (ref_total[LAST3_FRAME] == 0 ||
cpi->interp_filter_selected[LAST3_FRAME][ifilter] * 50 cpi->interp_filter_selected[LAST3_FRAME][ifilter] * 50
< ref_total[LAST3_FRAME]) && < ref_total[LAST3_FRAME]) &&
#if CONFIG_LAST4_REF
(ref_total[LAST4_FRAME] == 0 ||
cpi->interp_filter_selected[LAST4_FRAME][ifilter] * 50
< ref_total[LAST4_FRAME]) &&
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(ref_total[GOLDEN_FRAME] == 0 || (ref_total[GOLDEN_FRAME] == 0 ||
@ -3531,7 +3609,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cpi->ref_frame_flags = get_ref_frame_flags(cpi); cpi->ref_frame_flags = get_ref_frame_flags(cpi);
#if CONFIG_MULTI_REF && CONFIG_LAST3_REF #if CONFIG_MULTI_REF && CONFIG_LAST3_REF
cm->frame_before_last_type = cm->last_frame_type; #if CONFIG_LAST4_REF
cm->last3_frame_type = cm->last2_frame_type;
#endif // CONFIG_LAST4_REF
cm->last2_frame_type = cm->last_frame_type;
#endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF #endif // CONFIG_MULTI_REF && CONFIG_LAST3_REF
cm->last_frame_type = cm->frame_type; cm->last_frame_type = cm->frame_type;
@ -3678,6 +3759,9 @@ static int frame_is_reference(const VP9_COMP *cpi) {
cpi->refresh_last2_frame || cpi->refresh_last2_frame ||
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->refresh_last3_frame || cpi->refresh_last3_frame ||
#if CONFIG_LAST4_REF
cpi->refresh_last4_frame ||
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
cpi->refresh_golden_frame || cpi->refresh_golden_frame ||
@ -3803,6 +3887,9 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
cpi->refresh_last2_frame = 0; cpi->refresh_last2_frame = 0;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->refresh_last3_frame = 0; cpi->refresh_last3_frame = 0;
#if CONFIG_LAST4_REF
cpi->refresh_last4_frame = 0;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
cpi->refresh_golden_frame = 0; cpi->refresh_golden_frame = 0;
@ -3832,6 +3919,9 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags,
cpi->refresh_last2_frame = 0; cpi->refresh_last2_frame = 0;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
cpi->refresh_last3_frame = 0; cpi->refresh_last3_frame = 0;
#if CONFIG_LAST4_REF
cpi->refresh_last4_frame = 0;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rc->is_src_frame_alt_ref = 0; rc->is_src_frame_alt_ref = 0;

View File

@ -241,6 +241,9 @@ typedef struct VP9_COMP {
int lst2_fb_idx; int lst2_fb_idx;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
int lst3_fb_idx; int lst3_fb_idx;
#if CONFIG_LAST4_REF
int lst4_fb_idx;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
int gld_fb_idx; int gld_fb_idx;
@ -251,6 +254,9 @@ typedef struct VP9_COMP {
int refresh_last2_frame; int refresh_last2_frame;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
int refresh_last3_frame; int refresh_last3_frame;
#if CONFIG_LAST4_REF
int refresh_last4_frame;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
int refresh_golden_frame; int refresh_golden_frame;
@ -263,6 +269,9 @@ typedef struct VP9_COMP {
int ext_refresh_last2_frame; int ext_refresh_last2_frame;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
int ext_refresh_last3_frame; int ext_refresh_last3_frame;
#if CONFIG_LAST4_REF
int ext_refresh_last4_frame;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
int ext_refresh_golden_frame; int ext_refresh_golden_frame;
@ -507,6 +516,10 @@ static INLINE int get_ref_frame_idx(const VP9_COMP *cpi,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
} else if (ref_frame == LAST3_FRAME) { } else if (ref_frame == LAST3_FRAME) {
return cpi->lst3_fb_idx; return cpi->lst3_fb_idx;
#if CONFIG_LAST4_REF
} else if (ref_frame == LAST4_FRAME) {
return cpi->lst4_fb_idx;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
} else if (ref_frame == GOLDEN_FRAME) { } else if (ref_frame == GOLDEN_FRAME) {

View File

@ -631,6 +631,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_NEARESTL2] = 300; rd->thresh_mult[THR_NEARESTL2] = 300;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_NEARESTL3] = 300; rd->thresh_mult[THR_NEARESTL3] = 300;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_NEARESTL4] = 300;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_NEARESTG] = 300; rd->thresh_mult[THR_NEARESTG] = 300;
@ -641,6 +644,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_NEARESTL2] = 0; rd->thresh_mult[THR_NEARESTL2] = 0;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_NEARESTL3] = 0; rd->thresh_mult[THR_NEARESTL3] = 0;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_NEARESTL4] = 0;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_NEARESTG] = 0; rd->thresh_mult[THR_NEARESTG] = 0;
@ -654,6 +660,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_NEWL2] += 1000; rd->thresh_mult[THR_NEWL2] += 1000;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_NEWL3] += 1000; rd->thresh_mult[THR_NEWL3] += 1000;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_NEWL4] += 1000;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_NEWG] += 1000; rd->thresh_mult[THR_NEWG] += 1000;
@ -665,6 +674,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_NEW2L2] += 1000; rd->thresh_mult[THR_NEW2L2] += 1000;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_NEW2L3] += 1000; rd->thresh_mult[THR_NEW2L3] += 1000;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_NEW2L4] += 1000;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_NEW2G] += 1000; rd->thresh_mult[THR_NEW2G] += 1000;
@ -676,6 +688,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_NEARL2] += 1000; rd->thresh_mult[THR_NEARL2] += 1000;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_NEARL3] += 1000; rd->thresh_mult[THR_NEARL3] += 1000;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_NEARL4] += 1000;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_NEARG] += 1000; rd->thresh_mult[THR_NEARG] += 1000;
@ -688,6 +703,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_ZEROL2] += 2000; rd->thresh_mult[THR_ZEROL2] += 2000;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_ZEROL3] += 2000; rd->thresh_mult[THR_ZEROL3] += 2000;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_ZEROL4] += 2000;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_ZEROG] += 2000; rd->thresh_mult[THR_ZEROG] += 2000;
@ -735,6 +753,18 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_COMP_NEW_NEWL3A] += 2000; rd->thresh_mult[THR_COMP_NEW_NEWL3A] += 2000;
rd->thresh_mult[THR_COMP_ZERO_ZEROL3A] += 2500; rd->thresh_mult[THR_COMP_ZERO_ZEROL3A] += 2500;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_COMP_NEAREST_NEARESTL4A] += 1000;
rd->thresh_mult[THR_COMP_NEAREST_NEARL4A] += 1200;
rd->thresh_mult[THR_COMP_NEAR_NEARESTL4A] += 1200;
rd->thresh_mult[THR_COMP_NEAREST_NEWL4A] += 1500;
rd->thresh_mult[THR_COMP_NEW_NEARESTL4A] += 1500;
rd->thresh_mult[THR_COMP_NEAR_NEWL4A] += 1700;
rd->thresh_mult[THR_COMP_NEW_NEARL4A] += 1700;
rd->thresh_mult[THR_COMP_NEW_NEWL4A] += 2000;
rd->thresh_mult[THR_COMP_ZERO_ZEROL4A] += 2500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -760,6 +790,13 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_COMP_NEWL3A] += 2000; rd->thresh_mult[THR_COMP_NEWL3A] += 2000;
rd->thresh_mult[THR_COMP_ZEROL3A] += 2500; rd->thresh_mult[THR_COMP_ZEROL3A] += 2500;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_COMP_NEARESTL4A] += 1000;
rd->thresh_mult[THR_COMP_NEARL4A] += 1500;
rd->thresh_mult[THR_COMP_NEWL4A] += 2000;
rd->thresh_mult[THR_COMP_ZEROL4A] += 2500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -780,6 +817,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL2 ] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL2 ] += 1500;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL3 ] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL3 ] += 1500;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROL4 ] += 1500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_COMP_INTERINTRA_ZEROG ] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_ZEROG ] += 1500;
@ -790,6 +830,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL2] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL2] += 1500;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL3] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL3] += 1500;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTL4] += 1500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] += 1500;
@ -800,6 +843,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL2 ] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARL2 ] += 1500;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL3 ] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARL3 ] += 1500;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEARL4 ] += 1500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEARG ] += 1500; rd->thresh_mult[THR_COMP_INTERINTRA_NEARG ] += 1500;
@ -810,6 +856,9 @@ void vp9_set_rd_speed_thresholds(VP9_COMP *cpi) {
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL2 ] += 2000; rd->thresh_mult[THR_COMP_INTERINTRA_NEWL2 ] += 2000;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL3 ] += 2000; rd->thresh_mult[THR_COMP_INTERINTRA_NEWL3 ] += 2000;
#if CONFIG_LAST4_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEWL4 ] += 2000;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult[THR_COMP_INTERINTRA_NEWG ] += 2000; rd->thresh_mult[THR_COMP_INTERINTRA_NEWG ] += 2000;
@ -830,6 +879,9 @@ void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) {
rd->thresh_mult_sub8x8[THR_LAST2] += 2500; rd->thresh_mult_sub8x8[THR_LAST2] += 2500;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult_sub8x8[THR_LAST3] += 2500; rd->thresh_mult_sub8x8[THR_LAST3] += 2500;
#if CONFIG_LAST4_REF
rd->thresh_mult_sub8x8[THR_LAST4] += 2500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult_sub8x8[THR_GOLD] += 2500; rd->thresh_mult_sub8x8[THR_GOLD] += 2500;
@ -840,6 +892,9 @@ void vp9_set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi) {
rd->thresh_mult_sub8x8[THR_COMP_L2A] += 4500; rd->thresh_mult_sub8x8[THR_COMP_L2A] += 4500;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
rd->thresh_mult_sub8x8[THR_COMP_L3A] += 4500; rd->thresh_mult_sub8x8[THR_COMP_L3A] += 4500;
#if CONFIG_LAST4_REF
rd->thresh_mult_sub8x8[THR_COMP_L4A] += 4500;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
rd->thresh_mult_sub8x8[THR_COMP_GA] += 4500; rd->thresh_mult_sub8x8[THR_COMP_GA] += 4500;

View File

@ -41,6 +41,28 @@ extern "C" {
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
#if CONFIG_NEW_INTER
#if CONFIG_INTERINTRA
#define MAX_MODES 109
#else // CONFIG_INTERINTRA
#define MAX_MODES 85
#endif // CONFIG_INTERINTRA
#else // CONFIG_NEW_INTER
#if CONFIG_INTERINTRA
#define MAX_MODES 78
#else // CONFIG_INTERINTRA
#define MAX_MODES 54
#endif // CONFIG_INTERINTRA
#endif // CONFIG_NEW_INTER
#else // CONFIG_LAST4_REF
#if CONFIG_NEW_INTER #if CONFIG_NEW_INTER
#if CONFIG_INTERINTRA #if CONFIG_INTERINTRA
@ -59,6 +81,8 @@ extern "C" {
#endif // CONFIG_NEW_INTER #endif // CONFIG_NEW_INTER
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
#if CONFIG_NEW_INTER #if CONFIG_NEW_INTER
@ -105,7 +129,11 @@ extern "C" {
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
#define MAX_REFS 12
#else // CONFIG_LAST4_REF
#define MAX_REFS 10 #define MAX_REFS 10
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
#define MAX_REFS 8 #define MAX_REFS 8
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
@ -121,6 +149,9 @@ typedef enum {
THR_NEARESTL2, THR_NEARESTL2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_NEARESTL3, THR_NEARESTL3,
#if CONFIG_LAST4_REF
THR_NEARESTL4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_NEARESTA, THR_NEARESTA,
@ -133,6 +164,9 @@ typedef enum {
THR_NEWL2, THR_NEWL2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_NEWL3, THR_NEWL3,
#if CONFIG_LAST4_REF
THR_NEWL4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_NEWA, THR_NEWA,
@ -144,6 +178,9 @@ typedef enum {
THR_NEW2L2, THR_NEW2L2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_NEW2L3, THR_NEW2L3,
#if CONFIG_LAST4_REF
THR_NEW2L4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_NEW2A, THR_NEW2A,
@ -155,6 +192,9 @@ typedef enum {
THR_NEARL2, THR_NEARL2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_NEARL3, THR_NEARL3,
#if CONFIG_LAST4_REF
THR_NEARL4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_NEARA, THR_NEARA,
@ -165,6 +205,9 @@ typedef enum {
THR_ZEROL2, THR_ZEROL2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_ZEROL3, THR_ZEROL3,
#if CONFIG_LAST4_REF
THR_ZEROL4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_ZEROG, THR_ZEROG,
@ -176,6 +219,9 @@ typedef enum {
THR_COMP_NEAREST_NEARESTL2A, THR_COMP_NEAREST_NEARESTL2A,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_COMP_NEAREST_NEARESTL3A, THR_COMP_NEAREST_NEARESTL3A,
#if CONFIG_LAST4_REF
THR_COMP_NEAREST_NEARESTL4A,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_COMP_NEAREST_NEARESTGA, THR_COMP_NEAREST_NEARESTGA,
@ -185,6 +231,9 @@ typedef enum {
THR_COMP_NEARESTL2A, THR_COMP_NEARESTL2A,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_COMP_NEARESTL3A, THR_COMP_NEARESTL3A,
#if CONFIG_LAST4_REF
THR_COMP_NEARESTL4A,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_COMP_NEARESTGA, THR_COMP_NEARESTGA,
@ -240,6 +289,20 @@ typedef enum {
THR_COMP_NEW_NEWL3A, THR_COMP_NEW_NEWL3A,
THR_COMP_ZERO_ZEROL3A, THR_COMP_ZERO_ZEROL3A,
#if CONFIG_LAST4_REF
THR_COMP_NEAR_NEARESTL4A,
THR_COMP_NEAREST_NEARL4A,
THR_COMP_NEW_NEARESTL4A,
THR_COMP_NEAREST_NEWL4A,
THR_COMP_NEW_NEARL4A,
THR_COMP_NEAR_NEWL4A,
THR_COMP_NEW_NEWL4A,
THR_COMP_ZERO_ZEROL4A,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -262,6 +325,12 @@ typedef enum {
THR_COMP_NEWL3A, THR_COMP_NEWL3A,
THR_COMP_ZEROL3A, THR_COMP_ZEROL3A,
#if CONFIG_LAST4_REF
THR_COMP_NEARL4A,
THR_COMP_NEWL4A,
THR_COMP_ZEROL4A,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -294,6 +363,13 @@ typedef enum {
THR_COMP_INTERINTRA_NEARL3, THR_COMP_INTERINTRA_NEARL3,
THR_COMP_INTERINTRA_NEWL3, THR_COMP_INTERINTRA_NEWL3,
#if CONFIG_LAST4_REF
THR_COMP_INTERINTRA_ZEROL4,
THR_COMP_INTERINTRA_NEARESTL4,
THR_COMP_INTERINTRA_NEARL4,
THR_COMP_INTERINTRA_NEWL4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -315,6 +391,9 @@ typedef enum {
THR_LAST2, THR_LAST2,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_LAST3, THR_LAST3,
#if CONFIG_LAST4_REF
THR_LAST4,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_GOLD, THR_GOLD,
@ -324,6 +403,9 @@ typedef enum {
THR_COMP_L2A, THR_COMP_L2A,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
THR_COMP_L3A, THR_COMP_L3A,
#if CONFIG_LAST4_REF
THR_COMP_L4A,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
THR_COMP_GA, THR_COMP_GA,

View File

@ -52,6 +52,29 @@
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
#define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
(1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST3_FRAME) | (1 << LAST4_FRAME))
#define LAST2_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
(1 << LAST_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST3_FRAME) | (1 << LAST4_FRAME))
#define LAST3_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
(1 << LAST_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST2_FRAME) | (1 << LAST4_FRAME))
#define LAST4_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
(1 << LAST_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST2_FRAME) | (1 << LAST3_FRAME))
#define GOLDEN_FRAME_MODE_MASK ((1 << LAST_FRAME) | (1 << ALTREF_FRAME) | \
(1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST3_FRAME) | (1 << LAST4_FRAME))
#define ALT_REF_MODE_MASK ((1 << LAST_FRAME) | (1 << GOLDEN_FRAME) | \
(1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST3_FRAME) | (1 << LAST4_FRAME))
#else // CONFIG_LAST4_REF
#define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \ #define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
(1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \ (1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST3_FRAME)) (1 << LAST3_FRAME))
@ -68,6 +91,8 @@
(1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \ (1 << LAST2_FRAME) | (1 << INTRA_FRAME) | \
(1 << LAST3_FRAME)) (1 << LAST3_FRAME))
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
#define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \ #define LAST_FRAME_MODE_MASK ((1 << GOLDEN_FRAME) | (1 << ALTREF_FRAME) | \
@ -132,6 +157,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEARESTMV, {LAST2_FRAME, NONE}}, {NEARESTMV, {LAST2_FRAME, NONE}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{NEARESTMV, {LAST3_FRAME, NONE}}, {NEARESTMV, {LAST3_FRAME, NONE}},
#if CONFIG_LAST4_REF
{NEARESTMV, {LAST4_FRAME, NONE}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{NEARESTMV, {ALTREF_FRAME, NONE}}, {NEARESTMV, {ALTREF_FRAME, NONE}},
@ -144,6 +172,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEWMV, {LAST2_FRAME, NONE}}, {NEWMV, {LAST2_FRAME, NONE}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{NEWMV, {LAST3_FRAME, NONE}}, {NEWMV, {LAST3_FRAME, NONE}},
#if CONFIG_LAST4_REF
{NEWMV, {LAST4_FRAME, NONE}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{NEWMV, {ALTREF_FRAME, NONE}}, {NEWMV, {ALTREF_FRAME, NONE}},
@ -155,6 +186,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEW2MV, {LAST2_FRAME, NONE}}, {NEW2MV, {LAST2_FRAME, NONE}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{NEW2MV, {LAST3_FRAME, NONE}}, {NEW2MV, {LAST3_FRAME, NONE}},
#if CONFIG_LAST4_REF
{NEW2MV, {LAST4_FRAME, NONE}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{NEW2MV, {ALTREF_FRAME, NONE}}, {NEW2MV, {ALTREF_FRAME, NONE}},
@ -166,6 +200,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEARMV, {LAST2_FRAME, NONE}}, {NEARMV, {LAST2_FRAME, NONE}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{NEARMV, {LAST3_FRAME, NONE}}, {NEARMV, {LAST3_FRAME, NONE}},
#if CONFIG_LAST4_REF
{NEARMV, {LAST4_FRAME, NONE}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{NEARMV, {ALTREF_FRAME, NONE}}, {NEARMV, {ALTREF_FRAME, NONE}},
@ -176,6 +213,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{ZEROMV, {LAST2_FRAME, NONE}}, {ZEROMV, {LAST2_FRAME, NONE}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{ZEROMV, {LAST3_FRAME, NONE}}, {ZEROMV, {LAST3_FRAME, NONE}},
#if CONFIG_LAST4_REF
{ZEROMV, {LAST4_FRAME, NONE}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{ZEROMV, {GOLDEN_FRAME, NONE}}, {ZEROMV, {GOLDEN_FRAME, NONE}},
@ -187,6 +227,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEAREST_NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}}, {NEAREST_NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{NEAREST_NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}}, {NEAREST_NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST4_REF
{NEAREST_NEARESTMV, {LAST4_FRAME, ALTREF_FRAME}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{NEAREST_NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}}, {NEAREST_NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}},
@ -197,6 +240,9 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}}, {NEARESTMV, {LAST2_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}}, {NEARESTMV, {LAST3_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST4_REF
{NEARESTMV, {LAST4_FRAME, ALTREF_FRAME}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}}, {NEARESTMV, {GOLDEN_FRAME, ALTREF_FRAME}},
@ -251,6 +297,21 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEW_NEWMV, {LAST3_FRAME, ALTREF_FRAME}}, {NEW_NEWMV, {LAST3_FRAME, ALTREF_FRAME}},
{ZERO_ZEROMV, {LAST3_FRAME, ALTREF_FRAME}}, {ZERO_ZEROMV, {LAST3_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST4_REF
{NEAR_NEARESTMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEAREST_NEARMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEW_NEARESTMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEAREST_NEWMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEW_NEARMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEAR_NEWMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEW_NEWMV, {LAST4_FRAME, ALTREF_FRAME}},
{ZERO_ZEROMV, {LAST4_FRAME, ALTREF_FRAME}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -273,6 +334,12 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEARMV, {LAST3_FRAME, ALTREF_FRAME}}, {NEARMV, {LAST3_FRAME, ALTREF_FRAME}},
{NEWMV, {LAST3_FRAME, ALTREF_FRAME}}, {NEWMV, {LAST3_FRAME, ALTREF_FRAME}},
{ZEROMV, {LAST3_FRAME, ALTREF_FRAME}}, {ZEROMV, {LAST3_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST4_REF
{NEARMV, {LAST4_FRAME, ALTREF_FRAME}},
{NEWMV, {LAST4_FRAME, ALTREF_FRAME}},
{ZEROMV, {LAST4_FRAME, ALTREF_FRAME}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -304,6 +371,13 @@ static const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
{NEARESTMV, {LAST3_FRAME, INTRA_FRAME}}, {NEARESTMV, {LAST3_FRAME, INTRA_FRAME}},
{NEARMV, {LAST3_FRAME, INTRA_FRAME}}, {NEARMV, {LAST3_FRAME, INTRA_FRAME}},
{NEWMV, {LAST3_FRAME, INTRA_FRAME}}, {NEWMV, {LAST3_FRAME, INTRA_FRAME}},
#if CONFIG_LAST4_REF
{ZEROMV, {LAST4_FRAME, INTRA_FRAME}},
{NEARESTMV, {LAST4_FRAME, INTRA_FRAME}},
{NEARMV, {LAST4_FRAME, INTRA_FRAME}},
{NEWMV, {LAST4_FRAME, INTRA_FRAME}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -325,6 +399,9 @@ static const REF_DEFINITION vp9_ref_order[MAX_REFS] = {
{{LAST2_FRAME, NONE}}, {{LAST2_FRAME, NONE}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{{LAST3_FRAME, NONE}}, {{LAST3_FRAME, NONE}},
#if CONFIG_LAST4_REF
{{LAST4_FRAME, NONE}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{{GOLDEN_FRAME, NONE}}, {{GOLDEN_FRAME, NONE}},
@ -334,6 +411,9 @@ static const REF_DEFINITION vp9_ref_order[MAX_REFS] = {
{{LAST2_FRAME, ALTREF_FRAME}}, {{LAST2_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
{{LAST3_FRAME, ALTREF_FRAME}}, {{LAST3_FRAME, ALTREF_FRAME}},
#if CONFIG_LAST4_REF
{{LAST4_FRAME, ALTREF_FRAME}},
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
{{GOLDEN_FRAME, ALTREF_FRAME}}, {{GOLDEN_FRAME, ALTREF_FRAME}},
@ -4466,6 +4546,9 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
vp9_prob ref_single_p3 = vp9_get_pred_prob_single_ref_p3(cm, xd); vp9_prob ref_single_p3 = vp9_get_pred_prob_single_ref_p3(cm, xd);
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
vp9_prob ref_single_p4 = vp9_get_pred_prob_single_ref_p4(cm, xd); vp9_prob ref_single_p4 = vp9_get_pred_prob_single_ref_p4(cm, xd);
#if CONFIG_LAST4_REF
vp9_prob ref_single_p5 = vp9_get_pred_prob_single_ref_p5(cm, xd);
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
unsigned int base_cost = vp9_cost_bit(intra_inter_p, 1); unsigned int base_cost = vp9_cost_bit(intra_inter_p, 1);
@ -4478,6 +4561,9 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
ref_costs_single[LAST2_FRAME] = ref_costs_single[LAST2_FRAME] =
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
ref_costs_single[LAST3_FRAME] = ref_costs_single[LAST3_FRAME] =
#if CONFIG_LAST4_REF
ref_costs_single[LAST4_FRAME] =
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
ref_costs_single[GOLDEN_FRAME] = ref_costs_single[GOLDEN_FRAME] =
@ -4485,6 +4571,26 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[LAST3_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[LAST4_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[GOLDEN_FRAME] += vp9_cost_bit(ref_single_p1, 1);
ref_costs_single[ALTREF_FRAME] += vp9_cost_bit(ref_single_p1, 1);
ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p3, 0);
ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p3, 0);
ref_costs_single[LAST3_FRAME] += vp9_cost_bit(ref_single_p3, 1);
ref_costs_single[LAST4_FRAME] += vp9_cost_bit(ref_single_p3, 1);
ref_costs_single[GOLDEN_FRAME] += vp9_cost_bit(ref_single_p2, 0);
ref_costs_single[ALTREF_FRAME] += vp9_cost_bit(ref_single_p2, 1);
ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p4, 0);
ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p4, 1);
ref_costs_single[LAST3_FRAME] += vp9_cost_bit(ref_single_p5, 0);
ref_costs_single[LAST4_FRAME] += vp9_cost_bit(ref_single_p5, 1);
#else // CONFIG_LAST4_REF
ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p1, 0); ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p1, 0); ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[LAST3_FRAME] += vp9_cost_bit(ref_single_p1, 0); ref_costs_single[LAST3_FRAME] += vp9_cost_bit(ref_single_p1, 0);
@ -4499,6 +4605,7 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p4, 0); ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p4, 0);
ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p4, 1); ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p4, 1);
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p1, 0); ref_costs_single[LAST_FRAME] += vp9_cost_bit(ref_single_p1, 0);
ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p1, 0); ref_costs_single[LAST2_FRAME] += vp9_cost_bit(ref_single_p1, 0);
@ -4522,6 +4629,9 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
ref_costs_single[LAST2_FRAME] = 512; ref_costs_single[LAST2_FRAME] = 512;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
ref_costs_single[LAST3_FRAME] = 512; ref_costs_single[LAST3_FRAME] = 512;
#if CONFIG_LAST4_REF
ref_costs_single[LAST4_FRAME] = 512;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
ref_costs_single[GOLDEN_FRAME] = 512; ref_costs_single[GOLDEN_FRAME] = 512;
@ -4534,6 +4644,9 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
vp9_prob ref_comp_p1 = vp9_get_pred_prob_comp_ref_p1(cm, xd); vp9_prob ref_comp_p1 = vp9_get_pred_prob_comp_ref_p1(cm, xd);
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
vp9_prob ref_comp_p2 = vp9_get_pred_prob_comp_ref_p2(cm, xd); vp9_prob ref_comp_p2 = vp9_get_pred_prob_comp_ref_p2(cm, xd);
#if CONFIG_LAST4_REF
vp9_prob ref_comp_p3 = vp9_get_pred_prob_comp_ref_p3(cm, xd);
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
unsigned int base_cost = vp9_cost_bit(intra_inter_p, 1); unsigned int base_cost = vp9_cost_bit(intra_inter_p, 1);
@ -4546,6 +4659,9 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
ref_costs_comp[LAST2_FRAME] = ref_costs_comp[LAST2_FRAME] =
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
ref_costs_comp[LAST3_FRAME] = ref_costs_comp[LAST3_FRAME] =
#if CONFIG_LAST4_REF
ref_costs_comp[LAST4_FRAME] =
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
ref_costs_comp[GOLDEN_FRAME] = ref_costs_comp[GOLDEN_FRAME] =
@ -4553,6 +4669,22 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
#if CONFIG_MULTI_REF #if CONFIG_MULTI_REF
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
#if CONFIG_LAST4_REF
ref_costs_comp[LAST_FRAME] += vp9_cost_bit(ref_comp_p, 0);
ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p, 0);
ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p, 1);
ref_costs_comp[LAST4_FRAME] += vp9_cost_bit(ref_comp_p, 1);
ref_costs_comp[GOLDEN_FRAME] += vp9_cost_bit(ref_comp_p, 1);
ref_costs_comp[LAST_FRAME] += vp9_cost_bit(ref_comp_p1, 1);
ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p1, 0);
ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p2, 0);
ref_costs_comp[LAST4_FRAME] += vp9_cost_bit(ref_comp_p2, 0);
ref_costs_comp[GOLDEN_FRAME] += vp9_cost_bit(ref_comp_p2, 1);
ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p3, 1);
ref_costs_comp[LAST4_FRAME] += vp9_cost_bit(ref_comp_p3, 0);
#else // CONFIG_LAST4_REF
ref_costs_comp[LAST_FRAME] += vp9_cost_bit(ref_comp_p, 0); ref_costs_comp[LAST_FRAME] += vp9_cost_bit(ref_comp_p, 0);
ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p, 0); ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p, 0);
ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p, 1); ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p, 1);
@ -4562,6 +4694,7 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p1, 0); ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p1, 0);
ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p2, 0); ref_costs_comp[LAST3_FRAME] += vp9_cost_bit(ref_comp_p2, 0);
ref_costs_comp[GOLDEN_FRAME] += vp9_cost_bit(ref_comp_p2, 1); ref_costs_comp[GOLDEN_FRAME] += vp9_cost_bit(ref_comp_p2, 1);
#endif // CONFIG_LAST4_REF
#else // CONFIG_LAST3_REF #else // CONFIG_LAST3_REF
ref_costs_comp[LAST_FRAME] += vp9_cost_bit(ref_comp_p, 0); ref_costs_comp[LAST_FRAME] += vp9_cost_bit(ref_comp_p, 0);
ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p, 0); ref_costs_comp[LAST2_FRAME] += vp9_cost_bit(ref_comp_p, 0);
@ -4580,6 +4713,9 @@ static void estimate_ref_frame_costs(const VP9_COMMON *cm,
ref_costs_comp[LAST2_FRAME] = 512; ref_costs_comp[LAST2_FRAME] = 512;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
ref_costs_comp[LAST3_FRAME] = 512; ref_costs_comp[LAST3_FRAME] = 512;
#if CONFIG_LAST4_REF
ref_costs_comp[LAST4_FRAME] = 512;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
ref_costs_comp[GOLDEN_FRAME] = 512; ref_costs_comp[GOLDEN_FRAME] = 512;
@ -6664,6 +6800,9 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
VP9_LAST2_FLAG, VP9_LAST2_FLAG,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
VP9_LAST3_FLAG, VP9_LAST3_FLAG,
#if CONFIG_LAST4_REF
VP9_LAST4_FLAG,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
VP9_GOLD_FLAG, VP9_GOLD_FLAG,
@ -6848,6 +6987,9 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
(1 << LAST2_FRAME) | (1 << LAST2_FRAME) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(1 << LAST3_FRAME) | (1 << LAST3_FRAME) |
#if CONFIG_LAST4_REF
(1 << LAST4_FRAME) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(1 << GOLDEN_FRAME); (1 << GOLDEN_FRAME);
@ -7008,6 +7150,12 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
ref_frame_skip_mask[0] |= LAST3_FRAME_MODE_MASK; ref_frame_skip_mask[0] |= LAST3_FRAME_MODE_MASK;
ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK;
break; break;
#if CONFIG_LAST4_REF
case LAST4_FRAME:
ref_frame_skip_mask[0] |= LAST4_FRAME_MODE_MASK;
ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK;
break;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
case GOLDEN_FRAME: case GOLDEN_FRAME:
@ -7036,9 +7184,16 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
continue; continue;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
if ((cm->frame_before_last_type == KEY_FRAME || if ((cm->last2_frame_type == KEY_FRAME ||
cm->last_frame_type == KEY_FRAME) && ref_frame == LAST3_FRAME) cm->last_frame_type == KEY_FRAME) && ref_frame == LAST3_FRAME)
continue; continue;
#if CONFIG_LAST4_REF
if ((cm->last3_frame_type == KEY_FRAME ||
cm->last2_frame_type == KEY_FRAME ||
cm->last_frame_type == KEY_FRAME) && ref_frame == LAST4_FRAME)
continue;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -8404,6 +8559,9 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
VP9_LAST2_FLAG, VP9_LAST2_FLAG,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
VP9_LAST3_FLAG, VP9_LAST3_FLAG,
#if CONFIG_LAST4_REF
VP9_LAST4_FLAG,
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
VP9_GOLD_FLAG, VP9_GOLD_FLAG,
@ -8540,9 +8698,16 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
continue; continue;
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
if ((cm->frame_before_last_type == KEY_FRAME || if ((cm->last2_frame_type == KEY_FRAME ||
cm->last_frame_type == KEY_FRAME) && ref_frame == LAST3_FRAME) cm->last_frame_type == KEY_FRAME) && ref_frame == LAST3_FRAME)
continue; continue;
#if CONFIG_LAST4_REF
if ((cm->last3_frame_type == KEY_FRAME ||
cm->last2_frame_type == KEY_FRAME ||
cm->last_frame_type == KEY_FRAME) && ref_frame == LAST4_FRAME)
continue;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -8559,6 +8724,9 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
(1 << LAST2_FRAME) | (1 << LAST2_FRAME) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(1 << LAST3_FRAME) | (1 << LAST3_FRAME) |
#if CONFIG_LAST4_REF
(1 << LAST4_FRAME) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(1 << ALTREF_FRAME); (1 << ALTREF_FRAME);
@ -8570,6 +8738,9 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | ref_frame_skip_mask[0] |= (1 << LAST_FRAME) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(1 << LAST3_FRAME) | (1 << LAST3_FRAME) |
#if CONFIG_LAST4_REF
(1 << LAST4_FRAME) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
(1 << GOLDEN_FRAME) | (1 << GOLDEN_FRAME) |
(1 << ALTREF_FRAME); (1 << ALTREF_FRAME);
@ -8580,10 +8751,24 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
case LAST3_FRAME: case LAST3_FRAME:
ref_frame_skip_mask[0] |= (1 << LAST_FRAME) | ref_frame_skip_mask[0] |= (1 << LAST_FRAME) |
(1 << LAST2_FRAME) | (1 << LAST2_FRAME) |
#if CONFIG_LAST4_REF
(1 << LAST4_FRAME) |
#endif // CONFIG_LAST4_REF
(1 << GOLDEN_FRAME) | (1 << GOLDEN_FRAME) |
(1 << ALTREF_FRAME); (1 << ALTREF_FRAME);
ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK; ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK;
break; break;
#if CONFIG_LAST4_REF
case LAST4_FRAME:
ref_frame_skip_mask[0] |= (1 << LAST_FRAME) |
(1 << LAST2_FRAME) |
(1 << LAST3_FRAME) |
(1 << GOLDEN_FRAME) |
(1 << ALTREF_FRAME);
ref_frame_skip_mask[1] |= SECOND_REF_FRAME_MASK;
break;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
@ -8593,6 +8778,9 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
(1 << LAST2_FRAME) | (1 << LAST2_FRAME) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(1 << LAST3_FRAME) | (1 << LAST3_FRAME) |
#if CONFIG_LAST4_REF
(1 << LAST4_FRAME) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(1 << ALTREF_FRAME); (1 << ALTREF_FRAME);
@ -8605,6 +8793,9 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
(1 << LAST2_FRAME) | (1 << LAST2_FRAME) |
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
(1 << LAST3_FRAME) | (1 << LAST3_FRAME) |
#if CONFIG_LAST4_REF
(1 << LAST4_FRAME) |
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
(1 << GOLDEN_FRAME); (1 << GOLDEN_FRAME);
@ -8748,6 +8939,10 @@ void vp9_rd_pick_inter_mode_sub8x8(VP9_COMP *cpi, MACROBLOCK *x,
#if CONFIG_LAST3_REF #if CONFIG_LAST3_REF
this_rd_thresh = (ref_frame == LAST3_FRAME) ? this_rd_thresh = (ref_frame == LAST3_FRAME) ?
rd_opt->threshes[segment_id][bsize][THR_LAST3] : this_rd_thresh; rd_opt->threshes[segment_id][bsize][THR_LAST3] : this_rd_thresh;
#if CONFIG_LAST4_REF
this_rd_thresh = (ref_frame == LAST4_FRAME) ?
rd_opt->threshes[segment_id][bsize][THR_LAST4] : this_rd_thresh;
#endif // CONFIG_LAST4_REF
#endif // CONFIG_LAST3_REF #endif // CONFIG_LAST3_REF
#endif // CONFIG_MULTI_REF #endif // CONFIG_MULTI_REF
this_rd_thresh = (ref_frame == GOLDEN_FRAME) ? this_rd_thresh = (ref_frame == GOLDEN_FRAME) ?