mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 00:58:12 +00:00
gst/videoscale/vs_4tap.c: Fix valgrind error on 4tap scaling method.
Original commit message from CVS: * gst/videoscale/vs_4tap.c: Fix valgrind error on 4tap scaling method.
This commit is contained in:
parent
db4d879623
commit
5aad3658f8
2 changed files with 33 additions and 22 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2008-01-13 David Schleef <ds@schleef.org>
|
||||||
|
|
||||||
|
* gst/videoscale/vs_4tap.c:
|
||||||
|
Fix valgrind error on 4tap scaling method.
|
||||||
|
|
||||||
2008-01-13 Sebastien Moutte <sebastien@moutte.net>
|
2008-01-13 Sebastien Moutte <sebastien@moutte.net>
|
||||||
|
|
||||||
* gst-libs/gst/sdp/gstsdpmessage.c: (is_multicast_address):
|
* gst-libs/gst/sdp/gstsdpmessage.c: (is_multicast_address):
|
||||||
|
|
|
@ -95,7 +95,7 @@ vs_4tap_init (void)
|
||||||
|
|
||||||
void
|
void
|
||||||
vs_scanline_resample_4tap_Y (uint8_t * dest, uint8_t * src,
|
vs_scanline_resample_4tap_Y (uint8_t * dest, uint8_t * src,
|
||||||
int n, int *xacc, int increment)
|
int n, int src_width, int *xacc, int increment)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -107,15 +107,19 @@ vs_scanline_resample_4tap_Y (uint8_t * dest, uint8_t * src,
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
j = acc >> 16;
|
j = acc >> 16;
|
||||||
x = (acc & 0xff00) >> 8;
|
x = (acc & 0xff00) >> 8;
|
||||||
y = (vs_4tap_taps[x][0] * src[MAX (j - 1, 0)] +
|
if (j - 1 >= 0 && j + 2 < src_width) {
|
||||||
vs_4tap_taps[x][1] * src[j] +
|
y = vs_4tap_taps[x][0] * src[MAX (j - 1, 0)];
|
||||||
vs_4tap_taps[x][2] * src[j + 1] +
|
y += vs_4tap_taps[x][1] * src[j];
|
||||||
vs_4tap_taps[x][3] * src[j + 2] + (1 << (SHIFT - 1))) >> SHIFT;
|
y += vs_4tap_taps[x][2] * src[j + 1];
|
||||||
if (y < 0)
|
y += vs_4tap_taps[x][3] * src[j + 2];
|
||||||
y = 0;
|
} else {
|
||||||
if (y > 255)
|
y = vs_4tap_taps[x][0] * src[CLAMP (j - 1, 0, src_width - 1)];
|
||||||
y = 255;
|
y += vs_4tap_taps[x][1] * src[CLAMP (j, 0, src_width - 1)];
|
||||||
dest[i] = y;
|
y += vs_4tap_taps[x][2] * src[CLAMP (j + 1, 0, src_width - 1)];
|
||||||
|
y += vs_4tap_taps[x][3] * src[CLAMP (j + 2, 0, src_width - 1)];
|
||||||
|
}
|
||||||
|
y += (1 << (SHIFT - 1));
|
||||||
|
dest[i] = CLAMP (y >> SHIFT, 0, 255);
|
||||||
acc += increment;
|
acc += increment;
|
||||||
}
|
}
|
||||||
*xacc = acc;
|
*xacc = acc;
|
||||||
|
@ -127,20 +131,21 @@ vs_scanline_merge_4tap_Y (uint8_t * dest, uint8_t * src1, uint8_t * src2,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int y;
|
int y;
|
||||||
|
int a, b, c, d;
|
||||||
|
|
||||||
acc = (acc >> 8) & 0xff;
|
acc = (acc >> 8) & 0xff;
|
||||||
|
a = vs_4tap_taps[acc][0];
|
||||||
|
b = vs_4tap_taps[acc][1];
|
||||||
|
c = vs_4tap_taps[acc][2];
|
||||||
|
d = vs_4tap_taps[acc][3];
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
y = (vs_4tap_taps[acc][0] * src1[i] +
|
y = a * src1[i];
|
||||||
vs_4tap_taps[acc][1] * src2[i] +
|
y += b * src2[i];
|
||||||
vs_4tap_taps[acc][2] * src3[i] +
|
y += c * src3[i];
|
||||||
vs_4tap_taps[acc][3] * src4[i] + (1 << (SHIFT - 1))) >> SHIFT;
|
y += d * src4[i];
|
||||||
if (y < 0)
|
y += (1 << (SHIFT - 1));
|
||||||
y = 0;
|
dest[i] = CLAMP (y >> SHIFT, 0, 255);
|
||||||
if (y > 255)
|
|
||||||
y = 255;
|
|
||||||
dest[i] = y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,7 +168,8 @@ vs_image_scale_4tap_Y (const VSImage * dest, const VSImage * src,
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
xacc = 0;
|
xacc = 0;
|
||||||
vs_scanline_resample_4tap_Y (tmpbuf + i * dest->width,
|
vs_scanline_resample_4tap_Y (tmpbuf + i * dest->width,
|
||||||
src->pixels + i * src->stride, dest->width, &xacc, x_increment);
|
src->pixels + i * src->stride, dest->width, src->width,
|
||||||
|
&xacc, x_increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
yacc = 0;
|
yacc = 0;
|
||||||
|
@ -178,7 +184,7 @@ vs_image_scale_4tap_Y (const VSImage * dest, const VSImage * src,
|
||||||
xacc = 0;
|
xacc = 0;
|
||||||
vs_scanline_resample_4tap_Y (tmpbuf + ((k + 3) & 3) * dest->width,
|
vs_scanline_resample_4tap_Y (tmpbuf + ((k + 3) & 3) * dest->width,
|
||||||
src->pixels + (k + 3) * src->stride,
|
src->pixels + (k + 3) * src->stride,
|
||||||
dest->width, &xacc, x_increment);
|
dest->width, src->width, &xacc, x_increment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue