[vlc-commits] [Git][videolan/vlc][master] 3 commits: input_clock: finer discontinuity handling

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jul 5 04:40:01 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
03d91093 by Thomas Guillem at 2024-07-05T04:25:43+00:00
input_clock: finer discontinuity handling

We need to compare both stream and system times for discontinuity.
Indeed, a big stream diff is OK if we have the same system diff.
This check is now done after buffering is complete (b_has_external_clock
== true).

- - - - -
00a498c0 by Thomas Guillem at 2024-07-05T04:25:43+00:00
clock: use private define for max PCR delay

The value is the same, no functional changes.

- - - - -
4d3b7c01 by Thomas Guillem at 2024-07-05T04:25:43+00:00
input_clock: lower discontinuity gap value

Now that both stream and system are compared, we can lower this value.
>From 60seconds to 300ms.

- - - - -


3 changed files:

- src/clock/clock.c
- src/clock/clock_internal.h
- src/clock/input_clock.c


Changes:

=====================================
src/clock/clock.c
=====================================
@@ -36,6 +36,8 @@
 
 #define COEFF_THRESHOLD 0.2 /* between 0.8 and 1.2 */
 
+#define MAX_PCR_DELAY VLC_TICK_FROM_SEC(60)
+
 struct vlc_clock_listener_id
 {
     vlc_clock_t *clock;
@@ -401,7 +403,7 @@ vlc_clock_monotonic_to_system(vlc_clock_t *clock, vlc_tick_t now,
             (ts - main_clock->first_pcr.stream) / rate +
             main_clock->first_pcr.system - now;
 
-        if (pcr_delay > CR_MAX_GAP)
+        if (pcr_delay > MAX_PCR_DELAY)
         {
             if (main_clock->logger != NULL)
                 vlc_error(main_clock->logger, "Invalid PCR delay ! Ignoring it...");


=====================================
src/clock/clock_internal.h
=====================================
@@ -27,9 +27,6 @@
 #include <vlc_common.h>
 #include <vlc_tick.h>
 
-/* Maximum gap allowed between two CRs. */
-#define CR_MAX_GAP VLC_TICK_FROM_SEC(60)
-
 /*****************************************************************************
  * Structures
  *****************************************************************************/


=====================================
src/clock/input_clock.c
=====================================
@@ -82,6 +82,8 @@
  * my dice --Meuuh */
 #define CR_MEAN_PTS_GAP VLC_TICK_FROM_MS(300)
 
+#define CR_MAX_GAP CR_MEAN_PTS_GAP
+
 /* Rate (in 1/256) at which we will read faster to try to increase our
  * internal buffer (if we control the pace of the source).
  */
@@ -232,18 +234,29 @@ vlc_tick_t input_clock_Update( input_clock_t *cl, vlc_object_t *p_log,
         /* */
         b_reset_reference= true;
     }
-    else if( cl->last.stream != VLC_TICK_INVALID &&
-             ( (cl->last.stream - i_ck_stream) > CR_MAX_GAP ||
-               (cl->last.stream - i_ck_stream) < -CR_MAX_GAP ) )
+    else if (cl->last.stream != VLC_TICK_INVALID && cl->b_has_external_clock)
     {
-        /* Stream discontinuity, for which we haven't received a
-         * warning from the stream control facilities (dd-edited
-         * stream ?). */
-        msg_Warn( p_log, "clock gap, unexpected stream discontinuity" );
-
-        /* */
-        msg_Warn( p_log, "feeding synchro with a new reference point trying to recover from clock gap" );
-        b_reset_reference= true;
+        assert(cl->last.system != VLC_TICK_INVALID);
+
+        /* We need compare both stream and system times for discontinuity.
+         * Indeed, a big stream diff is OK if we have the same system diff. */
+        vlc_tick_t stream_diff = i_ck_stream - cl->last.stream;
+        vlc_tick_t system_diff = i_ck_system - cl->last.system;
+        vlc_tick_t diff = stream_diff - system_diff;
+        if (diff > CR_MAX_GAP || diff < -CR_MAX_GAP)
+        {
+            /* Stream discontinuity, for which we haven't received a
+             * warning from the stream control facilities (dd-edited
+             * stream ?). */
+            msg_Warn(p_log, "clock gap, unexpected stream discontinuity: "
+                     "system_diff: %"PRId64" stream_diff: %"PRId64,
+                     system_diff, stream_diff);
+
+            /* */
+            msg_Warn(p_log, "feeding synchro with a new reference point trying"
+                     " to recover from clock gap");
+            b_reset_reference= true;
+        }
     }
 
     /* */



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ff99fc24998df86b3d46c8225d108463984a0f4e...4d3b7c01a7343899ced35bc335245f9f6cc091d1

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