ffmpegcolorspace: Include interlacing information in the AVPicture
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 28 Jul 2009 12:12:31 +0000 (14:12 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 6 Aug 2009 04:43:32 +0000 (06:43 +0200)
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
gst/ffmpegcolorspace/gstffmpegcodecmap.c
gst/ffmpegcolorspace/gstffmpegcodecmap.h
gst/ffmpegcolorspace/gstffmpegcolorspace.c
gst/ffmpegcolorspace/gstffmpegcolorspace.h
gst/ffmpegcolorspace/imgconvert.c

index 8793cb83483dda6185c26b2d07d4ae1dba666f1f..651d4fa95f67dcf38fe3775bd82f77b756de59c9 100644 (file)
@@ -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;
 
 /**
index ea5db1d3be6d03997ae16ff236b77573b7eaf8bb..0c06d1b9bbadfad4e0def946f01946ad0400a10a 100644 (file)
@@ -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:
index 91b731e1e0a964697458fb4b563137850ea54673..515f530beef1da7f030d3e860d322a4b11b6a410 100644 (file)
@@ -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__ */
 
index 0b1ec10ba9b523c8e57e852c998e0ac72f093ee3..2cd9737e845607d1e16fd7f38b4e71087f96c23b 100644 (file)
@@ -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,
index 9c8918a71957d5ae2f1b3d36918dc1bb6f5dc7fe..07950e32f7ecda0378c891844a97fa1d25fea95b 100644 (file)
@@ -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;
index 1db8e594d4234fff55d0a241892705082bfc5532..b1aaa9ffa265fe0a277afc6836c01d18df9c4df8 100644 (file)
@@ -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,