Skip to content

Commit

Permalink
svc-vp9: Fix to invalid scale factors
Browse files Browse the repository at this point in the history
Add check on valid scale factors in
set_svc_params.

Bug: 379259812

Change-Id: I407c5828806bf18bca0b84a520b078bbb8f73a31
  • Loading branch information
marco99zz committed Nov 19, 2024
1 parent 6e23d97 commit 6266e19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vp9/encoder/vp9_svc_layercontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,13 @@ void get_layer_resolution(const int width_org, const int height_org,
int *height_out) {
int w, h;

if (width_out == NULL || height_out == NULL || den == 0) return;
if (width_out == NULL || height_out == NULL) return;

if (den == 0 || num == 0) {
*width_out = width_org;
*height_out = height_org;
return;
}

w = width_org * num / den;
h = height_org * num / den;
Expand Down
6 changes: 6 additions & 0 deletions vp9/vp9_cx_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,12 @@ static vpx_codec_err_t ctrl_set_svc_parameters(vpx_codec_alg_priv_t *ctx,
LAYER_CONTEXT *lc = &cpi->svc.layer_context[layer];
lc->max_q = params->max_quantizers[layer];
lc->min_q = params->min_quantizers[layer];
// Checks on valid scale factors.
if (params->scaling_factor_num[sl] < 1 ||
params->scaling_factor_den[sl] < 1 ||
(params->scaling_factor_num[sl] > params->scaling_factor_den[sl])) {
return VPX_CODEC_INVALID_PARAM;
}
lc->scaling_factor_num = params->scaling_factor_num[sl];
lc->scaling_factor_den = params->scaling_factor_den[sl];
lc->speed = params->speed_per_layer[sl];
Expand Down

0 comments on commit 6266e19

Please sign in to comment.