Commit f704a1c8 authored by Zoe Liu's avatar Zoe Liu
Browse files

Add decoder support to ext_skip

At the frame header level, add the checking on whether an inter-coded
frame allows the use of 'skip_mode'. At the block level, add the
decoding of 'skip_mode' for all the blocks if 'skip_mode' is allowed
for the current frame. If 'skip_mode' is set, no further bit needs to
read out, and the block is set as:
- Inter-coded in compound mode;
- With the nearest forward and backward reference frames;
- In NEAREST_NEARESTMV mode;
- In SIMPLE_TRANSLATION motion mode;
- In COMPOUND_AVERAGE compound type; and
- Skip set for residual.

Change-Id: I50297f63a81135109332c4a51b516bffd7726777
parent 7193f020
......@@ -297,6 +297,9 @@ typedef struct MB_MODE_INFO {
TX_SIZE inter_tx_size[MAX_MIB_SIZE][MAX_MIB_SIZE];
TX_SIZE min_tx_size;
int8_t skip;
#if CONFIG_EXT_SKIP
int8_t skip_mode;
#endif // CONFIG_EXT_SKIP
int8_t segment_id;
int8_t seg_id_predicted; // valid only when temporal_update is enabled
......
......@@ -2009,12 +2009,22 @@ static const aom_cdf_prob
#endif // CONFIG_NEW_MULTISYMBOL
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
static const aom_cdf_prob default_skip_mode_cdfs[SKIP_MODE_CONTEXTS][CDF_SIZE(
2)] = { { AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(32768), 0 } };
#endif // CONFIG_EXT_SKIP
static const aom_cdf_prob default_skip_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)] = {
{ AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(32768), 0 }
};
#else
#else // !CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
static const aom_prob default_skip_mode_probs[SKIP_MODE_CONTEXTS] = { 192, 128,
64 };
#endif // CONFIG_EXT_SKIP
static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
#endif // CONFIG_NEW_MULTISYMBOL
......@@ -5993,9 +6003,15 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->intra_ext_tx_cdf, default_intra_ext_tx_cdf);
av1_copy(fc->inter_ext_tx_cdf, default_inter_ext_tx_cdf);
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
av1_copy(fc->skip_mode_cdfs, default_skip_mode_cdfs);
#endif // CONFIG_EXT_SKIP
av1_copy(fc->skip_cdfs, default_skip_cdfs);
av1_copy(fc->intra_inter_cdf, default_intra_inter_cdf);
#else
#else // !CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
av1_copy(fc->skip_mode_probs, default_skip_mode_probs);
#endif // CONFIG_EXT_SKIP
av1_copy(fc->skip_probs, default_skip_probs);
#endif // CONFIG_NEW_MULTISYMBOL
av1_copy(fc->seg.tree_cdf, default_seg_tree_cdf);
......@@ -6165,6 +6181,11 @@ void av1_adapt_intra_frame_probs(AV1_COMMON *cm) {
}
#if !CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
for (i = 0; i < SKIP_MODE_CONTEXTS; ++i)
fc->skip_mode_probs[i] = av1_mode_mv_merge_probs(pre_fc->skip_mode_probs[i],
counts->skip_mode[i]);
#endif // CONFIG_EXT_SKIP
for (i = 0; i < SKIP_CONTEXTS; ++i)
fc->skip_probs[i] =
av1_mode_mv_merge_probs(pre_fc->skip_probs[i], counts->skip[i]);
......
......@@ -290,9 +290,15 @@ typedef struct frame_contexts {
aom_prob compound_index_probs[COMP_INDEX_CONTEXTS];
#endif // CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
aom_cdf_prob skip_mode_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)];
#endif // CONFIG_EXT_SKIP
aom_cdf_prob skip_cdfs[SKIP_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob intra_inter_cdf[INTRA_INTER_CONTEXTS][CDF_SIZE(2)];
#else
#else // !CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_SKIP
aom_prob skip_mode_probs[SKIP_CONTEXTS];
#endif // CONFIG_EXT_SKIP
aom_prob skip_probs[SKIP_CONTEXTS];
#endif // CONFIG_NEW_MULTISYMBOL
nmv_context nmvc[NMV_CONTEXTS];
......@@ -475,6 +481,9 @@ typedef struct FRAME_COUNTS {
unsigned int quarter_tx_size[2];
#endif
unsigned int txfm_partition[TXFM_PARTITION_CONTEXTS][2];
#if CONFIG_EXT_SKIP
unsigned int skip_mode[SKIP_MODE_CONTEXTS][2];
#endif // CONFIG_EXT_SKIP
unsigned int skip[SKIP_CONTEXTS][2];
nmv_context_counts mv[NMV_CONTEXTS];
#if CONFIG_JNT_COMP
......
......@@ -633,6 +633,9 @@ typedef enum ATTRIBUTE_PACKED {
#define INTER_COMPOUND_MODES (1 + NEW_NEWMV - NEAREST_NEARESTMV)
#define SKIP_CONTEXTS 3
#if CONFIG_EXT_SKIP
#define SKIP_MODE_CONTEXTS 3
#endif // CONFIG_EXT_SKIP
#if CONFIG_JNT_COMP
#define COMP_INDEX_CONTEXTS 9
......
......@@ -1376,6 +1376,59 @@ void av1_setup_frame_sign_bias(AV1_COMMON *cm) {
}
}
#endif // CONFIG_FRAME_SIGN_BIAS
#if CONFIG_EXT_SKIP
void av1_setup_skip_mode_allowed(AV1_COMMON *const cm) {
cm->is_skip_mode_allowed = 0;
cm->ref_frame_idx_0 = cm->ref_frame_idx_1 = INVALID_IDX;
if (cm->frame_type == KEY_FRAME || cm->intra_only) return;
BufferPool *const pool = cm->buffer_pool;
RefCntBuffer *const frame_bufs = pool->frame_bufs;
int ref_frame_offset_0 = -1;
int ref_frame_offset_1 = INT_MAX;
int ref_idx_0 = INVALID_IDX;
int ref_idx_1 = INVALID_IDX;
// Identify the nearest forward and backward references
for (int i = 0; i < INTER_REFS_PER_FRAME; ++i) {
RefBuffer *const ref_frame = &cm->frame_refs[i];
const int buf_idx = ref_frame->idx;
// Invalid reference frame buffer
if (buf_idx == INVALID_IDX) continue;
const int ref_offset = frame_bufs[buf_idx].cur_frame_offset;
if (ref_offset < (int)cm->frame_offset) {
// Forward reference
if (ref_offset > ref_frame_offset_0) {
ref_frame_offset_0 = ref_offset;
ref_idx_0 = i;
}
} else if (ref_offset > (int)cm->frame_offset) {
// Backward reference
if (ref_offset < ref_frame_offset_1) {
ref_frame_offset_1 = ref_offset;
ref_idx_1 = i;
}
}
}
// Flag is set when and only when both forward and backward references
// are available and their distance is no greater than 3, i.e. as
// opposed to the current frame position, the reference distance pair are
// either: (1, 1), (1, 2), or (2, 1).
if (ref_idx_0 != INVALID_IDX && ref_idx_1 != INVALID_IDX) {
if ((ref_frame_offset_1 - ref_frame_offset_0) <= 3) {
cm->is_skip_mode_allowed = 1;
cm->ref_frame_idx_0 = ref_idx_0;
cm->ref_frame_idx_1 = ref_idx_1;
}
}
}
#endif // CONFIG_EXT_SKIP
#endif // CONFIG_FRAME_MARKER
#if CONFIG_MFMV
......
......@@ -384,6 +384,9 @@ void av1_setup_frame_buf_refs(AV1_COMMON *cm);
#if CONFIG_FRAME_SIGN_BIAS
void av1_setup_frame_sign_bias(AV1_COMMON *cm);
#endif // CONFIG_FRAME_SIGN_BIAS
#if CONFIG_EXT_SKIP
void av1_setup_skip_mode_allowed(AV1_COMMON *cm);
#endif // CONFIG_EXT_SKIP
#if CONFIG_MFMV
void av1_setup_motion_field(AV1_COMMON *cm);
#endif // CONFIG_MFMV
......
......@@ -248,6 +248,11 @@ typedef struct AV1Common {
// Each Inter frame can reference INTER_REFS_PER_FRAME buffers
RefBuffer frame_refs[INTER_REFS_PER_FRAME];
#if CONFIG_EXT_SKIP
int is_skip_mode_allowed;
int ref_frame_idx_0;
int ref_frame_idx_1;
#endif // CONFIG_EXT_SKIP
int new_fb_idx;
......
......@@ -108,6 +108,16 @@ static INLINE aom_cdf_prob *av1_get_pred_cdf_seg_id(
}
#endif
#if CONFIG_EXT_SKIP
static INLINE int av1_get_skip_mode_context(const MACROBLOCKD *xd) {
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
const int above_skip_mode = above_mi ? above_mi->mbmi.skip_mode : 0;
const int left_skip_mode = left_mi ? left_mi->mbmi.skip_mode : 0;
return above_skip_mode + left_skip_mode;
}
#endif // CONFIG_EXT_SKIP
static INLINE int av1_get_skip_context(const MACROBLOCKD *xd) {
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
......
......@@ -449,6 +449,9 @@ static INLINE int av1_is_interp_needed(const MACROBLOCKD *const xd) {
(void)xd;
const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
if (mbmi->motion_mode == WARPED_CAUSAL) return 0;
#if CONFIG_EXT_SKIP
if (mbmi->skip_mode) return 0;
#endif // CONFIG_EXT_SKIP
if (is_nontrans_global_motion(xd)) return 0;
return 1;
}
......
......@@ -3727,6 +3727,16 @@ size_t av1_decode_frame_headers_and_setup(AV1Decoder *pbi, const uint8_t *data,
(cm->last_frame_type != KEY_FRAME);
#endif // CONFIG_TEMPMV_SIGNALING
#if CONFIG_EXT_SKIP
av1_setup_skip_mode_allowed(cm);
#if 0
printf("\nDECODER: Frame=%d, frame_offset=%d, show_frame=%d, "
"is_skip_mode_allowed=%d, ref_frame_idx=(%d,%d)\n",
cm->current_video_frame, cm->frame_offset, cm->show_frame,
cm->is_skip_mode_allowed, cm->ref_frame_idx_0, cm->ref_frame_idx_1);
#endif // 0
#endif // CONFIG_EXT_SKIP
#if CONFIG_MFMV
av1_setup_motion_field(cm);
#endif // CONFIG_MFMV
......
......@@ -346,9 +346,22 @@ static void read_ncobmc_mode(MACROBLOCKD *xd, MODE_INFO *mi,
static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r, int16_t ctx) {
(void)cm;
#if CONFIG_EXT_SKIP
FRAME_CONTEXT *const ec_ctx = xd->tile_ctx;
const int mode =
xd->mi[0]->mbmi.skip_mode
? (NEAREST_NEARESTMV - NEAREST_NEARESTMV)
: aom_read_symbol(r, ec_ctx->inter_compound_mode_cdf[ctx],
INTER_COMPOUND_MODES, ACCT_STR);
if (xd->mi[0]->mbmi.skip_mode)
update_cdf(ec_ctx->inter_compound_mode_cdf[ctx], mode,
INTER_COMPOUND_MODES);
#else
const int mode =
aom_read_symbol(r, xd->tile_ctx->inter_compound_mode_cdf[ctx],
INTER_COMPOUND_MODES, ACCT_STR);
#endif // CONFIG_EXT_SKIP
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->inter_compound_mode[ctx][mode];
assert(is_inter_compound_mode(NEAREST_NEARESTMV + mode));
......@@ -631,6 +644,33 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
return segment_id;
}
#if CONFIG_EXT_SKIP
static int read_skip_mode(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
aom_reader *r) {
if (!cm->is_skip_mode_allowed) return 0;
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
// TODO(zoeliu): To revisit the handling of this scenario.
return 0;
} else {
const int ctx = av1_get_skip_mode_context(xd);
#if CONFIG_NEW_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
const int skip_mode =
aom_read_symbol(r, ec_ctx->skip_mode_cdfs[ctx], 2, ACCT_STR);
#else
const int skip_mode = aom_read(r, cm->fc->skip_mode_probs[ctx], ACCT_STR);
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->skip_mode[ctx][skip_mode];
// TODO(zoeliu): To handle:
// if (!is_comp_ref_allowed(xd->mi[0]->mbmi.sb_type))
return skip_mode;
}
}
#endif // CONFIG_EXT_SKIP
static int read_skip(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
aom_reader *r) {
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
......@@ -1399,6 +1439,21 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
}
}
#if CONFIG_EXT_SKIP
static void update_block_reference_mode(AV1_COMMON *cm, const MACROBLOCKD *xd,
REFERENCE_MODE mode) {
if (cm->reference_mode == REFERENCE_MODE_SELECT) {
assert(mode == SINGLE_REFERENCE || mode == COMPOUND_REFERENCE);
const int ctx = av1_get_reference_mode_context(cm, xd);
#if CONFIG_NEW_MULTISYMBOL
update_cdf(xd->tile_ctx->comp_inter_cdf[ctx], mode, 2);
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->comp_inter[ctx][mode];
}
}
#endif // CONFIG_EXT_SKIP
#if CONFIG_NEW_MULTISYMBOL
#define READ_REF_BIT(pname) \
aom_read_symbol(r, av1_get_pred_cdf_##pname(cm, xd), 2, ACCT_STR)
......@@ -1448,6 +1503,70 @@ static COMP_REFERENCE_TYPE read_comp_reference_type(AV1_COMMON *cm,
}
#endif // CONFIG_EXT_COMP_REFS
#if CONFIG_EXT_SKIP
#if CONFIG_EXT_COMP_REFS
static void update_comp_reference_type(AV1_COMMON *cm, const MACROBLOCKD *xd,
COMP_REFERENCE_TYPE comp_ref_type) {
assert(comp_ref_type == UNIDIR_COMP_REFERENCE ||
comp_ref_type == BIDIR_COMP_REFERENCE);
(void)cm;
const int ctx = av1_get_comp_reference_type_context(xd);
#if USE_UNI_COMP_REFS
#if CONFIG_NEW_MULTISYMBOL
update_cdf(xd->tile_ctx->comp_ref_type_cdf[ctx], comp_ref_type, 2);
#endif // CONFIG_NEW_MULTISYMBOL
#endif // USE_UNI_COMP_REFS
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->comp_ref_type[ctx][comp_ref_type];
}
#endif // CONFIG_EXT_COMP_REFS
static void set_ref_frames_for_skip_mode(AV1_COMMON *const cm,
MACROBLOCKD *const xd,
MV_REFERENCE_FRAME ref_frame[2]) {
assert(xd->mi[0]->mbmi.skip_mode);
ref_frame[0] = LAST_FRAME + cm->ref_frame_idx_0;
ref_frame[1] = LAST_FRAME + cm->ref_frame_idx_1;
const REFERENCE_MODE mode = COMPOUND_REFERENCE;
update_block_reference_mode(cm, xd, mode);
#if CONFIG_EXT_COMP_REFS
const COMP_REFERENCE_TYPE comp_ref_type = BIDIR_COMP_REFERENCE;
update_comp_reference_type(cm, xd, comp_ref_type);
#endif // CONFIG_EXT_COMP_REFS
// Update stats for both forward and backward references
#if CONFIG_NEW_MULTISYMBOL
#define UPDATE_REF_BIT(bname, pname, cname, iname) \
update_cdf(av1_get_pred_cdf_##pname(cm, xd), bname, 2); \
if (counts) \
++counts->comp_##cname[av1_get_pred_context_##pname(cm, xd)][iname][bname];
#else
#define UPDATE_REF_BIT(bname, pname, cname, iname) \
if (counts) \
++counts->comp_##cname[av1_get_pred_context_##pname(cm, xd)][iname][bname];
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
const int bit = (ref_frame[0] == GOLDEN_FRAME || ref_frame[0] == LAST3_FRAME);
UPDATE_REF_BIT(bit, comp_ref_p, ref, 0)
if (!bit) {
UPDATE_REF_BIT(ref_frame[0] == LAST_FRAME, comp_ref_p1, ref, 1)
} else {
UPDATE_REF_BIT(ref_frame[0] == GOLDEN_FRAME, comp_ref_p2, ref, 2)
}
const int bit_bwd = ref_frame[1] == ALTREF_FRAME;
UPDATE_REF_BIT(bit_bwd, comp_bwdref_p, bwdref, 0)
if (!bit_bwd) {
UPDATE_REF_BIT(ref_frame[1] == ALTREF2_FRAME, comp_bwdref_p1, bwdref, 1)
}
}
#endif // CONFIG_EXT_SKIP
// Read the referncence frame
static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
aom_reader *r, int segment_id,
......@@ -1469,7 +1588,15 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
ref_frame[0] = LAST_FRAME;
ref_frame[1] = NONE_FRAME;
} else {
#if CONFIG_EXT_SKIP
if (xd->mi[0]->mbmi.skip_mode) {
set_ref_frames_for_skip_mode(cm, xd, ref_frame);
return;
}
#endif // CONFIG_EXT_SKIP
const REFERENCE_MODE mode = read_block_reference_mode(cm, xd, r);
// FIXME(rbultje) I'm pretty sure this breaks segmentation ref frame coding
if (mode == COMPOUND_REFERENCE) {
#if CONFIG_EXT_COMP_REFS
......@@ -2110,6 +2237,22 @@ static int read_is_inter_block(AV1_COMMON *const cm, MACROBLOCKD *const xd,
}
}
#if CONFIG_EXT_SKIP
static void update_block_intra_inter(AV1_COMMON *const cm,
MACROBLOCKD *const xd, int segment_id,
const int is_inter) {
if (!segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
const int ctx = av1_get_intra_inter_context(xd);
#if CONFIG_NEW_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
update_cdf(ec_ctx->intra_inter_cdf[ctx], is_inter, 2);
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->intra_inter[ctx][is_inter];
}
}
#endif // CONFIG_EXT_SKIP
#if CONFIG_COMPOUND_SINGLEREF
static int read_is_inter_singleref_comp_mode(AV1_COMMON *const cm,
MACROBLOCKD *const xd,
......@@ -2134,9 +2277,7 @@ static void fpm_sync(void *const data, int mi_row) {
#if DEC_MISMATCH_DEBUG
static void dec_dump_logs(AV1_COMMON *cm, MODE_INFO *const mi, int mi_row,
int mi_col,
int16_t inter_mode_ctx[MODE_CTX_REF_FRAMES],
int16_t mode_ctx) {
int mi_col, int16_t mode_ctx) {
int_mv mv[2] = { { 0 } };
int ref;
MB_MODE_INFO *const mbmi = &mi->mbmi;
......@@ -2157,20 +2298,19 @@ static void dec_dump_logs(AV1_COMMON *cm, MODE_INFO *const mi, int mi_row,
}
}
int8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
#define FRAME_TO_CHECK 1
if (cm->current_video_frame == FRAME_TO_CHECK && cm->show_frame == 1) {
printf(
"=== DECODER ===: "
"Frame=%d, (mi_row,mi_col)=(%d,%d), mode=%d, bsize=%d, "
"Frame=%d, (mi_row,mi_col)=(%d,%d), skip_mode=%d, mode=%d, bsize=%d, "
"show_frame=%d, mv[0]=(%d,%d), mv[1]=(%d,%d), ref[0]=%d, "
"ref[1]=%d, motion_mode=%d, inter_mode_ctx=%d, mode_ctx=%d, "
"ref[1]=%d, motion_mode=%d, mode_ctx=%d, "
"newmv_ctx=%d, zeromv_ctx=%d, refmv_ctx=%d\n",
cm->current_video_frame, mi_row, mi_col, mbmi->mode, mbmi->sb_type,
cm->show_frame, mv[0].as_mv.row, mv[0].as_mv.col, mv[1].as_mv.row,
mv[1].as_mv.col, mbmi->ref_frame[0], mbmi->ref_frame[1],
mbmi->motion_mode, inter_mode_ctx[ref_frame_type], mode_ctx, newmv_ctx,
zeromv_ctx, refmv_ctx);
cm->current_video_frame, mi_row, mi_col, mbmi->skip_mode, mbmi->mode,
mbmi->sb_type, cm->show_frame, mv[0].as_mv.row, mv[0].as_mv.col,
mv[1].as_mv.row, mv[1].as_mv.col, mbmi->ref_frame[0],
mbmi->ref_frame[1], mbmi->motion_mode, mode_ctx, newmv_ctx, zeromv_ctx,
refmv_ctx);
}
}
#endif // DEC_MISMATCH_DEBUG
......@@ -2583,7 +2723,11 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
cm->reference_mode != SINGLE_REFERENCE &&
is_inter_compound_mode(mbmi->mode)
#endif // CONFIG_COMPOUND_SINGLEREF
&& mbmi->motion_mode == SIMPLE_TRANSLATION) {
&& mbmi->motion_mode == SIMPLE_TRANSLATION
#if CONFIG_EXT_SKIP
&& !mbmi->skip_mode
#endif // CONFIG_EXT_SKIP
) {
if (is_any_masked_compound_used(bsize)) {
#if CONFIG_JNT_COMP
if (cm->allow_masked_compound && mbmi->compound_idx)
......@@ -2636,7 +2780,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
}
#if DEC_MISMATCH_DEBUG
dec_dump_logs(cm, mi, mi_row, mi_col, inter_mode_ctx, mode_ctx);
dec_dump_logs(cm, mi, mi_row, mi_col, mode_ctx);
#endif // DEC_MISMATCH_DEBUG
}
......@@ -2652,54 +2796,91 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
mbmi->mv[0].as_int = 0;
mbmi->mv[1].as_int = 0;
mbmi->segment_id = read_inter_segment_id(cm, xd, mi_row, mi_col, r);
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
if (cm->delta_q_present_flag) {
xd->current_qindex =
xd->prev_qindex +
read_delta_qindex(cm, xd, r, mbmi, mi_col, mi_row) * cm->delta_q_res;
/* Normative: Clamp to [1,MAXQ] to not interfere with lossless mode */
xd->current_qindex = clamp(xd->current_qindex, 1, MAXQ);
xd->prev_qindex = xd->current_qindex;
#if CONFIG_EXT_SKIP
mbmi->skip_mode = read_skip_mode(cm, xd, mbmi->segment_id, r);
#if 0
if (mbmi->skip_mode)
printf("Frame=%d, frame_offset=%d, (mi_row,mi_col)=(%d,%d), skip_mode=%d\n",
cm->current_video_frame, cm->frame_offset, mi_row, mi_col,
mbmi->skip_mode);
#endif // 0
if (mbmi->skip_mode) {
mbmi->skip = 1;
if (cm->delta_q_present_flag) {
xd->current_qindex = xd->prev_qindex;
#if CONFIG_EXT_DELTA_Q
if (cm->delta_lf_present_flag) {
if (cm->delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
if (cm->delta_lf_multi)
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id)
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
xd->prev_delta_lf[lf_id];
else
#endif // CONFIG_LOOPFILTER_LEVEL
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
xd->prev_delta_lf_from_base;
}
#endif // CONFIG_EXT_DELTA_Q
}
update_block_intra_inter(cm, xd, mbmi->segment_id, inter_block);
} else {
#endif // CONFIG_EXT_SKIP
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
if (cm->delta_q_present_flag) {
xd->current_qindex =
xd->prev_qindex +
read_delta_qindex(cm, xd, r, mbmi, mi_col, mi_row) * cm->delta_q_res;
/* Normative: Clamp to [1,MAXQ] to not interfere with lossless mode */
xd->current_qindex = clamp(xd->current_qindex, 1, MAXQ);
xd->prev_qindex = xd->current_qindex;
#if CONFIG_EXT_DELTA_Q
if (cm->delta_lf_present_flag) {
#if CONFIG_LOOPFILTER_LEVEL
if (cm->delta_lf_multi) {
for (int lf_id = 0; lf_id < FRAME_LF_COUNT; ++lf_id) {
const int tmp_lvl =
xd->prev_delta_lf[lf_id] +
read_delta_lflevel(cm, xd, r, lf_id, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf[lf_id] = xd->curr_delta_lf[lf_id];
}
} else {
const int tmp_lvl =
xd->prev_delta_lf[lf_id] +
read_delta_lflevel(cm, xd, r, lf_id, mbmi, mi_col, mi_row) *
xd->prev_delta_lf_from_base +
read_delta_lflevel(cm, xd, r, -1, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->curr_delta_lf[lf_id] = xd->curr_delta_lf[lf_id] =
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf[lf_id] = xd->curr_delta_lf[lf_id];
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
}
} else {
const int tmp_lvl =
#else
const int current_delta_lf_from_base =
xd->prev_delta_lf_from_base +
read_delta_lflevel(cm, xd, r, -1, mbmi, mi_col, mi_row) *
read_delta_lflevel(cm, xd, r, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(tmp_lvl, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
clamp(current_delta_lf_from_base, -MAX_LOOP_FILTER,
MAX_LOOP_FILTER);
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
}
#else
const int current_delta_lf_from_base =
xd->prev_delta_lf_from_base +
read_delta_lflevel(cm, xd, r, mbmi, mi_col, mi_row) *
cm->delta_lf_res;
mbmi->current_delta_lf_from_base = xd->current_delta_lf_from_base =
clamp(current_delta_lf_from_base, -MAX_LOOP_FILTER, MAX_LOOP_FILTER);
xd->prev_delta_lf_from_base = xd->current_delta_lf_from_base;
#endif // CONFIG_LOOPFILTER_LEVEL
}
#endif // CONFIG_EXT_DELTA_Q
}
#endif
inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r);
#if CONFIG_EXT_SKIP
}
#endif // CONFIG_EXT_SKIP
mbmi->current_q_index = xd->current_qindex;
inter_block = read_is_inter_block(cm, xd, mbmi->segment_id, r);
xd->above_txfm_context =
cm->above_txfm_context + (mi_col << TX_UNIT_WIDE_LOG2);
xd->left_txfm_context = xd->left_txfm_context_buffer +
......@@ -2749,16 +2930,22 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
} else {
mbmi->tx_size = read_tx_size(cm, xd, inter_block, !mbmi->skip, r);
if (inter_block) {
const int width = block_size_wide[bsize] >> tx_size_wide_log2[0];