| @@ -77,7 +77,6 @@ · 76 unmodified lines |
| 77 | #define MINQ_ADJ_LIMIT_CQ 20 | 77 | #define MINQ_ADJ_LIMIT_CQ 20 |
| 78 | #define HIGH_UNDERSHOOT_RATIO 2 | 78 | #define HIGH_UNDERSHOOT_RATIO 2 |
| 79 | #define AV_WQ_FACTOR 4.0 | 79 | #define AV_WQ_FACTOR 4.0 |
| 80 | #define DEF_EPMB_LOW 2000.0 | | |
| 81 | | 80 | |
| 82 | #define DOUBLE_DIVIDE_CHECK(x) ((x) < 0 ? (x)-0.000001 : (x) + 0.000001) | 81 | #define DOUBLE_DIVIDE_CHECK(x) ((x) < 0 ? (x)-0.000001 : (x) + 0.000001) |
| 83 | | 82 | |
| @@ -1833,6 +1832,7 @@ void vp9_init_second_pass(VP9_COMP *cpi) { · 1749 unmodified lines |
| 1833 | } | 1832 | } |
| 1834 | | 1833 | |
| 1835 | static double get_sr_decay_rate(const FRAME_INFO *frame_info, | 1834 | static double get_sr_decay_rate(const FRAME_INFO *frame_info, |
| | 1835 | const TWO_PASS *const twopass, |
| 1836 | const FIRSTPASS_STATS *frame) { | 1836 | const FIRSTPASS_STATS *frame) { |
| 1837 | double sr_diff = (frame->sr_coded_error - frame->coded_error); | 1837 | double sr_diff = (frame->sr_coded_error - frame->coded_error); |
| 1838 | double sr_decay = 1.0; | 1838 | double sr_decay = 1.0; |
| @@ -1854,28 +1854,31 @@ static double get_sr_decay_rate(const FRAME_INFO *frame_info, · 15 unmodified lines |
| 1854 | | 1854 | |
| 1855 | if ((sr_diff > LOW_SR_DIFF_TRHESH)) { | 1855 | if ((sr_diff > LOW_SR_DIFF_TRHESH)) { |
| 1856 | sr_diff = VPXMIN(sr_diff, SR_DIFF_MAX); | 1856 | sr_diff = VPXMIN(sr_diff, SR_DIFF_MAX); |
| 1857 | sr_decay = 1.0 - (SR_DIFF_PART * sr_diff) - motion_amplitude_part - | 1857 | sr_decay = 1.0 - (twopass->sr_diff_part * sr_diff) - motion_amplitude_part - |
| 1858 | (INTRA_PART * modified_pcnt_intra); | 1858 | (INTRA_PART * modified_pcnt_intra); |
| 1859 | } | 1859 | } |
| 1860 | return VPXMAX(sr_decay, DEFAULT_DECAY_LIMIT); | 1860 | return VPXMAX(sr_decay, twopass->sr_default_decay_limit); |
| 1861 | } | 1861 | } |
| 1862 | | 1862 | |
| 1863 | // This function gives an estimate of how badly we believe the prediction | 1863 | // This function gives an estimate of how badly we believe the prediction |
| 1864 | // quality is decaying from frame to frame. | 1864 | // quality is decaying from frame to frame. |
| 1865 | static double get_zero_motion_factor(const FRAME_INFO *frame_info, | 1865 | static double get_zero_motion_factor(const FRAME_INFO *frame_info, |
| | 1866 | const TWO_PASS *const twopass, |
| 1866 | const FIRSTPASS_STATS *frame_stats) { | 1867 | const FIRSTPASS_STATS *frame_stats) { |
| 1867 | const double zero_motion_pct = | 1868 | const double zero_motion_pct = |
| 1868 | frame_stats->pcnt_inter - frame_stats->pcnt_motion; | 1869 | frame_stats->pcnt_inter - frame_stats->pcnt_motion; |
| 1869 | double sr_decay = get_sr_decay_rate(frame_info, frame_stats); | 1870 | double sr_decay = get_sr_decay_rate(frame_info, twopass, frame_stats); |
| 1870 | return VPXMIN(sr_decay, zero_motion_pct); | 1871 | return VPXMIN(sr_decay, zero_motion_pct); |
| 1871 | } | 1872 | } |
| 1872 | | 1873 | |
| 1873 | static double get_prediction_decay_rate(const FRAME_INFO *frame_info, | 1874 | static double get_prediction_decay_rate(const FRAME_INFO *frame_info, |
| | 1875 | const TWO_PASS *const twopass, |
| 1874 | const FIRSTPASS_STATS *frame_stats) { | 1876 | const FIRSTPASS_STATS *frame_stats) { |
| 1875 | const double sr_decay_rate = get_sr_decay_rate(frame_info, frame_stats); | 1877 | const double sr_decay_rate = |
| | 1878 | get_sr_decay_rate(frame_info, twopass, frame_stats); |
| 1876 | const double zero_motion_factor = | 1879 | const double zero_motion_factor = |
| 1877 | (0.95 * pow((frame_stats->pcnt_inter - frame_stats->pcnt_motion), | 1880 | (0.95 * pow((frame_stats->pcnt_inter - frame_stats->pcnt_motion), |
| 1878 | ZM_POWER_FACTOR)); | 1881 | twopass->zm_power_factor)); |
| 1879 | | 1882 | |
| 1880 | return VPXMAX(zero_motion_factor, | 1883 | return VPXMAX(zero_motion_factor, |
| 1881 | (sr_decay_rate + ((1.0 - sr_decay_rate) * zero_motion_factor))); | 1884 | (sr_decay_rate + ((1.0 - sr_decay_rate) * zero_motion_factor))); |
| @@ -1959,6 +1962,7 @@ static void accumulate_frame_motion_stats(const FIRSTPASS_STATS *stats, · 77 unmodified lines |
| 1959 | | 1962 | |
| 1960 | static double calc_frame_boost(const FRAME_INFO *frame_info, | 1963 | static double calc_frame_boost(const FRAME_INFO *frame_info, |
| 1961 | const FIRSTPASS_STATS *this_frame, | 1964 | const FIRSTPASS_STATS *this_frame, |
| | 1965 | const TWO_PASS *const twopass, |
| 1962 | int avg_frame_qindex, | 1966 | int avg_frame_qindex, |
| 1963 | double this_frame_mv_in_out) { | 1967 | double this_frame_mv_in_out) { |
| 1964 | double frame_boost; | 1968 | double frame_boost; |
| @@ -1968,7 +1972,7 @@ static double calc_frame_boost(const FRAME_INFO *frame_info, · 3 unmodified lines |
| 1968 | const double active_area = calculate_active_area(frame_info, this_frame); | 1972 | const double active_area = calculate_active_area(frame_info, this_frame); |
| 1969 | | 1973 | |
| 1970 | // Underlying boost factor is based on inter error ratio. | 1974 | // Underlying boost factor is based on inter error ratio. |
| 1971 | frame_boost = (BASELINE_ERR_PER_MB * active_area) / | 1975 | frame_boost = (twopass->base_err_per_mb * active_area) / |
| 1972 | DOUBLE_DIVIDE_CHECK(this_frame->coded_error); | 1976 | DOUBLE_DIVIDE_CHECK(this_frame->coded_error); |
| 1973 | | 1977 | |
| 1974 | // Small adjustment for cases where there is a zoom out | 1978 | // Small adjustment for cases where there is a zoom out |
| @@ -1978,37 +1982,25 @@ static double calc_frame_boost(const FRAME_INFO *frame_info, · 3 unmodified lines |
| 1978 | // Q correction and scalling | 1982 | // Q correction and scalling |
| 1979 | frame_boost = frame_boost * boost_q_correction; | 1983 | frame_boost = frame_boost * boost_q_correction; |
| 1980 | | 1984 | |
| 1981 | return VPXMIN(frame_boost, GF_MAX_FRAME_BOOST * boost_q_correction); | 1985 | return VPXMIN(frame_boost, twopass->gf_frame_max_boost * boost_q_correction); |
| 1982 | } | | |
| 1983 | | | |
| 1984 | static double kf_err_per_mb(VP9_COMP *cpi) { | | |
| 1985 | const VP9_COMMON *const cm = &cpi->common; | | |
| 1986 | unsigned int screen_area = (cm->width * cm->height); | | |
| 1987 | | | |
| 1988 | // Use a different error per mb factor for calculating boost for | | |
| 1989 | // different formats. | | |
| 1990 | if (screen_area < 1280 * 720) { | | |
| 1991 | return 2000.0; | | |
| 1992 | } else if (screen_area < 1920 * 1080) { | | |
| 1993 | return 500.0; | | |
| 1994 | } | | |
| 1995 | return 250.0; | | |
| 1996 | } | 1986 | } |
| 1997 | | 1987 | |
| 1998 | static double calc_kf_frame_boost(VP9_COMP *cpi, | 1988 | static double calc_kf_frame_boost(VP9_COMP *cpi, |
| 1999 | const FIRSTPASS_STATS *this_frame, | 1989 | const FIRSTPASS_STATS *this_frame, |
| 2000 | double *sr_accumulator, | 1990 | double *sr_accumulator, |
| 2001 | double this_frame_mv_in_out, | 1991 | double this_frame_mv_in_out, |
| 2002 | double max_boost) { | 1992 | double zm_factor) { |
| | 1993 | TWO_PASS *const twopass = &cpi->twopass; |
| 2003 | double frame_boost; | 1994 | double frame_boost; |
| 2004 | const double lq = vp9_convert_qindex_to_q( | 1995 | const double lq = vp9_convert_qindex_to_q( |
| 2005 | cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth); | 1996 | cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth); |
| 2006 | const double boost_q_correction = VPXMIN((0.50 + (lq * 0.015)), 2.00); | 1997 | const double boost_q_correction = VPXMIN((0.50 + (lq * 0.015)), 2.00); |
| 2007 | const double active_area = | 1998 | const double active_area = |
| 2008 | calculate_active_area(&cpi->frame_info, this_frame); | 1999 | calculate_active_area(&cpi->frame_info, this_frame); |
| | 2000 | double max_boost; |
| 2009 | | 2001 | |
| 2010 | // Underlying boost factor is based on inter error ratio. | 2002 | // Underlying boost factor is based on inter error ratio. |
| 2011 | frame_boost = (kf_err_per_mb(cpi) * active_area) / | 2003 | frame_boost = (twopass->kf_err_per_mb * active_area) / |
| 2012 | DOUBLE_DIVIDE_CHECK(this_frame->coded_error + *sr_accumulator); | 2004 | DOUBLE_DIVIDE_CHECK(this_frame->coded_error + *sr_accumulator); |
| 2013 | | 2005 | |
| 2014 | // Update the accumulator for second ref error difference. | 2006 | // Update the accumulator for second ref error difference. |
| @@ -2027,13 +2019,20 @@ static double calc_kf_frame_boost(VP9_COMP *cpi, · 12 unmodified lines |
| 2027 | // boost calculation. | 2019 | // boost calculation. |
| 2028 | frame_boost = ((frame_boost + 40.0) * boost_q_correction); | 2020 | frame_boost = ((frame_boost + 40.0) * boost_q_correction); |
| 2029 | | 2021 | |
| 2030 | return VPXMIN(frame_boost, max_boost * boost_q_correction); | 2022 | // Maximum allowed boost this frame. May be different for first vs subsequent |
| | 2023 | // key frames. |
| | 2024 | max_boost = (cpi->common.current_video_frame == 0) |
| | 2025 | ? twopass->kf_frame_max_boost_first |
| | 2026 | : twopass->kf_frame_max_boost_subs; |
| | 2027 | max_boost *= zm_factor * boost_q_correction; |
| | 2028 | |
| | 2029 | return VPXMIN(frame_boost, max_boost); |
| 2031 | } | 2030 | } |
| 2032 | | 2031 | |
| 2033 | static int compute_arf_boost(const FRAME_INFO *frame_info, | 2032 | static int compute_arf_boost(const FRAME_INFO *frame_info, |
| 2034 | const FIRST_PASS_INFO *first_pass_info, | 2033 | TWO_PASS *const twopass, int arf_show_idx, |
| 2035 | int arf_show_idx, int f_frames, int b_frames, | 2034 | int f_frames, int b_frames, int avg_frame_qindex) { |
| 2036 | int avg_frame_qindex) { | 2035 | const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; |
| 2037 | int i; | 2036 | int i; |
| 2038 | double boost_score = 0.0; | 2037 | double boost_score = 0.0; |
| 2039 | double mv_ratio_accumulator = 0.0; | 2038 | double mv_ratio_accumulator = 0.0; |
| @@ -2064,14 +2063,15 @@ static int compute_arf_boost(const FRAME_INFO *frame_info, · 24 unmodified lines |
| 2064 | | 2063 | |
| 2065 | // Accumulate the effect of prediction quality decay. | 2064 | // Accumulate the effect of prediction quality decay. |
| 2066 | if (!flash_detected) { | 2065 | if (!flash_detected) { |
| 2067 | decay_accumulator *= get_prediction_decay_rate(frame_info, this_frame); | 2066 | decay_accumulator *= |
| | 2067 | get_prediction_decay_rate(frame_info, twopass, this_frame); |
| 2068 | decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR | 2068 | decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR |
| 2069 | ? MIN_DECAY_FACTOR | 2069 | ? MIN_DECAY_FACTOR |
| 2070 | : decay_accumulator; | 2070 | : decay_accumulator; |
| 2071 | } | 2071 | } |
| 2072 | boost_score += decay_accumulator * calc_frame_boost(frame_info, this_frame, | 2072 | boost_score += decay_accumulator * |
| 2073 | avg_frame_qindex, | 2073 | calc_frame_boost(frame_info, this_frame, twopass, |
| 2074 | this_frame_mv_in_out); | 2074 | avg_frame_qindex, this_frame_mv_in_out); |
| 2075 | } | 2075 | } |
| 2076 | | 2076 | |
| 2077 | arf_boost = (int)boost_score; | 2077 | arf_boost = (int)boost_score; |
| @@ -2104,14 +2104,15 @@ static int compute_arf_boost(const FRAME_INFO *frame_info, · 26 unmodified lines |
| 2104 | | 2104 | |
| 2105 | // Cumulative effect of prediction quality decay. | 2105 | // Cumulative effect of prediction quality decay. |
| 2106 | if (!flash_detected) { | 2106 | if (!flash_detected) { |
| 2107 | decay_accumulator *= get_prediction_decay_rate(frame_info, this_frame); | 2107 | decay_accumulator *= |
| | 2108 | get_prediction_decay_rate(frame_info, twopass, this_frame); |
| 2108 | decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR | 2109 | decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR |
| 2109 | ? MIN_DECAY_FACTOR | 2110 | ? MIN_DECAY_FACTOR |
| 2110 | : decay_accumulator; | 2111 | : decay_accumulator; |
| 2111 | } | 2112 | } |
| 2112 | boost_score += decay_accumulator * calc_frame_boost(frame_info, this_frame, | 2113 | boost_score += decay_accumulator * |
| 2113 | avg_frame_qindex, | 2114 | calc_frame_boost(frame_info, this_frame, twopass, |
| 2114 | this_frame_mv_in_out); | 2115 | avg_frame_qindex, this_frame_mv_in_out); |
| 2115 | } | 2116 | } |
| 2116 | arf_boost += (int)boost_score; | 2117 | arf_boost += (int)boost_score; |
| 2117 | | 2118 | |
| @@ -2127,8 +2128,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { · 9 unmodified lines |
| 2127 | TWO_PASS *const twopass = &cpi->twopass; | 2128 | TWO_PASS *const twopass = &cpi->twopass; |
| 2128 | const int avg_inter_frame_qindex = cpi->rc.avg_frame_qindex[INTER_FRAME]; | 2129 | const int avg_inter_frame_qindex = cpi->rc.avg_frame_qindex[INTER_FRAME]; |
| 2129 | int arf_show_idx = get_show_idx(twopass); | 2130 | int arf_show_idx = get_show_idx(twopass); |
| 2130 | return compute_arf_boost(frame_info, &twopass->first_pass_info, arf_show_idx, | 2131 | return compute_arf_boost(frame_info, twopass, arf_show_idx, f_frames, |
| 2131 | f_frames, b_frames, avg_inter_frame_qindex); | 2132 | b_frames, avg_inter_frame_qindex); |
| 2132 | } | 2133 | } |
| 2133 | | 2134 | |
| 2134 | // Calculate a section intra ratio used in setting max loop filter. | 2135 | // Calculate a section intra ratio used in setting max loop filter. |
| @@ -2557,10 +2558,11 @@ typedef struct RANGE { · 422 unmodified lines |
| 2557 | * structs. | 2558 | * structs. |
| 2558 | */ | 2559 | */ |
| 2559 | static int get_gop_coding_frame_num( | 2560 | static int get_gop_coding_frame_num( |
| 2560 | int *use_alt_ref, const FRAME_INFO *frame_info, | 2561 | int *use_alt_ref, const FRAME_INFO *frame_info, TWO_PASS *const twopass, |
| 2561 | const FIRST_PASS_INFO *first_pass_info, const RATE_CONTROL *rc, | 2562 | const RATE_CONTROL *rc, int gf_start_show_idx, |
| 2562 | int gf_start_show_idx, const RANGE *active_gf_interval, | 2563 | const RANGE *active_gf_interval, double gop_intra_factor, |
| 2563 | double gop_intra_factor, int lag_in_frames) { | 2564 | int lag_in_frames) { |
| | 2565 | const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; |
| 2564 | double loop_decay_rate = 1.00; | 2566 | double loop_decay_rate = 1.00; |
| 2565 | double mv_ratio_accumulator = 0.0; | 2567 | double mv_ratio_accumulator = 0.0; |
| 2566 | double this_frame_mv_in_out = 0.0; | 2568 | double this_frame_mv_in_out = 0.0; |
| @@ -2603,13 +2605,14 @@ static int get_gop_coding_frame_num( · 36 unmodified lines |
| 2603 | if ((rc->frames_since_key + gop_coding_frames - 1) > 1) { | 2605 | if ((rc->frames_since_key + gop_coding_frames - 1) > 1) { |
| 2604 | zero_motion_accumulator = | 2606 | zero_motion_accumulator = |
| 2605 | VPXMIN(zero_motion_accumulator, | 2607 | VPXMIN(zero_motion_accumulator, |
| 2606 | get_zero_motion_factor(frame_info, next_frame)); | 2608 | get_zero_motion_factor(frame_info, twopass, next_frame)); |
| 2607 | } | 2609 | } |
| 2608 | | 2610 | |
| 2609 | // Accumulate the effect of prediction quality decay. | 2611 | // Accumulate the effect of prediction quality decay. |
| 2610 | if (!flash_detected) { | 2612 | if (!flash_detected) { |
| 2611 | double last_loop_decay_rate = loop_decay_rate; | 2613 | double last_loop_decay_rate = loop_decay_rate; |
| 2612 | loop_decay_rate = get_prediction_decay_rate(frame_info, next_frame); | 2614 | loop_decay_rate = |
| | 2615 | get_prediction_decay_rate(frame_info, twopass, next_frame); |
| 2613 | | 2616 | |
| 2614 | // Break clause to detect very still sections after motion. For example, | 2617 | // Break clause to detect very still sections after motion. For example, |
| 2615 | // a static image after a fade or other transition. | 2618 | // a static image after a fade or other transition. |
| @@ -2807,14 +2810,14 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 191 unmodified lines |
| 2807 | use_alt_ref = gop_command->use_alt_ref; | 2810 | use_alt_ref = gop_command->use_alt_ref; |
| 2808 | } else { | 2811 | } else { |
| 2809 | gop_coding_frames = get_gop_coding_frame_num( | 2812 | gop_coding_frames = get_gop_coding_frame_num( |
| 2810 | &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx, | 2813 | &use_alt_ref, frame_info, twopass, rc, gf_start_show_idx, |
| 2811 | &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); | 2814 | &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); |
| 2812 | use_alt_ref &= allow_alt_ref; | 2815 | use_alt_ref &= allow_alt_ref; |
| 2813 | } | 2816 | } |
| 2814 | } | 2817 | } |
| 2815 | #else | 2818 | #else |
| 2816 | gop_coding_frames = get_gop_coding_frame_num( | 2819 | gop_coding_frames = get_gop_coding_frame_num( |
| 2817 | &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx, | 2820 | &use_alt_ref, frame_info, twopass, rc, gf_start_show_idx, |
| 2818 | &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); | 2821 | &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames); |
| 2819 | use_alt_ref &= allow_alt_ref; | 2822 | use_alt_ref &= allow_alt_ref; |
| 2820 | #endif | 2823 | #endif |
| @@ -2836,8 +2839,8 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 15 unmodified lines |
| 2836 | | 2839 | |
| 2837 | // Calculate the boost for alt ref. | 2840 | // Calculate the boost for alt ref. |
| 2838 | rc->gfu_boost = | 2841 | rc->gfu_boost = |
| 2839 | compute_arf_boost(frame_info, first_pass_info, arf_show_idx, f_frames, | 2842 | compute_arf_boost(frame_info, twopass, arf_show_idx, f_frames, b_frames, |
| 2840 | b_frames, avg_inter_frame_qindex); | 2843 | avg_inter_frame_qindex); |
| 2841 | rc->source_alt_ref_pending = 1; | 2844 | rc->source_alt_ref_pending = 1; |
| 2842 | } else { | 2845 | } else { |
| 2843 | const int f_frames = gop_coding_frames - 1; | 2846 | const int f_frames = gop_coding_frames - 1; |
| @@ -2847,9 +2850,9 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 3 unmodified lines |
| 2847 | const int gld_show_idx = | 2850 | const int gld_show_idx = |
| 2848 | VPXMIN(gf_start_show_idx + 1, fps_get_num_frames(first_pass_info)); | 2851 | VPXMIN(gf_start_show_idx + 1, fps_get_num_frames(first_pass_info)); |
| 2849 | const int arf_boost = | 2852 | const int arf_boost = |
| 2850 | compute_arf_boost(frame_info, first_pass_info, gld_show_idx, f_frames, | 2853 | compute_arf_boost(frame_info, twopass, gld_show_idx, f_frames, b_frames, |
| 2851 | b_frames, avg_inter_frame_qindex); | 2854 | avg_inter_frame_qindex); |
| 2852 | rc->gfu_boost = VPXMIN(MAX_GF_BOOST, arf_boost); | 2855 | rc->gfu_boost = VPXMIN(twopass->gf_max_total_boost, arf_boost); |
| 2853 | rc->source_alt_ref_pending = 0; | 2856 | rc->source_alt_ref_pending = 0; |
| 2854 | } | 2857 | } |
| 2855 | | 2858 | |
| @@ -2952,7 +2955,9 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 96 unmodified lines |
| 2952 | cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone), | 2955 | cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone), |
| 2953 | group_av_noise, vbr_group_bits_per_frame); | 2956 | group_av_noise, vbr_group_bits_per_frame); |
| 2954 | twopass->active_worst_quality = | 2957 | twopass->active_worst_quality = |
| 2955 | (tmp_q + (twopass->active_worst_quality * 3)) >> 2; | 2958 | (int)((tmp_q + (twopass->active_worst_quality * |
| | 2959 | (twopass->active_wq_factor - 1))) / |
| | 2960 | twopass->active_wq_factor); |
| 2956 | | 2961 | |
| 2957 | #if CONFIG_ALWAYS_ADJUST_BPM | 2962 | #if CONFIG_ALWAYS_ADJUST_BPM |
| 2958 | // Reset rolling actual and target bits counters for ARF groups. | 2963 | // Reset rolling actual and target bits counters for ARF groups. |
| @@ -3174,8 +3179,9 @@ static int test_candidate_kf(const FIRST_PASS_INFO *first_pass_info, · 215 unmodified lines |
| 3174 | | 3179 | |
| 3175 | int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf, | 3180 | int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf, |
| 3176 | const FRAME_INFO *frame_info, | 3181 | const FRAME_INFO *frame_info, |
| 3177 | const FIRST_PASS_INFO *first_pass_info, | 3182 | const TWO_PASS *const twopass, int kf_show_idx, |
| 3178 | int kf_show_idx, int min_gf_interval) { | 3183 | int min_gf_interval) { |
| | 3184 | const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info; |
| 3179 | double recent_loop_decay[FRAMES_TO_CHECK_DECAY]; | 3185 | double recent_loop_decay[FRAMES_TO_CHECK_DECAY]; |
| 3180 | int j; | 3186 | int j; |
| 3181 | int frames_to_key; | 3187 | int frames_to_key; |
| @@ -3202,7 +3208,8 @@ int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf, · 20 unmodified lines |
| 3202 | break; | 3208 | break; |
| 3203 | | 3209 | |
| 3204 | // How fast is the prediction quality decaying? | 3210 | // How fast is the prediction quality decaying? |
| 3205 | loop_decay_rate = get_prediction_decay_rate(frame_info, next_frame); | 3211 | loop_decay_rate = |
| | 3212 | get_prediction_decay_rate(frame_info, twopass, next_frame); |
| 3206 | | 3213 | |
| 3207 | // We want to know something about the recent past... rather than | 3214 | // We want to know something about the recent past... rather than |
| 3208 | // as used elsewhere where we are concerned with decay in prediction | 3215 | // as used elsewhere where we are concerned with decay in prediction |
| @@ -3289,7 +3296,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 80 unmodified lines |
| 3289 | mean_mod_score, av_err); | 3296 | mean_mod_score, av_err); |
| 3290 | | 3297 | |
| 3291 | rc->frames_to_key = vp9_get_frames_to_next_key( | 3298 | rc->frames_to_key = vp9_get_frames_to_next_key( |
| 3292 | oxcf, frame_info, first_pass_info, kf_show_idx, rc->min_gf_interval); | 3299 | oxcf, frame_info, twopass, kf_show_idx, rc->min_gf_interval); |
| 3293 | | 3300 | |
| 3294 | // If there is a max kf interval set by the user we must obey it. | 3301 | // If there is a max kf interval set by the user we must obey it. |
| 3295 | // We already breakout of the loop above at 2x max. | 3302 | // We already breakout of the loop above at 2x max. |
| @@ -3369,9 +3376,9 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 73 unmodified lines |
| 3369 | // Monitor for static sections. | 3376 | // Monitor for static sections. |
| 3370 | // First frame in kf group the second ref indicator is invalid. | 3377 | // First frame in kf group the second ref indicator is invalid. |
| 3371 | if (i > 0) { | 3378 | if (i > 0) { |
| 3372 | zero_motion_accumulator = | 3379 | zero_motion_accumulator = VPXMIN( |
| 3373 | VPXMIN(zero_motion_accumulator, | 3380 | zero_motion_accumulator, |
| 3374 | get_zero_motion_factor(&cpi->frame_info, &next_frame)); | 3381 | get_zero_motion_factor(&cpi->frame_info, twopass, &next_frame)); |
| 3375 | } else { | 3382 | } else { |
| 3376 | zero_motion_accumulator = | 3383 | zero_motion_accumulator = |
| 3377 | next_frame.pcnt_inter - next_frame.pcnt_motion; | 3384 | next_frame.pcnt_inter - next_frame.pcnt_motion; |
| @@ -3385,8 +3392,8 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 7 unmodified lines |
| 3385 | // the first key frame or it points to a refernce before the new key | 3392 | // the first key frame or it points to a refernce before the new key |
| 3386 | // frame. | 3393 | // frame. |
| 3387 | if (i < 2) sr_accumulator = 0.0; | 3394 | if (i < 2) sr_accumulator = 0.0; |
| 3388 | frame_boost = calc_kf_frame_boost(cpi, &next_frame, &sr_accumulator, 0, | 3395 | frame_boost = |
| 3389 | KF_MAX_FRAME_BOOST * zm_factor); | 3396 | calc_kf_frame_boost(cpi, &next_frame, &sr_accumulator, 0, zm_factor); |
| 3390 | | 3397 | |
| 3391 | boost_score += frame_boost; | 3398 | boost_score += frame_boost; |
| 3392 | | 3399 | |
| @@ -3415,12 +3422,12 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 22 unmodified lines |
| 3415 | // Special case for static / slide show content but dont apply | 3422 | // Special case for static / slide show content but dont apply |
| 3416 | // if the kf group is very short. | 3423 | // if the kf group is very short. |
| 3417 | if ((zero_motion_accumulator > 0.99) && (rc->frames_to_key > 8)) { | 3424 | if ((zero_motion_accumulator > 0.99) && (rc->frames_to_key > 8)) { |
| 3418 | rc->kf_boost = MAX_KF_TOT_BOOST; | 3425 | rc->kf_boost = twopass->kf_max_total_boost; |
| 3419 | } else { | 3426 | } else { |
| 3420 | // Apply various clamps for min and max boost | 3427 | // Apply various clamps for min and max oost |
| 3421 | rc->kf_boost = VPXMAX((int)boost_score, (rc->frames_to_key * 3)); | 3428 | rc->kf_boost = VPXMAX((int)boost_score, (rc->frames_to_key * 3)); |
| 3422 | rc->kf_boost = VPXMAX(rc->kf_boost, MIN_KF_TOT_BOOST); | 3429 | rc->kf_boost = VPXMAX(rc->kf_boost, MIN_KF_TOT_BOOST); |
| 3423 | rc->kf_boost = VPXMIN(rc->kf_boost, MAX_KF_TOT_BOOST); | 3430 | rc->kf_boost = VPXMIN(rc->kf_boost, twopass->kf_max_total_boost); |
| 3424 | } | 3431 | } |
| 3425 | | 3432 | |
| 3426 | // Work out how many bits to allocate for the key frame itself. | 3433 | // Work out how many bits to allocate for the key frame itself. |
| @@ -3477,107 +3484,113 @@ static int is_skippable_frame(const VP9_COMP *cpi) { · 50 unmodified lines |
| 3477 | | 3484 | |
| 3478 | // Configure image size specific vizier parameters. | 3485 | // Configure image size specific vizier parameters. |
| 3479 | // Later these will be set via additional command line options | 3486 | // Later these will be set via additional command line options |
| 3480 | static void init_vizier_params(RATE_CONTROL *const rc, int screen_area) { | 3487 | static void init_vizier_params(TWO_PASS *const twopass, int screen_area) { |
| 3481 | if (1) { | 3488 | if (1) { |
| 3482 | // Force defaults for now | 3489 | // Force defaults for now |
| 3483 | rc->active_wq_factor = AV_WQ_FACTOR; | 3490 | twopass->active_wq_factor = AV_WQ_FACTOR; |
| 3484 | rc->base_err_per_mb = BASELINE_ERR_PER_MB; | 3491 | twopass->base_err_per_mb = BASELINE_ERR_PER_MB; |
| 3485 | rc->sr_default_decay_limit = DEFAULT_DECAY_LIMIT; | 3492 | twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT; |
| 3486 | rc->sr_diff_part = SR_DIFF_PART; | 3493 | twopass->sr_diff_part = SR_DIFF_PART; |
| 3487 | rc->gf_frame_max_boost = GF_MAX_FRAME_BOOST; | 3494 | twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST; |
| 3488 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3495 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3489 | rc->kf_err_per_mb = DEF_EPMB_LOW; | 3496 | if (screen_area < 1280 * 720) { |
| 3490 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; // Max for first kf. | 3497 | twopass->kf_err_per_mb = 2000.0; |
| 3491 | rc->kf_frame_max_boost_subs = KF_MAX_FRAME_BOOST / 2; // Max for other kfs. | 3498 | } else if (screen_area < 1920 * 1080) { |
| 3492 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3499 | twopass->kf_err_per_mb = 500.0; |
| 3493 | rc->zm_power_factor = ZM_POWER_FACTOR; | 3500 | } else { |
| | 3501 | twopass->kf_err_per_mb = 250.0; |
| | 3502 | } |
| | 3503 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| | 3504 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| | 3505 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| | 3506 | twopass->zm_power_factor = ZM_POWER_FACTOR; |
| 3494 | } else { | 3507 | } else { |
| 3495 | // Vizer experimental parameters from training. | 3508 | // Vizer experimental parameters from training. |
| 3496 | // Later these will be set via the command line. | 3509 | // Later these will be set via the command line. |
| 3497 | if (screen_area <= 176 * 144) { | 3510 | if (screen_area <= 176 * 144) { |
| 3498 | rc->active_wq_factor = 46.0; | 3511 | twopass->active_wq_factor = 46.0; |
| 3499 | rc->base_err_per_mb = 37597.399760969536; | 3512 | twopass->base_err_per_mb = 37597.399760969536; |
| 3500 | rc->sr_default_decay_limit = 0.3905639800962774; | 3513 | twopass->sr_default_decay_limit = 0.3905639800962774; |
| 3501 | rc->sr_diff_part = 0.009599023654146284; | 3514 | twopass->sr_diff_part = 0.009599023654146284; |
| 3502 | rc->gf_frame_max_boost = 87.27362648627846; | 3515 | twopass->gf_frame_max_boost = 87.27362648627846; |
| 3503 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3516 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3504 | rc->kf_err_per_mb = 1854.8255436877148; | 3517 | twopass->kf_err_per_mb = 1854.8255436877148; |
| 3505 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3518 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3506 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3519 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3507 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3520 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3508 | rc->zm_power_factor = 2.93715229184991; | 3521 | twopass->zm_power_factor = 2.93715229184991; |
| 3509 | } else if (screen_area <= 320 * 240) { | 3522 | } else if (screen_area <= 320 * 240) { |
| 3510 | rc->active_wq_factor = 55.0; | 3523 | twopass->active_wq_factor = 55.0; |
| 3511 | rc->base_err_per_mb = 34525.33177195309; | 3524 | twopass->base_err_per_mb = 34525.33177195309; |
| 3512 | rc->sr_default_decay_limit = 0.23901360046804604; | 3525 | twopass->sr_default_decay_limit = 0.23901360046804604; |
| 3513 | rc->sr_diff_part = 0.008581014394766773; | 3526 | twopass->sr_diff_part = 0.008581014394766773; |
| 3514 | rc->gf_frame_max_boost = 127.34978204980285; | 3527 | twopass->gf_frame_max_boost = 127.34978204980285; |
| 3515 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3528 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3516 | rc->kf_err_per_mb = 723.8337508755031; | 3529 | twopass->kf_err_per_mb = 723.8337508755031; |
| 3517 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3530 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3518 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3531 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3519 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3532 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3520 | rc->zm_power_factor = 3.5299221493593413; | 3533 | twopass->zm_power_factor = 3.5299221493593413; |
| 3521 | } else if (screen_area <= 640 * 360) { | 3534 | } else if (screen_area <= 640 * 360) { |
| 3522 | rc->active_wq_factor = 12.5; | 3535 | twopass->active_wq_factor = 12.5; |
| 3523 | rc->base_err_per_mb = 18823.978018028298; | 3536 | twopass->base_err_per_mb = 18823.978018028298; |
| 3524 | rc->sr_default_decay_limit = 0.6043527690301296; | 3537 | twopass->sr_default_decay_limit = 0.6043527690301296; |
| 3525 | rc->sr_diff_part = 0.00343296783885544; | 3538 | twopass->sr_diff_part = 0.00343296783885544; |
| 3526 | rc->gf_frame_max_boost = 75.17672317013668; | 3539 | twopass->gf_frame_max_boost = 75.17672317013668; |
| 3527 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3540 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3528 | rc->kf_err_per_mb = 422.2871502380377; | 3541 | twopass->kf_err_per_mb = 422.2871502380377; |
| 3529 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3542 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3530 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3543 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3531 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3544 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3532 | rc->zm_power_factor = 2.265742666649307; | 3545 | twopass->zm_power_factor = 2.265742666649307; |
| 3533 | } else if (screen_area <= 854 * 480) { | 3546 | } else if (screen_area <= 854 * 480) { |
| 3534 | rc->active_wq_factor = 51.5; | 3547 | twopass->active_wq_factor = 51.5; |
| 3535 | rc->base_err_per_mb = 33718.98307662595; | 3548 | twopass->base_err_per_mb = 33718.98307662595; |
| 3536 | rc->sr_default_decay_limit = 0.33633414970713393; | 3549 | twopass->sr_default_decay_limit = 0.33633414970713393; |
| 3537 | rc->sr_diff_part = 0.00868988716928333; | 3550 | twopass->sr_diff_part = 0.00868988716928333; |
| 3538 | rc->gf_frame_max_boost = 85.2868528581522; | 3551 | twopass->gf_frame_max_boost = 85.2868528581522; |
| 3539 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3552 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3540 | rc->kf_err_per_mb = 1513.4883914008383; | 3553 | twopass->kf_err_per_mb = 1513.4883914008383; |
| 3541 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3554 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3542 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3555 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3543 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3556 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3544 | rc->zm_power_factor = 3.552278528517416; | 3557 | twopass->zm_power_factor = 3.552278528517416; |
| 3545 | } else if (screen_area <= 1280 * 720) { | 3558 | } else if (screen_area <= 1280 * 720) { |
| 3546 | rc->active_wq_factor = 41.5; | 3559 | twopass->active_wq_factor = 41.5; |
| 3547 | rc->base_err_per_mb = 29527.46375825401; | 3560 | twopass->base_err_per_mb = 29527.46375825401; |
| 3548 | rc->sr_default_decay_limit = 0.5009117586299728; | 3561 | twopass->sr_default_decay_limit = 0.5009117586299728; |
| 3549 | rc->sr_diff_part = 0.005007364627260114; | 3562 | twopass->sr_diff_part = 0.005007364627260114; |
| 3550 | rc->gf_frame_max_boost = GF_MAX_FRAME_BOOST; | 3563 | twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST; |
| 3551 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3564 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3552 | rc->kf_err_per_mb = 998.6342911785146; | 3565 | twopass->kf_err_per_mb = 998.6342911785146; |
| 3553 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3566 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3554 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3567 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3555 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3568 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3556 | rc->zm_power_factor = 2.568627575572356; | 3569 | twopass->zm_power_factor = 2.568627575572356; |
| 3557 | } else if (screen_area <= 1920 * 1080) { | 3570 | } else if (screen_area <= 1920 * 1080) { |
| 3558 | rc->active_wq_factor = 31.0; | 3571 | twopass->active_wq_factor = 31.0; |
| 3559 | rc->base_err_per_mb = 34474.723463367416; | 3572 | twopass->base_err_per_mb = 34474.723463367416; |
| 3560 | rc->sr_default_decay_limit = 0.23346886902707745; | 3573 | twopass->sr_default_decay_limit = 0.23346886902707745; |
| 3561 | rc->sr_diff_part = 0.011431716637966029; | 3574 | twopass->sr_diff_part = 0.011431716637966029; |
| 3562 | rc->gf_frame_max_boost = 81.00472969483079; | 3575 | twopass->gf_frame_max_boost = 81.00472969483079; |
| 3563 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3576 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3564 | rc->kf_err_per_mb = 35931.25734431429; | 3577 | twopass->kf_err_per_mb = 35931.25734431429; |
| 3565 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3578 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3566 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3579 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3567 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3580 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3568 | rc->zm_power_factor = 5.5776463538431935; | 3581 | twopass->zm_power_factor = 5.5776463538431935; |
| 3569 | } else { | 3582 | } else { |
| 3570 | rc->active_wq_factor = AV_WQ_FACTOR; | 3583 | twopass->active_wq_factor = AV_WQ_FACTOR; |
| 3571 | rc->base_err_per_mb = BASELINE_ERR_PER_MB; | 3584 | twopass->base_err_per_mb = BASELINE_ERR_PER_MB; |
| 3572 | rc->sr_default_decay_limit = DEFAULT_DECAY_LIMIT; | 3585 | twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT; |
| 3573 | rc->sr_diff_part = SR_DIFF_PART; | 3586 | twopass->sr_diff_part = SR_DIFF_PART; |
| 3574 | rc->gf_frame_max_boost = GF_MAX_FRAME_BOOST; | 3587 | twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST; |
| 3575 | rc->gf_max_total_boost = MAX_GF_BOOST; | 3588 | twopass->gf_max_total_boost = MAX_GF_BOOST; |
| 3576 | rc->kf_err_per_mb = DEF_EPMB_LOW; | 3589 | twopass->kf_err_per_mb = 250.0; |
| 3577 | rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; | 3590 | twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; |
| 3578 | rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2; | 3591 | twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first; |
| 3579 | rc->kf_max_total_boost = MAX_KF_TOT_BOOST; | 3592 | twopass->kf_max_total_boost = MAX_KF_TOT_BOOST; |
| 3580 | rc->zm_power_factor = ZM_POWER_FACTOR; | 3593 | twopass->zm_power_factor = ZM_POWER_FACTOR; |
| 3581 | } | 3594 | } |
| 3582 | } | 3595 | } |
| 3583 | } | 3596 | } |
| @@ -3596,7 +3609,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { · 12 unmodified lines |
| 3596 | if (cm->current_video_frame == 0) { | 3609 | if (cm->current_video_frame == 0) { |
| 3597 | unsigned int screen_area = (cm->width * cm->height); | 3610 | unsigned int screen_area = (cm->width * cm->height); |
| 3598 | | 3611 | |
| 3599 | init_vizier_params(rc, screen_area); | 3612 | init_vizier_params(twopass, screen_area); |
| 3600 | } | 3613 | } |
| 3601 | | 3614 | |
| 3602 | // If this is an arf frame then we dont want to read the stats file or | 3615 | // If this is an arf frame then we dont want to read the stats file or |
| @@ -3862,9 +3875,9 @@ void vp9_get_next_group_of_picture(const VP9_COMP *cpi, int *first_is_key_frame, · 259 unmodified lines |
| 3862 | | 3875 | |
| 3863 | *first_is_key_frame = 0; | 3876 | *first_is_key_frame = 0; |
| 3864 | if (rc.frames_to_key == 0) { | 3877 | if (rc.frames_to_key == 0) { |
| 3865 | rc.frames_to_key = vp9_get_frames_to_next_key( | 3878 | rc.frames_to_key = |
| 3866 | &cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info, | 3879 | vp9_get_frames_to_next_key(&cpi->oxcf, &cpi->frame_info, twopass, |
| 3867 | *first_show_idx, rc.min_gf_interval); | 3880 | *first_show_idx, rc.min_gf_interval); |
| 3868 | rc.frames_since_key = 0; | 3881 | rc.frames_since_key = 0; |
| 3869 | *first_is_key_frame = 1; | 3882 | *first_is_key_frame = 1; |
| 3870 | } | 3883 | } |
| @@ -3903,9 +3916,9 @@ int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf, · 32 unmodified lines |
| 3903 | gop_intra_factor = 1.0; | 3916 | gop_intra_factor = 1.0; |
| 3904 | } | 3917 | } |
| 3905 | | 3918 | |
| 3906 | frame_count = get_gop_coding_frame_num( | 3919 | frame_count = get_gop_coding_frame_num(use_alt_ref, frame_info, twopass, rc, |
| 3907 | use_alt_ref, frame_info, first_pass_info, rc, show_idx, | 3920 | show_idx, &active_gf_interval, |
| 3908 | &active_gf_interval, gop_intra_factor, oxcf->lag_in_frames); | 3921 | gop_intra_factor, oxcf->lag_in_frames); |
| 3909 | *use_alt_ref &= allow_alt_ref; | 3922 | *use_alt_ref &= allow_alt_ref; |
| 3910 | return frame_count; | 3923 | return frame_count; |
| 3911 | } | 3924 | } |
| @@ -3929,7 +3942,7 @@ int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, · 17 unmodified lines |
| 3929 | int first_is_key_frame = 0; | 3942 | int first_is_key_frame = 0; |
| 3930 | if (rc.frames_to_key == 0) { | 3943 | if (rc.frames_to_key == 0) { |
| 3931 | rc.frames_to_key = vp9_get_frames_to_next_key( | 3944 | rc.frames_to_key = vp9_get_frames_to_next_key( |
| 3932 | oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval); | 3945 | oxcf, frame_info, twopass, show_idx, rc.min_gf_interval); |
| 3933 | rc.frames_since_key = 0; | 3946 | rc.frames_since_key = 0; |
| 3934 | first_is_key_frame = 1; | 3947 | first_is_key_frame = 1; |
| 3935 | } | 3948 | } |
| @@ -3951,8 +3964,7 @@ int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, · 15 unmodified lines |
| 3951 | | 3964 | |
| 3952 | void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf, | 3965 | void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf, |
| 3953 | const FRAME_INFO *frame_info, | 3966 | const FRAME_INFO *frame_info, |
| 3954 | const FIRST_PASS_INFO *first_pass_info, | 3967 | const TWO_PASS *const twopass, int *key_frame_map) { |
| 3955 | int *key_frame_map) { | | |
| 3956 | int show_idx = 0; | 3968 | int show_idx = 0; |
| 3957 | RATE_CONTROL rc; | 3969 | RATE_CONTROL rc; |
| 3958 | vp9_rc_init(oxcf, 1, &rc); | 3970 | vp9_rc_init(oxcf, 1, &rc); |
| @@ -3966,7 +3978,7 @@ void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf, · 7 unmodified lines |
| 3966 | int key_frame_group_size; | 3978 | int key_frame_group_size; |
| 3967 | key_frame_map[show_idx] = 1; | 3979 | key_frame_map[show_idx] = 1; |
| 3968 | key_frame_group_size = vp9_get_frames_to_next_key( | 3980 | key_frame_group_size = vp9_get_frames_to_next_key( |
| 3969 | oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval); | 3981 | oxcf, frame_info, twopass, show_idx, rc.min_gf_interval); |
| 3970 | assert(key_frame_group_size > 0); | 3982 | assert(key_frame_group_size > 0); |
| 3971 | show_idx += key_frame_group_size; | 3983 | show_idx += key_frame_group_size; |
| 3972 | } | 3984 | } |