[vlc-commits] [Git][videolan/vlc][master] test: video_output: fix test not ending correctly

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Dec 14 13:09:56 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
8758a175 by Alexandre Janniaux at 2021-12-14T12:05:02+00:00
test: video_output: fix test not ending correctly

The test was failing randomly because the decoder was asked to decode
more data and its output format was reset to VLC_CODEC_UNKNOWN, which is
not an allocatable format for picture_NewFromResource.

Abandon the picture allocation in decoder_decoder(dec, picture) callback
to let the scenario handle the allocation, and in particular discard it
if it already did the test. The new test_finished boolean will force the
decoder callback to no-op. It is a bit redundant with the display_opened
callback where it could loop doing the update until it is correctly
closed but much clearer.

I'm not sure yet, but it seems that the easiest method to control the
behaviour of the test is to have a custom demux to push data at will.
It's adding a lot of code and is trickier to manage so here we fix the
test first.

Fixes #26374

- - - - -


3 changed files:

- test/src/video_output/video_output.c
- test/src/video_output/video_output.h
- test/src/video_output/video_output_scenarios.c


Changes:

=====================================
test/src/video_output/video_output.c
=====================================
@@ -73,18 +73,9 @@ static int DecoderDecode(decoder_t *dec, block_t *block)
     if (block == NULL)
         return VLC_SUCCESS;
 
-    const picture_resource_t resource = {
-        .p_sys = NULL,
-    };
-    picture_t *pic = picture_NewFromResource(&dec->fmt_out.video, &resource);
-    assert(pic);
-    pic->date = block->i_pts;
-    pic->b_progressive = true;
-    block_Release(block);
-
     struct vout_scenario *scenario = &vout_scenarios[current_scenario];
     assert(scenario->decoder_decode != NULL);
-    scenario->decoder_decode(dec, pic);
+    scenario->decoder_decode(dec, block);
 
     return VLC_SUCCESS;
 }


=====================================
test/src/video_output/video_output.h
=====================================
@@ -34,7 +34,7 @@
 struct vout_scenario {
     const char *source;
     void (*decoder_setup)(decoder_t *);
-    void (*decoder_decode)(decoder_t *, picture_t *);
+    void (*decoder_decode)(decoder_t *, block_t *);
     int  (*display_setup)(vout_display_t *, video_format_t *,
                           struct vlc_video_context *);
     void (*display_prepare)(vout_display_t *, picture_t *);


=====================================
test/src/video_output/video_output_scenarios.c
=====================================
@@ -41,6 +41,7 @@ static struct scenario_data
     unsigned display_picture_count;
     bool converter_opened;
     bool display_opened;
+    bool test_finished;
 
     vlc_fourcc_t display_chroma;
 } scenario_data;
@@ -62,8 +63,11 @@ static void decoder_fixed_size(decoder_t *dec, vlc_fourcc_t chroma,
 static void decoder_rgba_800_600(decoder_t *dec)
     { decoder_fixed_size(dec, VLC_CODEC_RGBA, 800, 600); }
 
-static void decoder_decode_change_chroma(decoder_t *dec, picture_t *pic)
+static void decoder_decode_change_chroma(decoder_t *dec, block_t *block)
 {
+    if (scenario_data.test_finished)
+        goto end;
+
     static const vlc_fourcc_t chroma_list[] = {
         VLC_CODEC_RGBA,
         VLC_CODEC_I420,
@@ -88,16 +92,26 @@ static void decoder_decode_change_chroma(decoder_t *dec, picture_t *pic)
         = chroma_list[index];
 
     int ret = decoder_UpdateVideoOutput(dec, NULL);
-    //assert(ret == VLC_SUCCESS);
     if (ret != VLC_SUCCESS)
     {
+        scenario_data.test_finished = true;
         vlc_sem_post(&scenario_data.wait_stop);
-        return;
+        goto end;
     }
 
+    const picture_resource_t resource = {
+        .p_sys = NULL,
+    };
+    picture_t *pic = picture_NewFromResource(&dec->fmt_out.video, &resource);
+    assert(pic);
+    pic->date = block->i_pts;
+    pic->b_progressive = true;
+
     /* Simulate the chroma change */
     pic->format.i_chroma = chroma_list[index];
     decoder_QueueVideo(dec, pic);
+end:
+    block_Release(block);
 }
 
 static int display_fixed_size(vout_display_t *vd, video_format_t *fmtp,
@@ -122,6 +136,7 @@ static int display_fail_second_time(vout_display_t *vd, video_format_t *fmtp,
     {
         msg_Info(vd, "Failing the display %4.4s: %ux%u",
                  (const char *)&chroma, width, height);
+        scenario_data.test_finished = true;
         return VLC_EGENERIC;
     }
 
@@ -149,6 +164,7 @@ void vout_scenario_init(void)
     scenario_data.display_picture_count = 0;
     scenario_data.converter_opened = false;
     scenario_data.display_opened = false;
+    scenario_data.test_finished = false;
     vlc_sem_init(&scenario_data.wait_stop, 0);
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8758a1756117ed6f759c2c837b078e9a13459c70

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8758a1756117ed6f759c2c837b078e9a13459c70
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list