video-frame: Take TFF flag from the video info if it was set in there
authorSebastian Dröge <sebastian@centricular.com>
Fri, 16 Aug 2019 08:58:28 +0000 (11:58 +0300)
committerSebastian Dröge <slomo@coaxion.net>
Fri, 16 Aug 2019 09:00:28 +0000 (09:00 +0000)
The caps and thus the video info have preference. If the field order is
set in there then it applies to all frames.

This works around issues where the tff field order is only set in the
caps but not additionally in the buffer flags.

gst-libs/gst/video/video-frame.c

index cb385ce..6cef04a 100644 (file)
@@ -138,15 +138,21 @@ gst_video_frame_map_id (GstVideoFrame * frame, GstVideoInfo * info,
       if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_INTERLACED)) {
         frame->flags |= GST_VIDEO_FRAME_FLAG_INTERLACED;
       }
-    } else
+    } else {
       frame->flags |= GST_VIDEO_FRAME_FLAG_INTERLACED;
+    }
 
-    if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_TFF))
+    if (GST_VIDEO_INFO_FIELD_ORDER (info) ==
+        GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST) {
       frame->flags |= GST_VIDEO_FRAME_FLAG_TFF;
-    if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_RFF))
-      frame->flags |= GST_VIDEO_FRAME_FLAG_RFF;
-    if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_ONEFIELD))
-      frame->flags |= GST_VIDEO_FRAME_FLAG_ONEFIELD;
+    } else {
+      if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_TFF))
+        frame->flags |= GST_VIDEO_FRAME_FLAG_TFF;
+      if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_RFF))
+        frame->flags |= GST_VIDEO_FRAME_FLAG_RFF;
+      if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_ONEFIELD))
+        frame->flags |= GST_VIDEO_FRAME_FLAG_ONEFIELD;
+    }
   }
   return TRUE;