Commit 744f4823 authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Small boost to every other frame.

Instead of a single mid GF boost apply a few extra bits to
every other frame. This gives a very small average metrics
improvement on both derf and YT sets.

Also use min GF interval as min KF interval.

Change-Id: Iee238b8cae0ffaed850a5a944ac825cee18da485
parent 9cc16115
...@@ -862,8 +862,6 @@ static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_ ...@@ -862,8 +862,6 @@ static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_
double correction_factor; double correction_factor;
double corr_high; double corr_high;
double speed_correction = 1.0; double speed_correction = 1.0;
double rolling_ratio;
double pow_highq = 0.90; double pow_highq = 0.90;
double pow_lowq = 0.40; double pow_lowq = 0.40;
...@@ -873,8 +871,10 @@ static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_ ...@@ -873,8 +871,10 @@ static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_
target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20)) ? (512 * section_target_bandwitdh) / num_mbs : 512 * (section_target_bandwitdh / num_mbs); target_norm_bits_per_mb = (section_target_bandwitdh < (1 << 20)) ? (512 * section_target_bandwitdh) / num_mbs : 512 * (section_target_bandwitdh / num_mbs);
// Calculate a corrective factor based on a rolling ratio of bits spent vs target bits // Calculate a corrective factor based on a rolling ratio of bits spent vs target bits
if ((cpi->rolling_target_bits > 0.0) && (cpi->active_worst_quality < cpi->worst_quality)) if ((cpi->rolling_target_bits > 0) && (cpi->active_worst_quality < cpi->worst_quality))
{ {
double rolling_ratio;
rolling_ratio = (double)cpi->rolling_actual_bits / (double)cpi->rolling_target_bits; rolling_ratio = (double)cpi->rolling_actual_bits / (double)cpi->rolling_target_bits;
//if ( cpi->twopass.est_max_qcorrection_factor > rolling_ratio ) //if ( cpi->twopass.est_max_qcorrection_factor > rolling_ratio )
...@@ -2107,6 +2107,10 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2107,6 +2107,10 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
if (cpi->twopass.gf_group_bits < 0) if (cpi->twopass.gf_group_bits < 0)
cpi->twopass.gf_group_bits = 0; cpi->twopass.gf_group_bits = 0;
// This condition could fail if there are two kfs very close together
// despite (MIN_GF_INTERVAL) and would cause a devide by 0 in the
// calculation of cpi->twopass.alt_extra_bits.
if ( cpi->baseline_gf_interval >= 3 )
{ {
#if NEW_BOOST #if NEW_BOOST
int boost = (cpi->source_alt_ref_pending) int boost = (cpi->source_alt_ref_pending)
...@@ -2114,19 +2118,24 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2114,19 +2118,24 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
#else #else
int boost = cpi->gfu_boost; int boost = cpi->gfu_boost;
#endif #endif
// Set aside some bits for a mid gf sequence boost if ( boost >= 150 )
if ((boost > 150) && (cpi->baseline_gf_interval > 5))
{ {
int pct_extra = (boost - 100) / 50; int pct_extra;
pct_extra = (pct_extra > 10) ? 10 : pct_extra;
cpi->twopass.mid_gf_extra_bits = pct_extra = (boost - 100) / 50;
pct_extra = (pct_extra > 20) ? 20 : pct_extra;
cpi->twopass.alt_extra_bits =
(cpi->twopass.gf_group_bits * pct_extra) / 100; (cpi->twopass.gf_group_bits * pct_extra) / 100;
cpi->twopass.gf_group_bits -= cpi->twopass.mid_gf_extra_bits; cpi->twopass.gf_group_bits -= cpi->twopass.alt_extra_bits;
cpi->twopass.alt_extra_bits /=
((cpi->baseline_gf_interval-1)>>1);
} }
else else
cpi->twopass.mid_gf_extra_bits = 0; cpi->twopass.alt_extra_bits = 0;
} }
else
cpi->twopass.alt_extra_bits = 0;
} }
// Adjustment to estimate_max_q based on a measure of complexity of the section // Adjustment to estimate_max_q based on a measure of complexity of the section
...@@ -2206,9 +2215,12 @@ static void assign_std_frame_bits(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2206,9 +2215,12 @@ static void assign_std_frame_bits(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
target_frame_size += cpi->min_frame_bandwidth; // Add in the minimum number of bits that is set aside for every frame. target_frame_size += cpi->min_frame_bandwidth; // Add in the minimum number of bits that is set aside for every frame.
// Special case for the frame that lies half way between two gfs // Every other frame gets a few extra bits
if (cpi->common.frames_since_golden == cpi->baseline_gf_interval / 2) if ( (cpi->common.frames_since_golden & 0x01) &&
target_frame_size += cpi->twopass.mid_gf_extra_bits; (cpi->frames_till_gf_update_due > 0) )
{
target_frame_size += cpi->twopass.alt_extra_bits;
}
cpi->per_frame_bandwidth = target_frame_size; // Per frame bit target for this frame cpi->per_frame_bandwidth = target_frame_size; // Per frame bit target for this frame
} }
...@@ -2551,8 +2563,11 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2551,8 +2563,11 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
&& lookup_next_frame_stats(cpi, &next_frame) != EOF) && lookup_next_frame_stats(cpi, &next_frame) != EOF)
{ {
// Normal scene cut check // Normal scene cut check
if (test_candidate_kf(cpi, &last_frame, this_frame, &next_frame)) if ( ( i >= MIN_GF_INTERVAL ) &&
test_candidate_kf(cpi, &last_frame, this_frame, &next_frame) )
{
break; break;
}
// How fast is prediction quality decaying // How fast is prediction quality decaying
loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame); loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
......
...@@ -552,7 +552,7 @@ typedef struct VP8_COMP ...@@ -552,7 +552,7 @@ typedef struct VP8_COMP
int gf_group_bits; // Projected Bits available for a group of frames including 1 GF or ARF int gf_group_bits; // Projected Bits available for a group of frames including 1 GF or ARF
int gf_bits; // Bits for the golden frame or ARF - 2 pass only int gf_bits; // Bits for the golden frame or ARF - 2 pass only
int mid_gf_extra_bits; // A few extra bits for the frame half way between two gfs. int alt_extra_bits;
double est_max_qcorrection_factor; double est_max_qcorrection_factor;
} twopass; } twopass;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment