use consistent framerate naming
s/frame_rate/framerate/g Change-Id: I6fc3e088e419c5f46e3a9390dd8a2cad2677a2fc
This commit is contained in:
parent
c0562d08f6
commit
9581eb6e8a
@ -923,7 +923,7 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t
|
|||||||
if (flags & VP8D_DEBUG_TXT_RATE_INFO)
|
if (flags & VP8D_DEBUG_TXT_RATE_INFO)
|
||||||
{
|
{
|
||||||
char message[512];
|
char message[512];
|
||||||
sprintf(message, "Bitrate: %10.2f frame_rate: %10.2f ", oci->bitrate, oci->framerate);
|
sprintf(message, "Bitrate: %10.2f framerate: %10.2f ", oci->bitrate, oci->framerate);
|
||||||
vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
|
vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1325,7 +1325,7 @@ static int estimate_kf_group_q(VP8_COMP *cpi, double section_err, int section_ta
|
|||||||
return Q;
|
return Q;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void vp8_new_frame_rate(VP8_COMP *cpi, double framerate);
|
extern void vp8_new_framerate(VP8_COMP *cpi, double framerate);
|
||||||
|
|
||||||
void vp8_init_second_pass(VP8_COMP *cpi)
|
void vp8_init_second_pass(VP8_COMP *cpi)
|
||||||
{
|
{
|
||||||
@ -1349,9 +1349,9 @@ void vp8_init_second_pass(VP8_COMP *cpi)
|
|||||||
* sum duration is not. Its calculated based on the actual durations of
|
* sum duration is not. Its calculated based on the actual durations of
|
||||||
* all frames from the first pass.
|
* all frames from the first pass.
|
||||||
*/
|
*/
|
||||||
vp8_new_frame_rate(cpi, 10000000.0 * cpi->twopass.total_stats.count / cpi->twopass.total_stats.duration);
|
vp8_new_framerate(cpi, 10000000.0 * cpi->twopass.total_stats.count / cpi->twopass.total_stats.duration);
|
||||||
|
|
||||||
cpi->output_frame_rate = cpi->frame_rate;
|
cpi->output_framerate = cpi->framerate;
|
||||||
cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats.duration * cpi->oxcf.target_bandwidth / 10000000.0) ;
|
cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats.duration * cpi->oxcf.target_bandwidth / 10000000.0) ;
|
||||||
cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats.duration * two_pass_min_rate / 10000000.0);
|
cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats.duration * two_pass_min_rate / 10000000.0);
|
||||||
|
|
||||||
@ -2529,7 +2529,7 @@ void vp8_second_pass(VP8_COMP *cpi)
|
|||||||
|
|
||||||
/* Set nominal per second bandwidth for this frame */
|
/* Set nominal per second bandwidth for this frame */
|
||||||
cpi->target_bandwidth = (int)
|
cpi->target_bandwidth = (int)
|
||||||
(cpi->per_frame_bandwidth * cpi->output_frame_rate);
|
(cpi->per_frame_bandwidth * cpi->output_framerate);
|
||||||
if (cpi->target_bandwidth < 0)
|
if (cpi->target_bandwidth < 0)
|
||||||
cpi->target_bandwidth = 0;
|
cpi->target_bandwidth = 0;
|
||||||
|
|
||||||
@ -3185,7 +3185,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
|
|||||||
|
|
||||||
/* Convert to a per second bitrate */
|
/* Convert to a per second bitrate */
|
||||||
cpi->target_bandwidth = (int)(cpi->twopass.kf_bits *
|
cpi->target_bandwidth = (int)(cpi->twopass.kf_bits *
|
||||||
cpi->output_frame_rate);
|
cpi->output_framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note the total error score of the kf group minus the key frame itself */
|
/* Note the total error score of the kf group minus the key frame itself */
|
||||||
@ -3224,7 +3224,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
|
|||||||
cpi->common.vert_scale = NORMAL;
|
cpi->common.vert_scale = NORMAL;
|
||||||
|
|
||||||
/* Calculate Average bits per frame. */
|
/* Calculate Average bits per frame. */
|
||||||
av_bits_per_frame = cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->frame_rate);
|
av_bits_per_frame = cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->framerate);
|
||||||
|
|
||||||
/* CBR... Use the clip average as the target for deciding resample */
|
/* CBR... Use the clip average as the target for deciding resample */
|
||||||
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
|
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER)
|
||||||
@ -3299,7 +3299,7 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int64_t clip_bits = (int64_t)(cpi->twopass.total_stats.count * cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->frame_rate));
|
int64_t clip_bits = (int64_t)(cpi->twopass.total_stats.count * cpi->oxcf.target_bandwidth / DOUBLE_DIVIDE_CHECK((double)cpi->framerate));
|
||||||
int64_t over_spend = cpi->oxcf.starting_buffer_level - cpi->buffer_level;
|
int64_t over_spend = cpi->oxcf.starting_buffer_level - cpi->buffer_level;
|
||||||
|
|
||||||
/* If triggered last time the threshold for triggering again is
|
/* If triggered last time the threshold for triggering again is
|
||||||
|
@ -301,11 +301,11 @@ static int rescale(int val, int num, int denom)
|
|||||||
static void init_temporal_layer_context(VP8_COMP *cpi,
|
static void init_temporal_layer_context(VP8_COMP *cpi,
|
||||||
VP8_CONFIG *oxcf,
|
VP8_CONFIG *oxcf,
|
||||||
const int layer,
|
const int layer,
|
||||||
double prev_layer_frame_rate)
|
double prev_layer_framerate)
|
||||||
{
|
{
|
||||||
LAYER_CONTEXT *lc = &cpi->layer_context[layer];
|
LAYER_CONTEXT *lc = &cpi->layer_context[layer];
|
||||||
|
|
||||||
lc->frame_rate = cpi->output_frame_rate / cpi->oxcf.rate_decimator[layer];
|
lc->framerate = cpi->output_framerate / cpi->oxcf.rate_decimator[layer];
|
||||||
lc->target_bandwidth = cpi->oxcf.target_bitrate[layer] * 1000;
|
lc->target_bandwidth = cpi->oxcf.target_bitrate[layer] * 1000;
|
||||||
|
|
||||||
lc->starting_buffer_level_in_ms = oxcf->starting_buffer_level;
|
lc->starting_buffer_level_in_ms = oxcf->starting_buffer_level;
|
||||||
@ -335,7 +335,7 @@ static void init_temporal_layer_context(VP8_COMP *cpi,
|
|||||||
lc->avg_frame_size_for_layer =
|
lc->avg_frame_size_for_layer =
|
||||||
(int)((cpi->oxcf.target_bitrate[layer] -
|
(int)((cpi->oxcf.target_bitrate[layer] -
|
||||||
cpi->oxcf.target_bitrate[layer-1]) * 1000 /
|
cpi->oxcf.target_bitrate[layer-1]) * 1000 /
|
||||||
(lc->frame_rate - prev_layer_frame_rate));
|
(lc->framerate - prev_layer_framerate));
|
||||||
|
|
||||||
lc->active_worst_quality = cpi->oxcf.worst_allowed_q;
|
lc->active_worst_quality = cpi->oxcf.worst_allowed_q;
|
||||||
lc->active_best_quality = cpi->oxcf.best_allowed_q;
|
lc->active_best_quality = cpi->oxcf.best_allowed_q;
|
||||||
@ -363,7 +363,7 @@ static void reset_temporal_layer_change(VP8_COMP *cpi,
|
|||||||
const int prev_num_layers)
|
const int prev_num_layers)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double prev_layer_frame_rate = 0;
|
double prev_layer_framerate = 0;
|
||||||
const int curr_num_layers = cpi->oxcf.number_of_layers;
|
const int curr_num_layers = cpi->oxcf.number_of_layers;
|
||||||
// If the previous state was 1 layer, get current layer context from cpi.
|
// If the previous state was 1 layer, get current layer context from cpi.
|
||||||
// We need this to set the layer context for the new layers below.
|
// We need this to set the layer context for the new layers below.
|
||||||
@ -377,7 +377,7 @@ static void reset_temporal_layer_change(VP8_COMP *cpi,
|
|||||||
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
||||||
if (i >= prev_num_layers)
|
if (i >= prev_num_layers)
|
||||||
{
|
{
|
||||||
init_temporal_layer_context(cpi, oxcf, i, prev_layer_frame_rate);
|
init_temporal_layer_context(cpi, oxcf, i, prev_layer_framerate);
|
||||||
}
|
}
|
||||||
// The initial buffer levels are set based on their starting levels.
|
// The initial buffer levels are set based on their starting levels.
|
||||||
// We could set the buffer levels based on the previous state (normalized
|
// We could set the buffer levels based on the previous state (normalized
|
||||||
@ -403,8 +403,8 @@ static void reset_temporal_layer_change(VP8_COMP *cpi,
|
|||||||
lc->bits_off_target = lc->buffer_level;
|
lc->bits_off_target = lc->buffer_level;
|
||||||
restore_layer_context(cpi, 0);
|
restore_layer_context(cpi, 0);
|
||||||
}
|
}
|
||||||
prev_layer_frame_rate = cpi->output_frame_rate /
|
prev_layer_framerate = cpi->output_framerate /
|
||||||
cpi->oxcf.rate_decimator[i];
|
cpi->oxcf.rate_decimator[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1282,21 +1282,21 @@ int vp8_reverse_trans(int x)
|
|||||||
|
|
||||||
return 63;
|
return 63;
|
||||||
}
|
}
|
||||||
void vp8_new_frame_rate(VP8_COMP *cpi, double framerate)
|
void vp8_new_framerate(VP8_COMP *cpi, double framerate)
|
||||||
{
|
{
|
||||||
if(framerate < .1)
|
if(framerate < .1)
|
||||||
framerate = 30;
|
framerate = 30;
|
||||||
|
|
||||||
cpi->frame_rate = framerate;
|
cpi->framerate = framerate;
|
||||||
cpi->output_frame_rate = framerate;
|
cpi->output_framerate = framerate;
|
||||||
cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth /
|
cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth /
|
||||||
cpi->output_frame_rate);
|
cpi->output_framerate);
|
||||||
cpi->av_per_frame_bandwidth = cpi->per_frame_bandwidth;
|
cpi->av_per_frame_bandwidth = cpi->per_frame_bandwidth;
|
||||||
cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth *
|
cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth *
|
||||||
cpi->oxcf.two_pass_vbrmin_section / 100);
|
cpi->oxcf.two_pass_vbrmin_section / 100);
|
||||||
|
|
||||||
/* Set Maximum gf/arf interval */
|
/* Set Maximum gf/arf interval */
|
||||||
cpi->max_gf_interval = ((int)(cpi->output_frame_rate / 2.0) + 2);
|
cpi->max_gf_interval = ((int)(cpi->output_framerate / 2.0) + 2);
|
||||||
|
|
||||||
if(cpi->max_gf_interval < 12)
|
if(cpi->max_gf_interval < 12)
|
||||||
cpi->max_gf_interval = 12;
|
cpi->max_gf_interval = 12;
|
||||||
@ -1337,13 +1337,13 @@ static void init_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
|
|||||||
* seems like a reasonable framerate, then use that as a guess, otherwise
|
* seems like a reasonable framerate, then use that as a guess, otherwise
|
||||||
* use 30.
|
* use 30.
|
||||||
*/
|
*/
|
||||||
cpi->frame_rate = (double)(oxcf->timebase.den) /
|
cpi->framerate = (double)(oxcf->timebase.den) /
|
||||||
(double)(oxcf->timebase.num);
|
(double)(oxcf->timebase.num);
|
||||||
|
|
||||||
if (cpi->frame_rate > 180)
|
if (cpi->framerate > 180)
|
||||||
cpi->frame_rate = 30;
|
cpi->framerate = 30;
|
||||||
|
|
||||||
cpi->ref_frame_rate = cpi->frame_rate;
|
cpi->ref_framerate = cpi->framerate;
|
||||||
|
|
||||||
/* change includes all joint functionality */
|
/* change includes all joint functionality */
|
||||||
vp8_change_config(cpi, oxcf);
|
vp8_change_config(cpi, oxcf);
|
||||||
@ -1369,13 +1369,13 @@ static void init_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
|
|||||||
if (cpi->oxcf.number_of_layers > 1)
|
if (cpi->oxcf.number_of_layers > 1)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
double prev_layer_frame_rate=0;
|
double prev_layer_framerate=0;
|
||||||
|
|
||||||
for (i=0; i<cpi->oxcf.number_of_layers; i++)
|
for (i=0; i<cpi->oxcf.number_of_layers; i++)
|
||||||
{
|
{
|
||||||
init_temporal_layer_context(cpi, oxcf, i, prev_layer_frame_rate);
|
init_temporal_layer_context(cpi, oxcf, i, prev_layer_framerate);
|
||||||
prev_layer_frame_rate = cpi->output_frame_rate /
|
prev_layer_framerate = cpi->output_framerate /
|
||||||
cpi->oxcf.rate_decimator[i];
|
cpi->oxcf.rate_decimator[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1399,14 +1399,14 @@ static void update_layer_contexts (VP8_COMP *cpi)
|
|||||||
if (oxcf->number_of_layers > 1)
|
if (oxcf->number_of_layers > 1)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
double prev_layer_frame_rate=0;
|
double prev_layer_framerate=0;
|
||||||
|
|
||||||
for (i=0; i<oxcf->number_of_layers; i++)
|
for (i=0; i<oxcf->number_of_layers; i++)
|
||||||
{
|
{
|
||||||
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
||||||
|
|
||||||
lc->frame_rate =
|
lc->framerate =
|
||||||
cpi->ref_frame_rate / oxcf->rate_decimator[i];
|
cpi->ref_framerate / oxcf->rate_decimator[i];
|
||||||
lc->target_bandwidth = oxcf->target_bitrate[i] * 1000;
|
lc->target_bandwidth = oxcf->target_bitrate[i] * 1000;
|
||||||
|
|
||||||
lc->starting_buffer_level = rescale(
|
lc->starting_buffer_level = rescale(
|
||||||
@ -1432,9 +1432,9 @@ static void update_layer_contexts (VP8_COMP *cpi)
|
|||||||
lc->avg_frame_size_for_layer =
|
lc->avg_frame_size_for_layer =
|
||||||
(int)((oxcf->target_bitrate[i] -
|
(int)((oxcf->target_bitrate[i] -
|
||||||
oxcf->target_bitrate[i-1]) * 1000 /
|
oxcf->target_bitrate[i-1]) * 1000 /
|
||||||
(lc->frame_rate - prev_layer_frame_rate));
|
(lc->framerate - prev_layer_framerate));
|
||||||
|
|
||||||
prev_layer_frame_rate = lc->frame_rate;
|
prev_layer_framerate = lc->framerate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1625,7 +1625,7 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
|
|||||||
cpi->oxcf.target_bandwidth, 1000);
|
cpi->oxcf.target_bandwidth, 1000);
|
||||||
|
|
||||||
/* Set up frame rate and related parameters rate control values. */
|
/* Set up frame rate and related parameters rate control values. */
|
||||||
vp8_new_frame_rate(cpi, cpi->frame_rate);
|
vp8_new_framerate(cpi, cpi->framerate);
|
||||||
|
|
||||||
/* Set absolute upper and lower quality limits */
|
/* Set absolute upper and lower quality limits */
|
||||||
cpi->worst_quality = cpi->oxcf.worst_allowed_q;
|
cpi->worst_quality = cpi->oxcf.worst_allowed_q;
|
||||||
@ -1945,7 +1945,7 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
|
|||||||
|
|
||||||
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
|
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
|
||||||
{
|
{
|
||||||
cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate;
|
cpi->prior_key_frame_distance[i] = (int)cpi->output_framerate;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OUTPUT_YUV_SRC
|
#ifdef OUTPUT_YUV_SRC
|
||||||
@ -2273,7 +2273,7 @@ void vp8_remove_compressor(VP8_COMP **ptr)
|
|||||||
{
|
{
|
||||||
extern int count_mb_seg[4];
|
extern int count_mb_seg[4];
|
||||||
FILE *f = fopen("modes.stt", "a");
|
FILE *f = fopen("modes.stt", "a");
|
||||||
double dr = (double)cpi->frame_rate * (double)bytes * (double)8 / (double)count / (double)1000 ;
|
double dr = (double)cpi->framerate * (double)bytes * (double)8 / (double)count / (double)1000 ;
|
||||||
fprintf(f, "intra_mode in Intra Frames:\n");
|
fprintf(f, "intra_mode in Intra Frames:\n");
|
||||||
fprintf(f, "Y: %8d, %8d, %8d, %8d, %8d\n", y_modes[0], y_modes[1], y_modes[2], y_modes[3], y_modes[4]);
|
fprintf(f, "Y: %8d, %8d, %8d, %8d, %8d\n", y_modes[0], y_modes[1], y_modes[2], y_modes[3], y_modes[4]);
|
||||||
fprintf(f, "UV:%8d, %8d, %8d, %8d\n", uv_modes[0], uv_modes[1], uv_modes[2], uv_modes[3]);
|
fprintf(f, "UV:%8d, %8d, %8d, %8d\n", uv_modes[0], uv_modes[1], uv_modes[2], uv_modes[3]);
|
||||||
@ -3368,12 +3368,12 @@ static void encode_frame_to_data_rate
|
|||||||
cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
|
cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
|
||||||
/* per second target bitrate */
|
/* per second target bitrate */
|
||||||
cpi->target_bandwidth = (int)(cpi->twopass.gf_bits *
|
cpi->target_bandwidth = (int)(cpi->twopass.gf_bits *
|
||||||
cpi->output_frame_rate);
|
cpi->output_framerate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
cpi->per_frame_bandwidth = (int)(cpi->target_bandwidth / cpi->output_frame_rate);
|
cpi->per_frame_bandwidth = (int)(cpi->target_bandwidth / cpi->output_framerate);
|
||||||
|
|
||||||
/* Default turn off buffer to buffer copying */
|
/* Default turn off buffer to buffer copying */
|
||||||
cm->copy_buffer_to_gf = 0;
|
cm->copy_buffer_to_gf = 0;
|
||||||
@ -4557,7 +4557,7 @@ static void encode_frame_to_data_rate
|
|||||||
{
|
{
|
||||||
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
||||||
int bits_off_for_this_layer =
|
int bits_off_for_this_layer =
|
||||||
(int)(lc->target_bandwidth / lc->frame_rate -
|
(int)(lc->target_bandwidth / lc->framerate -
|
||||||
cpi->projected_frame_size);
|
cpi->projected_frame_size);
|
||||||
|
|
||||||
lc->bits_off_target += bits_off_for_this_layer;
|
lc->bits_off_target += bits_off_for_this_layer;
|
||||||
@ -4805,7 +4805,7 @@ static void Pass2Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest,
|
|||||||
{
|
{
|
||||||
double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
|
double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
|
||||||
*cpi->oxcf.two_pass_vbrmin_section / 100);
|
*cpi->oxcf.two_pass_vbrmin_section / 100);
|
||||||
cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->frame_rate);
|
cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->framerate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -5039,7 +5039,7 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
|
|||||||
if (this_duration)
|
if (this_duration)
|
||||||
{
|
{
|
||||||
if (step)
|
if (step)
|
||||||
cpi->ref_frame_rate = 10000000.0 / this_duration;
|
cpi->ref_framerate = 10000000.0 / this_duration;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double avg_duration, interval;
|
double avg_duration, interval;
|
||||||
@ -5053,11 +5053,11 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
|
|||||||
if(interval > 10000000.0)
|
if(interval > 10000000.0)
|
||||||
interval = 10000000;
|
interval = 10000000;
|
||||||
|
|
||||||
avg_duration = 10000000.0 / cpi->ref_frame_rate;
|
avg_duration = 10000000.0 / cpi->ref_framerate;
|
||||||
avg_duration *= (interval - avg_duration + this_duration);
|
avg_duration *= (interval - avg_duration + this_duration);
|
||||||
avg_duration /= interval;
|
avg_duration /= interval;
|
||||||
|
|
||||||
cpi->ref_frame_rate = 10000000.0 / avg_duration;
|
cpi->ref_framerate = 10000000.0 / avg_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpi->oxcf.number_of_layers > 1)
|
if (cpi->oxcf.number_of_layers > 1)
|
||||||
@ -5068,12 +5068,12 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
|
|||||||
for (i=0; i<cpi->oxcf.number_of_layers; i++)
|
for (i=0; i<cpi->oxcf.number_of_layers; i++)
|
||||||
{
|
{
|
||||||
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
LAYER_CONTEXT *lc = &cpi->layer_context[i];
|
||||||
lc->frame_rate = cpi->ref_frame_rate /
|
lc->framerate = cpi->ref_framerate /
|
||||||
cpi->oxcf.rate_decimator[i];
|
cpi->oxcf.rate_decimator[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
vp8_new_frame_rate(cpi, cpi->ref_frame_rate);
|
vp8_new_framerate(cpi, cpi->ref_framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
cpi->last_time_stamp_seen = cpi->source->ts_start;
|
cpi->last_time_stamp_seen = cpi->source->ts_start;
|
||||||
@ -5090,7 +5090,7 @@ int vp8_get_compressed_data(VP8_COMP *cpi, unsigned int *frame_flags, unsigned l
|
|||||||
layer = cpi->oxcf.layer_id[
|
layer = cpi->oxcf.layer_id[
|
||||||
cpi->temporal_pattern_counter % cpi->oxcf.periodicity];
|
cpi->temporal_pattern_counter % cpi->oxcf.periodicity];
|
||||||
restore_layer_context (cpi, layer);
|
restore_layer_context (cpi, layer);
|
||||||
vp8_new_frame_rate (cpi, cpi->layer_context[layer].frame_rate);
|
vp8_new_framerate(cpi, cpi->layer_context[layer].framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpi->compressor_speed == 2)
|
if (cpi->compressor_speed == 2)
|
||||||
|
@ -232,7 +232,7 @@ enum
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
/* Layer configuration */
|
/* Layer configuration */
|
||||||
double frame_rate;
|
double framerate;
|
||||||
int target_bandwidth;
|
int target_bandwidth;
|
||||||
|
|
||||||
/* Layer specific coding parameters */
|
/* Layer specific coding parameters */
|
||||||
@ -401,7 +401,7 @@ typedef struct VP8_COMP
|
|||||||
/* Minimum allocation that should be used for any frame */
|
/* Minimum allocation that should be used for any frame */
|
||||||
int min_frame_bandwidth;
|
int min_frame_bandwidth;
|
||||||
int inter_frame_target;
|
int inter_frame_target;
|
||||||
double output_frame_rate;
|
double output_framerate;
|
||||||
int64_t last_time_stamp_seen;
|
int64_t last_time_stamp_seen;
|
||||||
int64_t last_end_time_stamp_seen;
|
int64_t last_end_time_stamp_seen;
|
||||||
int64_t first_time_stamp_ever;
|
int64_t first_time_stamp_ever;
|
||||||
@ -415,8 +415,8 @@ typedef struct VP8_COMP
|
|||||||
|
|
||||||
int buffered_mode;
|
int buffered_mode;
|
||||||
|
|
||||||
double frame_rate;
|
double framerate;
|
||||||
double ref_frame_rate;
|
double ref_framerate;
|
||||||
int64_t buffer_level;
|
int64_t buffer_level;
|
||||||
int64_t bits_off_target;
|
int64_t bits_off_target;
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ static void calc_iframe_target_size(VP8_COMP *cpi)
|
|||||||
int initial_boost = 32; /* |3.0 * per_frame_bandwidth| */
|
int initial_boost = 32; /* |3.0 * per_frame_bandwidth| */
|
||||||
/* Boost depends somewhat on frame rate: only used for 1 layer case. */
|
/* Boost depends somewhat on frame rate: only used for 1 layer case. */
|
||||||
if (cpi->oxcf.number_of_layers == 1) {
|
if (cpi->oxcf.number_of_layers == 1) {
|
||||||
kf_boost = MAX(initial_boost, (int)(2 * cpi->output_frame_rate - 16));
|
kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Initial factor: set target size to: |3.0 * per_frame_bandwidth|. */
|
/* Initial factor: set target size to: |3.0 * per_frame_bandwidth|. */
|
||||||
@ -399,9 +399,9 @@ static void calc_iframe_target_size(VP8_COMP *cpi)
|
|||||||
kf_boost = kf_boost * kf_boost_qadjustment[Q] / 100;
|
kf_boost = kf_boost * kf_boost_qadjustment[Q] / 100;
|
||||||
|
|
||||||
/* frame separation adjustment ( down) */
|
/* frame separation adjustment ( down) */
|
||||||
if (cpi->frames_since_key < cpi->output_frame_rate / 2)
|
if (cpi->frames_since_key < cpi->output_framerate / 2)
|
||||||
kf_boost = (int)(kf_boost
|
kf_boost = (int)(kf_boost
|
||||||
* cpi->frames_since_key / (cpi->output_frame_rate / 2));
|
* cpi->frames_since_key / (cpi->output_framerate / 2));
|
||||||
|
|
||||||
/* Minimal target size is |2* per_frame_bandwidth|. */
|
/* Minimal target size is |2* per_frame_bandwidth|. */
|
||||||
if (kf_boost < 16)
|
if (kf_boost < 16)
|
||||||
@ -1360,7 +1360,7 @@ static int estimate_keyframe_frequency(VP8_COMP *cpi)
|
|||||||
* whichever is smaller.
|
* whichever is smaller.
|
||||||
*/
|
*/
|
||||||
int key_freq = cpi->oxcf.key_freq>0 ? cpi->oxcf.key_freq : 1;
|
int key_freq = cpi->oxcf.key_freq>0 ? cpi->oxcf.key_freq : 1;
|
||||||
av_key_frame_frequency = 1 + (int)cpi->output_frame_rate * 2;
|
av_key_frame_frequency = 1 + (int)cpi->output_framerate * 2;
|
||||||
|
|
||||||
if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
|
if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
|
||||||
av_key_frame_frequency = key_freq;
|
av_key_frame_frequency = key_freq;
|
||||||
|
@ -341,7 +341,7 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, MACROBLOCK *x, int Qvalue)
|
|||||||
|
|
||||||
void vp8_auto_select_speed(VP8_COMP *cpi)
|
void vp8_auto_select_speed(VP8_COMP *cpi)
|
||||||
{
|
{
|
||||||
int milliseconds_for_compress = (int)(1000000 / cpi->frame_rate);
|
int milliseconds_for_compress = (int)(1000000 / cpi->framerate);
|
||||||
|
|
||||||
milliseconds_for_compress = milliseconds_for_compress * (16 - cpi->oxcf.cpu_used) / 16;
|
milliseconds_for_compress = milliseconds_for_compress * (16 - cpi->oxcf.cpu_used) / 16;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ extern "C"
|
|||||||
// 3 - lowest quality/fastest decode
|
// 3 - lowest quality/fastest decode
|
||||||
int width; // width of data passed to the compressor
|
int width; // width of data passed to the compressor
|
||||||
int height; // height of data passed to the compressor
|
int height; // height of data passed to the compressor
|
||||||
double frame_rate; // set to passed in framerate
|
double framerate; // set to passed in framerate
|
||||||
int64_t target_bandwidth; // bandwidth to be used in kilobits per second
|
int64_t target_bandwidth; // bandwidth to be used in kilobits per second
|
||||||
|
|
||||||
int noise_sensitivity; // parameter used for applying pre processing blur: recommendation 0
|
int noise_sensitivity; // parameter used for applying pre processing blur: recommendation 0
|
||||||
|
@ -758,7 +758,7 @@ int vp9_post_proc_frame(VP9_COMMON *oci, YV12_BUFFER_CONFIG *dest,
|
|||||||
if (flags & VP9D_DEBUG_TXT_RATE_INFO) {
|
if (flags & VP9D_DEBUG_TXT_RATE_INFO) {
|
||||||
char message[512];
|
char message[512];
|
||||||
snprintf(message, sizeof(message),
|
snprintf(message, sizeof(message),
|
||||||
"Bitrate: %10.2f frame_rate: %10.2f ",
|
"Bitrate: %10.2f framerate: %10.2f ",
|
||||||
oci->bitrate, oci->framerate);
|
oci->bitrate, oci->framerate);
|
||||||
vp9_blit_text(message, oci->post_proc_buffer.y_buffer,
|
vp9_blit_text(message, oci->post_proc_buffer.y_buffer,
|
||||||
oci->post_proc_buffer.y_stride);
|
oci->post_proc_buffer.y_stride);
|
||||||
|
@ -1093,13 +1093,13 @@ static int estimate_cq(VP9_COMP *cpi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern void vp9_new_frame_rate(VP9_COMP *cpi, double framerate);
|
extern void vp9_new_framerate(VP9_COMP *cpi, double framerate);
|
||||||
|
|
||||||
void vp9_init_second_pass(VP9_COMP *cpi) {
|
void vp9_init_second_pass(VP9_COMP *cpi) {
|
||||||
FIRSTPASS_STATS this_frame;
|
FIRSTPASS_STATS this_frame;
|
||||||
FIRSTPASS_STATS *start_pos;
|
FIRSTPASS_STATS *start_pos;
|
||||||
|
|
||||||
double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.frame_rate;
|
double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.framerate;
|
||||||
double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
|
double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
|
||||||
* cpi->oxcf.two_pass_vbrmin_section / 100);
|
* cpi->oxcf.two_pass_vbrmin_section / 100);
|
||||||
|
|
||||||
@ -1120,10 +1120,10 @@ void vp9_init_second_pass(VP9_COMP *cpi) {
|
|||||||
// encoded in the second pass is a guess. However the sum duration is not.
|
// encoded in the second pass is a guess. However the sum duration is not.
|
||||||
// Its calculated based on the actual durations of all frames from the first
|
// Its calculated based on the actual durations of all frames from the first
|
||||||
// pass.
|
// pass.
|
||||||
vp9_new_frame_rate(cpi, 10000000.0 * cpi->twopass.total_stats.count /
|
vp9_new_framerate(cpi, 10000000.0 * cpi->twopass.total_stats.count /
|
||||||
cpi->twopass.total_stats.duration);
|
cpi->twopass.total_stats.duration);
|
||||||
|
|
||||||
cpi->output_frame_rate = cpi->oxcf.frame_rate;
|
cpi->output_framerate = cpi->oxcf.framerate;
|
||||||
cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats.duration *
|
cpi->twopass.bits_left = (int64_t)(cpi->twopass.total_stats.duration *
|
||||||
cpi->oxcf.target_bandwidth / 10000000.0);
|
cpi->oxcf.target_bandwidth / 10000000.0);
|
||||||
cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats.duration *
|
cpi->twopass.bits_left -= (int64_t)(cpi->twopass.total_stats.duration *
|
||||||
@ -2203,7 +2203,7 @@ void vp9_second_pass(VP9_COMP *cpi) {
|
|||||||
|
|
||||||
// Set nominal per second bandwidth for this frame
|
// Set nominal per second bandwidth for this frame
|
||||||
cpi->target_bandwidth = (int)(cpi->per_frame_bandwidth
|
cpi->target_bandwidth = (int)(cpi->per_frame_bandwidth
|
||||||
* cpi->output_frame_rate);
|
* cpi->output_framerate);
|
||||||
if (cpi->target_bandwidth < 0)
|
if (cpi->target_bandwidth < 0)
|
||||||
cpi->target_bandwidth = 0;
|
cpi->target_bandwidth = 0;
|
||||||
|
|
||||||
@ -2623,7 +2623,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
|||||||
cpi->per_frame_bandwidth = cpi->twopass.kf_bits;
|
cpi->per_frame_bandwidth = cpi->twopass.kf_bits;
|
||||||
// Convert to a per second bitrate
|
// Convert to a per second bitrate
|
||||||
cpi->target_bandwidth = (int)(cpi->twopass.kf_bits *
|
cpi->target_bandwidth = (int)(cpi->twopass.kf_bits *
|
||||||
cpi->output_frame_rate);
|
cpi->output_framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note the total error score of the kf group minus the key frame itself
|
// Note the total error score of the kf group minus the key frame itself
|
||||||
|
@ -1026,14 +1026,14 @@ int vp9_reverse_trans(int x) {
|
|||||||
|
|
||||||
return 63;
|
return 63;
|
||||||
};
|
};
|
||||||
void vp9_new_frame_rate(VP9_COMP *cpi, double framerate) {
|
void vp9_new_framerate(VP9_COMP *cpi, double framerate) {
|
||||||
if (framerate < 0.1)
|
if (framerate < 0.1)
|
||||||
framerate = 30;
|
framerate = 30;
|
||||||
|
|
||||||
cpi->oxcf.frame_rate = framerate;
|
cpi->oxcf.framerate = framerate;
|
||||||
cpi->output_frame_rate = cpi->oxcf.frame_rate;
|
cpi->output_framerate = cpi->oxcf.framerate;
|
||||||
cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_frame_rate);
|
cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_framerate);
|
||||||
cpi->av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_frame_rate);
|
cpi->av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->output_framerate);
|
||||||
cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100);
|
cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100);
|
||||||
|
|
||||||
|
|
||||||
@ -1230,7 +1230,7 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
|
|||||||
cpi->oxcf.target_bandwidth, 1000);
|
cpi->oxcf.target_bandwidth, 1000);
|
||||||
|
|
||||||
// Set up frame rate and related parameters rate control values.
|
// Set up frame rate and related parameters rate control values.
|
||||||
vp9_new_frame_rate(cpi, cpi->oxcf.frame_rate);
|
vp9_new_framerate(cpi, cpi->oxcf.framerate);
|
||||||
|
|
||||||
// Set absolute upper and lower quality limits
|
// Set absolute upper and lower quality limits
|
||||||
cpi->worst_quality = cpi->oxcf.worst_allowed_q;
|
cpi->worst_quality = cpi->oxcf.worst_allowed_q;
|
||||||
@ -1522,7 +1522,7 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
|
|||||||
cal_nmvsadcosts_hp(cpi->mb.nmvsadcost_hp);
|
cal_nmvsadcosts_hp(cpi->mb.nmvsadcost_hp);
|
||||||
|
|
||||||
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
|
for (i = 0; i < KEY_FRAME_CONTEXT; i++)
|
||||||
cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate;
|
cpi->prior_key_frame_distance[i] = (int)cpi->output_framerate;
|
||||||
|
|
||||||
#ifdef OUTPUT_YUV_SRC
|
#ifdef OUTPUT_YUV_SRC
|
||||||
yuv_file = fopen("bd.yuv", "ab");
|
yuv_file = fopen("bd.yuv", "ab");
|
||||||
@ -2530,7 +2530,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
|||||||
cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
|
cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
|
||||||
// per second target bitrate
|
// per second target bitrate
|
||||||
cpi->target_bandwidth = (int)(cpi->twopass.gf_bits *
|
cpi->target_bandwidth = (int)(cpi->twopass.gf_bits *
|
||||||
cpi->output_frame_rate);
|
cpi->output_framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear zbin over-quant value and mode boost values.
|
// Clear zbin over-quant value and mode boost values.
|
||||||
@ -3472,14 +3472,14 @@ static void Pass2Encode(VP9_COMP *cpi, unsigned long *size,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!cpi->refresh_alt_ref_frame) {
|
if (!cpi->refresh_alt_ref_frame) {
|
||||||
double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.frame_rate;
|
double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.framerate;
|
||||||
double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
|
double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
|
||||||
* cpi->oxcf.two_pass_vbrmin_section / 100);
|
* cpi->oxcf.two_pass_vbrmin_section / 100);
|
||||||
|
|
||||||
if (two_pass_min_rate < lower_bounds_min_rate)
|
if (two_pass_min_rate < lower_bounds_min_rate)
|
||||||
two_pass_min_rate = lower_bounds_min_rate;
|
two_pass_min_rate = lower_bounds_min_rate;
|
||||||
|
|
||||||
cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->oxcf.frame_rate);
|
cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->oxcf.framerate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3701,18 +3701,18 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
|
|||||||
|
|
||||||
if (this_duration) {
|
if (this_duration) {
|
||||||
if (step) {
|
if (step) {
|
||||||
vp9_new_frame_rate(cpi, 10000000.0 / this_duration);
|
vp9_new_framerate(cpi, 10000000.0 / this_duration);
|
||||||
} else {
|
} else {
|
||||||
// Average this frame's rate into the last second's average
|
// Average this frame's rate into the last second's average
|
||||||
// frame rate. If we haven't seen 1 second yet, then average
|
// frame rate. If we haven't seen 1 second yet, then average
|
||||||
// over the whole interval seen.
|
// over the whole interval seen.
|
||||||
const double interval = MIN((double)(cpi->source->ts_end
|
const double interval = MIN((double)(cpi->source->ts_end
|
||||||
- cpi->first_time_stamp_ever), 10000000.0);
|
- cpi->first_time_stamp_ever), 10000000.0);
|
||||||
double avg_duration = 10000000.0 / cpi->oxcf.frame_rate;
|
double avg_duration = 10000000.0 / cpi->oxcf.framerate;
|
||||||
avg_duration *= (interval - avg_duration + this_duration);
|
avg_duration *= (interval - avg_duration + this_duration);
|
||||||
avg_duration /= interval;
|
avg_duration /= interval;
|
||||||
|
|
||||||
vp9_new_frame_rate(cpi, 10000000.0 / avg_duration);
|
vp9_new_framerate(cpi, 10000000.0 / avg_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ typedef struct VP9_COMP {
|
|||||||
int av_per_frame_bandwidth; // Average frame size target for clip
|
int av_per_frame_bandwidth; // Average frame size target for clip
|
||||||
int min_frame_bandwidth; // Minimum allocation that should be used for any frame
|
int min_frame_bandwidth; // Minimum allocation that should be used for any frame
|
||||||
int inter_frame_target;
|
int inter_frame_target;
|
||||||
double output_frame_rate;
|
double output_framerate;
|
||||||
int64_t last_time_stamp_seen;
|
int64_t last_time_stamp_seen;
|
||||||
int64_t last_end_time_stamp_seen;
|
int64_t last_end_time_stamp_seen;
|
||||||
int64_t first_time_stamp_ever;
|
int64_t first_time_stamp_ever;
|
||||||
|
@ -451,7 +451,7 @@ static int estimate_keyframe_frequency(VP9_COMP *cpi) {
|
|||||||
* whichever is smaller.
|
* whichever is smaller.
|
||||||
*/
|
*/
|
||||||
int key_freq = cpi->oxcf.key_freq > 0 ? cpi->oxcf.key_freq : 1;
|
int key_freq = cpi->oxcf.key_freq > 0 ? cpi->oxcf.key_freq : 1;
|
||||||
av_key_frame_frequency = (int)cpi->output_frame_rate * 2;
|
av_key_frame_frequency = (int)cpi->output_framerate * 2;
|
||||||
|
|
||||||
if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
|
if (cpi->oxcf.auto_key && av_key_frame_frequency > key_freq)
|
||||||
av_key_frame_frequency = cpi->oxcf.key_freq;
|
av_key_frame_frequency = cpi->oxcf.key_freq;
|
||||||
|
@ -233,10 +233,10 @@ static vpx_codec_err_t set_vp9e_config(VP9_CONFIG *oxcf,
|
|||||||
oxcf->width = cfg.g_w;
|
oxcf->width = cfg.g_w;
|
||||||
oxcf->height = cfg.g_h;
|
oxcf->height = cfg.g_h;
|
||||||
/* guess a frame rate if out of whack, use 30 */
|
/* guess a frame rate if out of whack, use 30 */
|
||||||
oxcf->frame_rate = (double)(cfg.g_timebase.den) / (double)(cfg.g_timebase.num);
|
oxcf->framerate = (double)(cfg.g_timebase.den) / (double)(cfg.g_timebase.num);
|
||||||
|
|
||||||
if (oxcf->frame_rate > 180) {
|
if (oxcf->framerate > 180) {
|
||||||
oxcf->frame_rate = 30;
|
oxcf->framerate = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cfg.g_pass) {
|
switch (cfg.g_pass) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user