mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
videoscale: Use correct boundary checks for YUY2/UYVY
Fixes bug #613093.
This commit is contained in:
parent
f21e123bcc
commit
bbdc60fbcb
2 changed files with 16 additions and 16 deletions
|
@ -612,7 +612,7 @@ vs_scanline_resample_4tap_YUYV (uint8_t * dest, uint8_t * src,
|
|||
j = acc >> 17;
|
||||
x = (acc & 0x1ffff) >> 9;
|
||||
|
||||
if (2 * (j - 1) >= 0 && 2 * (j + 4) < src_width) {
|
||||
if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) {
|
||||
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 1 - 4, 1)];
|
||||
y += vs_4tap_taps[x][1] * src[j * 4 + 1];
|
||||
y += vs_4tap_taps[x][2] * src[j * 4 + 1 + 4];
|
||||
|
@ -627,7 +627,7 @@ vs_scanline_resample_4tap_YUYV (uint8_t * dest, uint8_t * src,
|
|||
dest[i * 4 + 1] = CLAMP (y >> SHIFT, 0, 255);
|
||||
|
||||
if (2 * i + 1 < n) {
|
||||
if (2 * (j - 1) >= 0 && 2 * (j + 4) < src_width) {
|
||||
if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) {
|
||||
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 3 - 4, 3)];
|
||||
y += vs_4tap_taps[x][1] * src[j * 4 + 3];
|
||||
y += vs_4tap_taps[x][2] * src[j * 4 + 3 + 4];
|
||||
|
@ -810,7 +810,7 @@ vs_scanline_resample_4tap_UYVY (uint8_t * dest, uint8_t * src,
|
|||
j = acc >> 17;
|
||||
x = (acc & 0x1ffff) >> 9;
|
||||
|
||||
if (2 * (j - 2) >= 0 && 2 * (j + 4) < src_width) {
|
||||
if (2 * j - 2 >= 0 && 2 * j + 4 < src_width) {
|
||||
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 0 - 4, 0)];
|
||||
y += vs_4tap_taps[x][1] * src[j * 4 + 0];
|
||||
y += vs_4tap_taps[x][2] * src[j * 4 + 0 + 4];
|
||||
|
@ -825,7 +825,7 @@ vs_scanline_resample_4tap_UYVY (uint8_t * dest, uint8_t * src,
|
|||
dest[i * 4 + 0] = CLAMP (y >> SHIFT, 0, 255);
|
||||
|
||||
if (2 * i + 1 < n) {
|
||||
if (2 * (j - 1) >= 0 && 2 * (j + 4) < src_width) {
|
||||
if (2 * j - 1 >= 0 && 2 * j + 4 < src_width) {
|
||||
y = vs_4tap_taps[x][0] * src[MAX (j * 4 + 2 - 4, 2)];
|
||||
y += vs_4tap_taps[x][1] * src[j * 4 + 2];
|
||||
y += vs_4tap_taps[x][2] * src[j * 4 + 2 + 4];
|
||||
|
|
|
@ -377,11 +377,11 @@ vs_scanline_resample_nearest_YUYV (uint8_t * dest, uint8_t * src, int src_width,
|
|||
j = acc >> 17;
|
||||
x = acc & 0x1ffff;
|
||||
dest[i * 4 + 1] = (x < 65536
|
||||
|| 2 * (j + 2) >= src_width) ? src[j * 4 + 1] : src[j * 4 + 5];
|
||||
|| 2 * j + 2 >= src_width) ? src[j * 4 + 1] : src[j * 4 + 5];
|
||||
|
||||
if (2 * i + 1 < n && 2 * (j + 1) < src_width)
|
||||
if (2 * i + 1 < n && 2 * j + 1 < src_width)
|
||||
dest[i * 4 + 3] = (x < 65536
|
||||
|| 2 * (j + 3) >= src_width) ? src[j * 4 + 3] : src[j * 4 + 7];
|
||||
|| 2 * j + 3 >= src_width) ? src[j * 4 + 3] : src[j * 4 + 7];
|
||||
|
||||
acc += increment;
|
||||
|
||||
|
@ -421,14 +421,14 @@ vs_scanline_resample_linear_YUYV (uint8_t * dest, uint8_t * src, int src_width,
|
|||
j = acc >> 17;
|
||||
x = acc & 0x1ffff;
|
||||
|
||||
if (2 * (j + 2) < src_width)
|
||||
if (2 * j + 2 < src_width)
|
||||
dest[i * 4 + 1] =
|
||||
(src[j * 4 + 1] * (131072 - x) + src[j * 4 + 5] * x) >> 17;
|
||||
else
|
||||
dest[i * 4 + 1] = src[j * 4 + 1];
|
||||
|
||||
if (2 * i + 1 < n && 2 * (j + 1) < src_width) {
|
||||
if (2 * (j + 3) < src_width)
|
||||
if (2 * i + 1 < n && 2 * j + 1 < src_width) {
|
||||
if (2 * j + 3 < src_width)
|
||||
dest[i * 4 + 3] =
|
||||
(src[j * 4 + 3] * (131072 - x) + src[j * 4 + 7] * x) >> 17;
|
||||
else
|
||||
|
@ -516,11 +516,11 @@ vs_scanline_resample_nearest_UYVY (uint8_t * dest, uint8_t * src, int src_width,
|
|||
x = acc & 0x1ffff;
|
||||
|
||||
dest[i * 4 + 0] = (x < 65536
|
||||
|| 2 * (j + 2) >= src_width) ? src[j * 4 + 0] : src[j * 4 + 4];
|
||||
|| 2 * j + 2 >= src_width) ? src[j * 4 + 0] : src[j * 4 + 4];
|
||||
|
||||
if (2 * i + 1 < n && 2 * (j + 1) < src_width)
|
||||
if (2 * i + 1 < n && 2 * j + 1 < src_width)
|
||||
dest[i * 4 + 2] = (x < 65536
|
||||
|| 2 * (j + 3) >= src_width) ? src[j * 4 + 2] : src[j * 4 + 6];
|
||||
|| 2 * j + 3 >= src_width) ? src[j * 4 + 2] : src[j * 4 + 6];
|
||||
|
||||
acc += increment;
|
||||
|
||||
|
@ -559,14 +559,14 @@ vs_scanline_resample_linear_UYVY (uint8_t * dest, uint8_t * src, int src_width,
|
|||
|
||||
j = acc >> 17;
|
||||
x = acc & 0x1ffff;
|
||||
if (2 * (j + 2) < src_width)
|
||||
if (2 * j + 2 < src_width)
|
||||
dest[i * 4 + 0] =
|
||||
(src[j * 4 + 0] * (131072 - x) + src[j * 4 + 4] * x) >> 17;
|
||||
else
|
||||
dest[i * 4 + 0] = src[j * 4 + 0];
|
||||
|
||||
if (i * 2 + 1 < n && 2 * (j + 1) < src_width) {
|
||||
if (2 * (j + 3) < src_width)
|
||||
if (i * 2 + 1 < n && 2 * j + 1 < src_width) {
|
||||
if (2 * j + 3 < src_width)
|
||||
dest[i * 4 + 2] =
|
||||
(src[j * 4 + 2] * (131072 - x) + src[j * 4 + 6] * x) >> 17;
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue