Skip to content

Commit 2007a16

Browse files
committed
sdl3: fix b80eb82
The actual count should be returned **without** duplicites. The fixed fix fixed just the content of the array but not the count. This would trigger assertion in video_decoder_order_output_codecs()->get_pixfmt_desc(VIDEO_CODEC_NONE).
1 parent dc9f09f commit 2007a16

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/video_codec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,8 @@ i444_8_to_uyvy(int width, int height, const unsigned char *in,
11301130

11311131
struct pixfmt_desc get_pixfmt_desc(codec_t pixfmt)
11321132
{
1133-
assert(pixfmt >= VIDEO_CODEC_FIRST && pixfmt < VIDEO_CODEC_END);
1133+
assert(pixfmt >= VIDEO_CODEC_FIRST);
1134+
assert(pixfmt <= VIDEO_CODEC_END);
11341135
struct pixfmt_desc ret = { 0 };
11351136
ret.depth = codec_info[pixfmt].bits_per_channel;
11361137
ret.subsampling = codec_info[pixfmt].subsampling;

src/video_display/sdl3.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -605,16 +605,16 @@ get_ug_to_sdl_format(const struct fmt_data *supp_fmts, codec_t ug_codec)
605605
static int
606606
get_supported_pfs(const struct fmt_data *supp_fmts, codec_t *codecs)
607607
{
608-
bool codec_set[VC_COUNT]= {};
609-
int i = 0;
610-
for (; supp_fmts[i].ug_codec != VC_NONE; ++i) {
608+
bool codec_set[VC_COUNT] = {};
609+
int count = 0;
610+
for (int i = 0; supp_fmts[i].ug_codec != VC_NONE; ++i) {
611611
if (codec_set[supp_fmts[i].ug_codec]) {
612612
continue;
613613
}
614-
codecs[i] = supp_fmts[i].ug_codec;
614+
codecs[count++] = supp_fmts[i].ug_codec;
615615
codec_set[supp_fmts[i].ug_codec] = true;
616616
}
617-
return i;
617+
return count;
618618
}
619619

620620
static void

0 commit comments

Comments
 (0)