From 79864820dee14bb4683633899c55fcda4258b22a Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 4 Apr 2016 11:57:37 -0700 Subject: [PATCH] Refactor vp10_drl_idx concept Remove the implicit assumption on offsetting the index by 1. Change-Id: I2d2b9848916e16723fddd58e7a15e4e7ac4963e3 --- av1/common/mvref_common.h | 12 ++++++------ av1/decoder/decodemv.c | 4 ++-- av1/encoder/bitstream.c | 4 ++-- av1/encoder/encodeframe.c | 4 ++-- av1/encoder/rdopt.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h index 6b5580eca..851febd99 100644 --- a/av1/common/mvref_common.h +++ b/av1/common/mvref_common.h @@ -354,16 +354,16 @@ static int16_t av1_mode_context_analyzer(const int16_t *const mode_context, static INLINE uint8_t av1_drl_ctx(const CANDIDATE_MV *ref_mv_stack, int ref_idx) { - if (ref_mv_stack[ref_idx + 1].weight >= REF_CAT_LEVEL && - ref_mv_stack[ref_idx + 2].weight >= REF_CAT_LEVEL) + if (ref_mv_stack[ref_idx].weight >= REF_CAT_LEVEL && + ref_mv_stack[ref_idx + 1].weight >= REF_CAT_LEVEL) return 0; - if (ref_mv_stack[ref_idx + 1].weight >= REF_CAT_LEVEL && - ref_mv_stack[ref_idx + 2].weight < REF_CAT_LEVEL) + if (ref_mv_stack[ref_idx].weight >= REF_CAT_LEVEL && + ref_mv_stack[ref_idx + 1].weight < REF_CAT_LEVEL) return 1; - if (ref_mv_stack[ref_idx + 1].weight < REF_CAT_LEVEL && - ref_mv_stack[ref_idx + 2].weight < REF_CAT_LEVEL) + if (ref_mv_stack[ref_idx].weight < REF_CAT_LEVEL && + ref_mv_stack[ref_idx + 1].weight < REF_CAT_LEVEL) return 2; assert(0); diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c index 699502d55..7ca53fc02 100644 --- a/av1/decoder/decodemv.c +++ b/av1/decoder/decodemv.c @@ -118,7 +118,7 @@ static void read_drl_idx(const AV1_COMMON *cm, mbmi->ref_mv_idx = 0; if (xd->ref_mv_count[ref_frame_type] > 2) { - uint8_t drl0_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], 0); + uint8_t drl0_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], 1); aom_prob drl0_prob = cm->fc->drl_prob0[drl0_ctx]; if (aom_read(r, drl0_prob)) { mbmi->ref_mv_idx = 1; @@ -126,7 +126,7 @@ static void read_drl_idx(const AV1_COMMON *cm, ++xd->counts->drl_mode0[drl0_ctx][1]; if (xd->ref_mv_count[ref_frame_type] > 3) { uint8_t drl1_ctx = - av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], 1); + av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], 2); aom_prob drl1_prob = cm->fc->drl_prob1[drl1_ctx]; if (aom_read(r, drl1_prob)) { mbmi->ref_mv_idx = 2; diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 94f935c56..d12e4fe48 100644 --- a/av1/encoder/bitstream.c +++ b/av1/encoder/bitstream.c @@ -117,13 +117,13 @@ static void write_drl_idx(const AV1_COMMON *cm, uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame); if (mbmi_ext->ref_mv_count[ref_frame_type] > 2) { uint8_t drl0_ctx = - av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 0); + av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1); aom_prob drl0_prob = cm->fc->drl_prob0[drl0_ctx]; aom_write(w, mbmi->ref_mv_idx != 0, drl0_prob); if (mbmi_ext->ref_mv_count[ref_frame_type] > 3 && mbmi->ref_mv_idx > 0) { uint8_t drl1_ctx = - av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1); + av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 2); aom_prob drl1_prob = cm->fc->drl_prob1[drl1_ctx]; aom_write(w, mbmi->ref_mv_idx != 1, drl1_prob); } diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 8b45fa8dd..cfb70d117 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c @@ -1245,7 +1245,7 @@ static void update_stats(AV1_COMMON *cm, ThreadData *td) { uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame); if (mbmi_ext->ref_mv_count[ref_frame_type] > 2) { uint8_t drl0_ctx = - av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 0); + av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1); if (mbmi->ref_mv_idx == 0) ++counts->drl_mode0[drl0_ctx][0]; else @@ -1254,7 +1254,7 @@ static void update_stats(AV1_COMMON *cm, ThreadData *td) { if (mbmi_ext->ref_mv_count[ref_frame_type] > 3 && mbmi->ref_mv_idx > 0) { uint8_t drl1_ctx = - av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1); + av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 2); if (mbmi->ref_mv_idx == 1) ++counts->drl_mode1[drl1_ctx][0]; else diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index f69d2d608..97413357f 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c @@ -3266,7 +3266,7 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data, int ref_idx; int ref_set = AOMMIN(2, mbmi_ext->ref_mv_count[ref_frame_type] - 2); uint8_t drl0_ctx = - av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 0); + av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1); rate2 += cpi->drl_mode_cost0[drl0_ctx][0]; @@ -3320,7 +3320,7 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data, if (mbmi_ext->ref_mv_count[ref_frame_type] > 3) { uint8_t drl1_ctx = - av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 1); + av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], 2); tmp_rate += cpi->drl_mode_cost1[drl1_ctx][ref_idx]; }