From: Minghai Shang Date: Fri, 28 Feb 2014 18:30:20 +0000 (-0800) Subject: [svc] Fix "possible loss of data", "division by zero" and X-Git-Tag: v1.4.0~2206^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e526c048729212db8ad046ab89d256b3a22fef26;p=platform%2Fupstream%2Flibvpx.git [svc] Fix "possible loss of data", "division by zero" and "index 5 out of bounds for type" compiler warings Change-Id: I414d39198cb02d1b8e2330002ed5fe062aaea95e --- diff --git a/vpx/src/svc_encodeframe.c b/vpx/src/svc_encodeframe.c index 5537fb5..c783724 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); + } } }