summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorDeepa K G <deepa.kg@ittiam.com>2019-04-09 17:55:36 +0530
committerDeepa K G <deepa.kg@ittiam.com>2019-06-11 19:06:00 +0530
commit24e38521a8aef038f1b87892bf79f31cc99c05a1 (patch)
treeb48694771cf57dd3f18d5150796ee7c8e8752122 /vp9/encoder
parentf0ff0600d01e88dfe11c5771b7d01bdee27cbd50 (diff)
downloadlibvpx-24e38521a8aef038f1b87892bf79f31cc99c05a1.tar
libvpx-24e38521a8aef038f1b87892bf79f31cc99c05a1.tar.gz
libvpx-24e38521a8aef038f1b87892bf79f31cc99c05a1.tar.bz2
libvpx-24e38521a8aef038f1b87892bf79f31cc99c05a1.zip
Use previous ARF as GOLDEN frame for the next GOP
This patch uses ARF itself as the GOLDEN frame for the next gf group instead of replacing it with the overlay frame. By doing so, bits consumed by the overlay frame will be reduced. Change-Id: I909ceaa6d501c267d315614075913d45ad426c15
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_encoder.c8
-rw-r--r--vp9/encoder/vp9_firstpass.c10
-rw-r--r--vp9/encoder/vp9_ratectrl.c20
-rw-r--r--vp9/encoder/vp9_ratectrl.h4
4 files changed, 40 insertions, 2 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 900d92f85..260058827 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3063,8 +3063,12 @@ static void update_ref_frames(VP9_COMP *cpi) {
BufferPool *const pool = cm->buffer_pool;
GF_GROUP *const gf_group = &cpi->twopass.gf_group;
- // Pop ARF.
- if (cm->show_existing_frame) {
+ if (cpi->rc.show_arf_as_gld) {
+ int tmp = cpi->alt_fb_idx;
+ cpi->alt_fb_idx = cpi->gld_fb_idx;
+ cpi->gld_fb_idx = tmp;
+ } else if (cm->show_existing_frame) {
+ // Pop ARF.
cpi->lst_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx =
stack_pop(gf_group->arf_index_stack, gf_group->stack_size);
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 01121dea6..e0acf563b 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2455,6 +2455,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
int gf_arf_bits;
const int is_key_frame = frame_is_intra_only(cm);
const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
+ int is_alt_ref_flash = 0;
double gop_intra_factor = 1.0;
int gop_frames;
@@ -2678,6 +2679,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Reset the file position.
reset_fpf_position(twopass, start_pos);
+ if (rc->source_alt_ref_pending)
+ is_alt_ref_flash = detect_flash(twopass, rc->baseline_gf_interval);
+
// Calculate the bits to be allocated to the gf/arf group as a whole
gf_group_bits = calculate_total_gf_group_bits(cpi, gf_group_err);
@@ -2755,6 +2759,12 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
twopass->rolling_arf_group_target_bits = 0;
twopass->rolling_arf_group_actual_bits = 0;
#endif
+ rc->preserve_arf_as_gld = rc->preserve_next_arf_as_gld;
+ rc->preserve_next_arf_as_gld = 0;
+ // If alt ref frame is flash do not set preserve_arf_as_gld
+ if (!is_lossless_requested(&cpi->oxcf) && !cpi->use_svc &&
+ cpi->oxcf.aq_mode == NO_AQ && cpi->multi_layer_arf && !is_alt_ref_flash)
+ rc->preserve_next_arf_as_gld = 1;
}
// Intra / Inter threshold very low
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index e45030ab8..a8f75b750 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -436,6 +436,10 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
rc->use_post_encode_drop = 0;
rc->ext_use_post_encode_drop = 0;
rc->arf_active_best_quality_adjustment_factor = 1.0;
+
+ rc->preserve_arf_as_gld = 0;
+ rc->preserve_next_arf_as_gld = 0;
+ rc->show_arf_as_gld = 0;
}
static int check_buffer_above_thresh(VP9_COMP *cpi, int drop_mark) {
@@ -1574,6 +1578,7 @@ void vp9_configure_buffer_updates(VP9_COMP *cpi, int gf_group_index) {
cpi->rc.is_src_frame_alt_ref = 0;
cm->show_existing_frame = 0;
+ cpi->rc.show_arf_as_gld = 0;
switch (twopass->gf_group.update_type[gf_group_index]) {
case KF_UPDATE:
cpi->refresh_last_frame = 1;
@@ -1595,6 +1600,12 @@ void vp9_configure_buffer_updates(VP9_COMP *cpi, int gf_group_index) {
cpi->refresh_golden_frame = 1;
cpi->refresh_alt_ref_frame = 0;
cpi->rc.is_src_frame_alt_ref = 1;
+ if (cpi->rc.preserve_arf_as_gld) {
+ cpi->rc.show_arf_as_gld = 1;
+ cpi->refresh_golden_frame = 0;
+ cm->show_existing_frame = 1;
+ cm->refresh_frame_context = 0;
+ }
break;
case MID_OVERLAY_UPDATE:
cpi->refresh_last_frame = 1;
@@ -1716,6 +1727,15 @@ static void update_golden_frame_stats(VP9_COMP *cpi) {
if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
rc->frames_since_golden++;
+
+ if (rc->show_arf_as_gld) {
+ rc->frames_since_golden = 0;
+ // If we are not using alt ref in the up and coming group clear the arf
+ // active flag. In multi arf group case, if the index is not 0 then
+ // we are overlaying a mid group arf so should not reset the flag.
+ if (!rc->source_alt_ref_pending && (cpi->twopass.gf_group.index == 0))
+ rc->source_alt_ref_active = 0;
+ }
}
}
diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h
index 2c2048edc..09d69e4d4 100644
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -199,6 +199,10 @@ typedef struct {
int damped_adjustment[RATE_FACTOR_LEVELS];
double arf_active_best_quality_adjustment_factor;
int arf_active_best_quality_adjustment_window;
+
+ int preserve_arf_as_gld;
+ int preserve_next_arf_as_gld;
+ int show_arf_as_gld;
} RATE_CONTROL;
struct VP9_COMP;