Commit 060e192b authored by Cheng Chen's avatar Cheng Chen

JNT_COMP: turn off for one_sided_compound

One_sided_compound is less likely to provide gains for jnt_comp.
Stop jnt_comp search when one_sided_compound is true. It saves coding
time as well as bit overhead.

Change-Id: I6714e5d211eba14a5793bdae7215ccfcc1d8f67a
parent 473cf898
......@@ -1364,6 +1364,28 @@ static INLINE int use_compressed_header(const AV1_COMMON *cm) {
#endif // CONFIG_NEW_MULTISYMBOL
}
#if CONFIG_JNT_COMP
static INLINE int has_two_sided_comp_refs(const AV1_COMMON *cm,
const MB_MODE_INFO *mbmi) {
if (!has_second_ref(mbmi)) return 0;
const int bck_idx = cm->frame_refs[mbmi->ref_frame[0] - LAST_FRAME].idx;
const int fwd_idx = cm->frame_refs[mbmi->ref_frame[1] - LAST_FRAME].idx;
if (bck_idx < 0 || fwd_idx < 0) return 0;
const int cur_frame_index = cm->cur_frame->cur_frame_offset;
const int bck_frame_index =
cm->buffer_pool->frame_bufs[bck_idx].cur_frame_offset;
const int fwd_frame_index =
cm->buffer_pool->frame_bufs[fwd_idx].cur_frame_offset;
return ((bck_frame_index > cur_frame_index) &&
(fwd_frame_index < cur_frame_index)) ||
((bck_frame_index < cur_frame_index) &&
(fwd_frame_index > cur_frame_index));
}
#endif // CONFIG_JNT_COMP
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -115,7 +115,7 @@ static INLINE int get_comp_index_context(const AV1_COMMON *cm,
if (above_mi) {
const MB_MODE_INFO *above_mbmi = &above_mi->mbmi;
if (has_second_ref(above_mbmi))
if (has_two_sided_comp_refs(cm, above_mbmi))
above_ctx = above_mbmi->compound_idx;
else if (above_mbmi->ref_frame[0] == ALTREF_FRAME)
above_ctx = 1;
......@@ -123,7 +123,7 @@ static INLINE int get_comp_index_context(const AV1_COMMON *cm,
if (left_mi) {
const MB_MODE_INFO *left_mbmi = &left_mi->mbmi;
if (has_second_ref(left_mbmi))
if (has_two_sided_comp_refs(cm, left_mbmi))
left_ctx = left_mbmi->compound_idx;
else if (left_mbmi->ref_frame[0] == ALTREF_FRAME)
left_ctx = 1;
......
......@@ -930,11 +930,11 @@ typedef struct SubpelParams {
#if CONFIG_JNT_COMP
void av1_jnt_comp_weight_assign(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
int order_idx, int *fwd_offset, int *bck_offset,
int is_compound) {
int order_idx, int *fwd_offset,
int *bck_offset) {
assert(fwd_offset != NULL && bck_offset != NULL);
if (is_compound) {
if (has_two_sided_comp_refs(cm, mbmi)) {
int bck_idx = cm->frame_refs[mbmi->ref_frame[0] - LAST_FRAME].idx;
int fwd_idx = cm->frame_refs[mbmi->ref_frame[1] - LAST_FRAME].idx;
int bck_frame_index = 0, fwd_frame_index = 0;
......@@ -1295,7 +1295,7 @@ static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
get_conv_params_no_round(ref, ref, plane, tmp_dst, MAX_SB_SIZE);
#if CONFIG_JNT_COMP
av1_jnt_comp_weight_assign(cm, &mi->mbmi, 0, &conv_params.fwd_offset,
&conv_params.bck_offset, is_compound);
&conv_params.bck_offset);
#endif // CONFIG_JNT_COMP
#else
......
......@@ -559,11 +559,10 @@ void av1_build_wedge_inter_predictor_from_buf(MACROBLOCKD *xd, BLOCK_SIZE bsize,
int ext_dst_stride0[3],
uint8_t *ext_dst1[3],
int ext_dst_stride1[3]);
#if CONFIG_JNT_COMP
void av1_jnt_comp_weight_assign(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
int order_idx, int *fwd_offset, int *bck_offset,
int is_compound);
int order_idx, int *fwd_offset,
int *bck_offset);
#endif // CONFIG_JNT_COMP
#ifdef __cplusplus
......
......@@ -2159,12 +2159,14 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
is_compound = has_second_ref(mbmi);
#if CONFIG_JNT_COMP
if (is_compound) {
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
mbmi->compound_idx =
aom_read(r, ec_ctx->compound_index_probs[comp_index_ctx], ACCT_STR);
if (xd->counts)
++xd->counts->compound_index[comp_index_ctx][mbmi->compound_idx];
} else {
mbmi->compound_idx = 1;
}
#endif // CONFIG_JNT_COMP
......
......@@ -1497,7 +1497,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
write_ref_frames(cm, xd, w);
#if CONFIG_JNT_COMP
if (has_second_ref(mbmi)) {
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
aom_write(w, mbmi->compound_idx,
ec_ctx->compound_index_probs[comp_index_ctx]);
......
......@@ -608,7 +608,7 @@ static void update_state(const AV1_COMP *const cpi, TileDataEnc *tile_data,
av1_copy_frame_mvs(cm, mi, mi_row, mi_col, x_mis, y_mis);
#if CONFIG_JNT_COMP
if (has_second_ref(mbmi)) {
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
++td->counts->compound_index[comp_index_ctx][mbmi->compound_idx];
}
......
......@@ -5992,7 +5992,7 @@ static void joint_motion_search(const AV1_COMP *cpi, MACROBLOCK *x,
#if CONFIG_JNT_COMP
const int order_idx = id != 0;
av1_jnt_comp_weight_assign(cm, mbmi, order_idx, &xd->jcp_param.fwd_offset,
&xd->jcp_param.bck_offset, 1);
&xd->jcp_param.bck_offset);
#endif // CONFIG_JNT_COMP
// Do compound motion search on the current reference frame.
......@@ -6708,7 +6708,7 @@ static void build_second_inter_pred(const AV1_COMP *cpi, MACROBLOCK *x,
#if CONFIG_JNT_COMP
av1_jnt_comp_weight_assign(cm, mbmi, 0, &xd->jcp_param.fwd_offset,
&xd->jcp_param.bck_offset, 1);
&xd->jcp_param.bck_offset);
#endif // CONFIG_JNT_COMP
if (scaled_ref_frame) {
......@@ -8247,7 +8247,7 @@ static int64_t handle_inter_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
#endif // CONFIG_COMPOUND_SINGLEREF
#if CONFIG_JNT_COMP
if (is_comp_pred) {
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
rd_stats->rate += av1_cost_bit(cm->fc->compound_index_probs[comp_index_ctx],
mbmi->compound_idx);
......@@ -9979,6 +9979,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
#if CONFIG_JNT_COMP
{
int cum_rate = rate2;
mbmi->compound_idx = 1;
MB_MODE_INFO backup_mbmi = *mbmi;
int_mv backup_frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME];
......@@ -9996,6 +9997,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
for (int comp_idx = 0; comp_idx < 1 + has_second_ref(mbmi);
++comp_idx) {
if (comp_idx == 0 && !has_two_sided_comp_refs(cm, mbmi)) continue;
RD_STATS rd_stats, rd_stats_y, rd_stats_uv;
av1_init_rd_stats(&rd_stats);
av1_init_rd_stats(&rd_stats_y);
......@@ -10148,6 +10150,8 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
ref_idx = sidx;
if (has_second_ref(mbmi)) ref_idx /= 2;
mbmi->compound_idx = sidx % 2;
if (mbmi->compound_idx == 0 && !has_two_sided_comp_refs(cm, mbmi))
continue;
#endif // CONFIG_JNT_COMP
av1_invalid_rd_stats(&tmp_rd_stats);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment