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
3063 BufferPool *const pool = cm->buffer_pool;3063 BufferPool *const pool = cm->buffer_pool;
3064 GF_GROUP *const gf_group = &cpi->twopass.gf_group;3064 GF_GROUP *const gf_group = &cpi->twopass.gf_group;
3065 3065
3066 // Pop ARF.3066 if (cpi->rc.show_arf_as_gld) {
3067 if (cm->show_existing_frame) {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.
3068 cpi->lst_fb_idx = cpi->alt_fb_idx;3072 cpi->lst_fb_idx = cpi->alt_fb_idx;
3069 cpi->alt_fb_idx =3073 cpi->alt_fb_idx =
3070 stack_pop(gf_group->arf_index_stack, gf_group->stack_size);3074 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
2455 int gf_arf_bits;2455 int gf_arf_bits;
2456 const int is_key_frame = frame_is_intra_only(cm);2456 const int is_key_frame = frame_is_intra_only(cm);
2457 const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;2457 const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
2458 int is_alt_ref_flash = 0;
2458 2459
2459 double gop_intra_factor = 1.0;2460 double gop_intra_factor = 1.0;
2460 int gop_frames;2461 int gop_frames;
@@ -2678,6 +2679,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 217 unmodified lines
2678 // Reset the file position.2679 // Reset the file position.
2679 reset_fpf_position(twopass, start_pos);2680 reset_fpf_position(twopass, start_pos);
2680 2681
2682 if (rc->source_alt_ref_pending)
2683 is_alt_ref_flash = detect_flash(twopass, rc->baseline_gf_interval);
2684
2681 // Calculate the bits to be allocated to the gf/arf group as a whole2685 // Calculate the bits to be allocated to the gf/arf group as a whole
2682 gf_group_bits = calculate_total_gf_group_bits(cpi, gf_group_err);2686 gf_group_bits = calculate_total_gf_group_bits(cpi, gf_group_err);
2683 2687
@@ -2755,6 +2759,12 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { · 71 unmodified lines
2755 twopass->rolling_arf_group_target_bits = 0;2759 twopass->rolling_arf_group_target_bits = 0;
2756 twopass->rolling_arf_group_actual_bits = 0;2760 twopass->rolling_arf_group_actual_bits = 0;
2757#endif2761#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;
2758}2768}
2759 2769
2760// Intra / Inter threshold very low2770// 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
436 rc->use_post_encode_drop = 0;436 rc->use_post_encode_drop = 0;
437 rc->ext_use_post_encode_drop = 0;437 rc->ext_use_post_encode_drop = 0;
438 rc->arf_active_best_quality_adjustment_factor = 1.0;438 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;
439}443}
440 444
441static int check_buffer_above_thresh(VP9_COMP *cpi, int drop_mark) {445static 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
1574 1578
1575 cpi->rc.is_src_frame_alt_ref = 0;1579 cpi->rc.is_src_frame_alt_ref = 0;
1576 cm->show_existing_frame = 0;1580 cm->show_existing_frame = 0;
1581 cpi->rc.show_arf_as_gld = 0;
1577 switch (twopass->gf_group.update_type[gf_group_index]) {1582 switch (twopass->gf_group.update_type[gf_group_index]) {
1578 case KF_UPDATE:1583 case KF_UPDATE:
1579 cpi->refresh_last_frame = 1;1584 cpi->refresh_last_frame = 1;
@@ -1595,6 +1600,12 @@ void vp9_configure_buffer_updates(VP9_COMP *cpi, int gf_group_index) { · 15 unmodified lines
1595 cpi->refresh_golden_frame = 1;1600 cpi->refresh_golden_frame = 1;
1596 cpi->refresh_alt_ref_frame = 0;1601 cpi->refresh_alt_ref_frame = 0;
1597 cpi->rc.is_src_frame_alt_ref = 1;1602 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 }
1598 break;1609 break;
1599 case MID_OVERLAY_UPDATE:1610 case MID_OVERLAY_UPDATE:
1600 cpi->refresh_last_frame = 1;1611 cpi->refresh_last_frame = 1;
@@ -1716,6 +1727,15 @@ static void update_golden_frame_stats(VP9_COMP *cpi) { · 115 unmodified lines
1716 if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;1727 if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
1717 1728
1718 rc->frames_since_golden++;1729 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 }
1719 }1739 }
1720}1740}
1721 1741
vp9/encoder/vp9_ratectrl.h+4−0
@@ -199,6 +199,10 @@ typedef struct { · 198 unmodified lines
199 int damped_adjustment[RATE_FACTOR_LEVELS];199 int damped_adjustment[RATE_FACTOR_LEVELS];
200 double arf_active_best_quality_adjustment_factor;200 double arf_active_best_quality_adjustment_factor;
201 int arf_active_best_quality_adjustment_window;201 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;
202} RATE_CONTROL;206} RATE_CONTROL;
203 207
204struct VP9_COMP;208struct 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