Commit 8d164de2 authored by Fangwen Fu's avatar Fangwen Fu

enable explicit temp mv prediction signaling

Change-Id: Ieb2922c3df4ef4f8514b8a6df6f9a8fc45ef3cf4
parent 6b763c9c
......@@ -238,6 +238,16 @@ enum aome_enc_control_id {
*/
AV1E_SET_LOSSLESS = AV1E_SET_GF_CBR_BOOST_PCT + 2,
#if CONFIG_TEMPMV_SIGNALING
/*!\brief Codec control function to set temporal mv prediction
* enabling/disabling.
*
* This will enable or disable temporal mv predicton. The default value is 0.
*
* Supported in codecs: AV1
*/
AV1E_SET_DISABLE_TEMPMV,
#endif
/*!\brief Codec control function to set number of tile columns.
*
* In encoding and decoding, AV1 allows an input image frame be partitioned
......@@ -631,6 +641,11 @@ AOM_CTRL_USE_TYPE(AV1E_SET_NUM_TG, unsigned int)
AOM_CTRL_USE_TYPE(AV1E_SET_MTU, unsigned int)
#define AOM_CTRL_AV1E_SET_MTU
#if CONFIG_TEMPMV_SIGNALING
AOM_CTRL_USE_TYPE(AV1E_SET_DISABLE_TEMPMV, unsigned int)
#define AOM_CTRL_AV1E_SET_DISABLE_TEMPMV
#endif
AOM_CTRL_USE_TYPE(AV1E_SET_FRAME_PARALLEL_DECODING, unsigned int)
#define AOM_CTRL_AV1E_SET_FRAME_PARALLEL_DECODING
......
......@@ -399,6 +399,10 @@ static const arg_def_t mtu_size =
"MTU size for a tile group, default is 0 (no MTU targeting), "
"overrides maximum number of tile groups");
#endif
#if CONFIG_TEMPMV_SIGNALING
static const arg_def_t disable_tempmv = ARG_DEF(
NULL, "disable-tempmv", 1, "Disable temporal mv prediction (default is 0)");
#endif
static const arg_def_t frame_parallel_decoding =
ARG_DEF(NULL, "frame-parallel", 1,
"Enable frame parallel decodability features "
......@@ -503,6 +507,9 @@ static const arg_def_t *av1_args[] = { &cpu_used_av1,
&num_tg,
&mtu_size,
#endif
#if CONFIG_TEMPMV_SIGNALING
&disable_tempmv,
#endif
#if CONFIG_AOM_HIGHBITDEPTH
&bitdeptharg,
&inbitdeptharg,
......@@ -544,6 +551,9 @@ static const int av1_arg_ctrl_map[] = { AOME_SET_CPUUSED,
#if CONFIG_TILE_GROUPS
AV1E_SET_NUM_TG,
AV1E_SET_MTU,
#endif
#if CONFIG_TEMPMV_SIGNALING
AV1E_SET_DISABLE_TEMPMV,
#endif
0 };
#endif
......
......@@ -55,6 +55,9 @@ struct av1_extracfg {
#if CONFIG_TILE_GROUPS
unsigned int num_tg;
unsigned int mtu_size;
#endif
#if CONFIG_TEMPMV_SIGNALING
unsigned int disable_tempmv;
#endif
unsigned int frame_parallel_decoding_mode;
AQ_MODE aq_mode;
......@@ -108,6 +111,9 @@ static struct av1_extracfg default_extra_cfg = {
#if CONFIG_TILE_GROUPS
1, // max number of tile groups
0, // mtu_size
#endif
#if CONFIG_TEMPMV_SIGNALING
0, // disable temporal mv prediction
#endif
1, // frame_parallel_decoding_mode
NO_AQ, // aq_mode
......@@ -426,6 +432,9 @@ static aom_codec_err_t set_encoder_config(
oxcf->mtu = extra_cfg->mtu_size;
#endif
#if CONFIG_TEMPMV_SIGNALING
oxcf->disable_tempmv = extra_cfg->disable_tempmv;
#endif
oxcf->under_shoot_pct = cfg->rc_undershoot_pct;
oxcf->over_shoot_pct = cfg->rc_overshoot_pct;
......@@ -776,7 +785,14 @@ static aom_codec_err_t ctrl_set_mtu(aom_codec_alg_priv_t *ctx, va_list args) {
return update_extra_cfg(ctx, &extra_cfg);
}
#endif
#if CONFIG_TEMPMV_SIGNALING
static aom_codec_err_t ctrl_set_disable_tempmv(aom_codec_alg_priv_t *ctx,
va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
extra_cfg.disable_tempmv = CAST(AV1E_SET_DISABLE_TEMPMV, args);
return update_extra_cfg(ctx, &extra_cfg);
}
#endif
static aom_codec_err_t ctrl_set_frame_parallel_decoding_mode(
aom_codec_alg_priv_t *ctx, va_list args) {
struct av1_extracfg extra_cfg = ctx->extra_cfg;
......@@ -1393,6 +1409,9 @@ static aom_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
#if CONFIG_TILE_GROUPS
{ AV1E_SET_NUM_TG, ctrl_set_num_tg },
{ AV1E_SET_MTU, ctrl_set_mtu },
#endif
#if CONFIG_TEMPMV_SIGNALING
{ AV1E_SET_DISABLE_TEMPMV, ctrl_set_disable_tempmv },
#endif
{ AV1E_SET_FRAME_PARALLEL_DECODING, ctrl_set_frame_parallel_decoding_mode },
{ AV1E_SET_AQ_MODE, ctrl_set_aq_mode },
......
......@@ -417,9 +417,12 @@ static void setup_ref_mv_list(const AV1_COMMON *cm, const MACROBLOCKD *xd,
for (idx = 0; idx < nearest_refmv_count; ++idx)
ref_mv_stack[idx].weight += REF_CAT_LEVEL;
#if CONFIG_TEMPMV_SIGNALING
if (cm->use_prev_frame_mvs && rf[1] == NONE_FRAME) {
#else
if (prev_frame_mvs_base && cm->show_frame && cm->last_show_frame &&
rf[1] == NONE_FRAME) {
#endif
int blk_row, blk_col;
int coll_blk_count = 0;
#if CONFIG_CB4X4
......
......@@ -109,7 +109,9 @@ typedef struct {
int mi_cols;
aom_codec_frame_buffer_t raw_frame_buffer;
YV12_BUFFER_CONFIG buf;
#if CONFIG_TEMPMV_SIGNALING
uint8_t intra_only;
#endif
// The Following variables will only be used in frame parallel decode.
// frame_worker_owner indicates which FrameWorker owns this buffer. NULL means
......
......@@ -4132,7 +4132,11 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
cm->allow_high_precision_mv = aom_rb_read_bit(rb);
cm->interp_filter = read_frame_interp_filter(rb);
#if CONFIG_TEMPMV_SIGNALING
if (!cm->error_resilient_mode) {
cm->use_prev_frame_mvs = aom_rb_read_bit(rb);
}
#endif
for (i = 0; i < INTER_REFS_PER_FRAME; ++i) {
RefBuffer *const ref_buf = &cm->frame_refs[i];
#if CONFIG_AOM_HIGHBITDEPTH
......@@ -4148,6 +4152,9 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
}
}
}
#if CONFIG_TEMPMV_SIGNALING
cm->cur_frame->intra_only = cm->frame_type == KEY_FRAME || cm->intra_only;
#endif
#if CONFIG_REFERENCE_BUFFER
if (pbi->seq_params.frame_id_numbers_present_flag) {
......@@ -4733,10 +4740,21 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
cm->setup_mi(cm);
#endif
#if CONFIG_TEMPMV_SIGNALING
if (cm->use_prev_frame_mvs) {
RefBuffer *last_fb_ref_buf = &cm->frame_refs[LAST_FRAME - LAST_FRAME];
cm->prev_frame = &cm->buffer_pool->frame_bufs[last_fb_ref_buf->idx];
assert(!cm->error_resilient_mode &&
cm->width == last_fb_ref_buf->buf->y_width &&
cm->height == last_fb_ref_buf->buf->y_height &&
!cm->prev_frame->intra_only);
}
#else
cm->use_prev_frame_mvs =
!cm->error_resilient_mode && cm->width == cm->last_width &&
cm->height == cm->last_height && !cm->last_intra_only &&
cm->last_show_frame && (cm->last_frame_type != KEY_FRAME);
#endif
#if CONFIG_EXT_REFS
// NOTE(zoeliu): As cm->prev_frame can take neither a frame of
// show_exisiting_frame=1, nor can it take a frame not used as
......
......@@ -4252,6 +4252,11 @@ static void write_uncompressed_header(AV1_COMP *cpi,
fix_interp_filter(cm, cpi->td.counts);
write_frame_interp_filter(cm->interp_filter, wb);
#if CONFIG_TEMPMV_SIGNALING
if (!cm->error_resilient_mode) {
aom_wb_write_bit(wb, cm->use_prev_frame_mvs);
}
#endif
}
}
......
......@@ -5028,10 +5028,20 @@ static void encode_frame_internal(AV1_COMP *cpi) {
av1_initialize_rd_consts(cpi);
av1_initialize_me_consts(cpi, x, cm->base_qindex);
init_encode_frame_mb_context(cpi);
#if CONFIG_TEMPMV_SIGNALING
const int last_fb_buf_idx = get_ref_frame_buf_idx(cpi, LAST_FRAME);
if (last_fb_buf_idx != INVALID_IDX) {
cm->prev_frame = &cm->buffer_pool->frame_bufs[last_fb_buf_idx];
cm->use_prev_frame_mvs &= !cm->error_resilient_mode &&
cm->width == cm->prev_frame->buf.y_width &&
cm->height == cm->prev_frame->buf.y_height &&
!cm->intra_only && !cm->prev_frame->intra_only;
}
#else
cm->use_prev_frame_mvs =
!cm->error_resilient_mode && cm->width == cm->last_width &&
cm->height == cm->last_height && !cm->intra_only && cm->last_show_frame;
#endif
#if CONFIG_DELTA_Q
// Fix delta q resolution for the moment
......
......@@ -4611,6 +4611,12 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
// Set the arf sign bias for this frame.
set_arf_sign_bias(cpi);
#if CONFIG_TEMPMV_SIGNALING
// frame type has been decided outside of this function call
cm->cur_frame->intra_only = cm->frame_type == KEY_FRAME || cm->intra_only;
cm->use_prev_frame_mvs =
!cpi->oxcf.disable_tempmv && !cm->cur_frame->intra_only;
#endif
#if CONFIG_EXT_REFS
// NOTE:
......
......@@ -199,6 +199,9 @@ typedef struct AV1EncoderConfig {
unsigned int mtu;
#endif
#if CONFIG_TEMPMV_SIGNALING
unsigned int disable_tempmv;
#endif
// Internal frame size scaling.
RESIZE_TYPE resize_mode;
int scaled_frame_width;
......@@ -788,6 +791,9 @@ void av1_scale_references(AV1_COMP *cpi);
void av1_update_reference_frames(AV1_COMP *cpi);
void av1_set_high_precision_mv(AV1_COMP *cpi, int allow_high_precision_mv);
#if CONFIG_TEMPMV_SIGNALING
void av1_set_temporal_mv_prediction(AV1_COMP *cpi, int allow_tempmv_prediction);
#endif
YV12_BUFFER_CONFIG *av1_scale_if_required_fast(AV1_COMMON *cm,
YV12_BUFFER_CONFIG *unscaled,
......
......@@ -291,6 +291,7 @@ EXPERIMENT_LIST="
deblocking_across_tiles
tile_groups
ec_adapt
tempmv_signaling
rd_debug
reference_buffer
coef_interleave
......
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