From c89562b61a13c95036bd661a988e4c6b9b2cfbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 12 Feb 2005 22:29:00 +0000 Subject: [PATCH] Convert to and from YV12 (fixes #156379) Original commit message from CVS: Convert to and from YV12 (fixes #156379) --- ChangeLog | 9 +++++++++ gst/ffmpegcolorspace/avcodec.h | 3 ++- gst/ffmpegcolorspace/gstffmpegcodecmap.c | 22 ++++++++++++++++++++++ gst/ffmpegcolorspace/imgconvert.c | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8552e72683..cd69df3776 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-02-12 Tim-Philipp Müller + + * gst/ffmpegcolorspace/avcodec.h: + * gst/ffmpegcolorspace/gstffmpegcodecmap.c: + (gst_ffmpeg_pixfmt_to_caps), (gst_ffmpeg_caps_to_pixfmt), + (gst_ffmpegcsp_avpicture_fill): + * gst/ffmpegcolorspace/imgconvert.c: + Convert to and from YV12 (fixes #156379). + 2005-02-12 Julien MOUTTE * sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new), diff --git a/gst/ffmpegcolorspace/avcodec.h b/gst/ffmpegcolorspace/avcodec.h index b6f94d7536..f9a39f9ac8 100644 --- a/gst/ffmpegcolorspace/avcodec.h +++ b/gst/ffmpegcolorspace/avcodec.h @@ -52,7 +52,8 @@ enum CodecType { * to run on the IBM VGA graphics adapter use 6-bit palette components. */ enum PixelFormat { - PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) + PIX_FMT_YUV420P, ///< Planar YUV 4:2:0 (1 Cr & Cb sample per 2x2 Y samples) (I420) + PIX_FMT_YVU420P, ///< Planar YUV 4:2:0 (1 Cb & Cr sample per 2x2 Y samples) (YV12) PIX_FMT_YUV422, ///< Packed pixel, Y0 Cb Y1 Cr PIX_FMT_RGB24, ///< Packed pixel, 3 bytes per pixel, RGBRGB... PIX_FMT_BGR24, ///< Packed pixel, 3 bytes per pixel, BGRBGR... diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.c b/gst/ffmpegcolorspace/gstffmpegcodecmap.c index 0b2fbed2ab..e0b91f66b1 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.c +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.c @@ -124,6 +124,9 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context) case PIX_FMT_YUV420P: fmt = GST_MAKE_FOURCC ('I', '4', '2', '0'); break; + case PIX_FMT_YVU420P: + fmt = GST_MAKE_FOURCC ('Y', 'V', '1', '2'); + break; case PIX_FMT_YUV422: fmt = GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'); break; @@ -461,6 +464,9 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps, case GST_MAKE_FOURCC ('I', '4', '2', '0'): context->pix_fmt = PIX_FMT_YUV420P; break; + case GST_MAKE_FOURCC ('Y', 'V', '1', '2'): + context->pix_fmt = PIX_FMT_YVU420P; + break; case GST_MAKE_FOURCC ('Y', '4', '1', 'B'): context->pix_fmt = PIX_FMT_YUV411P; break; @@ -622,6 +628,22 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, picture->linesize[1] = stride2; picture->linesize[2] = stride2; return size + 2 * size2; + /* PIX_FMT_YVU420P = YV12: same as PIX_FMT_YUV420P, but + * with U and V plane swapped. Strides as in videotestsrc */ + case PIX_FMT_YVU420P: + stride = ROUND_UP_4 (width); + h2 = ROUND_UP_2 (height); + size = stride * h2; + stride2 = ROUND_UP_8 (stride) / 2; + h2 = ROUND_UP_2 (height) / 2; + size2 = stride2 * h2; + picture->data[0] = ptr; + picture->data[2] = picture->data[0] + size; + picture->data[1] = picture->data[2] + size2; + picture->linesize[0] = stride; + picture->linesize[1] = ROUND_UP_8 (stride) / 2; + picture->linesize[2] = ROUND_UP_8 (stride) / 2; + return size + 2 * size2; case PIX_FMT_RGB24: case PIX_FMT_BGR24: stride = ROUND_UP_4 (width * 3); diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index 0dea17f703..64e7a11843 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -53,6 +53,17 @@ static PixFmtInfo pix_fmt_info[PIX_FMT_NB] = { /* .y_chroma_shift = */ 1, /* .depth = */ 8, }, + /* [PIX_FMT_YVU420P] = */ { + /* .format = */ PIX_FMT_YVU420P, + /* .name = */ "yvu420p", + /* .nb_channels = */ 3, + /* .color_type = */ FF_COLOR_YUV, + /* .pixel_type = */ FF_PIXEL_PLANAR, + /* .is_alpha = */ 0, + /* .x_chroma_shift = */ 1, + /* .y_chroma_shift = */ 1, + /* .depth = */ 8, + }, /* [PIX_FMT_YUV422P] = */ { /* .format = */ PIX_FMT_YUV422P, /* .name = */ "yuv422p",