History

avfilter/scale_eval: Use 64bit, check values in ff_scale_adjust_dimensions()

Found by reviewing CID1513722 Operands don't affect result

Michael Niedermayer committed 2 years ago

Commit ad9df8b1 parent 6db4e322 files · +7 −4Browse files

Unified · Split

2 files
  1. libavfilter/scale_eval.c +6 −3
  2. libavfilter/scale_eval.h +1 −1
libavfilter/scale_eval.c+6−3
@@ -114,7 +114,7 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, · 113 unmodified lines
114 int *ret_w, int *ret_h,114 int *ret_w, int *ret_h,
115 int force_original_aspect_ratio, int force_divisible_by)115 int force_original_aspect_ratio, int force_divisible_by)
116{116{
117 int w, h;117 int64_t w, h;
118 int factor_w, factor_h;118 int factor_w, factor_h;
119 119
120 w = *ret_w;120 w = *ret_w;
@@ -149,9 +149,9 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, · 28 unmodified lines
149 * unless force_divisible_by is defined as well */149 * unless force_divisible_by is defined as well */
150 if (force_original_aspect_ratio) {150 if (force_original_aspect_ratio) {
151 // Including force_divisible_by here rounds to the nearest multiple of it.151 // Including force_divisible_by here rounds to the nearest multiple of it.
152 int tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by)152 int64_t tmp_w = av_rescale(h, inlink->w, inlink->h * (int64_t)force_divisible_by)
153 * force_divisible_by;153 * force_divisible_by;
154 int tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by)154 int64_t tmp_h = av_rescale(w, inlink->h, inlink->w * (int64_t)force_divisible_by)
155 * force_divisible_by;155 * force_divisible_by;
156 156
157 if (force_original_aspect_ratio == 1) {157 if (force_original_aspect_ratio == 1) {
@@ -173,6 +173,9 @@ int ff_scale_adjust_dimensions(AVFilterLink *inlink, · 15 unmodified lines
173 }173 }
174 }174 }
175 175
176 if ((int32_t)w != w || (int32_t)h != h)
177 return AVERROR(EINVAL);
178
176 *ret_w = w;179 *ret_w = w;
177 *ret_h = h;180 *ret_h = h;
178 181
libavfilter/scale_eval.h+1−1
@@ -41,7 +41,7 @@ int ff_scale_eval_dimensions(void *ctx, · 40 unmodified lines
41 * force_original_aspect_ratio is set. force_divisible_by is used only when41 * force_original_aspect_ratio is set. force_divisible_by is used only when
42 * force_original_aspect_ratio is set and must be at least 1.42 * force_original_aspect_ratio is set and must be at least 1.
43 *43 *
44 * Returns 0.44 * Returns negative error code on error or non negative on success
45 */45 */
46int ff_scale_adjust_dimensions(AVFilterLink *inlink,46int ff_scale_adjust_dimensions(AVFilterLink *inlink,
47 int *ret_w, int *ret_h,47 int *ret_w, int *ret_h,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t