Skip to content

Commit

Permalink
test: video_output: fix test not ending correctly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexandre-janniaux authored and jbkempf committed Dec 14, 2021
1 parent eca2d51 commit 8758a17
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
11 changes: 1 addition & 10 deletions test/src/video_output/video_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion test/src/video_output/video_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
22 changes: 19 additions & 3 deletions test/src/video_output/video_output_scenarios.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 8758a17

Please sign in to comment.