[vlc-commits] demux: ts: flag blocks on pes scrambling

Francois Cartegnie git at videolan.org
Fri Jul 15 13:16:24 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Jul 15 13:13:33 2016 +0200| [e237192508a9c5bcea59ff9cb23b7cc9a73ef671] | committer: Francois Cartegnie

demux: ts: flag blocks on pes scrambling

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

 modules/demux/mpeg/pes.h |   11 ++++++++++-
 modules/demux/mpeg/ps.h  |    6 +++++-
 modules/demux/mpeg/ts.c  |   11 +++++++----
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/modules/demux/mpeg/pes.h b/modules/demux/mpeg/pes.h
index 1decfc0..1e024bc 100644
--- a/modules/demux/mpeg/pes.h
+++ b/modules/demux/mpeg/pes.h
@@ -43,7 +43,7 @@ static inline mtime_t ExtractMPEG1PESTimestamp( const uint8_t *p_data )
 inline
 static int ParsePESHeader( vlc_object_t *p_object, const uint8_t *p_header, size_t i_header,
                            unsigned *pi_skip, mtime_t *pi_dts, mtime_t *pi_pts,
-                           uint8_t *pi_stream_id )
+                           uint8_t *pi_stream_id, bool *pb_pes_scambling )
 {
     unsigned i_skip;
 
@@ -63,6 +63,8 @@ static int ParsePESHeader( vlc_object_t *p_object, const uint8_t *p_header, size
     case 0xF2:  /* DSMCC stream */
     case 0xF8:  /* ITU-T H.222.1 type E stream */
         i_skip = 6;
+        if( pb_pes_scambling )
+            *pb_pes_scambling = false;
         break;
     default:
         if( ( p_header[6]&0xC0 ) == 0x80 )
@@ -70,6 +72,9 @@ static int ParsePESHeader( vlc_object_t *p_object, const uint8_t *p_header, size
             /* mpeg2 PES */
             i_skip = p_header[8] + 9;
 
+            if( pb_pes_scambling )
+                *pb_pes_scambling = p_header[6]&0x30;
+
             if( p_header[7]&0x80 )    /* has pts */
             {
                 if( i_header < 9 + 5 )
@@ -87,6 +92,10 @@ static int ParsePESHeader( vlc_object_t *p_object, const uint8_t *p_header, size
         else
         {
             i_skip = 6;
+
+            if( pb_pes_scambling )
+                *pb_pes_scambling = false;
+
             if( i_header < i_skip + 1 )
                 return VLC_EGENERIC;
             while( i_skip < 23 && p_header[i_skip] == 0xff )
diff --git a/modules/demux/mpeg/ps.h b/modules/demux/mpeg/ps.h
index ceb1244..ad65733 100644
--- a/modules/demux/mpeg/ps.h
+++ b/modules/demux/mpeg/ps.h
@@ -423,11 +423,15 @@ static inline int ps_pkt_parse_pes( vlc_object_t *p_object, block_t *p_pes, int
     mtime_t i_pts = -1;
     mtime_t i_dts = -1;
     uint8_t i_stream_id = 0;
+    bool b_pes_scrambling = false;
 
     if( ParsePESHeader( p_object, p_pes->p_buffer, p_pes->i_buffer,
-                        &i_skip, &i_dts, &i_pts, &i_stream_id ) != VLC_SUCCESS )
+                        &i_skip, &i_dts, &i_pts, &i_stream_id, &b_pes_scrambling ) != VLC_SUCCESS )
         return VLC_EGENERIC;
 
+    if( b_pes_scrambling )
+        p_pes->i_flags |= BLOCK_FLAG_SCRAMBLED;
+
     if( i_skip_extra >= 0 )
         i_skip += i_skip_extra;
     else if( p_pes->i_buffer > i_skip + 3 &&
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index 3cda63f..aed4edd 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -1228,6 +1228,7 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
     mtime_t i_pts = -1;
     mtime_t i_length = 0;
     uint8_t i_stream_id;
+    bool b_pes_scrambling = false;
     const es_mpeg4_descriptor_t *p_mpeg4desc = NULL;
 
     assert(pid->type == TYPE_PES);
@@ -1262,7 +1263,7 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
     ts_pes_es_t *p_es = pid->u.p_pes->p_es;
 
     if( ParsePESHeader( VLC_OBJECT(p_demux), (uint8_t*)&header, i_max, &i_skip,
-                        &i_dts, &i_pts, &i_stream_id ) == VLC_EGENERIC )
+                        &i_dts, &i_pts, &i_stream_id, &b_pes_scrambling ) == VLC_EGENERIC )
     {
         block_ChainRelease( p_pes );
         return;
@@ -1273,6 +1274,8 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
             i_pts = TimeStampWrapAround( p_es->p_program->pcr.i_first, i_pts );
         if( i_dts != -1 && p_es->p_program )
             i_dts = TimeStampWrapAround( p_es->p_program->pcr.i_first, i_dts );
+        if( b_pes_scrambling )
+            p_pes->i_flags |= BLOCK_FLAG_SCRAMBLED;
     }
 
     if( p_es->i_sl_es_id )
@@ -1829,7 +1832,7 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
                     uint8_t i_stream_id;
                     if ( VLC_SUCCESS == ParsePESHeader( VLC_OBJECT(p_demux), &p_pkt->p_buffer[i_skip],
                                                         p_pkt->i_buffer - i_skip, &i_skip,
-                                                        &i_dts, &i_pts, &i_stream_id ) )
+                                                        &i_dts, &i_pts, &i_stream_id, NULL ) )
                     {
                         if( i_dts > -1 )
                             i_pcr = i_dts;
@@ -1911,7 +1914,7 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_
 
                 if ( VLC_SUCCESS == ParsePESHeader( VLC_OBJECT(p_demux), &p_pkt->p_buffer[i_skip],
                                                     p_pkt->i_buffer - i_skip, &i_skip,
-                                                    &i_dts, &i_pts, &i_stream_id ) )
+                                                    &i_dts, &i_pts, &i_stream_id, NULL ) )
                 {
                     if( i_dts != -1 )
                         *pi_pcr = i_dts;
@@ -2121,7 +2124,7 @@ static void PCRCheckDTS( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr)
         uint8_t i_stream_id;
 
         if( ParsePESHeader( VLC_OBJECT(p_demux), (uint8_t*)&header, i_max, &i_skip,
-                            &i_dts, &i_pts, &i_stream_id ) == VLC_EGENERIC )
+                            &i_dts, &i_pts, &i_stream_id, NULL ) == VLC_EGENERIC )
             continue;
 
         if (p_pmt->pcr.i_pcroffset > 0) {



More information about the vlc-commits mailing list