diff options
author | Wim Taymans <wtaymans@redhat.com> | 2015-06-12 16:52:27 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2015-06-12 16:58:10 +0200 |
commit | 1fbbff491acfc92fb2f37c9cf3d41e0e6175e5e4 (patch) | |
tree | 73acb7ab7b64996594e005c8d1f573163cbf925a /gst-libs | |
parent | f4f389483658e23ca7f410cc0633ce3fd358f70c (diff) |
video-scaler: make sure to clamp to max width
When estimating the area that should first be vertically scaled, make
sure we clamp to the max input size or else we get invalid reads.
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/video/video-scaler.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/gst-libs/gst/video/video-scaler.c b/gst-libs/gst/video/video-scaler.c index 881fd0892..3d47da5c0 100644 --- a/gst-libs/gst/video/video-scaler.c +++ b/gst-libs/gst/video/video-scaler.c @@ -1137,6 +1137,7 @@ gst_video_scaler_combine_packed_YUV (GstVideoScaler * y_scale, scale->in_y_offset = get_y_offset (in_format); scale->out_y_offset = get_y_offset (out_format); + scale->inc = y_scale->inc; for (i = 0; i < out_size; i++) { if ((i & 1) == scale->out_y_offset) { @@ -1498,24 +1499,30 @@ gst_video_scaler_2d (GstVideoScaler * hscale, GstVideoScaler * vscale, vfunc (vscale, lines, LINE (dest, dest_stride, i), i, width, n_elems); } } else { - guint vx, vw, w1; + guint vx, vw, w1, ws; guint h_taps; h_taps = hscale->resampler.max_taps; w1 = x + width - 1; + ws = hscale->resampler.offset[w1]; + /* we need to estimate the area that we first need to scale in the + * vertical direction. Scale x and width to find the lower bound and + * overshoot the width to find the upper bound */ vx = (hscale->inc * x) >> 16; vx = MIN (vx, hscale->resampler.offset[x]); vw = (hscale->inc * (x + width)) >> 16; if (hscale->merged) { if ((w1 & 1) == hscale->out_y_offset) - vw = MAX (vw, hscale->resampler.offset[w1] + (2 * h_taps)); + vw = MAX (vw, ws + (2 * h_taps)); else - vw = MAX (vw, hscale->resampler.offset[w1] + (4 * h_taps)); + vw = MAX (vw, ws + (4 * h_taps)); } else { - vw = MAX (vw, hscale->resampler.offset[w1] + h_taps); + vw = MAX (vw, ws + h_taps); } vw += 1; + /* but clamp to max size */ + vw = MIN (vw, hscale->resampler.in_size); if (vscale->tmpwidth < vw) realloc_tmplines (vscale, n_elems, vw); |