slomo gst-plugins-bad: gst-plugins-bad/ gst-plugins-bad/gst/mpegtsmux/ gst-plugins-bad/gst/mpegtsmux/tsmux/

[email protected] Mon, 5 Jan 2009 03:29:03 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
--===============8279047959789967709==

CVS Root:       /cvs/gstreamer
Module:         gst-plugins-bad
Changes by:     slomo
Date:           Mon Jan 05 2009  11:29:03 UTC

Log message:
Patch by: vanista <vanista at gmail dot com>
* gst/mpegtsmux/mpegtsmux.c: (mpegtsmux_create_stream):
* gst/mpegtsmux/tsmux/tsmux.c: (tsmux_write_pmt):
* gst/mpegtsmux/tsmux/tsmuxstream.c: (tsmux_stream_new),
(tsmux_stream_write_pes_header), (tsmux_stream_get_es_descrs):
* gst/mpegtsmux/tsmux/tsmuxstream.h:
Improve muxing of AC3/h264 streams a bit. Fixes bug #550613.

Modified files:
    .               : ChangeLog
    gst/mpegtsmux   : mpegtsmux.c
    gst/mpegtsmux/tsmux: tsmux.c tsmuxstream.c tsmuxstream.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3854&r2=1.3855
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mpegtsmux/mpegtsmux.c.diff?r1=1.5&r2=1.6
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c.diff?r1=1.3&r2=1.4
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c.diff?r1=1.3&r2=1.4
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h.diff?r1=1.2&r2=1.3

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3854
retrieving revision 1.3855
diff -u -d -r1.3854 -r1.3855
--- ChangeLog	5 Jan 2009 10:34:01 -0000	1.3854
+++ ChangeLog	5 Jan 2009 11:28:47 -0000	1.3855
@@ -1,5 +1,16 @@
 2009-01-05  Sebastian Dröge  <[email protected]>
 
+	Patch by: vanista <vanista at gmail dot com>
+
+	* gst/mpegtsmux/mpegtsmux.c: (mpegtsmux_create_stream):
+	* gst/mpegtsmux/tsmux/tsmux.c: (tsmux_write_pmt):
+	* gst/mpegtsmux/tsmux/tsmuxstream.c: (tsmux_stream_new),
+	(tsmux_stream_write_pes_header), (tsmux_stream_get_es_descrs):
+	* gst/mpegtsmux/tsmux/tsmuxstream.h:
+	Improve muxing of AC3/h264 streams a bit. Fixes bug #550613.
+2009-01-05  Sebastian Dröge  <[email protected]>
 	* gst/mxf/mxfdemux.c:
 	(gst_mxf_demux_handle_header_metadata_update_streams),
 	(gst_mxf_demux_pad_next_component):
Index: mpegtsmux.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/mpegtsmux.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mpegtsmux.c	24 Nov 2008 10:46:01 -0000	1.5
+++ mpegtsmux.c	5 Jan 2009 11:28:48 -0000	1.6
@@ -399,6 +399,10 @@
   }
   if (ts_data->stream != NULL) {
+    gst_structure_get_int (s, "rate", &ts_data->stream->audio_sampling);
+    gst_structure_get_int (s, "channels", &ts_data->stream->audio_channels);
+    gst_structure_get_int (s, "bitrate", &ts_data->stream->audio_bitrate);
     tsmux_stream_set_buffer_release_func (ts_data->stream, release_buffer_cb);
     tsmux_program_add_stream (mux->program, ts_data->stream);
Index: tsmux.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tsmux.c	2 Sep 2008 09:46:04 -0000	1.3
+++ tsmux.c	5 Jan 2009 11:28:49 -0000	1.4
@@ -1000,9 +1000,14 @@
     else
       tsmux_put16 (&pos, 0xE000 | tsmux_stream_get_pid (program->pcr_stream));
-    /* FIXME: Write program descriptors if needed, for now write a 
-     * length of 0 */
-    tsmux_put16 (&pos, 0xF000);
+    /* 4 bits reserved, 12 bits program_info_length, descriptor : HDMV */
+    tsmux_put16 (&pos, 0xF00C);
+    tsmux_put16 (&pos, 0x0504);
+    tsmux_put16 (&pos, 0x4844);
+    tsmux_put16 (&pos, 0x4D56);
+    tsmux_put16 (&pos, 0x8804);
+    tsmux_put16 (&pos, 0x0FFF);
+    tsmux_put16 (&pos, 0xFCFC);
     /* Write out the entries */
     for (i = 0; i < program->nb_streams; i++) {
Index: tsmuxstream.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.c,v
--- tsmuxstream.c	24 Nov 2008 10:46:01 -0000	1.3
+++ tsmuxstream.c	5 Jan 2009 11:28:49 -0000	1.4
@@ -157,7 +157,7 @@
           stream->id_extended = 0x80;
           break;
         case TSMUX_ST_PS_AUDIO_AC3:
-          stream->id_extended = 0x81;
+          stream->id_extended = 0x71;
         case TSMUX_ST_PS_AUDIO_DTS:
           stream->id_extended = 0x82;
@@ -559,7 +559,7 @@
       ext_len = 1;              /* Only writing 1 byte into the extended fields */
       *data++ = 0x80 | ext_len;
       /* Write the extended streamID */
-      *data++ = 0x80 | stream->id_extended;
+      *data++ = stream->id_extended;
     }
 }
@@ -631,9 +631,28 @@
    * PMT ES_info field */
   pos = buf;
+  /* tag (registration_descriptor), length, format_identifier */
   switch (stream->stream_type) {
+    case TSMUX_ST_AUDIO_AAC:
+      /* FIXME */
+      break;
+    case TSMUX_ST_VIDEO_MPEG4:
+    case TSMUX_ST_VIDEO_H264:
+      *pos++ = 0x05;
+      *pos++ = 8;
+      *pos++ = 0x48;            /* 'H' */
+      *pos++ = 0x44;            /* 'D' */
+      *pos++ = 0x4D;            /* 'M' */
+      *pos++ = 0x56;            /* 'V' */
+      /* FIXME : Not sure about this additional_identification_info */
+      *pos++ = 0xFF;
+      *pos++ = 0x1B;
+      *pos++ = 0x44;
+      *pos++ = 0x3F;
     case TSMUX_ST_VIDEO_DIRAC:
-      /* tag (registration_descriptor), length, format_identifier */
       *pos++ = 0x05;
       *pos++ = 4;
       *pos++ = 0x64;            /* 'd' */
@@ -641,6 +660,145 @@
       *pos++ = 0x61;            /* 'a' */
       *pos++ = 0x63;            /* 'c' */
       break;
+    case TSMUX_ST_PS_AUDIO_AC3:
+    {
+      *pos++ = 4;
+      *pos++ = 0x41;            /* 'A' */
+      *pos++ = 0x43;            /* 'C' */
+      *pos++ = 0x2D;            /* '-' */
+      *pos++ = 0x33;            /* '3' */
+      /* audio_stream_descriptor () | ATSC A/52-2001 Annex A
+       *
+       * descriptor_tag       8 uimsbf
+       * descriptor_length    8 uimsbf
+       * sample_rate_code     3 bslbf
+       * bsid                 5 bslbf
+       * bit_rate_code        6 bslbf
+       * surround_mode        2 bslbf
+       * bsmod                3 bslbf
+       * num_channels         4 bslbf
+       * full_svc             1 bslbf
+       * langcod              8 bslbf
+       * [...]
+       */
+      *pos++ = 0x81;
+      *pos++ = 0x04;
+      /* 3 bits sample_rate_code, 5 bits hardcoded bsid (default ver 8) */
+      switch (stream->audio_sampling) {
+        case 48000:
+          *pos++ = 0x08;
+          break;
+        case 44100:
+          *pos++ = 0x28;
+        case 32000:
+          *pos++ = 0x48;
+        default:
+          *pos++ = 0xE8;
+          break;                /* 48, 44.1 or 32 Khz */
+      }
+      /* 1 bit bit_rate_limit, 5 bits bit_rate_code, 2 bits suround_mode */
+      switch (stream->audio_bitrate) {
+        case 32:
+          *pos++ = 0x00 << 2;
+        case 40:
+          *pos++ = 0x01 << 2;
+        case 48:
+          *pos++ = 0x02 << 2;
+        case 56:
+          *pos++ = 0x03 << 2;
+        case 64:
+          *pos++ = 0x04 << 2;
+        case 80:
+          *pos++ = 0x05 << 2;
+        case 96:
+          *pos++ = 0x06 << 2;
+        case 112:
+          *pos++ = 0x07 << 2;
+        case 128:
+          *pos++ = 0x08 << 2;
+        case 160:
+          *pos++ = 0x09 << 2;
+        case 192:
+          *pos++ = 0x0A << 2;
+        case 224:
+          *pos++ = 0x0B << 2;
+        case 256:
+          *pos++ = 0x0C << 2;
+        case 320:
+          *pos++ = 0x0D << 2;
+        case 384:
+          *pos++ = 0x0E << 2;
+        case 448:
+          *pos++ = 0x0F << 2;
+        case 512:
+          *pos++ = 0x10 << 2;
+        case 576:
+          *pos++ = 0x11 << 2;
+        case 640:
+          *pos++ = 0x12 << 2;
+          *pos++ = 0x32 << 2;
+          break;                /* 640 Kb/s upper limit */
+      /* 3 bits bsmod, 4 bits num_channels, 1 bit full_svc */
+      switch (stream->audio_channels) {
+        case 1:
+          *pos++ = 0x01 << 1;
+          break;                /* 1/0 */
+        case 2:
+          *pos++ = 0x02 << 1;
+          break;                /* 2/0 */
+        case 3:
+          *pos++ = 0x0A << 1;
+          break;                /* <= 3 */
+        case 4:
+          *pos++ = 0x0B << 1;
+          break;                /* <= 4 */
+        case 5:
+          *pos++ = 0x0C << 1;
+          break;                /* <= 5 */
+        case 6:
+          *pos++ = 0x0D << 1;
+          break;                /* <= 6 */
+      *pos++ = 0x00;
+    }
+    case TSMUX_ST_PS_AUDIO_DTS:
+    case TSMUX_ST_PS_AUDIO_LPCM:
     default:
Index: tsmuxstream.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmuxstream.h,v
retrieving revision 1.2
diff -u -d -r1.2 -r1.3
--- tsmuxstream.h	1 Sep 2008 17:41:39 -0000	1.2
+++ tsmuxstream.h	5 Jan 2009 11:28:49 -0000	1.3
@@ -183,6 +183,10 @@
   gint   pcr_ref;
   gint64 last_pcr;
+  gint audio_sampling;
+  gint audio_channels;
+  gint audio_bitrate;
 };
 /* stream management */


--===============8279047959789967709==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------

--===============8279047959789967709==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose

--===============8279047959789967709==--