mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
videoscale: simplify YUYV and UYVY linear scaling
Simplify the code and make it handle odd width
This commit is contained in:
parent
ccf53052a0
commit
85c572a57e
1 changed files with 38 additions and 65 deletions
|
@ -302,54 +302,40 @@ vs_scanline_resample_linear_YUYV (uint8_t * dest, uint8_t * src, int src_width,
|
||||||
int n, int *accumulator, int increment)
|
int n, int *accumulator, int increment)
|
||||||
{
|
{
|
||||||
int acc = *accumulator;
|
int acc = *accumulator;
|
||||||
int i;
|
int i, j, x;
|
||||||
int j;
|
|
||||||
int x;
|
|
||||||
int quads = (n + 1) / 2;
|
|
||||||
|
|
||||||
for (i = 0; i < quads; i++) {
|
for (i = 0; i < n; i += 2) {
|
||||||
j = acc >> 16;
|
j = acc >> 16;
|
||||||
x = acc & 0xffff;
|
x = acc & 0xffff;
|
||||||
|
|
||||||
if (j + 1 < src_width)
|
if (j + 1 < src_width)
|
||||||
dest[i * 4 + 0] =
|
dest[i * 2 + 0] = BLEND (src[j * 2 + 0], src[j * 2 + 2], x);
|
||||||
(src[j * 2 + 0] * (65536 - x) + src[j * 2 + 2] * x) >> 16;
|
|
||||||
else
|
else
|
||||||
dest[i * 4 + 0] = src[j * 2 + 0];
|
dest[i * 2 + 0] = src[j * 2 + 0];
|
||||||
|
|
||||||
j = acc >> 17;
|
j >>= 1;
|
||||||
x = acc & 0x1ffff;
|
if (2 * (j + 1) < src_width) {
|
||||||
|
dest[i * 2 + 1] = BLEND (src[j * 4 + 1], src[j * 4 + 5], x);
|
||||||
if (2 * j + 2 < src_width)
|
dest[i * 2 + 3] = BLEND (src[j * 4 + 3], src[j * 4 + 7], x);
|
||||||
dest[i * 4 + 1] =
|
} else {
|
||||||
(src[j * 4 + 1] * (131072 - x) + src[j * 4 + 5] * x) >> 17;
|
dest[i * 2 + 1] = src[j * 4 + 1];
|
||||||
else
|
dest[i * 2 + 3] = src[j * 4 + 3];
|
||||||
dest[i * 4 + 1] = src[j * 4 + 1];
|
|
||||||
|
|
||||||
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
|
|
||||||
dest[i * 4 + 3] = src[j * 4 + 3];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
acc += increment;
|
acc += increment;
|
||||||
|
|
||||||
|
if (i < n - 1) {
|
||||||
j = acc >> 16;
|
j = acc >> 16;
|
||||||
x = acc & 0xffff;
|
|
||||||
|
|
||||||
if (2 * i + 1 < n && j < src_width) {
|
if (j + 1 < src_width) {
|
||||||
if (j + 1 < src_width)
|
x = acc & 0xffff;
|
||||||
dest[i * 4 + 2] =
|
dest[i * 2 + 2] = BLEND (src[j * 2 + 0], src[j * 2 + 2], x);
|
||||||
(src[j * 2 + 0] * (65536 - x) + src[j * 2 + 2] * x) >> 16;
|
} else
|
||||||
else
|
dest[i * 2 + 2] = src[j * 2 + 0];
|
||||||
dest[i * 4 + 2] = src[j * 2 + 0];
|
|
||||||
acc += increment;
|
acc += increment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*accumulator = acc;
|
*accumulator = acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,53 +405,40 @@ vs_scanline_resample_linear_UYVY (uint8_t * dest, uint8_t * src, int src_width,
|
||||||
int n, int *accumulator, int increment)
|
int n, int *accumulator, int increment)
|
||||||
{
|
{
|
||||||
int acc = *accumulator;
|
int acc = *accumulator;
|
||||||
int i;
|
int i, j, x;
|
||||||
int j;
|
|
||||||
int x;
|
|
||||||
int quads = (n + 1) / 2;
|
|
||||||
|
|
||||||
for (i = 0; i < quads; i++) {
|
for (i = 0; i < n; i += 2) {
|
||||||
j = acc >> 16;
|
j = acc >> 16;
|
||||||
x = acc & 0xffff;
|
x = acc & 0xffff;
|
||||||
|
|
||||||
if (j + 1 < src_width)
|
if (j + 1 < src_width)
|
||||||
dest[i * 4 + 1] =
|
dest[i * 2 + 1] = BLEND (src[j * 2 + 1], src[j * 2 + 3], x);
|
||||||
(src[j * 2 + 1] * (65536 - x) + src[j * 2 + 3] * x) >> 16;
|
|
||||||
else
|
else
|
||||||
dest[i * 4 + 1] = src[j * 2 + 1];
|
dest[i * 2 + 1] = src[j * 2 + 1];
|
||||||
|
|
||||||
j = acc >> 17;
|
j >>= 1;
|
||||||
x = acc & 0x1ffff;
|
if (2 * (j + 1) < src_width) {
|
||||||
if (2 * j + 2 < src_width)
|
dest[i * 2 + 0] = BLEND (src[j * 4 + 0], src[j * 4 + 4], x);
|
||||||
dest[i * 4 + 0] =
|
dest[i * 2 + 2] = BLEND (src[j * 4 + 2], src[j * 4 + 6], x);
|
||||||
(src[j * 4 + 0] * (131072 - x) + src[j * 4 + 4] * x) >> 17;
|
} else {
|
||||||
else
|
dest[i * 2 + 0] = src[j * 4 + 0];
|
||||||
dest[i * 4 + 0] = src[j * 4 + 0];
|
dest[i * 2 + 2] = src[j * 4 + 2];
|
||||||
|
|
||||||
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
|
|
||||||
dest[i * 4 + 2] = src[j * 4 + 2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
acc += increment;
|
acc += increment;
|
||||||
|
|
||||||
|
if (i < n - 1) {
|
||||||
j = acc >> 16;
|
j = acc >> 16;
|
||||||
x = acc & 0xffff;
|
|
||||||
|
|
||||||
if (2 * i + 1 < n && j < src_width) {
|
if (j + 1 < src_width) {
|
||||||
if (j + 1 < src_width)
|
x = acc & 0xffff;
|
||||||
dest[i * 4 + 3] =
|
dest[i * 2 + 3] = BLEND (src[j * 2 + 1], src[j * 2 + 3], x);
|
||||||
(src[j * 2 + 1] * (65536 - x) + src[j * 2 + 3] * x) >> 16;
|
} else
|
||||||
else
|
dest[i * 2 + 3] = src[j * 2 + 1];
|
||||||
dest[i * 4 + 3] = src[j * 2 + 1];
|
|
||||||
acc += increment;
|
acc += increment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*accumulator = acc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue