video: add support for max-framerate
authorWim Taymans <wim.taymans@collabora.co.uk>
Fri, 11 Nov 2011 12:14:21 +0000 (13:14 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 11 Nov 2011 12:14:21 +0000 (13:14 +0100)
Add support for max-framerate in the video helpers and update the video
caps document.

docs/design/draft-media-types.txt
gst-libs/gst/video/video.c
gst-libs/gst/video/video.h

index 4b7c891..42cab2c 100644 (file)
@@ -12,6 +12,10 @@ Media Types
   framerate, GST_TYPE_FRACTION, default 0/1
     The framerate of the video 0/1 for variable framerate
 
+  max-framerate, GST_TYPE_FRACTION, default as framerate
+    For variable framerates this would be the maximum framerate that
+    is expected. This value is only valid when the framerate is 0/1
+
   pixel-aspect-ratio, GST_TYPE_FRACTION, default 1/1
     The pixel aspect ration of the video
 
index 247ed6f..1ec4d53 100644 (file)
@@ -826,9 +826,16 @@ gst_video_info_from_caps (GstVideoInfo * info, const GstCaps * caps)
   gst_video_info_set_format (info, format, width, height);
 
   if (gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) {
+    if (fps_n == 0) {
+      /* variable framerate */
+      info->flags |= GST_VIDEO_FLAG_VARIABLE_FPS;
+      /* see if we have a max-framerate */
+      gst_structure_get_fraction (structure, "max-framerate", &fps_n, &fps_d);
+    }
     info->fps_n = fps_n;
     info->fps_d = fps_d;
   } else {
+    /* unspecified is variable framerate */
     info->fps_n = 0;
     info->fps_d = 1;
   }
@@ -915,7 +922,6 @@ gst_video_info_to_caps (GstVideoInfo * info)
       "format", G_TYPE_STRING, format,
       "width", G_TYPE_INT, info->width,
       "height", G_TYPE_INT, info->height,
-      "framerate", GST_TYPE_FRACTION, info->fps_n, info->fps_d,
       "pixel-aspect-ratio", GST_TYPE_FRACTION, info->par_n, info->par_d, NULL);
 
   if (info->flags & GST_VIDEO_FLAG_INTERLACED)
@@ -930,6 +936,16 @@ gst_video_info_to_caps (GstVideoInfo * info)
   if (info->views > 1)
     gst_caps_set_simple (caps, "views", G_TYPE_INT, info->views, NULL);
 
+  if (info->flags & GST_VIDEO_FLAG_VARIABLE_FPS && info->fps_n != 0) {
+    /* variable fps with a max-framerate */
+    gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, 0, 1,
+        "max-framerate", GST_TYPE_FRACTION, info->fps_n, info->fps_d, NULL);
+  } else {
+    /* no variable fps or no max-framerate */
+    gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION,
+        info->fps_n, info->fps_d, NULL);
+  }
+
   return caps;
 }
 
index eb27a04..42a2024 100644 (file)
@@ -312,17 +312,20 @@ typedef struct _GstVideoFrame GstVideoFrame;
  * @GST_VIDEO_FLAG_ONEFIELD: one field
  * @GST_VIDEO_FLAG_TELECINE: telecine
  * @GST_VIDEO_FLAG_PROGRESSIVE: video is progressive
+ * @GST_VIDEO_FLAG_VARIABLE_FPS: a variable fps is selected, fps_n and fps_d
+ * denote the maximum fps of the video
  *
  * Extra video flags
  */
 typedef enum {
-  GST_VIDEO_FLAG_NONE        = 0,
-  GST_VIDEO_FLAG_INTERLACED  = (1 << 0),
-  GST_VIDEO_FLAG_TFF         = (1 << 1),
-  GST_VIDEO_FLAG_RFF         = (1 << 2),
-  GST_VIDEO_FLAG_ONEFIELD    = (1 << 3),
-  GST_VIDEO_FLAG_TELECINE    = (1 << 4),
-  GST_VIDEO_FLAG_PROGRESSIVE = (1 << 5)
+  GST_VIDEO_FLAG_NONE         = 0,
+  GST_VIDEO_FLAG_INTERLACED   = (1 << 0),
+  GST_VIDEO_FLAG_TFF          = (1 << 1),
+  GST_VIDEO_FLAG_RFF          = (1 << 2),
+  GST_VIDEO_FLAG_ONEFIELD     = (1 << 3),
+  GST_VIDEO_FLAG_TELECINE     = (1 << 4),
+  GST_VIDEO_FLAG_PROGRESSIVE  = (1 << 5),
+  GST_VIDEO_FLAG_VARIABLE_FPS = (1 << 6)
 } GstVideoFlags;
 
 /**