History

Merge "Use previous ARF as GOLDEN frame for the next GOP"

Deepa K G committed 7 years ago

Commit cb2edce2 parents 6ae0631 24e38524 files · +40 −2Browse files

Unified · Split

4 files
  1. vp9/encoder/vp9_encoder.c +6 −2
  2. vp9/encoder/vp9_firstpass.c +10 −0
  3. vp9/encoder/vp9_ratectrl.c +20 −0
  4. vp9/encoder/vp9_ratectrl.h +4 −0
vp9/encoder/vp9_encoder.c+6−2
@@ -3063,8 +3063,12 @@ static void update_ref_frames(VP9_COMP *cpi) { · 3062 unmodified lines
30633063 BufferPool *const pool = cm->buffer_pool;
30643064 GF_GROUP *const gf_group = &cpi->twopass.gf_group;
30653065
3066− // Pop ARF.
3067− if (cm->show_existing_frame) {
3066+ if (cpi->rc.show_arf_as_gld) {
3067+ int tmp = cpi->alt_fb_idx;
3068+ cpi->alt_fb_idx = cpi->gld_fb_idx;
3069+ cpi->gld_fb_idx = tmp;
3070+ } else if (cm->show_existing_frame) {
3071+ // Pop ARF.
30683072 cpi->lst_fb_idx = cpi->alt_fb_idx;
30693073 cpi->alt_fb_idx =
30703074 stack_pop(gf_group->arf_index_stack, gf_group->stack_size);
vp9/encoder/vp9_firstpass.c+10−0
@@ -2455,6 +2455,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 2454 unmodified lines
24552455 int gf_arf_bits;
24562456 const int is_key_frame = frame_is_intra_only(cm);
24572457 const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
2458+ int is_alt_ref_flash = 0;
24582459
24592460 double gop_intra_factor = 1.0;
24602461 int gop_frames;
@@ -2678,6 +2679,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 217 unmodified lines
26782679 // Reset the file position.
26792680 reset_fpf_position(twopass, start_pos);
26802681
2682+ if (rc->source_alt_ref_pending)
2683+ is_alt_ref_flash = detect_flash(twopass, rc->baseline_gf_interval);
2684+
26812685 // Calculate the bits to be allocated to the gf/arf group as a whole
26822686 gf_group_bits = calculate_total_gf_group_bits(cpi, gf_group_err);
26832687
@@ -2755,6 +2759,12 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 71 unmodified lines
27552759 twopass->rolling_arf_group_target_bits = 0;
27562760 twopass->rolling_arf_group_actual_bits = 0;
27572761 #endif
2762+ rc->preserve_arf_as_gld = rc->preserve_next_arf_as_gld;
2763+ rc->preserve_next_arf_as_gld = 0;
2764+ // If alt ref frame is flash do not set preserve_arf_as_gld
2765+ if (!is_lossless_requested(&cpi->oxcf) && !cpi->use_svc &&
2766+ cpi->oxcf.aq_mode == NO_AQ && cpi->multi_layer_arf && !is_alt_ref_flash)
2767+ rc->preserve_next_arf_as_gld = 1;
27582768 }
27592769
27602770 // Intra / Inter threshold very low
vp9/encoder/vp9_ratectrl.c+20−0
@@ -436,6 +436,10 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { · 435 unmodified lines
436436 rc->use_post_encode_drop = 0;
437437 rc->ext_use_post_encode_drop = 0;
438438 rc->arf_active_best_quality_adjustment_factor = 1.0;
439+
440+ rc->preserve_arf_as_gld = 0;
441+ rc->preserve_next_arf_as_gld = 0;
442+ rc->show_arf_as_gld = 0;
439443 }
440444
441445 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) { · 1132 unmodified lines
15741578
15751579 cpi->rc.is_src_frame_alt_ref = 0;
15761580 cm->show_existing_frame = 0;
1581+ cpi->rc.show_arf_as_gld = 0;
15771582 switch (twopass->gf_group.update_type[gf_group_index]) {
15781583 case KF_UPDATE:
15791584 cpi->refresh_last_frame = 1;
@@ -1595,6 +1600,12 @@ void vp9_configure_buffer_updates(VP9_COMP *cpi, int gf_group_index) { · 15 unmodified lines
15951600 cpi->refresh_golden_frame = 1;
15961601 cpi->refresh_alt_ref_frame = 0;
15971602 cpi->rc.is_src_frame_alt_ref = 1;
1603+ if (cpi->rc.preserve_arf_as_gld) {
1604+ cpi->rc.show_arf_as_gld = 1;
1605+ cpi->refresh_golden_frame = 0;
1606+ cm->show_existing_frame = 1;
1607+ cm->refresh_frame_context = 0;
1608+ }
15981609 break;
15991610 case MID_OVERLAY_UPDATE:
16001611 cpi->refresh_last_frame = 1;
@@ -1716,6 +1727,15 @@ static void update_golden_frame_stats(VP9_COMP *cpi) { · 115 unmodified lines
17161727 if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
17171728
17181729 rc->frames_since_golden++;
1730+
1731+ if (rc->show_arf_as_gld) {
1732+ rc->frames_since_golden = 0;
1733+ // If we are not using alt ref in the up and coming group clear the arf
1734+ // active flag. In multi arf group case, if the index is not 0 then
1735+ // we are overlaying a mid group arf so should not reset the flag.
1736+ if (!rc->source_alt_ref_pending && (cpi->twopass.gf_group.index == 0))
1737+ rc->source_alt_ref_active = 0;
1738+ }
17191739 }
17201740 }
17211741
vp9/encoder/vp9_ratectrl.h+4−0
@@ -199,6 +199,10 @@ typedef struct { · 198 unmodified lines
199199 int damped_adjustment[RATE_FACTOR_LEVELS];
200200 double arf_active_best_quality_adjustment_factor;
201201 int arf_active_best_quality_adjustment_window;
202+
203+ int preserve_arf_as_gld;
204+ int preserve_next_arf_as_gld;
205+ int show_arf_as_gld;
202206 } RATE_CONTROL;
203207
204208 struct VP9_COMP;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t