summaryrefslogtreecommitdiff
path: root/vpx/src
diff options
context:
space:
mode:
authorMinghai Shang <minghai@google.com>2014-02-26 13:30:50 -0800
committerMinghai Shang <minghai@google.com>2014-02-26 13:30:50 -0800
commit8c196b27b317e8c588e7af82a9a38cd48b4cb08b (patch)
tree447bc789b44a48cc53af4125ae81ee97370a5ce7 /vpx/src
parentc79bd22a5f83ce2a2a2a9d9fe37d409c098c41d7 (diff)
downloadlibvpx-8c196b27b317e8c588e7af82a9a38cd48b4cb08b.tar
libvpx-8c196b27b317e8c588e7af82a9a38cd48b4cb08b.tar.gz
libvpx-8c196b27b317e8c588e7af82a9a38cd48b4cb08b.tar.bz2
libvpx-8c196b27b317e8c588e7af82a9a38cd48b4cb08b.zip
[svc] Add target bitrate settings for each layers.
Change-Id: Ia7677fb436667bc4f76db71f65e4784f433f7826
Diffstat (limited to 'vpx/src')
-rw-r--r--vpx/src/svc_encodeframe.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c
index c12d8a3b0..4badca977 100644
--- a/vpx/src/svc_encodeframe.c
+++ b/vpx/src/svc_encodeframe.c
@@ -534,6 +534,29 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
res = parse_options(svc_ctx, si->options);
if (res != VPX_CODEC_OK) return res;
+ // Assign target bitrate for each layer. We calculate the ratio
+ // from the resolution for now.
+ // TODO(Minghai): Optimize the mechanism of allocating bits after
+ // implementing svc two pass rate control.
+ if (si->layers > 1) {
+ int i;
+ float total = 0;
+ float alloc_ratio[VPX_SS_MAX_LAYERS] = {0};
+
+ for (i = 0; i < si->layers; ++i) {
+ int pos = i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers;
+ alloc_ratio[i] = si->scaling_factor_num[pos] * 1.0 /
+ si->scaling_factor_den[pos];
+ alloc_ratio[i] *= alloc_ratio[i];
+ total += alloc_ratio[i];
+ }
+
+ for (i = 0; i < si->layers; ++i) {
+ enc_cfg->ss_target_bitrate[i] = enc_cfg->rc_target_bitrate *
+ alloc_ratio[i] / total;
+ }
+ }
+
// modify encoder configuration
enc_cfg->ss_number_layers = si->layers;
enc_cfg->ts_number_layers = 1; // Temporal layers not used in this encoder.