Convert to and from YV12 (fixes #156379)

Original commit message from CVS:
Convert to and from YV12 (fixes #156379)
This commit is contained in:
Tim-Philipp Müller 2005-02-12 22:29:00 +00:00
parent 4aa7bf75d6
commit c89562b61a
4 changed files with 44 additions and 1 deletions

View file

@ -1,3 +1,12 @@
2005-02-12 Tim-Philipp Müller <tim at centricular dot net>
* 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 <julien@moutte.net>
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),

View file

@ -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...

View file

@ -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);

View file

@ -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",