mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
!colorspace: fix odd size problems
This commit is contained in:
parent
4eb4602746
commit
e2e6fdcb6b
3 changed files with 172 additions and 49 deletions
|
@ -257,7 +257,7 @@ AC_SUBST(EXIF_CFLAGS)
|
||||||
AM_CONDITIONAL(USE_EXIF, test "x$HAVE_EXIF" = "xyes")
|
AM_CONDITIONAL(USE_EXIF, test "x$HAVE_EXIF" = "xyes")
|
||||||
|
|
||||||
dnl Orc
|
dnl Orc
|
||||||
ORC_CHECK([0.4.11])
|
ORC_CHECK([0.4.16])
|
||||||
|
|
||||||
dnl set license and copyright notice
|
dnl set license and copyright notice
|
||||||
GST_LICENSE="LGPL"
|
GST_LICENSE="LGPL"
|
||||||
|
|
|
@ -1870,8 +1870,9 @@ convert_I420_YUY2 (ColorspaceConvert * convert, guint8 * dest,
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_I420 (convert, convert->tmpline, src, convert->height - 1);
|
cogorc_convert_I420_YUY2 (FRAME_GET_LINE (dest, 0, i), convert->tmpline, FRAME_GET_LINE (src, 0, i), FRAME_GET_LINE (src, 0, i), /* note i, not i+1 */
|
||||||
putline_YUY2 (convert, dest, convert->tmpline, convert->height - 1);
|
FRAME_GET_LINE (src, 1, i >> 1),
|
||||||
|
FRAME_GET_LINE (src, 2, i >> 1), (convert->width + 1) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1892,8 +1893,9 @@ convert_I420_UYVY (ColorspaceConvert * convert, guint8 * dest,
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_I420 (convert, convert->tmpline, src, convert->height - 1);
|
cogorc_convert_I420_UYVY (FRAME_GET_LINE (dest, 0, i), convert->tmpline, FRAME_GET_LINE (src, 0, i), FRAME_GET_LINE (src, 0, i), /* note i, not i+1 */
|
||||||
putline_UYVY (convert, dest, convert->tmpline, convert->height - 1);
|
FRAME_GET_LINE (src, 1, i >> 1),
|
||||||
|
FRAME_GET_LINE (src, 2, i >> 1), (convert->width + 1) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1914,8 +1916,9 @@ convert_I420_AYUV (ColorspaceConvert * convert, guint8 * dest,
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_I420 (convert, convert->tmpline, src, convert->height - 1);
|
cogorc_convert_I420_AYUV (FRAME_GET_LINE (dest, 0, i), convert->tmpline, FRAME_GET_LINE (src, 0, i), FRAME_GET_LINE (src, 0, i), /* note i, not i+1 */
|
||||||
putline_AYUV (convert, dest, convert->tmpline, convert->height - 1);
|
FRAME_GET_LINE (src, 1, i >> 1),
|
||||||
|
FRAME_GET_LINE (src, 2, i >> 1), convert->width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1949,17 +1952,43 @@ convert_I420_Y444 (ColorspaceConvert * convert, guint8 * dest,
|
||||||
cogorc_planar_chroma_420_444 (FRAME_GET_LINE (dest, 1, 0),
|
cogorc_planar_chroma_420_444 (FRAME_GET_LINE (dest, 1, 0),
|
||||||
2 * convert->dest_stride[1], FRAME_GET_LINE (dest, 1, 1),
|
2 * convert->dest_stride[1], FRAME_GET_LINE (dest, 1, 1),
|
||||||
2 * convert->dest_stride[1], FRAME_GET_LINE (src, 1, 0),
|
2 * convert->dest_stride[1], FRAME_GET_LINE (src, 1, 0),
|
||||||
convert->src_stride[1], (convert->width + 1) / 2, convert->height / 2);
|
convert->src_stride[1], convert->width / 2, convert->height / 2);
|
||||||
|
|
||||||
cogorc_planar_chroma_420_444 (FRAME_GET_LINE (dest, 2, 0),
|
cogorc_planar_chroma_420_444 (FRAME_GET_LINE (dest, 2, 0),
|
||||||
2 * convert->dest_stride[2], FRAME_GET_LINE (dest, 2, 1),
|
2 * convert->dest_stride[2], FRAME_GET_LINE (dest, 2, 1),
|
||||||
2 * convert->dest_stride[2], FRAME_GET_LINE (src, 2, 0),
|
2 * convert->dest_stride[2], FRAME_GET_LINE (src, 2, 0),
|
||||||
convert->src_stride[2], (convert->width + 1) / 2, convert->height / 2);
|
convert->src_stride[2], convert->width / 2, convert->height / 2);
|
||||||
|
|
||||||
|
/* now handle last column */
|
||||||
|
if (convert->width & 1) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < convert->height; i++) {
|
||||||
|
guint8 *d;
|
||||||
|
const guint8 *s;
|
||||||
|
d = FRAME_GET_LINE (dest, 1, i);
|
||||||
|
s = FRAME_GET_LINE (src, 1, i / 2);
|
||||||
|
*d = *s;
|
||||||
|
d = FRAME_GET_LINE (dest, 2, i);
|
||||||
|
s = FRAME_GET_LINE (src, 2, i / 2);
|
||||||
|
*d = *s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_I420 (convert, convert->tmpline, src, convert->height - 1);
|
int i;
|
||||||
putline_Y444 (convert, dest, convert->tmpline, convert->height - 1);
|
guint8 *d;
|
||||||
|
const guint8 *s;
|
||||||
|
d = FRAME_GET_LINE (dest, 1, convert->height - 1);
|
||||||
|
s = FRAME_GET_LINE (src, 1, (convert->height - 1) / 2);
|
||||||
|
for (i = 0; i < convert->width; i++) {
|
||||||
|
d[i] = s[i / 2];
|
||||||
|
}
|
||||||
|
d = FRAME_GET_LINE (dest, 2, convert->height - 1);
|
||||||
|
s = FRAME_GET_LINE (src, 2, (convert->height - 1) / 2);
|
||||||
|
for (i = 0; i < convert->width; i++) {
|
||||||
|
d[i] = s[i / 2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1983,9 +2012,13 @@ convert_YUY2_I420 (ColorspaceConvert * convert, guint8 * dest,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->width & 1) {
|
||||||
getline_YUY2 (convert, convert->tmpline, src, convert->height - 1);
|
cogorc_convert_YUY2_I420 (FRAME_GET_LINE (dest, 0, i),
|
||||||
putline_I420 (convert, dest, convert->tmpline, convert->height - 1);
|
convert->tmpline,
|
||||||
|
FRAME_GET_LINE (dest, 1, i >> 1),
|
||||||
|
FRAME_GET_LINE (dest, 2, i >> 1),
|
||||||
|
FRAME_GET_LINE (src, 0, i),
|
||||||
|
FRAME_GET_LINE (src, 0, i), (convert->width + 1) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1995,13 +2028,23 @@ convert_YUY2_AYUV (ColorspaceConvert * convert, guint8 * dest,
|
||||||
{
|
{
|
||||||
cogorc_convert_YUY2_AYUV (FRAME_GET_LINE (dest, 0, 0),
|
cogorc_convert_YUY2_AYUV (FRAME_GET_LINE (dest, 0, 0),
|
||||||
convert->dest_stride[0], FRAME_GET_LINE (src, 0, 0),
|
convert->dest_stride[0], FRAME_GET_LINE (src, 0, 0),
|
||||||
convert->src_stride[0], (convert->width + 1) / 2,
|
convert->src_stride[0], convert->width / 2, convert->height);
|
||||||
convert->height & 1 ? convert->height - 1 : convert->height);
|
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last column */
|
||||||
if (convert->height & 1) {
|
if (convert->width & 1) {
|
||||||
getline_YUY2 (convert, convert->tmpline, src, convert->height - 1);
|
int i;
|
||||||
putline_AYUV (convert, dest, convert->tmpline, convert->height - 1);
|
for (i = 0; i < convert->height; i++) {
|
||||||
|
guint8 *d;
|
||||||
|
const guint8 *s;
|
||||||
|
d = FRAME_GET_LINE (dest, 0, i);
|
||||||
|
s = FRAME_GET_LINE (src, 0, i);
|
||||||
|
d += (convert->width - 1) * 4;
|
||||||
|
s += (convert->width / 2 - 1) * 4;
|
||||||
|
d[0] = 0xff;
|
||||||
|
d[1] = s[0];
|
||||||
|
d[2] = s[1];
|
||||||
|
d[3] = s[3];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2045,8 +2088,12 @@ convert_UYVY_I420 (ColorspaceConvert * convert, guint8 * dest,
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_UYVY (convert, convert->tmpline, src, convert->height - 1);
|
cogorc_convert_UYVY_I420 (FRAME_GET_LINE (dest, 0, i),
|
||||||
putline_I420 (convert, dest, convert->tmpline, convert->height - 1);
|
convert->tmpline,
|
||||||
|
FRAME_GET_LINE (dest, 1, i >> 1),
|
||||||
|
FRAME_GET_LINE (dest, 2, i >> 1),
|
||||||
|
FRAME_GET_LINE (src, 0, i),
|
||||||
|
FRAME_GET_LINE (src, 0, i), (convert->width + 1) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2056,13 +2103,24 @@ convert_UYVY_AYUV (ColorspaceConvert * convert, guint8 * dest,
|
||||||
{
|
{
|
||||||
cogorc_convert_UYVY_AYUV (FRAME_GET_LINE (dest, 0, 0),
|
cogorc_convert_UYVY_AYUV (FRAME_GET_LINE (dest, 0, 0),
|
||||||
convert->dest_stride[0], FRAME_GET_LINE (src, 0, 0),
|
convert->dest_stride[0], FRAME_GET_LINE (src, 0, 0),
|
||||||
convert->src_stride[0], (convert->width + 1) / 2,
|
convert->src_stride[0], convert->width / 2,
|
||||||
convert->height & 1 ? convert->height - 1 : convert->height);
|
convert->width & 1 ? convert->height - 1 : convert->height);
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last column */
|
||||||
if (convert->height & 1) {
|
if (convert->width & 1) {
|
||||||
getline_UYVY (convert, convert->tmpline, src, convert->height - 1);
|
int i;
|
||||||
putline_AYUV (convert, dest, convert->tmpline, convert->height - 1);
|
for (i = 0; i < convert->height; i++) {
|
||||||
|
guint8 *d;
|
||||||
|
const guint8 *s;
|
||||||
|
d = FRAME_GET_LINE (dest, 0, i);
|
||||||
|
s = FRAME_GET_LINE (src, 0, i);
|
||||||
|
d += (convert->width - 1) * 4;
|
||||||
|
s += (convert->width / 2 - 1) * 4;
|
||||||
|
d[0] = 0xff;
|
||||||
|
d[1] = s[1];
|
||||||
|
d[2] = s[0];
|
||||||
|
d[3] = s[2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2136,13 +2194,29 @@ convert_AYUV_Y42B (ColorspaceConvert * convert, guint8 * dest,
|
||||||
convert->dest_stride[0], FRAME_GET_LINE (dest, 1, 0),
|
convert->dest_stride[0], FRAME_GET_LINE (dest, 1, 0),
|
||||||
convert->dest_stride[1], FRAME_GET_LINE (dest, 2, 0),
|
convert->dest_stride[1], FRAME_GET_LINE (dest, 2, 0),
|
||||||
convert->dest_stride[2], FRAME_GET_LINE (src, 0, 0),
|
convert->dest_stride[2], FRAME_GET_LINE (src, 0, 0),
|
||||||
convert->src_stride[0], (convert->width + 1) / 2,
|
convert->src_stride[0], convert->width / 2, convert->height);
|
||||||
convert->height & 1 ? convert->height - 1 : convert->height);
|
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last column */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_AYUV (convert, convert->tmpline, src, convert->height - 1);
|
int i;
|
||||||
putline_Y42B (convert, dest, convert->tmpline, convert->height - 1);
|
for (i = 0; i < convert->height; i++) {
|
||||||
|
guint8 *d;
|
||||||
|
const guint8 *s;
|
||||||
|
s = FRAME_GET_LINE (src, 0, i);
|
||||||
|
s += (convert->width - 1) * 4;
|
||||||
|
|
||||||
|
d = FRAME_GET_LINE (dest, 0, i);
|
||||||
|
d += convert->width - 1;
|
||||||
|
d[0] = s[1];
|
||||||
|
|
||||||
|
d = FRAME_GET_LINE (dest, 1, i);
|
||||||
|
d += convert->width / 2 - 1;
|
||||||
|
d[0] = s[2];
|
||||||
|
|
||||||
|
d = FRAME_GET_LINE (dest, 2, i);
|
||||||
|
d += convert->width / 2 - 1;
|
||||||
|
d[0] = s[3];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2169,19 +2243,38 @@ convert_Y42B_I420 (ColorspaceConvert * convert, guint8 * dest,
|
||||||
cogorc_planar_chroma_422_420 (FRAME_GET_LINE (dest, 1, 0),
|
cogorc_planar_chroma_422_420 (FRAME_GET_LINE (dest, 1, 0),
|
||||||
convert->dest_stride[1], FRAME_GET_LINE (src, 1, 0),
|
convert->dest_stride[1], FRAME_GET_LINE (src, 1, 0),
|
||||||
2 * convert->src_stride[1], FRAME_GET_LINE (src, 1, 1),
|
2 * convert->src_stride[1], FRAME_GET_LINE (src, 1, 1),
|
||||||
2 * convert->src_stride[1], (convert->width + 1) / 2,
|
2 * convert->src_stride[1], convert->width / 2,
|
||||||
convert->height / 2);
|
(convert->height + 1) / 2);
|
||||||
|
|
||||||
cogorc_planar_chroma_422_420 (FRAME_GET_LINE (dest, 2, 0),
|
cogorc_planar_chroma_422_420 (FRAME_GET_LINE (dest, 2, 0),
|
||||||
convert->dest_stride[2], FRAME_GET_LINE (src, 2, 0),
|
convert->dest_stride[2], FRAME_GET_LINE (src, 2, 0),
|
||||||
2 * convert->src_stride[2], FRAME_GET_LINE (src, 2, 1),
|
2 * convert->src_stride[2], FRAME_GET_LINE (src, 2, 1),
|
||||||
2 * convert->src_stride[2], (convert->width + 1) / 2,
|
2 * convert->src_stride[2], convert->width / 2,
|
||||||
convert->height / 2);
|
(convert->height + 1) / 2);
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last column */
|
||||||
if (convert->height & 1) {
|
if (convert->width & 1) {
|
||||||
getline_Y42B (convert, convert->tmpline, src, convert->height - 1);
|
int i;
|
||||||
putline_I420 (convert, dest, convert->tmpline, convert->height - 1);
|
for (i = 0; i < (convert->height + 1) / 2; i++) {
|
||||||
|
guint8 *d;
|
||||||
|
const guint8 *s1, *s2;
|
||||||
|
|
||||||
|
s1 = FRAME_GET_LINE (src, 1, i * 2);
|
||||||
|
s2 = FRAME_GET_LINE (src, 1, i * 2 + 1);
|
||||||
|
d = FRAME_GET_LINE (dest, 1, i);
|
||||||
|
s1 += convert->width / 2;
|
||||||
|
s2 += convert->width / 2;
|
||||||
|
d += convert->width / 2;
|
||||||
|
d[0] = (s1[0] + s2[0] + 1) / 2;
|
||||||
|
|
||||||
|
s1 = FRAME_GET_LINE (src, 2, i * 2);
|
||||||
|
s2 = FRAME_GET_LINE (src, 2, i * 2 + 1);
|
||||||
|
d = FRAME_GET_LINE (dest, 2, i);
|
||||||
|
s1 += convert->width / 2;
|
||||||
|
s2 += convert->width / 2;
|
||||||
|
d += convert->width / 2;
|
||||||
|
d[0] = (s1[0] + s2[0] + 1) / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2247,19 +2340,49 @@ convert_Y444_I420 (ColorspaceConvert * convert, guint8 * dest,
|
||||||
cogorc_planar_chroma_444_420 (FRAME_GET_LINE (dest, 1, 0),
|
cogorc_planar_chroma_444_420 (FRAME_GET_LINE (dest, 1, 0),
|
||||||
convert->dest_stride[1], FRAME_GET_LINE (src, 1, 0),
|
convert->dest_stride[1], FRAME_GET_LINE (src, 1, 0),
|
||||||
2 * convert->src_stride[1], FRAME_GET_LINE (src, 1, 1),
|
2 * convert->src_stride[1], FRAME_GET_LINE (src, 1, 1),
|
||||||
2 * convert->src_stride[1], (convert->width + 1) / 2,
|
2 * convert->src_stride[1], convert->width / 2, convert->height / 2);
|
||||||
convert->height / 2);
|
|
||||||
|
|
||||||
cogorc_planar_chroma_444_420 (FRAME_GET_LINE (dest, 2, 0),
|
cogorc_planar_chroma_444_420 (FRAME_GET_LINE (dest, 2, 0),
|
||||||
convert->dest_stride[2], FRAME_GET_LINE (src, 2, 0),
|
convert->dest_stride[2], FRAME_GET_LINE (src, 2, 0),
|
||||||
2 * convert->src_stride[2], FRAME_GET_LINE (src, 2, 1),
|
2 * convert->src_stride[2], FRAME_GET_LINE (src, 2, 1),
|
||||||
2 * convert->src_stride[2], (convert->width + 1) / 2,
|
2 * convert->src_stride[2], convert->width / 2, convert->height / 2);
|
||||||
convert->height / 2);
|
|
||||||
|
/* now handle last column */
|
||||||
|
if (convert->width & 1) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < (convert->height + 1) / 2; i++) {
|
||||||
|
guint8 *d;
|
||||||
|
const guint8 *s1, *s2;
|
||||||
|
|
||||||
|
s1 = FRAME_GET_LINE (src, 1, i * 2);
|
||||||
|
s2 = FRAME_GET_LINE (src, 1, i * 2 + 1);
|
||||||
|
d = FRAME_GET_LINE (dest, 1, i);
|
||||||
|
s1 += convert->width / 2;
|
||||||
|
s2 += convert->width / 2;
|
||||||
|
d += convert->width / 2;
|
||||||
|
d[0] = (s1[0] + s2[0] + 1) / 2;
|
||||||
|
|
||||||
|
s1 = FRAME_GET_LINE (src, 2, i * 2);
|
||||||
|
s2 = FRAME_GET_LINE (src, 2, i * 2 + 1);
|
||||||
|
d = FRAME_GET_LINE (dest, 2, i);
|
||||||
|
s1 += convert->width / 2;
|
||||||
|
s2 += convert->width / 2;
|
||||||
|
d += convert->width / 2;
|
||||||
|
d[0] = (s1[0] + s2[0] + 1) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* now handle last line */
|
/* now handle last line */
|
||||||
if (convert->height & 1) {
|
if (convert->height & 1) {
|
||||||
getline_Y444 (convert, convert->tmpline, src, convert->height - 1);
|
int i;
|
||||||
putline_I420 (convert, dest, convert->tmpline, convert->height - 1);
|
guint8 *d;
|
||||||
|
const guint8 *s;
|
||||||
|
s = FRAME_GET_LINE (src, 1, convert->height - 1);
|
||||||
|
d = FRAME_GET_LINE (dest, 1, convert->height / 2);
|
||||||
|
for (i = 0; i < convert->width / 2; i++) {
|
||||||
|
d[i] = (s[i * 2] + s[i * 2 + 1] + 1) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -616,7 +616,7 @@ avgub d, s1, s2
|
||||||
|
|
||||||
.function cogorc_convert_YUY2_AYUV
|
.function cogorc_convert_YUY2_AYUV
|
||||||
.flags 2d
|
.flags 2d
|
||||||
.dest 8 ayuv guint8
|
.dest 8 ayuv align 4 guint8
|
||||||
.source 4 yuy2 guint8
|
.source 4 yuy2 guint8
|
||||||
.const 2 c255 0xff
|
.const 2 c255 0xff
|
||||||
.temp 2 yy
|
.temp 2 yy
|
||||||
|
@ -632,7 +632,7 @@ x2 mergewl ayuv, ayay, uvuv
|
||||||
|
|
||||||
.function cogorc_convert_UYVY_AYUV
|
.function cogorc_convert_UYVY_AYUV
|
||||||
.flags 2d
|
.flags 2d
|
||||||
.dest 8 ayuv guint8
|
.dest 8 ayuv align 4 guint8
|
||||||
.source 4 uyvy guint8
|
.source 4 uyvy guint8
|
||||||
.const 2 c255 0xff
|
.const 2 c255 0xff
|
||||||
.temp 2 yy
|
.temp 2 yy
|
||||||
|
|
Loading…
Reference in a new issue