[vlc-commits] demux: ps: always shift 0xbd es id

Francois Cartegnie git at videolan.org
Sun Jul 9 14:51:30 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Jul  9 13:54:41 2017 +0200| [13a816fdeb968fd974c939f2b1203531d9fe6619] | committer: Francois Cartegnie

demux: ps: always shift 0xbd es id

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=13a816fdeb968fd974c939f2b1203531d9fe6619
---

 modules/demux/mpeg/ps.h | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/modules/demux/mpeg/ps.h b/modules/demux/mpeg/ps.h
index 90271b2c89..2e135d6362 100644
--- a/modules/demux/mpeg/ps.h
+++ b/modules/demux/mpeg/ps.h
@@ -320,22 +320,25 @@ static inline int ps_track_fill( ps_track_t *tk, ps_psm_t *p_psm,
 /* return the id of a PES (should be valid) */
 static inline int ps_pkt_id( block_t *p_pkt )
 {
-    if( p_pkt->p_buffer[3] == 0xbd &&
-        p_pkt->i_buffer >= 9 &&
-        p_pkt->i_buffer >= 9 + (size_t)p_pkt->p_buffer[8] )
+    if( p_pkt->p_buffer[3] == 0xbd )
     {
-        const unsigned i_start = 9 + p_pkt->p_buffer[8];
-        const uint8_t i_sub_id = p_pkt->p_buffer[i_start];
-
-        if( (i_sub_id & 0xfe) == 0xa0 &&
-            p_pkt->i_buffer >= i_start + 7 &&
-            ( p_pkt->p_buffer[i_start + 5] >=  0xc0 ||
-              p_pkt->p_buffer[i_start + 6] != 0x80 ) )
+        uint8_t i_sub_id = 0;
+        if( p_pkt->i_buffer >= 9 &&
+            p_pkt->i_buffer >= 9 + (size_t)p_pkt->p_buffer[8] )
         {
-            /* AOB LPCM/MLP extension
-             * XXX for MLP I think that the !=0x80 test is not good and
-             * will fail for some valid files */
-            return 0xa000 | (i_sub_id & 0x01);
+            const unsigned i_start = 9 + p_pkt->p_buffer[8];
+            i_sub_id = p_pkt->p_buffer[i_start];
+
+            if( (i_sub_id & 0xfe) == 0xa0 &&
+                p_pkt->i_buffer >= i_start + 7 &&
+                ( p_pkt->p_buffer[i_start + 5] >=  0xc0 ||
+                p_pkt->p_buffer[i_start + 6] != 0x80 ) )
+            {
+                /* AOB LPCM/MLP extension
+                * XXX for MLP I think that the !=0x80 test is not good and
+                * will fail for some valid files */
+                return 0xa000 | (i_sub_id & 0x01);
+            }
         }
 
         /* VOB extension */



More information about the vlc-commits mailing list