[libbluray-devel] PES header parsing for PES PRIVATE STREAM 2

hpi1 git at videolan.org
Mon Jun 17 11:39:22 CEST 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Jun 13 11:26:31 2013 +0300| [ba37e1432b28cbf0871988ab3a41b845ddb49753] | committer: hpi1

PES header parsing for PES PRIVATE STREAM 2

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=ba37e1432b28cbf0871988ab3a41b845ddb49753
---

 src/libbluray/decoders/m2ts_demux.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/libbluray/decoders/m2ts_demux.c b/src/libbluray/decoders/m2ts_demux.c
index b85e252..2cd38e2 100644
--- a/src/libbluray/decoders/m2ts_demux.c
+++ b/src/libbluray/decoders/m2ts_demux.c
@@ -85,16 +85,20 @@ static int _add_ts(PES_BUFFER *p, unsigned pusi, uint8_t *buf, unsigned len)
 
     if (pusi) {
         // Parse PES header
+        unsigned pes_pid    = buf[3];
         unsigned pes_length = buf[4] << 8 | buf[5];
-        unsigned pts_exists = buf[7] & 0x80;
-        unsigned dts_exists = buf[7] & 0x40;
-        unsigned hdr_len    = buf[8] + 9;
+        unsigned hdr_len    = 6;
 
         if (buf[0] || buf[1] || buf[2] != 1) {
             BD_DEBUG(DBG_DECODE, "invalid PES header (00 00 01)");
             return -1;
         }
 
+        if (pes_pid != 0xbf) {
+        unsigned pts_exists = buf[7] & 0x80;
+        unsigned dts_exists = buf[7] & 0x40;
+        hdr_len += buf[8] + 3;
+
         if (len < hdr_len) {
             BD_DEBUG(DBG_DECODE, "invalid BDAV TS (PES header not in single TS packet)\n");
             return -1;
@@ -106,6 +110,7 @@ static int _add_ts(PES_BUFFER *p, unsigned pusi, uint8_t *buf, unsigned len)
         if (dts_exists) {
             p->dts = _parse_timestamp(buf + 14);
         }
+        }
 
         buf += hdr_len;
         len -= hdr_len;



More information about the libbluray-devel mailing list