mpegtsdemux: Don't pretend doing NAL alignment
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 10 Oct 2018 18:36:57 +0000 (18:36 +0000)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 14 Apr 2020 15:36:16 +0000 (11:36 -0400)
Per specification in 2.14.2 "For PES packetization, no specific data
alignment constraints apply". So we should not advertise NAL
alignment.

This bug was introduced at the same moment the alignment field was introduced
10 years ago. The plan was that alignment=none (or no alignment field) was to
be used for mpegtsdemux, but no one noticed the error. The reason is that at
the same moment, everything dealing with H264 started defaulting to AU
alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=606662#c22

This patch will have a side effect that a parser is now needed after the
tsdemux element. The following pipeline will not negotiate anymore as the
mpegtsmux element requires alignment={nal,au}.

  ... ! tsdemux ! mpegtsmux ! ...

As a side effect, anyone that forked from tsdemux should updated their code to
fix this bug.

gst/mpegtsdemux/tsdemux.c

index 2863656ee86eb6477ca1646215bf425cb6d1c0cc..7193367c16b89b3f1bc66ae07f29fe982235ea1e 100644 (file)
@@ -230,10 +230,8 @@ struct _TSDemuxStream
     "video/mpeg, " \
       "mpegversion = (int) { 1, 2, 4 }, " \
       "systemstream = (boolean) FALSE; " \
-    "video/x-h264,stream-format=(string)byte-stream," \
-      "alignment=(string)nal;" \
-    "video/x-h265,stream-format=(string)byte-stream," \
-      "alignment=(string)nal;" \
+    "video/x-h264,stream-format=(string)byte-stream;" \
+    "video/x-h265,stream-format=(string)byte-stream;" \
     "video/x-dirac;" \
     "video/x-cavs;" \
     "video/x-wmv," \
@@ -1497,8 +1495,7 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
         case DRF_ID_HEVC:
           is_video = TRUE;
           caps = gst_caps_new_simple ("video/x-h265",
-              "stream-format", G_TYPE_STRING, "byte-stream",
-              "alignment", G_TYPE_STRING, "nal", NULL);
+              "stream-format", G_TYPE_STRING, "byte-stream", NULL);
           break;
         case DRF_ID_KLVA:
           sparse = TRUE;
@@ -1518,8 +1515,7 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
       if (program->program_number == 10510 && bstream->pid == 3401) {
         is_video = TRUE;
         caps = gst_caps_new_simple ("video/x-h264",
-            "stream-format", G_TYPE_STRING, "byte-stream",
-            "alignment", G_TYPE_STRING, "nal", NULL);
+            "stream-format", G_TYPE_STRING, "byte-stream", NULL);
       }
       break;
     case ST_HDV_AUX_V:
@@ -1560,14 +1556,12 @@ create_pad_for_stream (MpegTSBase * base, MpegTSBaseStream * bstream,
     case GST_MPEGTS_STREAM_TYPE_VIDEO_H264:
       is_video = TRUE;
       caps = gst_caps_new_simple ("video/x-h264",
-          "stream-format", G_TYPE_STRING, "byte-stream",
-          "alignment", G_TYPE_STRING, "nal", NULL);
+          "stream-format", G_TYPE_STRING, "byte-stream", NULL);
       break;
     case GST_MPEGTS_STREAM_TYPE_VIDEO_HEVC:
       is_video = TRUE;
       caps = gst_caps_new_simple ("video/x-h265",
-          "stream-format", G_TYPE_STRING, "byte-stream",
-          "alignment", G_TYPE_STRING, "nal", NULL);
+          "stream-format", G_TYPE_STRING, "byte-stream", NULL);
       break;
     case GST_MPEGTS_STREAM_TYPE_VIDEO_JP2K:
       is_video = TRUE;