cccombiner: fix scheduling with interlaced video buffers
authorMathieu Duponchelle <mathieu@centricular.com>
Thu, 15 Jul 2021 19:10:14 +0000 (21:10 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 30 Aug 2021 21:27:44 +0000 (21:27 +0000)
The initial code was written with the misunderstanding that
IS_TOP_FIELD indicated that an interlaced buffer contained
a top field, not that it contained only a top field

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2413>

ext/closedcaption/gstcccombiner.c

index d0bb23c..07d073e 100644 (file)
@@ -853,7 +853,7 @@ gst_cc_combiner_collect_captions (GstCCCombiner * self, gboolean timeout)
         /* Only relevant in alternate and mixed mode, no need to look at the caps */
         if (GST_BUFFER_FLAG_IS_SET (self->current_video_buffer,
                 GST_VIDEO_BUFFER_FLAG_INTERLACED)) {
-          if (GST_VIDEO_BUFFER_IS_TOP_FIELD (self->current_video_buffer)) {
+          if (!GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (self->current_video_buffer)) {
             dequeue_caption (self, tc, 0);
           }
         } else {
@@ -867,11 +867,12 @@ gst_cc_combiner_collect_captions (GstCCCombiner * self, gboolean timeout)
         if (self->progressive) {
           dequeue_caption (self, tc, 0);
         } else if (GST_BUFFER_FLAG_IS_SET (self->current_video_buffer,
-                GST_VIDEO_BUFFER_FLAG_INTERLACED)) {
+                GST_VIDEO_BUFFER_FLAG_INTERLACED) &&
+            GST_BUFFER_FLAG_IS_SET (self->current_video_buffer,
+                GST_VIDEO_BUFFER_FLAG_ONEFIELD)) {
           if (GST_VIDEO_BUFFER_IS_TOP_FIELD (self->current_video_buffer)) {
             dequeue_caption (self, tc, 0);
-          }
-          if (GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (self->current_video_buffer)) {
+          } else {
             dequeue_caption (self, tc, 1);
           }
         } else {
@@ -886,7 +887,7 @@ gst_cc_combiner_collect_captions (GstCCCombiner * self, gboolean timeout)
           dequeue_caption (self, tc, 0);
         } else if (GST_BUFFER_FLAG_IS_SET (self->current_video_buffer,
                 GST_VIDEO_BUFFER_FLAG_INTERLACED)) {
-          if (GST_VIDEO_BUFFER_IS_TOP_FIELD (self->current_video_buffer)) {
+          if (!GST_VIDEO_BUFFER_IS_BOTTOM_FIELD (self->current_video_buffer)) {
             dequeue_caption (self, tc, 0);
           }
         } else {