Commit 0bbc7f98 authored by Minghai Shang's avatar Minghai Shang Committed by Gerrit Code Review
Browse files

Merge "[svc] Fix "possible loss of data", "division by zero" and "index 5 out...

Merge "[svc] Fix "possible loss of data", "division by zero" and "index 5 out of bounds for type" compiler warings"
parents d6321c3e e526c048
...@@ -548,15 +548,20 @@ vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx, ...@@ -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) { for (i = 0; i < si->layers; ++i) {
int pos = i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers; int pos = i + VPX_SS_MAX_LAYERS - svc_ctx->spatial_layers;
alloc_ratio[i] = si->scaling_factor_num[pos] * 1.0 / if (pos < VPX_SS_MAX_LAYERS && si->scaling_factor_den[pos] > 0) {
si->scaling_factor_den[pos]; alloc_ratio[i] = (float)(si->scaling_factor_num[pos] * 1.0 /
alloc_ratio[i] *= alloc_ratio[i]; si->scaling_factor_den[pos]);
total += alloc_ratio[i];
alloc_ratio[i] *= alloc_ratio[i];
total += alloc_ratio[i];
}
} }
for (i = 0; i < si->layers; ++i) { for (i = 0; i < si->layers; ++i) {
enc_cfg->ss_target_bitrate[i] = enc_cfg->rc_target_bitrate * if (total > 0) {
alloc_ratio[i] / total; enc_cfg->ss_target_bitrate[i] = (unsigned int)
(enc_cfg->rc_target_bitrate * alloc_ratio[i] / total);
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment