extern void vp9_new_framerate(VP9_COMP *cpi, double framerate);
void vp9_init_second_pass(VP9_COMP *cpi) {
+ SVC *const svc = &cpi->svc;
FIRSTPASS_STATS this_frame;
const FIRSTPASS_STATS *start_pos;
struct twopass_rc *twopass = &cpi->twopass;
const VP9_CONFIG *const oxcf = &cpi->oxcf;
- const int is_spatial_svc = (cpi->svc.number_spatial_layers > 1) &&
- (cpi->svc.number_temporal_layers == 1);
+ const int is_spatial_svc = (svc->number_spatial_layers > 1) &&
+ (svc->number_temporal_layers == 1);
double frame_rate;
if (is_spatial_svc) {
- twopass = &cpi->svc.layer_context[cpi->svc.spatial_layer_id].twopass;
+ twopass = &svc->layer_context[svc->spatial_layer_id].twopass;
}
zero_stats(&twopass->total_stats);
vp9_update_spatial_layer_framerate(cpi, frame_rate);
twopass->bits_left =
(int64_t)(twopass->total_stats.duration *
- cpi->svc.layer_context[cpi->svc.spatial_layer_id].target_bandwidth /
+ svc->layer_context[svc->spatial_layer_id].target_bandwidth /
10000000.0);
} else {
vp9_new_framerate(cpi, frame_rate);
#include "vp9/encoder/vp9_svc_layercontext.h"
void vp9_init_layer_context(VP9_COMP *const cpi) {
+ SVC *const svc = &cpi->svc;
const VP9_CONFIG *const oxcf = &cpi->oxcf;
int layer;
int layer_end;
- cpi->svc.spatial_layer_id = 0;
- cpi->svc.temporal_layer_id = 0;
+ svc->spatial_layer_id = 0;
+ svc->temporal_layer_id = 0;
- if (cpi->svc.number_temporal_layers > 1) {
- layer_end = cpi->svc.number_temporal_layers;
+ if (svc->number_temporal_layers > 1) {
+ layer_end = svc->number_temporal_layers;
} else {
- layer_end = cpi->svc.number_spatial_layers;
+ layer_end = svc->number_spatial_layers;
}
for (layer = 0; layer < layer_end; ++layer) {
- LAYER_CONTEXT *const lc = &cpi->svc.layer_context[layer];
+ LAYER_CONTEXT *const lc = &svc->layer_context[layer];
RATE_CONTROL *const lrc = &lc->rc;
lc->current_video_frame_in_layer = 0;
lrc->avg_frame_qindex[INTER_FRAME] = q_trans[oxcf->worst_allowed_q];
lrc->rate_correction_factor = 1.0;
lrc->key_frame_rate_correction_factor = 1.0;
- if (cpi->svc.number_temporal_layers > 1) {
+ if (svc->number_temporal_layers > 1) {
lc->target_bandwidth = oxcf->ts_target_bitrate[layer] * 1000;
lrc->last_q[INTER_FRAME] = q_trans[oxcf->worst_allowed_q];
} else {
// Update the layer context from a change_config() call.
void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
const int target_bandwidth) {
+ SVC *const svc = &cpi->svc;
const VP9_CONFIG *const oxcf = &cpi->oxcf;
const RATE_CONTROL *const rc = &cpi->rc;
int layer;
int layer_end;
float bitrate_alloc = 1.0;
- if (cpi->svc.number_temporal_layers > 1) {
- layer_end = cpi->svc.number_temporal_layers;
+ if (svc->number_temporal_layers > 1) {
+ layer_end = svc->number_temporal_layers;
} else {
- layer_end = cpi->svc.number_spatial_layers;
+ layer_end = svc->number_spatial_layers;
}
for (layer = 0; layer < layer_end; ++layer) {
- LAYER_CONTEXT *const lc = &cpi->svc.layer_context[layer];
+ LAYER_CONTEXT *const lc = &svc->layer_context[layer];
RATE_CONTROL *const lrc = &lc->rc;
- if (cpi->svc.number_temporal_layers > 1) {
+ if (svc->number_temporal_layers > 1) {
lc->target_bandwidth = oxcf->ts_target_bitrate[layer] * 1000;
} else {
lc->target_bandwidth = oxcf->ss_target_bitrate[layer] * 1000;
lrc->bits_off_target = MIN(lrc->bits_off_target, lc->maximum_buffer_size);
lrc->buffer_level = MIN(lrc->buffer_level, lc->maximum_buffer_size);
// Update framerate-related quantities.
- if (cpi->svc.number_temporal_layers > 1) {
+ if (svc->number_temporal_layers > 1) {
lc->framerate = oxcf->framerate / oxcf->ts_rate_decimator[layer];
} else {
lc->framerate = oxcf->framerate;
}
void vp9_update_temporal_layer_framerate(VP9_COMP *const cpi) {
- const int layer = cpi->svc.temporal_layer_id;
+ SVC *const svc = &cpi->svc;
const VP9_CONFIG *const oxcf = &cpi->oxcf;
- LAYER_CONTEXT *const lc = get_layer_context(&cpi->svc);
+ LAYER_CONTEXT *const lc = get_layer_context(svc);
RATE_CONTROL *const lrc = &lc->rc;
+ const int layer = svc->temporal_layer_id;
lc->framerate = oxcf->framerate / oxcf->ts_rate_decimator[layer];
lrc->av_per_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
}
void vp9_init_second_pass_spatial_svc(VP9_COMP *cpi) {
+ SVC *const svc = &cpi->svc;
int i;
- for (i = 0; i < cpi->svc.number_spatial_layers; ++i) {
- struct twopass_rc *const twopass = &cpi->svc.layer_context[i].twopass;
- cpi->svc.spatial_layer_id = i;
+ for (i = 0; i < svc->number_spatial_layers; ++i) {
+ struct twopass_rc *const twopass = &svc->layer_context[i].twopass;
+
+ svc->spatial_layer_id = i;
vp9_init_second_pass(cpi);
twopass->total_stats.spatial_layer_id = i;
twopass->total_left_stats.spatial_layer_id = i;
}
- cpi->svc.spatial_layer_id = 0;
+ svc->spatial_layer_id = 0;
}