From 733bbab53a46c545f6a519c5ef8cd08819562d29 Mon Sep 17 00:00:00 2001 From: paulwilkins Date: Mon, 18 Jan 2016 15:31:42 +0000 Subject: [PATCH 1/5] Loop filter search resets on overlay frame. This patch fixes a bug that causes the loop filter search to reset to a low value or zero after each arf overlay frame. We expect the overlay frames to need little or no loop filtering but this should not propagate. Change-Id: I895b28474cf200f20d82793f3de40b60b19579fd --- vp9/common/vp9_loopfilter.h | 1 + vp9/encoder/vp9_encoder.c | 19 +++++++++++++++---- vp9/encoder/vp9_picklpf.c | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h index 7f943ea09..9ddd0b0a3 100644 --- a/vp9/common/vp9_loopfilter.h +++ b/vp9/common/vp9_loopfilter.h @@ -69,6 +69,7 @@ typedef struct { struct loopfilter { int filter_level; + int last_filt_level; int sharpness_level; int last_sharpness_level; diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 609344dcd..451eb0920 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -2822,6 +2822,7 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { if (xd->lossless) { lf->filter_level = 0; + lf->last_filt_level = 0; } else { struct vpx_usec_timer timer; @@ -2829,7 +2830,16 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { vpx_usec_timer_start(&timer); - vp9_pick_filter_level(cpi->Source, cpi, cpi->sf.lpf_pick); + if (!cpi->rc.is_src_frame_alt_ref) { + if ((cpi->common.frame_type == KEY_FRAME) && + (!cpi->rc.this_key_frame_forced)) { + lf->last_filt_level = 0; + } + vp9_pick_filter_level(cpi->Source, cpi, cpi->sf.lpf_pick); + lf->last_filt_level = lf->filter_level; + } else { + lf->filter_level = 0; + } vpx_usec_timer_mark(&timer); cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); @@ -3022,7 +3032,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { "%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf" "%6d %6d %5d %5d %5d " "%10"PRId64" %10.3lf" - "%10lf %8u %10"PRId64" %10d %10d %10d\n", + "%10lf %8u %10"PRId64" %10d %10d %10d %10d\n", cpi->common.current_video_frame, cm->width, cm->height, cpi->td.rd_counts.m_search_count, @@ -3054,7 +3064,8 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { (1 + cpi->twopass.total_left_stats.coded_error), cpi->tot_recode_hits, recon_err, cpi->rc.kf_boost, cpi->twopass.kf_zeromotion_pct, - cpi->twopass.fr_content_type); + cpi->twopass.fr_content_type, + cm->lf.filter_level); fclose(f); @@ -4312,7 +4323,7 @@ int vp9_get_compressed_data(VP9_COMP *cpi, unsigned int *frame_flags, cpi->svc.layer_context[cpi->svc.spatial_layer_id].has_alt_frame = 1; #endif - if (oxcf->arnr_max_frames > 0) { + if ((oxcf->arnr_max_frames > 0) && (oxcf->arnr_strength > 0)) { // Produce the filtered ARF frame. vp9_temporal_filter(cpi, arf_src_index); vpx_extend_frame_borders(&cpi->alt_ref_buffer); diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c index 5444bc89f..f6b1dfcd5 100644 --- a/vp9/encoder/vp9_picklpf.c +++ b/vp9/encoder/vp9_picklpf.c @@ -78,7 +78,8 @@ static int search_filter_level(const YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, // Start the search at the previous frame filter level unless it is now out of // range. - int filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level); + int filt_mid = + clamp(lf->last_filt_level, min_filter_level, max_filter_level); int filter_step = filt_mid < 16 ? 4 : filt_mid / 4; // Sum squared error at each filter level int64_t ss_err[MAX_LOOP_FILTER + 1]; From ad43a73883b2e18e07fc30f82486e83bf1746cdb Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 1 Feb 2016 09:47:39 -0800 Subject: [PATCH 2/5] Fix a signed overflow in vp9 motion cost. Change-Id: I5975e3aede62202d8ee6ced33889350c0a56554a --- vp9/encoder/vp9_mcomp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 84ef1b43e..4004dd3db 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -86,7 +86,9 @@ static int mv_err_cost(const MV *mv, const MV *ref, if (mvcost) { const MV diff = { mv->row - ref->row, mv->col - ref->col }; - return ROUND_POWER_OF_TWO(mv_cost(&diff, mvjcost, mvcost) * + // TODO(aconverse): See if this shift needs to be tied to + // VP9_PROB_COST_SHIFT. + return ROUND_POWER_OF_TWO((unsigned)mv_cost(&diff, mvjcost, mvcost) * error_per_bit, 13); } return 0; @@ -96,8 +98,9 @@ static int mvsad_err_cost(const MACROBLOCK *x, const MV *mv, const MV *ref, int error_per_bit) { const MV diff = { mv->row - ref->row, mv->col - ref->col }; - return ROUND_POWER_OF_TWO(mv_cost(&diff, x->nmvjointsadcost, - x->nmvsadcost) * error_per_bit, 8); + // TODO(aconverse): See if this shift needs to be tied to VP9_PROB_COST_SHIFT. + return ROUND_POWER_OF_TWO((unsigned)mv_cost(&diff, x->nmvjointsadcost, + x->nmvsadcost) * error_per_bit, 8); } void vp9_init_dsmotion_compensation(search_site_config *cfg, int stride) { From 724ba02f1bbc2c38b610895f416b459bf8113ddd Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 1 Feb 2016 23:47:02 -0800 Subject: [PATCH 3/5] vp9_denoiser: mark total_adj_strong_thresh inline avoids -Wunused-function warnings when INLINE is set Change-Id: I14a3b32837d358516b7702a2fb804bec010bb5c6 --- vp9/encoder/vp9_denoiser.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vp9/encoder/vp9_denoiser.h b/vp9/encoder/vp9_denoiser.h index 12dd5b5fa..9f13bd533 100644 --- a/vp9/encoder/vp9_denoiser.h +++ b/vp9/encoder/vp9_denoiser.h @@ -75,7 +75,8 @@ int vp9_denoiser_alloc(VP9_DENOISER *denoiser, int width, int height, // This function is used by both c and sse2 denoiser implementations. // Define it as a static function within the scope where vp9_denoiser.h // is referenced. -static int total_adj_strong_thresh(BLOCK_SIZE bs, int increase_denoising) { +static INLINE int total_adj_strong_thresh(BLOCK_SIZE bs, + int increase_denoising) { return (1 << num_pels_log2_lookup[bs]) * (increase_denoising ? 3 : 2); } #endif From ebf258688e2dd20c9cdfd42d3572b3ad14f684ea Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 1 Feb 2016 23:47:35 -0800 Subject: [PATCH 4/5] vp10: remove unused (read|write)_uniform dead code since: 5d3327e Remove palette from VP10 Change-Id: I4a36575706ea6fffefe5bc778595112ef6ff37d8 --- vp10/decoder/decodemv.c | 13 ------------- vp10/encoder/bitstream.c | 13 ------------- vp10/encoder/rdopt.c | 10 ---------- 3 files changed, 36 deletions(-) diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c index a28ae5592..01b796c10 100644 --- a/vp10/decoder/decodemv.c +++ b/vp10/decoder/decodemv.c @@ -24,19 +24,6 @@ #include "vpx_dsp/vpx_dsp_common.h" -static INLINE int read_uniform(vpx_reader *r, int n) { - int l = get_unsigned_bits(n); - int m = (1 << l) - n; - int v = vpx_read_literal(r, l-1); - - assert(l != 0); - - if (v < m) - return v; - else - return (v << 1) - m + vpx_read_literal(r, 1); -} - static PREDICTION_MODE read_intra_mode(vpx_reader *r, const vpx_prob *p) { return (PREDICTION_MODE)vpx_read_tree(r, vp10_intra_mode_tree, p); } diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index ede8bb370..04ce61d55 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -45,19 +45,6 @@ static const struct vp10_token partition_encodings[PARTITION_TYPES] = static const struct vp10_token inter_mode_encodings[INTER_MODES] = {{2, 2}, {6, 3}, {0, 1}, {7, 3}}; -static INLINE void write_uniform(vpx_writer *w, int n, int v) { - int l = get_unsigned_bits(n); - int m = (1 << l) - n; - if (l == 0) - return; - if (v < m) { - vpx_write_literal(w, v, l - 1); - } else { - vpx_write_literal(w, m + ((v - m) >> 1), l - 1); - vpx_write_literal(w, (v - m) & 1, 1); - } -} - static struct vp10_token ext_tx_encodings[TX_TYPES]; void vp10_encode_token_init() { diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index 90a716d2c..b1077cb21 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -132,16 +132,6 @@ static const REF_DEFINITION vp10_ref_order[MAX_REFS] = { {{INTRA_FRAME, NONE}}, }; -static INLINE int write_uniform_cost(int n, int v) { - int l = get_unsigned_bits(n), m = (1 << l) - n; - if (l == 0) - return 0; - if (v < m) - return (l - 1) * vp10_cost_bit(128, 0); - else - return l * vp10_cost_bit(128, 0); -} - static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx, int m, int n, int min_plane, int max_plane) { int i; From 06bcd852ad388b9dc1021c00c6d2d721a7ee590c Mon Sep 17 00:00:00 2001 From: hui su Date: Tue, 2 Feb 2016 18:03:39 -0800 Subject: [PATCH 5/5] Add high bit depth args to arg list So that their usage info. will show up with --help. Change-Id: I8542240dcc98e8be29ac63d081f5abb932627cbf --- vpxenc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vpxenc.c b/vpxenc.c index 8798e6918..c61d06073 100644 --- a/vpxenc.c +++ b/vpxenc.c @@ -454,6 +454,9 @@ static const arg_def_t *vp9_args[] = { &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, &noise_sens, &tune_content, &input_color_space, &min_gf_interval, &max_gf_interval, +#if CONFIG_VP9_HIGHBITDEPTH + &bitdeptharg, &inbitdeptharg, +#endif // CONFIG_VP9_HIGHBITDEPTH NULL }; static const int vp9_arg_ctrl_map[] = { @@ -480,6 +483,9 @@ static const arg_def_t *vp10_args[] = { &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, &noise_sens, &tune_content, &input_color_space, &min_gf_interval, &max_gf_interval, +#if CONFIG_VP9_HIGHBITDEPTH + &bitdeptharg, &inbitdeptharg, +#endif // CONFIG_VP9_HIGHBITDEPTH NULL }; static const int vp10_arg_ctrl_map[] = {