Commit f704a1c8 authored by Zoe Liu's avatar Zoe Liu

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
......
This diff is collapsed.
......@@ -112,6 +112,12 @@ macro (fix_experiment_configs)
endif ()
endif ()
if (CONFIG_EXT_SKIP)
if (NOT CONFIG_FRAME_MARKER)
change_config_and_warn(CONFIG_FRAME_MARKER 1 CONFIG_EXT_SKIP)
endif ()
endif ()
if (CONFIG_LPF_SB)
if (CONFIG_LOOPFILTER_LEVEL)
change_config_and_warn(CONFIG_LOOPFILTER_LEVEL 0 CONFIG_LPF_SB)
......
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