[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: ts: prevent flapping scrambling state

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Jan 25 11:09:48 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d4ea7c7e by François Cartegnie at 2024-01-25T10:35:38+00:00
demux: ts: prevent flapping scrambling state

- - - - -
ea36b2b1 by François Cartegnie at 2024-01-25T10:35:38+00:00
demux: ts: check flag on payload start

- - - - -


3 changed files:

- modules/demux/mpeg/ts.c
- modules/demux/mpeg/ts_pid.c
- modules/demux/mpeg/ts_pid.h


Changes:

=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -691,7 +691,8 @@ static int Demux( demux_t *p_demux )
         if( !p_pkt )
             continue;
 
-        if( !SCRAMBLED(*p_pid) != !(p_pkt->i_flags & BLOCK_FLAG_SCRAMBLED) )
+        if( !SCRAMBLED(*p_pid) != !(p_pkt->i_flags & BLOCK_FLAG_SCRAMBLED) &&
+            ( p_pkt->p_buffer[1] & 0x40 ) ) /* update on payload start */
         {
             UpdatePIDScrambledState( p_demux, p_pid, p_pkt->i_flags & BLOCK_FLAG_SCRAMBLED );
         }
@@ -1918,6 +1919,17 @@ static void UpdatePIDScrambledState( demux_t *p_demux, ts_pid_t *p_pid, bool b_s
     if( !SCRAMBLED(*p_pid) == !b_scrambled )
         return;
 
+    /* avoid flapping descrambled state on partial scrambling */
+    if( b_scrambled )
+    {
+        p_pid->i_scramble_counter = 4;
+    }
+    else if( p_pid->i_scramble_counter != 0 )
+    {
+        p_pid->i_scramble_counter--;
+        return;
+    }
+
     msg_Warn( p_demux, "scrambled state changed on pid %d (%d->%d)",
               p_pid->i_pid, !!SCRAMBLED(*p_pid), b_scrambled );
 


=====================================
modules/demux/mpeg/ts_pid.c
=====================================
@@ -175,6 +175,7 @@ static void PIDReset( ts_pid_t *pid )
     pid->i_dup      = 0;
     pid->i_flags    &= ~FLAG_SCRAMBLED;
     pid->type = TYPE_FREE;
+    pid->i_scramble_counter = 0;
     memset(pid->prevpktbytes, 0, PREVPKTKEEPBYTES);
 }
 


=====================================
modules/demux/mpeg/ts_pid.h
=====================================
@@ -60,6 +60,7 @@ struct ts_pid_t
     uint8_t     i_dup;  /* duplicate counter */
     uint8_t     type;
     uint8_t     prevpktbytes[PREVPKTKEEPBYTES];
+    uint8_t     i_scramble_counter;
 
     uint16_t    i_refcount;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/77c60d56ec00d42ee63eb58c741905f82c231112...ea36b2b13a297b740a2720dcac454dc6a73be5b6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/77c60d56ec00d42ee63eb58c741905f82c231112...ea36b2b13a297b740a2720dcac454dc6a73be5b6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list