[vlc-commits] [Git][videolan/vlc][master] 8 commits: test/clock: specify epsilon in the scenario for lowprecision_check

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat Nov 11 10:27:27 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
02ffd015 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: specify epsilon in the scenario for lowprecision_check

- - - - -
b159c36b by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: these variables are used

- - - - -
8e9a6954 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: add missing va_copy

- - - - -
a7ce1e21 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: use a switch case

- - - - -
3b97d7f3 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: name the slave clock

For the tracer.

- - - - -
4bc7fd70 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: simulate video rendering

And send render traces to the tracer_ctx.

- - - - -
77cd3505 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: simulate video rendering on most scenarios

Skip the long scenarios since the video convert/update can take some
time (on a 24h scale).

Only the normal scenario is checking if video play dates are correct.
Other scenarios will fail. Video rendering is enabled anyway in most
scenarios so that it can used to visualize video timestamps with a
output tracer.

- - - - -
5800fa28 by Thomas Guillem at 2023-11-11T10:03:27+00:00
test/clock: fix the output tracer "render_pts" system date

Don't override the system date for "render_pts", cf.
vlc_tracer_TraceRender()

- - - - -


1 changed file:

- test/src/clock/clock.c


Changes:

=====================================
test/src/clock/clock.c
=====================================
@@ -51,7 +51,9 @@ struct clock_scenario
     vlc_tick_t system_start; /* VLC_TICK_INVALID for vlc_tick_now() */
     vlc_tick_t duration;
     vlc_tick_t stream_increment; /* VLC_TICK_INVALID for manual increment */
+    unsigned video_fps;
     vlc_tick_t total_drift_duration; /* VLC_TICK_INVALID for non-drift test */
+    double coeff_epsilon; /* Valid for lowprecision/burst checks */
 
     void (*update)(const struct clock_ctx *ctx, size_t index,
                    vlc_tick_t *system, vlc_tick_t stream);
@@ -70,6 +72,7 @@ struct clock_ctx
 
 enum tracer_event_type {
     TRACER_EVENT_TYPE_UPDATE,
+    TRACER_EVENT_TYPE_RENDER_VIDEO,
     TRACER_EVENT_TYPE_STATUS,
 };
 
@@ -88,6 +91,11 @@ struct tracer_event
             vlc_tick_t offset;
         } update;
 
+        struct {
+            vlc_tick_t play_date;
+            vlc_tick_t pts;
+        } render_video;
+
         enum tracer_event_status status;
     };
 };
@@ -132,6 +140,20 @@ static void tracer_ctx_PushUpdate(struct tracer_ctx *ctx,
     assert(ret);
 }
 
+static void tracer_ctx_PushRenderVideo(struct tracer_ctx *ctx,
+                                       vlc_tick_t play_date, vlc_tick_t pts)
+{
+    struct tracer_event event = {
+        .type = TRACER_EVENT_TYPE_RENDER_VIDEO,
+        .render_video = {
+            .play_date = play_date,
+            .pts = pts,
+        },
+    };
+    bool ret = vlc_vector_push(&ctx->events, event);
+    assert(ret);
+}
+
 static void tracer_ctx_PushStatus(struct tracer_ctx *ctx,
                                   enum tracer_event_status status)
 {
@@ -145,22 +167,17 @@ static void tracer_ctx_PushStatus(struct tracer_ctx *ctx,
 
 static void TracerTrace(void *opaque, vlc_tick_t ts, va_list entries)
 {
-    (void) ts;
     struct vlc_tracer *libvlc_tracer = opaque;
-    if (libvlc_tracer != NULL)
-    {
-        /* If the user specified a tracer, forward directly to it after faking
-         * the system ts */
-        assert(tracer_ctx.forced_ts != VLC_TICK_INVALID);
-        vlc_tracer_vaTraceWithTs(libvlc_tracer, tracer_ctx.forced_ts, entries);
-    }
+    va_list copy;
+    va_copy(copy, entries);
 
     struct vlc_tracer_entry entry = va_arg(entries, struct vlc_tracer_entry);
 
-    bool is_render = false, is_status = false;
+    bool is_render = false, is_render_video = false, is_status = false;
     unsigned nb_update = 0;
     double coeff = 0.0f;
     vlc_tick_t offset = VLC_TICK_INVALID;
+    vlc_tick_t render_video_pts = VLC_TICK_INVALID;
     enum tracer_event_status status = 0;
 
     while (entry.key != NULL)
@@ -177,6 +194,8 @@ static void TracerTrace(void *opaque, vlc_tick_t ts, va_list entries)
                     nb_update++;
                     offset = VLC_TICK_FROM_NS(entry.value.integer);
                 }
+                else if (strcmp(entry.key, "render_pts") == 0)
+                    render_video_pts = VLC_TICK_FROM_NS(entry.value.integer);
                 break;
             case VLC_TRACER_DOUBLE:
                 if (!is_render)
@@ -195,6 +214,12 @@ static void TracerTrace(void *opaque, vlc_tick_t ts, va_list entries)
                     if (strcmp(entry.value.string, "RENDER") == 0)
                         is_render = true;
                 }
+                else if (strcmp(entry.key, "id") == 0)
+                {
+                    if (strcmp(entry.value.string, "video") == 0)
+                        is_render_video= true;
+                }
+
                 if (!is_render)
                     continue;
                 /* Assert that there is no "reset_bad_source" */
@@ -215,6 +240,19 @@ static void TracerTrace(void *opaque, vlc_tick_t ts, va_list entries)
         entry = va_arg(entries, struct vlc_tracer_entry);
     }
 
+    if (libvlc_tracer != NULL)
+    {
+        /* If the user specified a tracer, forward directly to it after faking
+         * the system ts */
+        assert(tracer_ctx.forced_ts != VLC_TICK_INVALID);
+
+        /* Use the original ts for the "render_pts" entry */
+        vlc_tick_t tracer_ts = render_video_pts != VLC_TICK_INVALID ?
+                               ts : tracer_ctx.forced_ts;
+        vlc_tracer_vaTraceWithTs(libvlc_tracer, tracer_ts, copy);
+    }
+    va_end(copy);
+
     if (!is_render)
         return;
 
@@ -225,6 +263,8 @@ static void TracerTrace(void *opaque, vlc_tick_t ts, va_list entries)
         assert(nb_update == 2);
         tracer_ctx_PushUpdate(&tracer_ctx, coeff, offset);
     }
+    else if (is_render_video && render_video_pts != VLC_TICK_INVALID)
+        tracer_ctx_PushRenderVideo(&tracer_ctx, ts, render_video_pts);
 }
 
 /* Used to check for some trace value and hack the ts to the user tracer */
@@ -269,7 +309,10 @@ static void play_scenario(libvlc_int_t *vlc, struct vlc_tracer *tracer,
                                                       NULL, NULL);
     assert(master != NULL);
 
-    vlc_clock_t *slave = vlc_clock_main_CreateSlave(mainclk, NULL, VIDEO_ES,
+    char *slave_name;
+    int ret = asprintf(&slave_name, "%s/video", scenario->name);
+    assert(ret != -1);
+    vlc_clock_t *slave = vlc_clock_main_CreateSlave(mainclk, slave_name, VIDEO_ES,
                                                     NULL, NULL);
     assert(slave != NULL);
 
@@ -287,6 +330,11 @@ static void play_scenario(libvlc_int_t *vlc, struct vlc_tracer *tracer,
     vlc_tick_t system = scenario->system_start;
     vlc_tick_t expected_system = scenario->system_start;
 
+    vlc_tick_t video_increment = 0;
+    vlc_tick_t video_ts = scenario->stream_start;
+    if (scenario->video_fps != 0)
+        video_increment = vlc_tick_rate_duration(scenario->video_fps);
+
     tracer_ctx.forced_ts = expected_system;
     size_t index = 0;
 
@@ -294,8 +342,23 @@ static void play_scenario(libvlc_int_t *vlc, struct vlc_tracer *tracer,
         stream += scenario->stream_increment, ++index)
     {
         scenario->update(&ctx, index, &system, stream);
-        expected_system += scenario->stream_increment;
 
+        vlc_tick_t video_system = expected_system;
+
+        if (video_increment > 0)
+        {
+            while (video_system < expected_system + scenario->stream_increment)
+            {
+                vlc_tick_t play_date =
+                    vlc_clock_ConvertToSystem(ctx.slave, video_system, video_ts,
+                                              1.0f);
+                vlc_clock_Update(ctx.slave, play_date, video_ts, 1.0f);
+                video_system += video_increment;
+                video_ts += video_increment;
+            }
+        }
+
+        expected_system += scenario->stream_increment;
         tracer_ctx.forced_ts = expected_system;
     }
 
@@ -309,6 +372,7 @@ static void play_scenario(libvlc_int_t *vlc, struct vlc_tracer *tracer,
     if (master != NULL)
         vlc_clock_Delete(master);
     vlc_clock_Delete(slave);
+    free(slave_name);
     vlc_clock_main_Delete(mainclk);
 }
 
@@ -367,11 +431,6 @@ static void normal_update(const struct clock_ctx *ctx, size_t index,
     /* The master can't drift */
     assert(drift == VLC_TICK_INVALID);
 
-    /* Check the slave is drifting (only system is moving) */
-    drift = vlc_clock_Update(ctx->slave, *system,
-                             VLC_TICK_0, 1.0f);
-    assert(drift == - (stream - VLC_TICK_0));
-
     *system += scenario->stream_increment;
 }
 
@@ -389,6 +448,8 @@ static void check_no_event_error(size_t expected_update_count)
             case TRACER_EVENT_TYPE_UPDATE:
                 update_count++;
                 break;
+            case TRACER_EVENT_TYPE_RENDER_VIDEO:
+                break;
             case TRACER_EVENT_TYPE_STATUS:
                 switch (event.status)
                 {
@@ -408,19 +469,30 @@ static void normal_check(const struct clock_ctx *ctx, size_t update_count,
                          vlc_tick_t expected_system_end,
                          vlc_tick_t stream_end)
 {
-    (void) expected_system_end; (void) stream_end;
     const struct clock_scenario *scenario = ctx->scenario;
 
     check_no_event_error(update_count);
+    vlc_tick_t last_video_date = VLC_TICK_INVALID;
+    vlc_tick_t video_increment = vlc_tick_rate_duration(scenario->video_fps);
 
     for (size_t i = 0; i < tracer_ctx.events.size; ++i)
     {
         struct tracer_event event = tracer_ctx.events.data[i];
-        if (event.type == TRACER_EVENT_TYPE_UPDATE)
+
+        switch (event.type)
         {
-            assert(event.update.coeff == 1.0f);
-            assert(event.update.offset ==
-                   scenario->system_start - scenario->stream_start);
+            case TRACER_EVENT_TYPE_UPDATE:
+                assert(event.update.coeff == 1.0f);
+                assert(event.update.offset ==
+                       scenario->system_start - scenario->stream_start);
+                break;
+            case TRACER_EVENT_TYPE_RENDER_VIDEO:
+                if (last_video_date != VLC_TICK_INVALID)
+                    assert(event.render_video.play_date - last_video_date == video_increment);
+                last_video_date = event.render_video.play_date;
+                break;
+            default:
+                break;
         }
     }
 
@@ -453,18 +525,22 @@ static void lowprecision_check(const struct clock_ctx *ctx, size_t update_count,
                                vlc_tick_t expected_system_end,
                                vlc_tick_t stream_end)
 {
-    (void) ctx; (void) expected_system_end; (void) stream_end;
+    const struct clock_scenario *scenario = ctx->scenario;
+    (void) expected_system_end; (void) stream_end;
 
     check_no_event_error(update_count);
 
-    static const double epsilon = 0.005;
-
     for (size_t i = 0; i < tracer_ctx.events.size; ++i)
     {
         struct tracer_event event = tracer_ctx.events.data[i];
-        if (event.type == TRACER_EVENT_TYPE_UPDATE)
-            assert(fabs(event.update.coeff - 1.0f) <= epsilon);
-
+        switch (event.type)
+        {
+            case TRACER_EVENT_TYPE_UPDATE:
+                assert(fabs(event.update.coeff - 1.0f) <= scenario->coeff_epsilon);
+                break;
+            default:
+                break;
+        }
     }
 }
 
@@ -527,16 +603,17 @@ static void drift_sudden_update(const struct clock_ctx *ctx, size_t index,
 #define VLC_TICK_2H VLC_TICK_FROM_SEC(2 * 60 * 60)
 #define DEFAULT_STREAM_INCREMENT VLC_TICK_FROM_MS(100)
 
-#define INIT_SYSTEM_STREAM_TIMING(duration_, increment_) \
+#define INIT_SYSTEM_STREAM_TIMING(duration_, increment_, video_fps_) \
     .stream_start = VLC_TICK_0 + VLC_TICK_FROM_MS(31000000), \
     .system_start = VLC_TICK_INVALID, \
     .duration = duration_, \
-    .stream_increment = increment_
+    .stream_increment = increment_, \
+    .video_fps = video_fps_
 
-#define DRIFT_SCENARIO(name_, desc_, duration_, increment_, drift_) \
+#define DRIFT_SCENARIO(name_, desc_, duration_, increment_, video_fps_, drift_) \
     .name = name_, \
     .desc = desc_, \
-    INIT_SYSTEM_STREAM_TIMING(duration_, increment_), \
+    INIT_SYSTEM_STREAM_TIMING(duration_, increment_, video_fps_), \
     .total_drift_duration = drift_, \
     .update = drift_update, \
     .check = drift_check,
@@ -545,14 +622,15 @@ static struct clock_scenario clock_scenarios[] = {
 {
     .name = "normal",
     .desc = "normal update has a coeff of 1.0f",
-    INIT_SYSTEM_STREAM_TIMING(VLC_TICK_2H, DEFAULT_STREAM_INCREMENT),
+    INIT_SYSTEM_STREAM_TIMING(VLC_TICK_2H, DEFAULT_STREAM_INCREMENT, 60),
     .update = normal_update,
     .check = normal_check,
 },
 {
     .name = "lowprecision",
     .desc = "low precision update has a coeff near 1.0f",
-    INIT_SYSTEM_STREAM_TIMING(VLC_TICK_2H, DEFAULT_STREAM_INCREMENT),
+    INIT_SYSTEM_STREAM_TIMING(VLC_TICK_FROM_SEC(240), DEFAULT_STREAM_INCREMENT, 60),
+    .coeff_epsilon = 0.005,
     .update = lowprecision_update,
     .check = lowprecision_check,
 },
@@ -562,6 +640,7 @@ static struct clock_scenario clock_scenarios[] = {
         "a drift of 72ms in 2h is handled",
         VLC_TICK_2H,
         DEFAULT_STREAM_INCREMENT,
+        60,
         VLC_TICK_FROM_MS(72)
 )},
 {
@@ -570,6 +649,7 @@ static struct clock_scenario clock_scenarios[] = {
         "a drift of -72ms in 2h is handled",
         VLC_TICK_2H,
         DEFAULT_STREAM_INCREMENT,
+        60,
         -VLC_TICK_FROM_MS(72)
     )
 },
@@ -579,6 +659,7 @@ static struct clock_scenario clock_scenarios[] = {
         "a drift of 864ms in 24h is handled",
         VLC_TICK_24H,
         DEFAULT_STREAM_INCREMENT,
+        0, /* too long to test video */
         VLC_TICK_FROM_MS(864)
     )
 },
@@ -588,13 +669,14 @@ static struct clock_scenario clock_scenarios[] = {
         "a drift of -864ms in 24h is handled",
         VLC_TICK_24H,
         DEFAULT_STREAM_INCREMENT,
+        0, /* too long to test video */
         -VLC_TICK_FROM_MS(864)
     )
 },
 {
     .name = "drift_sudden",
     .desc = "a sudden drift is handled",
-    INIT_SYSTEM_STREAM_TIMING(VLC_TICK_24H, DEFAULT_STREAM_INCREMENT),
+    INIT_SYSTEM_STREAM_TIMING(VLC_TICK_24H, DEFAULT_STREAM_INCREMENT, 0),
     .total_drift_duration = VLC_TICK_FROM_MS(864),
     .update = drift_sudden_update,
     .check = drift_check,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6834df46ba90ae5fbe66cb41141f48352036cc64...5800fa288abead2e71ccd73c04fb42b7d9646c4d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6834df46ba90ae5fbe66cb41141f48352036cc64...5800fa288abead2e71ccd73c04fb42b7d9646c4d
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