summaryrefslogtreecommitdiff
path: root/vpx
diff options
context:
space:
mode:
authorMinghai Shang <minghai@google.com>2014-02-28 11:50:48 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-02-28 11:50:48 -0800
commit0bbc7f9825516e8e59a8a701e43df1aa967fd70a (patch)
treefabc6c37b0ecfc6cc09c8926996074618c8ea756 /vpx
parentd6321c3e68dd675da246d8b191db142d44196d51 (diff)
parente526c048729212db8ad046ab89d256b3a22fef26 (diff)
downloadlibvpx-0bbc7f9825516e8e59a8a701e43df1aa967fd70a.tar.gz
libvpx-0bbc7f9825516e8e59a8a701e43df1aa967fd70a.tar.bz2
libvpx-0bbc7f9825516e8e59a8a701e43df1aa967fd70a.zip
Merge "[svc] Fix "possible loss of data", "division by zero" and "index 5 out of bounds for type" compiler warings"
Diffstat (limited to 'vpx')
-rw-r--r--vpx/src/svc_encodeframe.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c
index 5537fb508..c7837244f 100644
--- a/vpx/src/svc_encodeframe.c
+++ b/vpx/src/svc_encodeframe.c
@@ -548,15 +548,20 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
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];
+ if (pos < VPX_SS_MAX_LAYERS && si->scaling_factor_den[pos] > 0) {
+ alloc_ratio[i] = (float)(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;
+ if (total > 0) {
+ enc_cfg->ss_target_bitrate[i] = (unsigned int)
+ (enc_cfg->rc_target_bitrate * alloc_ratio[i] / total);
+ }
}
}