History

Add check_transition_to_still()

The behavior is the same as that of detect_transition_still, only we void using cpi and twopass->stats_in

angiebird committed 7 years ago

Commit 98390f21 parent 9f291d82 files · +40 −19Browse files

Unified · Split

2 files
  1. vp9/encoder/vp9_firstpass.c +36 −19
  2. vp9/encoder/vp9_firstpass.h +4 −0
vp9/encoder/vp9_firstpass.c+36−19
@@ -1804,33 +1804,46 @@ static double get_prediction_decay_rate(const FRAME_INFO *frame_info, · 1803 unmodified lines
18041804 (sr_decay_rate + ((1.0 - sr_decay_rate) * zero_motion_factor)));
18051805 }
18061806
1807+static int get_show_idx(const TWO_PASS *twopass) {
1808+ return (int)(twopass->stats_in - twopass->stats_in_start);
1809+}
18071810 // Function to test for a condition where a complex transition is followed
18081811 // by a static section. For example in slide shows where there is a fade
18091812 // between slides. This is to help with more optimal kf and gf positioning.
1813+static int check_transition_to_still(const FIRST_PASS_INFO *first_pass_info,
1814+ int show_idx, int still_interval) {
1815+ int j;
1816+ int num_frames = fps_get_num_frames(first_pass_info);
1817+ if (show_idx + still_interval > num_frames) {
1818+ return 0;
1819+ }
1820+
1821+ // Look ahead a few frames to see if static condition persists...
1822+ for (j = 0; j < still_interval; ++j) {
1823+ const FIRSTPASS_STATS *stats =
1824+ fps_get_frame_stats(first_pass_info, show_idx + j);
1825+ if (stats->pcnt_inter - stats->pcnt_motion < 0.999) break;
1826+ }
1827+
1828+ // Only if it does do we signal a transition to still.
1829+ return j == still_interval;
1830+}
1831+
18101832 static int detect_transition_to_still(VP9_COMP *cpi, int frame_interval,
18111833 int still_interval,
18121834 double loop_decay_rate,
18131835 double last_decay_rate) {
1814− TWO_PASS *const twopass = &cpi->twopass;
1836+ const TWO_PASS *const twopass = &cpi->twopass;
18151837 RATE_CONTROL *const rc = &cpi->rc;
1838+ int show_idx = get_show_idx(twopass);
18161839
18171840 // Break clause to detect very still sections after motion
18181841 // For example a static image after a fade or other transition
18191842 // instead of a clean scene cut.
18201843 if (frame_interval > rc->min_gf_interval && loop_decay_rate >= 0.999 &&
18211844 last_decay_rate < 0.9) {
1822− int j;
1823−
1824− // Look ahead a few frames to see if static condition persists...
1825− for (j = 0; j < still_interval; ++j) {
1826− const FIRSTPASS_STATS *stats = &twopass->stats_in[j];
1827− if (stats >= twopass->stats_in_end) break;
1828−
1829− if (stats->pcnt_inter - stats->pcnt_motion < 0.999) break;
1830− }
1831−
1832− // Only if it does do we signal a transition to still.
1833− return j == still_interval;
1845+ return check_transition_to_still(&twopass->first_pass_info, show_idx,
1846+ still_interval);
18341847 }
18351848
18361849 return 0;
@@ -2058,7 +2071,7 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { · 221 unmodified lines
20582071 const FRAME_INFO *frame_info = &cpi->frame_info;
20592072 TWO_PASS *const twopass = &cpi->twopass;
20602073 const int avg_inter_frame_qindex = cpi->rc.avg_frame_qindex[INTER_FRAME];
2061− int arf_show_idx = (int)(twopass->stats_in - twopass->stats_in_start);
2074+ int arf_show_idx = get_show_idx(twopass);
20622075 return compute_arf_boost(frame_info, &twopass->first_pass_info, arf_show_idx,
20632076 f_frames, b_frames, avg_inter_frame_qindex);
20642077 }
@@ -2608,10 +2621,14 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 543 unmodified lines
26082621
26092622 // Break clause to detect very still sections after motion. For example,
26102623 // a static image after a fade or other transition.
2611− if (detect_transition_to_still(cpi, i, 5, loop_decay_rate,
2612− last_loop_decay_rate)) {
2613− allow_alt_ref = 0;
2614− break;
2624+ if (i > rc->min_gf_interval && loop_decay_rate >= 0.999 &&
2625+ last_loop_decay_rate < 0.9) {
2626+ int still_interval = 5;
2627+ if (check_transition_to_still(first_pass_info, gf_start_show_idx + i,
2628+ still_interval)) {
2629+ allow_alt_ref = 0;
2630+ break;
2631+ }
26152632 }
26162633
26172634 // Update the accumulator for second ref error difference.
@@ -2666,7 +2683,7 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 48 unmodified lines
26662683 const int avg_inter_frame_qindex = rc->avg_frame_qindex[INTER_FRAME];
26672684 // TODO(angiebird): figure out why arf's location is assigned this way
26682685 const int arf_show_idx =
2669− VPXMIN(gf_start_show_idx + i + 1, first_pass_info->num_frames);
2686+ VPXMIN(gf_start_show_idx + i + 1, fps_get_num_frames(first_pass_info));
26702687
26712688 // Calculate the boost for alt ref.
26722689 rc->gfu_boost =
vp9/encoder/vp9_firstpass.h+4−0
@@ -158,6 +158,10 @@ static INLINE void fps_init_first_pass_info(FIRST_PASS_INFO *first_pass_info, · 157 unmodified lines
158158 first_pass_info->num_frames = num_frames;
159159 }
160160
161+static INLINE int fps_get_num_frames(const FIRST_PASS_INFO *first_pass_info) {
162+ return first_pass_info->num_frames;
163+}
164+
161165 static INLINE const FIRSTPASS_STATS *fps_get_frame_stats(
162166 const FIRST_PASS_INFO *first_pass_info, int show_idx) {
163167 if (show_idx >= first_pass_info->num_frames) {

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