[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: ts: flag corruption on PES size mismatch

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Feb 8 14:20:37 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
acf0f161 by François Cartegnie at 2024-02-08T13:58:14+00:00
demux: ts: flag corruption on PES size mismatch

- - - - -
7f923bd8 by François Cartegnie at 2024-02-08T13:58:14+00:00
demux: ts: use private flag for packet loss instead of discontinuity

Simple packet loss is not a real discontinuity.
It is also up to the aggregation layer to deal with the effects

- - - - -


2 changed files:

- modules/demux/mpeg/ts_pes.c
- test/modules/demux/ts_pes.c


Changes:

=====================================
modules/demux/mpeg/ts_pes.c
=====================================
@@ -106,6 +106,13 @@ static bool ts_pes_Push( ts_pes_parse_callback *cb,
     {
         block_t *p_datachain = p_pes->gather.p_data;
         uint32_t i_flags = p_pes->gather.i_block_flags;
+        if( p_pes->gather.i_data_size &&
+            p_pes->gather.i_gathered != p_pes->gather.i_data_size )
+        {
+            /* too early unit start resulting from packet loss */
+            /* or ending on a pkt not belonging to PES (%15 packets loss) */
+            i_flags |= BLOCK_FLAG_CORRUPTED;
+        }
         /* Flush the pes from pid */
         p_pes->gather.p_data = NULL;
         p_pes->gather.i_data_size = 0;
@@ -199,14 +206,14 @@ bool ts_pes_Gather( ts_pes_parse_callback *cb,
         if( p_pes->p_es )
             p_pes->p_es->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
     }
-    /* On dropped blocks discontinuity */
+    /* On dropped packets, detected by continuity counter */
     else if( p_pkt->i_flags & BLOCK_FLAG_DISCONTINUITY )
     {
         /* If we know the final size and didn't gather enough bytes it is corrupted
            or if the discontinuity doesn't carry the start code */
-        if( p_pes->gather.i_gathered && (p_pes->gather.i_data_size ||
-                                         (b_aligned_ts_payload && !b_unit_start) ) )
-            p_pes->gather.i_block_flags |= BLOCK_FLAG_CORRUPTED;
+       if( p_pes->gather.i_gathered && (p_pes->gather.i_data_size ||
+                                        (b_aligned_ts_payload && !b_unit_start) ) )
+           p_pes->gather.i_block_flags |= BLOCK_FLAG_CORRUPTED;
         b_ret |= ts_pes_Push( cb, p_pes, NULL, true, i_append_pcr );
 
         /* it can't match the target size and need to resync on sync code */
@@ -218,6 +225,13 @@ bool ts_pes_Gather( ts_pes_parse_callback *cb,
             p_pes->p_es->i_next_block_flags |= BLOCK_FLAG_DISCONTINUITY;
         p_pes->gather.i_block_flags|= BLOCK_FLAG_DISCONTINUITY;
     }
+    /* On dropped packets, detected by continuity counter */
+    else if( p_pkt->i_flags & BLOCK_FLAG_CORRUPTED )
+    {
+        p_pes->gather.i_block_flags |= BLOCK_FLAG_CORRUPTED;
+        /* can't reuse prev bytes to lookup sync code */
+        p_pes->gather.i_saved = 0;
+    }
 
     if ( unlikely(p_pes->gather.i_saved > 0) )
     {
@@ -296,6 +310,7 @@ bool ts_pes_Gather( ts_pes_parse_callback *cb,
                         block_Release( p_pkt );
                         return false;
                     }
+                    p_pes->gather.i_block_flags |= BLOCK_FLAG_CORRUPTED;
                     b_ret |= ts_pes_Push( cb, p_pes, p_pkt, p_pes->gather.p_data == NULL, i_append_pcr );
                     p_pkt = p_split;
                     b_first_sync_done = false;


=====================================
test/modules/demux/ts_pes.c
=====================================
@@ -160,6 +160,7 @@ int main(void)
     block_ChainProperties(output, &outputcount, &outputsize, NULL);
     ASSERT(outputcount == 1);
     ASSERT(outputsize == 256);
+    ASSERT(output->i_flags == 0);
     RESET;
 
     /* packets assembly, incorrect size, overflow by %15 pkt loss or size field corruption */
@@ -174,6 +175,7 @@ int main(void)
     block_ChainProperties(output, &outputcount, &outputsize, NULL);
     ASSERT(outputcount == 1);
     ASSERT(outputsize == 300);
+    ASSERT(output->i_flags & BLOCK_FLAG_CORRUPTED);
     RESET;
 
     /* no packets assembly from unit start, early termination by fixed size */
@@ -187,6 +189,7 @@ int main(void)
     ASSERT(output);
     block_ChainProperties(output, &outputcount, &outputsize, NULL);
     ASSERT(outputcount == 2);
+    ASSERT(output->i_flags & BLOCK_FLAG_CORRUPTED);
     RESET;
 
     /* no packets assembly from unit start, early termination by undef size  */
@@ -202,6 +205,7 @@ int main(void)
     block_ChainProperties(output, &outputcount, &outputsize, NULL);
     ASSERT(outputcount == 1);
     ASSERT(outputsize == 188);
+    ASSERT(output->i_flags & BLOCK_FLAG_CORRUPTED);
     RESET;
 
     /* packets assembly, payload undef, use next sync code from another payload undef */
@@ -217,6 +221,7 @@ int main(void)
     block_ChainProperties(output, &outputcount, &outputsize, NULL);
     ASSERT(outputcount == 1);
     ASSERT(outputsize == 150);
+    ASSERT(output->i_flags == 0);
     RESET;
 
     /* packets assembly, payload undef, use next sync code from fixed size */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ec29dfca1e59530dd412d779e0b045079b72ffb6...7f923bd8ea88ad2964bc9afa1056e5dcee00a611

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ec29dfca1e59530dd412d779e0b045079b72ffb6...7f923bd8ea88ad2964bc9afa1056e5dcee00a611
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