Commit 3cc5b92c authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Further code simplification and clean up.

Change-Id: Ifdb17b56090a317b2aa82cf125d57934902c5298
parent 583f2d8f
...@@ -53,7 +53,6 @@ extern "C" ...@@ -53,7 +53,6 @@ extern "C"
typedef enum typedef enum
{ {
MODE_REALTIME = 0x0,
MODE_GOODQUALITY = 0x1, MODE_GOODQUALITY = 0x1,
MODE_BESTQUALITY = 0x2, MODE_BESTQUALITY = 0x2,
MODE_FIRSTPASS = 0x3, MODE_FIRSTPASS = 0x3,
...@@ -175,10 +174,6 @@ extern "C" ...@@ -175,10 +174,6 @@ extern "C"
// these parameters aren't to be used in final build don't use!!! // these parameters aren't to be used in final build don't use!!!
int play_alternate; int play_alternate;
int alt_freq; int alt_freq;
int alt_q;
int key_q;
int gold_q;
int multi_threaded; // how many threads to run the encoder on int multi_threaded; // how many threads to run the encoder on
int token_partitions; // how many token partitions to create for multi core decoding int token_partitions; // how many token partitions to create for multi core decoding
......
...@@ -349,33 +349,8 @@ static int frame_max_bits(VP8_COMP *cpi) ...@@ -349,33 +349,8 @@ static int frame_max_bits(VP8_COMP *cpi)
// Max allocation for a single frame based on the max section guidelines passed in and how many bits are left // Max allocation for a single frame based on the max section guidelines passed in and how many bits are left
int max_bits; int max_bits;
// For CBR we need to also consider buffer fullness.
// If we are running below the optimal level then we need to gradually tighten up on max_bits.
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
double buffer_fullness_ratio = (double)cpi->buffer_level / DOUBLE_DIVIDE_CHECK((double)cpi->oxcf.optimal_buffer_level);
// For CBR base this on the target average bits per frame plus the maximum sedction rate passed in by the user
max_bits = (int)(cpi->av_per_frame_bandwidth * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0));
// If our buffer is below the optimum level
if (buffer_fullness_ratio < 1.0)
{
// The lower of max_bits / 4 or cpi->av_per_frame_bandwidth / 4.
int min_max_bits = ((cpi->av_per_frame_bandwidth >> 2) < (max_bits >> 2)) ? cpi->av_per_frame_bandwidth >> 2 : max_bits >> 2;
max_bits = (int)(max_bits * buffer_fullness_ratio);
if (max_bits < min_max_bits)
max_bits = min_max_bits; // Lowest value we will set ... which should allow the buffer to refil.
}
}
// VBR
else
{
// For VBR base this on the bits and frames left plus the two_pass_vbrmax_section rate passed in by the user // For VBR base this on the bits and frames left plus the two_pass_vbrmax_section rate passed in by the user
max_bits = (int)(((double)cpi->twopass.bits_left / (cpi->twopass.total_stats->count - (double)cpi->common.current_video_frame)) * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0)); max_bits = (int)(((double)cpi->twopass.bits_left / (cpi->twopass.total_stats->count - (double)cpi->common.current_video_frame)) * ((double)cpi->oxcf.two_pass_vbrmax_section / 100.0));
}
// Trap case where we are out of bits // Trap case where we are out of bits
if (max_bits < 0) if (max_bits < 0)
...@@ -1828,35 +1803,6 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -1828,35 +1803,6 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
cpi->twopass.gf_decay_rate = cpi->twopass.gf_decay_rate =
(i > 0) ? (int)(100.0 * (1.0 - decay_accumulator)) / i : 0; (i > 0) ? (int)(100.0 * (1.0 - decay_accumulator)) / i : 0;
// When using CBR apply additional buffer related upper limits
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
double max_boost;
// For cbr apply buffer related limits
if (cpi->drop_frames_allowed)
{
int df_buffer_level = cpi->oxcf.drop_frames_water_mark *
(cpi->oxcf.optimal_buffer_level / 100);
if (cpi->buffer_level > df_buffer_level)
max_boost = ((double)((cpi->buffer_level - df_buffer_level) * 2 / 3) * 16.0) / DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
else
max_boost = 0.0;
}
else if (cpi->buffer_level > 0)
{
max_boost = ((double)(cpi->buffer_level * 2 / 3) * 16.0) / DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
}
else
{
max_boost = 0.0;
}
if (boost_score > max_boost)
boost_score = max_boost;
}
// Dont allow conventional gf too near the next kf // Dont allow conventional gf too near the next kf
if ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL) if ((cpi->twopass.frames_to_key - i) < MIN_GF_INTERVAL)
{ {
...@@ -2175,13 +2121,6 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2175,13 +2121,6 @@ static void define_gf_group(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
} }
} }
// Apply an additional limit for CBR
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
if (cpi->twopass.gf_bits > (cpi->buffer_level >> 1))
cpi->twopass.gf_bits = cpi->buffer_level >> 1;
}
// Dont allow a negative value for gf_bits // Dont allow a negative value for gf_bits
if (gf_bits < 0) if (gf_bits < 0)
gf_bits = 0; gf_bits = 0;
...@@ -2839,51 +2778,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2839,51 +2778,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
max_grp_bits = (int64_t)max_bits * (int64_t)cpi->twopass.frames_to_key; max_grp_bits = (int64_t)max_bits * (int64_t)cpi->twopass.frames_to_key;
if (cpi->twopass.kf_group_bits > max_grp_bits) if (cpi->twopass.kf_group_bits > max_grp_bits)
cpi->twopass.kf_group_bits = max_grp_bits; cpi->twopass.kf_group_bits = max_grp_bits;
// Additional special case for CBR if buffer is getting full.
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
int opt_buffer_lvl = cpi->oxcf.optimal_buffer_level;
int buffer_lvl = cpi->buffer_level;
// If the buffer is near or above the optimal and this kf group is
// not being allocated much then increase the allocation a bit.
if (buffer_lvl >= opt_buffer_lvl)
{
int high_water_mark = (opt_buffer_lvl +
cpi->oxcf.maximum_buffer_size) >> 1;
int64_t av_group_bits;
// Av bits per frame * number of frames
av_group_bits = (int64_t)cpi->av_per_frame_bandwidth *
(int64_t)cpi->twopass.frames_to_key;
// We are at or above the maximum.
if (cpi->buffer_level >= high_water_mark)
{
int64_t min_group_bits;
min_group_bits = av_group_bits +
(int64_t)(buffer_lvl -
high_water_mark);
if (cpi->twopass.kf_group_bits < min_group_bits)
cpi->twopass.kf_group_bits = min_group_bits;
}
// We are above optimal but below the maximum
else if (cpi->twopass.kf_group_bits < av_group_bits)
{
int64_t bits_below_av = av_group_bits -
cpi->twopass.kf_group_bits;
cpi->twopass.kf_group_bits +=
(int64_t)((double)bits_below_av *
(double)(buffer_lvl - opt_buffer_lvl) /
(double)(high_water_mark - opt_buffer_lvl));
}
}
}
} }
else else
cpi->twopass.kf_group_bits = 0; cpi->twopass.kf_group_bits = 0;
...@@ -2963,33 +2857,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -2963,33 +2857,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
// cpi->twopass.section_max_qfactor = 1.0; // cpi->twopass.section_max_qfactor = 1.0;
} }
// When using CBR apply additional buffer fullness related upper limits
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
double max_boost;
if (cpi->drop_frames_allowed)
{
int df_buffer_level = cpi->oxcf.drop_frames_water_mark * (cpi->oxcf.optimal_buffer_level / 100);
if (cpi->buffer_level > df_buffer_level)
max_boost = ((double)((cpi->buffer_level - df_buffer_level) * 2 / 3) * 16.0) / DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
else
max_boost = 0.0;
}
else if (cpi->buffer_level > 0)
{
max_boost = ((double)(cpi->buffer_level * 2 / 3) * 16.0) / DOUBLE_DIVIDE_CHECK((double)cpi->av_per_frame_bandwidth);
}
else
{
max_boost = 0.0;
}
if (boost_score > max_boost)
boost_score = max_boost;
}
// Reset the first pass file position // Reset the first pass file position
reset_fpf_position(cpi, start_position); reset_fpf_position(cpi, start_position);
...@@ -3065,13 +2932,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -3065,13 +2932,6 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
// Calculate the number of bits to be spent on the key frame // Calculate the number of bits to be spent on the key frame
cpi->twopass.kf_bits = (int)((double)kf_boost * ((double)cpi->twopass.kf_group_bits / (double)allocation_chunks)); cpi->twopass.kf_bits = (int)((double)kf_boost * ((double)cpi->twopass.kf_group_bits / (double)allocation_chunks));
// Apply an additional limit for CBR
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
if (cpi->twopass.kf_bits > ((3 * cpi->buffer_level) >> 2))
cpi->twopass.kf_bits = (3 * cpi->buffer_level) >> 2;
}
// If the key frame is actually easier than the average for the // If the key frame is actually easier than the average for the
// kf group (which does sometimes happen... eg a blank intro frame) // kf group (which does sometimes happen... eg a blank intro frame)
// Then use an alternate calculation based on the kf error score // Then use an alternate calculation based on the kf error score
...@@ -3154,15 +3014,10 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -3154,15 +3014,10 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
//if ( av_bits_per_frame < 0.0 ) //if ( av_bits_per_frame < 0.0 )
// av_bits_per_frame = 0.0 // av_bits_per_frame = 0.0
// CBR... Use the clip average as the target for deciding resample
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
bits_per_frame = av_bits_per_frame;
}
// In VBR we want to avoid downsampling in easy section unless we are under extreme pressure // In VBR we want to avoid downsampling in easy section unless we are under extreme pressure
// So use the larger of target bitrate for this sectoion or average bitrate for sequence // So use the larger of target bitrate for this sectoion or average bitrate for sequence
else //else
// TBD deprecatae spatial resampling for experminetal
{ {
bits_per_frame = cpi->twopass.kf_group_bits / cpi->twopass.frames_to_key; // This accounts for how hard the section is... bits_per_frame = cpi->twopass.kf_group_bits / cpi->twopass.frames_to_key; // This accounts for how hard the section is...
...@@ -3197,20 +3052,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame) ...@@ -3197,20 +3052,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
fclose(f); fclose(f);
} }
// The trigger for spatial resampling depends on the various parameters such as whether we are streaming (CBR) or VBR. // The trigger for spatial resampling depends on the various parameters.
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
// Trigger resample if we are projected to fall below down sample level or
// resampled last time and are projected to remain below the up sample level
if ((projected_buffer_level < (cpi->oxcf.resample_down_water_mark * cpi->oxcf.optimal_buffer_level / 100)) ||
(last_kf_resampled && (projected_buffer_level < (cpi->oxcf.resample_up_water_mark * cpi->oxcf.optimal_buffer_level / 100))))
//( ((cpi->buffer_level < (cpi->oxcf.resample_down_water_mark * cpi->oxcf.optimal_buffer_level / 100))) &&
// ((projected_buffer_level < (cpi->oxcf.resample_up_water_mark * cpi->oxcf.optimal_buffer_level / 100))) ))
resample_trigger = TRUE;
else
resample_trigger = FALSE;
}
else
{ {
int64_t clip_bits = (int64_t)(cpi->twopass.total_stats->count * cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->oxcf.frame_rate)); int64_t clip_bits = (int64_t)(cpi->twopass.total_stats->count * cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->oxcf.frame_rate));
int64_t over_spend = cpi->oxcf.starting_buffer_level - cpi->buffer_level; int64_t over_spend = cpi->oxcf.starting_buffer_level - cpi->buffer_level;
......
...@@ -1231,8 +1231,6 @@ static void init_config(VP8_PTR ptr, VP8_CONFIG *oxcf) ...@@ -1231,8 +1231,6 @@ static void init_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
cpi->oxcf = *oxcf; cpi->oxcf = *oxcf;
cpi->auto_gold = 1;
cpi->auto_adjust_gold_quantizer = 1;
cpi->goldfreq = 7; cpi->goldfreq = 7;
cm->version = oxcf->Version; cm->version = oxcf->Version;
...@@ -1320,37 +1318,11 @@ void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf) ...@@ -1320,37 +1318,11 @@ void vp8_change_config(VP8_PTR ptr, VP8_CONFIG *oxcf)
break; break;
} }
cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q]; cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q];
cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q]; cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q];
cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level]; cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level];
if (oxcf->fixed_q >= 0) cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
{
if (oxcf->worst_allowed_q < 0)
cpi->oxcf.fixed_q = q_trans[0];
else
cpi->oxcf.fixed_q = q_trans[oxcf->worst_allowed_q];
if (oxcf->alt_q < 0)
cpi->oxcf.alt_q = q_trans[0];
else
cpi->oxcf.alt_q = q_trans[oxcf->alt_q];
if (oxcf->key_q < 0)
cpi->oxcf.key_q = q_trans[0];
else
cpi->oxcf.key_q = q_trans[oxcf->key_q];
if (oxcf->gold_q < 0)
cpi->oxcf.gold_q = q_trans[0];
else
cpi->oxcf.gold_q = q_trans[oxcf->gold_q];
}
cpi->baseline_gf_interval =
cpi->oxcf.alt_freq ? cpi->oxcf.alt_freq : DEFAULT_GF_INTERVAL;
cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG; cpi->ref_frame_flags = VP8_ALT_FLAG | VP8_GOLD_FLAG | VP8_LAST_FLAG;
...@@ -2434,10 +2406,6 @@ static void update_alt_ref_frame_stats(VP8_COMP *cpi) ...@@ -2434,10 +2406,6 @@ static void update_alt_ref_frame_stats(VP8_COMP *cpi)
{ {
VP8_COMMON *cm = &cpi->common; VP8_COMMON *cm = &cpi->common;
// Select an interval before next GF or altref
if (!cpi->auto_gold)
cpi->frames_till_gf_update_due = cpi->goldfreq;
// Update data structure that monitors level of reference to last GF // Update data structure that monitors level of reference to last GF
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols)); vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols; cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
...@@ -2460,10 +2428,6 @@ static void update_golden_frame_stats(VP8_COMP *cpi) ...@@ -2460,10 +2428,6 @@ static void update_golden_frame_stats(VP8_COMP *cpi)
// Update the Golden frame usage counts. // Update the Golden frame usage counts.
if (cm->refresh_golden_frame) if (cm->refresh_golden_frame)
{ {
// Select an interval before next GF
if (!cpi->auto_gold)
cpi->frames_till_gf_update_due = cpi->goldfreq;
// Update data structure that monitors level of reference to last GF // Update data structure that monitors level of reference to last GF
vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols)); vpx_memset(cpi->gf_active_flags, 1, (cm->mb_rows * cm->mb_cols));
cpi->gf_active_count = cm->mb_rows * cm->mb_cols; cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
...@@ -3110,37 +3074,6 @@ static void encode_frame_to_data_rate ...@@ -3110,37 +3074,6 @@ static void encode_frame_to_data_rate
return; return;
} }
// Reduce active_worst_allowed_q for CBR if our buffer is getting too full.
// This has a knock on effect on active best quality as well.
// For CBR if the buffer reaches its maximum level then we can no longer
// save up bits for later frames so we might as well use them up
// on the current frame.
if ((cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
(cpi->buffer_level >= cpi->oxcf.optimal_buffer_level) && cpi->buffered_mode)
{
int Adjustment = cpi->active_worst_quality / 4; // Max adjustment is 1/4
if (Adjustment)
{
int buff_lvl_step;
if (cpi->buffer_level < cpi->oxcf.maximum_buffer_size)
{
buff_lvl_step = (cpi->oxcf.maximum_buffer_size - cpi->oxcf.optimal_buffer_level) / Adjustment;
if (buff_lvl_step)
Adjustment = (cpi->buffer_level - cpi->oxcf.optimal_buffer_level) / buff_lvl_step;
else
Adjustment = 0;
}
cpi->active_worst_quality -= Adjustment;
if(cpi->active_worst_quality < cpi->active_best_quality)
cpi->active_worst_quality = cpi->active_best_quality;
}
}
vp8_clear_system_state(); vp8_clear_system_state();
// Set an active best quality and if necessary active worst quality // Set an active best quality and if necessary active worst quality
...@@ -3221,24 +3154,6 @@ static void encode_frame_to_data_rate ...@@ -3221,24 +3154,6 @@ static void encode_frame_to_data_rate
} }
} }
// If CBR and the buffer is as full then it is reasonable to allow
// higher quality on the frames to prevent bits just going to waste.
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
{
// Note that the use of >= here elliminates the risk of a devide
// by 0 error in the else if clause
if (cpi->buffer_level >= cpi->oxcf.maximum_buffer_size)
cpi->active_best_quality = cpi->best_quality;
else if (cpi->buffer_level > cpi->oxcf.optimal_buffer_level)
{
int Fraction = ((cpi->buffer_level - cpi->oxcf.optimal_buffer_level) * 128) / (cpi->oxcf.maximum_buffer_size - cpi->oxcf.optimal_buffer_level);
int min_qadjustment = ((cpi->active_best_quality - cpi->best_quality) * Fraction) / 128;
cpi->active_best_quality -= min_qadjustment;
}
}
// Clip the active best and worst quality values to limits // Clip the active best and worst quality values to limits
if (cpi->active_worst_quality > cpi->worst_quality) if (cpi->active_worst_quality > cpi->worst_quality)
cpi->active_worst_quality = cpi->worst_quality; cpi->active_worst_quality = cpi->worst_quality;
...@@ -3428,26 +3343,6 @@ static void encode_frame_to_data_rate ...@@ -3428,26 +3343,6 @@ static void encode_frame_to_data_rate
if (frame_over_shoot_limit == 0) if (frame_over_shoot_limit == 0)
frame_over_shoot_limit = 1; frame_over_shoot_limit = 1;
// Are we are overshooting and up against the limit of active max Q.
if ((cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
(Q == cpi->active_worst_quality) &&
(cpi->active_worst_quality < cpi->worst_quality) &&
(cpi->projected_frame_size > frame_over_shoot_limit))
{
int over_size_percent = ((cpi->projected_frame_size - frame_over_shoot_limit) * 100) / frame_over_shoot_limit;
// If so is there any scope for relaxing it
while ((cpi->active_worst_quality < cpi->worst_quality) && (over_size_percent > 0))
{
cpi->active_worst_quality++;
top_index = cpi->active_worst_quality;
over_size_percent = (int)(over_size_percent * 0.96); // Assume 1 qstep = about 4% on frame size.
}
// If we have updated the active max Q do not call vp8_update_rate_correction_factors() this loop.
active_worst_qchanged = TRUE;
}
else
active_worst_qchanged = FALSE; active_worst_qchanged = FALSE;
// Special case handling for forced key frames // Special case handling for forced key frames
...@@ -3804,19 +3699,6 @@ static void encode_frame_to_data_rate ...@@ -3804,19 +3699,6 @@ static void encode_frame_to_data_rate
cpi->ni_av_qi = (cpi->ni_tot_qi / cpi->ni_frames); cpi->ni_av_qi = (cpi->ni_tot_qi / cpi->ni_frames);
} }
#if 0
// If the frame was massively oversize and we are below optimal buffer level drop next frame
if ((cpi->drop_frames_allowed) &&
(cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
(cpi->buffer_level < cpi->oxcf.drop_frames_water_mark * cpi->oxcf.optimal_buffer_level / 100) &&
(cpi->projected_frame_size > (4 * cpi->this_frame_target)))
{
cpi->drop_frame = TRUE;
}
#endif
// Set the count for maximum consequative dropped frames based upon the ratio of // Set the count for maximum consequative dropped frames based upon the ratio of
// this frame size to the target average per frame bandwidth. // this frame size to the target average per frame bandwidth.
// (cpi->av_per_frame_bandwidth > 0) is just a sanity check to prevent / 0. // (cpi->av_per_frame_bandwidth > 0) is just a sanity check to prevent / 0.
......
...@@ -486,8 +486,6 @@ typedef struct VP8_COMP ...@@ -486,8 +486,6 @@ typedef struct VP8_COMP
int compressor_speed; int compressor_speed;
int interquantizer; int interquantizer;
int auto_gold;
int auto_adjust_gold_quantizer;
int goldfreq; int goldfreq;
int auto_worst_q; int auto_worst_q;
int cpu_used; int cpu_used;
......
...@@ -232,12 +232,8 @@ void vp8_setup_key_frame(VP8_COMP *cpi) ...@@ -232,12 +232,8 @@ void vp8_setup_key_frame(VP8_COMP *cpi)
//cpi->common.filter_level = 0; // Reset every key frame. //cpi->common.filter_level = 0; // Reset every key frame.
cpi->common.filter_level = cpi->common.base_qindex * 3 / 8 ; cpi->common.filter_level = cpi->common.base_qindex * 3 / 8 ;
// Provisional interval before next GF // interval before next GF
if (cpi->auto_gold)
//cpi->frames_till_gf_update_due = DEFAULT_GF_INTERVAL;
cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
else
cpi->frames_till_gf_update_due = cpi->goldfreq;
cpi->common.refresh_golden_frame = TRUE; cpi->common.refresh_golden_frame = TRUE;
cpi->common.refresh_alt_ref_frame = TRUE; cpi->common.refresh_alt_ref_frame = TRUE;
...@@ -308,18 +304,8 @@ static void calc_iframe_target_size(VP8_COMP *cpi) ...@@ -308,18 +304,8 @@ static void calc_iframe_target_size(VP8_COMP *cpi)
// Clear down mmx registers to allow floating point in what follows // Clear down mmx registers to allow floating point in what follows
vp8_clear_system_state(); //__asm emms; vp8_clear_system_state(); //__asm emms;
if (cpi->oxcf.fixed_q >= 0)
{
int Q = cpi->oxcf.key_q;
target = estimate_bits_at_q(INTRA_FRAME, Q, cpi->common.MBs,
cpi->key_frame_rate_correction_factor);
}
else
{
// New Two pass RC // New Two pass RC
target = cpi->per_frame_bandwidth; target = cpi->per_frame_bandwidth;
}
if (cpi->oxcf.rc_max_intra_bitrate_pct) if (cpi->oxcf.rc_max_intra_bitrate_pct)
{ {
...@@ -337,29 +323,11 @@ static void calc_iframe_target_size(VP8_COMP *cpi) ...@@ -337,29 +323,11 @@ static void calc_iframe_target_size(VP8_COMP *cpi)
// Do the best we can to define the parameteres for the next GF based // Do the best we can to define the parameteres for the next GF based
// on what information we have available. // on what information we have available.
// In this experimental code only two pass is supported. //
// In this experimental code only two pass is supported
// so we just use the interval determined in the two pass code.
static void calc_gf_params(VP8_COMP *cpi) static void calc_gf_params(VP8_COMP *cpi)
{ {
int Q = (cpi->oxcf.fixed_q < 0) ? cpi->last_q[INTER_FRAME] : cpi->oxcf.fixed_q;
int Boost = 0;
int gf_frame_useage = 0; // Golden frame useage since last GF
int tot_mbs = cpi->recent_ref_frame_usage[INTRA_FRAME] +
cpi->recent_ref_frame_usage[LAST_FRAME] +
cpi->recent_ref_frame_usage[GOLDEN_FRAME] +
cpi->recent_ref_frame_usage[ALTREF_FRAME];
int pct_gf_active = (100 * cpi->gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols);
// Reset the last boost indicator
//cpi->last_boost = 100;
if (tot_mbs)
gf_frame_useage = (cpi->recent_ref_frame_usage[GOLDEN_FRAME] + cpi->recent_ref_frame_usage[ALTREF_FRAME]) * 100 / tot_mbs;
if (pct_gf_active > gf_frame_useage)
gf_frame_useage = pct_gf_active;
// Set the gf interval // Set the gf interval
cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
} }
...@@ -404,82 +372,16 @@ static void calc_pframe_target_size(VP8_COMP *cpi) ...@@ -404,82 +372,16 @@ static void calc_pframe_target_size(VP8_COMP *cpi)
// Note the baseline target data rate for this inter frame. // Note the baseline target data rate for this inter frame.
cpi->inter_frame_target = cpi->this_frame_target; cpi->inter_frame_target = cpi->this_frame_target;