From 164b90f9d0fff9aae486e100ae81f70aae9520d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 28 Jul 2009 14:12:31 +0200 Subject: [PATCH] ffmpegcolorspace: Include interlacing information in the AVPicture This later allows to handle interlaced AVPicture different than progressive ones which is needed for horizontally subsampled YUV formats, see bug #589242. --- gst/ffmpegcolorspace/avcodec.h | 1 + gst/ffmpegcolorspace/gstffmpegcodecmap.c | 5 ++++- gst/ffmpegcolorspace/gstffmpegcodecmap.h | 3 ++- gst/ffmpegcolorspace/gstffmpegcolorspace.c | 9 +++++++-- gst/ffmpegcolorspace/gstffmpegcolorspace.h | 1 + gst/ffmpegcolorspace/imgconvert.c | 11 +++++++---- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gst/ffmpegcolorspace/avcodec.h b/gst/ffmpegcolorspace/avcodec.h index 8793cb8..651d4fa 100644 --- a/gst/ffmpegcolorspace/avcodec.h +++ b/gst/ffmpegcolorspace/avcodec.h @@ -190,6 +190,7 @@ typedef struct AVCodecContext { typedef struct AVPicture { uint8_t *data[4]; int linesize[4]; ///< number of bytes per line + int interlaced; } AVPicture; /** diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.c b/gst/ffmpegcolorspace/gstffmpegcodecmap.c index ea5db1d..0c06d1b 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.c +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.c @@ -801,7 +801,8 @@ gst_ffmpegcsp_caps_with_codectype (enum CodecType type, */ int gst_ffmpegcsp_avpicture_fill (AVPicture * picture, - uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height) + uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height, + int interlaced) { int size, w2, h2, size2; int stride, stride2; @@ -809,6 +810,8 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, pinfo = get_pix_fmt_info (pix_fmt); + picture->interlaced = interlaced; + switch (pix_fmt) { case PIX_FMT_YUV420P: case PIX_FMT_YUV422P: diff --git a/gst/ffmpegcolorspace/gstffmpegcodecmap.h b/gst/ffmpegcolorspace/gstffmpegcodecmap.h index 91b731e..515f530 100644 --- a/gst/ffmpegcolorspace/gstffmpegcodecmap.h +++ b/gst/ffmpegcolorspace/gstffmpegcodecmap.h @@ -51,7 +51,8 @@ gst_ffmpegcsp_avpicture_fill (AVPicture * picture, uint8_t * ptr, enum PixelFormat pix_fmt, int width, - int height); + int height, + int interlaced); #endif /* __GST_FFMPEG_CODECMAP_H__ */ diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.c b/gst/ffmpegcolorspace/gstffmpegcolorspace.c index 0b1ec10..2cd9737 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.c +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.c @@ -219,6 +219,9 @@ gst_ffmpegcsp_set_caps (GstBaseTransform * btrans, GstCaps * incaps, space->width = ctx->width = in_width; space->height = ctx->height = in_height; + space->interlaced = FALSE; + gst_structure_get_boolean (structure, "interlaced", &space->interlaced); + /* get from format */ ctx->pix_fmt = PIX_FMT_NB; gst_ffmpegcsp_caps_with_codectype (CODEC_TYPE_VIDEO, incaps, ctx); @@ -445,7 +448,8 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf, /* fill from with source data */ gst_ffmpegcsp_avpicture_fill (&space->from_frame, - GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height); + GST_BUFFER_DATA (inbuf), space->from_pixfmt, space->width, space->height, + space->interlaced); /* fill optional palette */ if (space->palette) @@ -453,7 +457,8 @@ gst_ffmpegcsp_transform (GstBaseTransform * btrans, GstBuffer * inbuf, /* fill target frame */ gst_ffmpegcsp_avpicture_fill (&space->to_frame, - GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height); + GST_BUFFER_DATA (outbuf), space->to_pixfmt, space->width, space->height, + space->interlaced); /* and convert */ result = img_convert (&space->to_frame, space->to_pixfmt, diff --git a/gst/ffmpegcolorspace/gstffmpegcolorspace.h b/gst/ffmpegcolorspace/gstffmpegcolorspace.h index 9c8918a..07950e3 100644 --- a/gst/ffmpegcolorspace/gstffmpegcolorspace.h +++ b/gst/ffmpegcolorspace/gstffmpegcolorspace.h @@ -46,6 +46,7 @@ struct _GstFFMpegCsp { GstBaseTransform element; gint width, height; + gboolean interlaced; gfloat fps; enum PixelFormat from_pixfmt, to_pixfmt; AVPicture from_frame, to_frame; diff --git a/gst/ffmpegcolorspace/imgconvert.c b/gst/ffmpegcolorspace/imgconvert.c index 1db8e59..b1aaa9f 100644 --- a/gst/ffmpegcolorspace/imgconvert.c +++ b/gst/ffmpegcolorspace/imgconvert.c @@ -565,7 +565,7 @@ avpicture_get_size (int pix_fmt, int width, int height) AVPicture dummy_pict; return gst_ffmpegcsp_avpicture_fill (&dummy_pict, NULL, pix_fmt, width, - height); + height, FALSE); } /** @@ -2908,7 +2908,8 @@ get_convert_table_entry (int src_pix_fmt, int dst_pix_fmt) } static int -avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height) +avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height, + int interlaced) { unsigned int size; void *ptr; @@ -2917,7 +2918,8 @@ avpicture_alloc (AVPicture * picture, int pix_fmt, int width, int height) ptr = av_malloc (size); if (!ptr) goto fail; - gst_ffmpegcsp_avpicture_fill (picture, ptr, pix_fmt, width, height); + gst_ffmpegcsp_avpicture_fill (picture, ptr, pix_fmt, width, height, + interlaced); return 0; fail: memset (picture, 0, sizeof (AVPicture)); @@ -3159,7 +3161,8 @@ no_chroma_filter: else int_pix_fmt = PIX_FMT_RGB24; } - if (avpicture_alloc (tmp, int_pix_fmt, dst_width, dst_height) < 0) + if (avpicture_alloc (tmp, int_pix_fmt, dst_width, dst_height, + dst->interlaced) < 0) return -1; ret = -1; if (img_convert (tmp, int_pix_fmt, -- 2.7.4