From 1469453cb95582c62cd48dde2c0b8e2c798b59a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 3 Nov 2010 10:35:35 +0100 Subject: [PATCH] ffmpegcolorspace: Fix IYU1 support Fix conversions to IYU1, they allocated infinite amounts of memory before because no conversion to IYU1 was actually implemented and it was running into an infinite loop trying to find suitable intermediate formats. Also fix the stride and sizes used for IYU1. --- gst/ffmpegcolorspace/gstffmpegcodecmap.c | 8 +++---- gst/ffmpegcolorspace/imgconvert.c | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.c b/gst/ffmpegcolorspace/gstffmpegcodecmap.c index bc885b1..318a90e 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.c +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.c @@ -958,14 +958,14 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, picture->linesize[0] = stride; return size; case PIX_FMT_UYVY411: - /* FIXME, probably not the right stride */ - stride = GST_ROUND_UP_4 (width); + stride = + GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) + GST_ROUND_UP_4 (width) / 2); size = stride * height; picture->data[0] = ptr; picture->data[1] = NULL; picture->data[2] = NULL; - picture->linesize[0] = width + width / 2; - return size + size / 2; + picture->linesize[0] = stride; + return size; case PIX_FMT_Y800: case PIX_FMT_GRAY8: stride = GST_ROUND_UP_4 (width); diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index 64ac475..cb145bb 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -1325,6 +1325,42 @@ uyvy411_to_yuv411p (AVPicture * dst, const AVPicture * src, } static void +yuv411p_to_uyvy411 (AVPicture * dst, const AVPicture * src, + int width, int height) +{ + uint8_t *p, *p1; + const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1; + int w; + + p1 = dst->data[0]; + lum1 = src->data[0]; + cb1 = src->data[1]; + cr1 = src->data[2]; + for (; height > 0; height--) { + p = p1; + lum = lum1; + cb = cb1; + cr = cr1; + for (w = width; w >= 4; w -= 4) { + p[0] = cb[0]; + p[1] = lum[0]; + p[2] = lum[1]; + p[3] = cr[0]; + p[4] = lum[2]; + p[5] = lum[3]; + p += 6; + lum += 4; + cb++; + cr++; + } + p1 += dst->linesize[0]; + lum1 += src->linesize[0]; + cb1 += src->linesize[1]; + cr1 += src->linesize[2]; + } +} + +static void yuv420p_to_yuv422 (AVPicture * dst, const AVPicture * src, int width, int height) { @@ -3437,6 +3473,7 @@ static ConvertEntry convert_table[] = { {PIX_FMT_PAL8, PIX_FMT_ABGR32, pal8_to_abgr32}, {PIX_FMT_UYVY411, PIX_FMT_YUV411P, uyvy411_to_yuv411p}, + {PIX_FMT_YUV411P, PIX_FMT_UYVY411, yuv411p_to_uyvy411}, {PIX_FMT_V308, PIX_FMT_RGB24, v308_to_rgb24}, -- 2.7.4