video-format: handle odd width in more pack/unpack functions

This commit is contained in:
Wim Taymans 2013-09-06 12:42:47 +02:00
parent 2f6f0ee214
commit 26d04c7582

View file

@ -309,13 +309,12 @@ unpack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
int i;
const guint8 *s = GET_LINE (y);
guint16 *d = dest;
guint32 a0, a1, a2, a3;
guint16 y0, y1, y2, y3, y4, y5;
guint16 u0, u2, u4;
guint16 v0, v2, v4;
for (i = 0; i < width - 5; i += 6) {
guint32 a0, a1, a2, a3;
guint16 y0, y1, y2, y3, y4, y5;
guint16 u0, u2, u4;
guint16 v0, v2, v4;
for (i = 0; i < width; i += 6) {
a0 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 0);
a1 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 4);
a2 = GST_READ_UINT32_LE (s + (i / 6) * 16 + 8);
@ -358,30 +357,36 @@ unpack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
d[4 * (i + 0) + 2] = u0;
d[4 * (i + 0) + 3] = v0;
d[4 * (i + 1) + 0] = 0xffff;
d[4 * (i + 1) + 1] = y1;
d[4 * (i + 1) + 2] = u0;
d[4 * (i + 1) + 3] = v0;
d[4 * (i + 2) + 0] = 0xffff;
d[4 * (i + 2) + 1] = y2;
d[4 * (i + 2) + 2] = u2;
d[4 * (i + 2) + 3] = v2;
d[4 * (i + 3) + 0] = 0xffff;
d[4 * (i + 3) + 1] = y3;
d[4 * (i + 3) + 2] = u2;
d[4 * (i + 3) + 3] = v2;
d[4 * (i + 4) + 0] = 0xffff;
d[4 * (i + 4) + 1] = y4;
d[4 * (i + 4) + 2] = u4;
d[4 * (i + 4) + 3] = v4;
d[4 * (i + 5) + 0] = 0xffff;
d[4 * (i + 5) + 1] = y5;
d[4 * (i + 5) + 2] = u4;
d[4 * (i + 5) + 3] = v4;
if (i < width - 1) {
d[4 * (i + 1) + 0] = 0xffff;
d[4 * (i + 1) + 1] = y1;
d[4 * (i + 1) + 2] = u0;
d[4 * (i + 1) + 3] = v0;
}
if (i < width - 2) {
d[4 * (i + 2) + 0] = 0xffff;
d[4 * (i + 2) + 1] = y2;
d[4 * (i + 2) + 2] = u2;
d[4 * (i + 2) + 3] = v2;
}
if (i < width - 3) {
d[4 * (i + 3) + 0] = 0xffff;
d[4 * (i + 3) + 1] = y3;
d[4 * (i + 3) + 2] = u2;
d[4 * (i + 3) + 3] = v2;
}
if (i < width - 4) {
d[4 * (i + 4) + 0] = 0xffff;
d[4 * (i + 4) + 1] = y4;
d[4 * (i + 4) + 2] = u4;
d[4 * (i + 4) + 3] = v4;
}
if (i < width - 5) {
d[4 * (i + 5) + 0] = 0xffff;
d[4 * (i + 5) + 1] = y5;
d[4 * (i + 5) + 2] = u4;
d[4 * (i + 5) + 3] = v4;
}
}
}
@ -394,13 +399,12 @@ pack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
int i;
guint8 *d = GET_LINE (y);
const guint16 *s = src;
guint32 a0, a1, a2, a3;
guint16 y0, y1, y2, y3, y4, y5;
guint16 u0, u1, u2;
guint16 v0, v1, v2;
for (i = 0; i < width - 5; i += 6) {
guint32 a0, a1, a2, a3;
guint16 y0, y1, y2, y3, y4, y5;
guint16 u0, u1, u2;
guint16 v0, v1, v2;
y0 = s[4 * (i + 0) + 1] >> 6;
y1 = s[4 * (i + 1) + 1] >> 6;
y2 = s[4 * (i + 2) + 1] >> 6;
@ -421,6 +425,48 @@ pack_v210 (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
a2 = v1 | (y3 << 10) | (u2 << 20);
a3 = y4 | (v2 << 10) | (y5 << 20);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 0, a0);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 4, a1);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 8, a2);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 12, a3);
}
if (i < width) {
y0 = s[4 * (i + 0) + 1] >> 6;
u0 = s[4 * (i + 0) + 2] >> 6;
v0 = s[4 * (i + 0) + 3] >> 6;
if (i < width - 1)
y1 = s[4 * (i + 1) + 1] >> 6;
else
y1 = y0;
if (i < width - 2) {
y2 = s[4 * (i + 2) + 1] >> 6;
u1 = s[4 * (i + 2) + 2] >> 6;
v1 = s[4 * (i + 2) + 3] >> 6;
} else {
y2 = y1;
u1 = u0;
v1 = v0;
}
if (i < width - 3)
y3 = s[4 * (i + 3) + 1] >> 6;
else
y3 = y2;
if (i < width - 4) {
y4 = s[4 * (i + 4) + 1] >> 6;
u2 = s[4 * (i + 4) + 2] >> 6;
v2 = s[4 * (i + 4) + 3] >> 6;
} else {
y4 = y3;
u2 = u1;
v2 = v1;
}
y5 = y4;
a0 = u0 | (y0 << 10) | (v0 << 20);
a1 = y1 | (u1 << 10) | (y2 << 20);
a2 = v1 | (y3 << 10) | (u2 << 20);
a3 = y4 | (v2 << 10) | (y5 << 20);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 0, a0);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 4, a1);
GST_WRITE_UINT32_LE (d + (i / 6) * 16 + 8, a2);
@ -1157,7 +1203,7 @@ unpack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
const guint8 *s = GET_LINE (y);
guint16 *d = dest;
for (i = 0; i < width - 1; i += 2) {
for (i = 0; i < width; i += 2) {
guint16 y0, y1;
guint16 u0;
guint16 v0;
@ -1179,10 +1225,12 @@ unpack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
d[i * 4 + 2] = u0;
d[i * 4 + 3] = v0;
d[i * 4 + 4] = 0xffff;
d[i * 4 + 5] = y1;
d[i * 4 + 6] = u0;
d[i * 4 + 7] = v0;
if (i < width - 1) {
d[i * 4 + 4] = 0xffff;
d[i * 4 + 5] = y1;
d[i * 4 + 6] = u0;
d[i * 4 + 7] = v0;
}
}
}
@ -1202,7 +1250,10 @@ pack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
guint16 v0;
y0 = s[4 * (i + 0) + 1];
y1 = (i < width - 1 ? s[4 * (i + 1) + 1] : y0);
if (i < width - 1)
y1 = s[4 * (i + 1) + 1];
else
y1 = y0;
u0 = s[4 * (i + 0) + 2];
v0 = s[4 * (i + 0) + 3];