Skip to content

Commit 1fb1fbe

Browse files
committed
vdisp/sdl2,sdl3: accept mode name for size
_but_ size= doesn't seem to work with sdl3 for YCbCr formats (does for RGB)
1 parent 10db49b commit 1fb1fbe

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/video_display/sdl2.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include "utils/color_out.h" // for color_printf, TBOLD, TRED
7676
#include "utils/list.h" // for simple_linked_list_append, simple_lin...
7777
#include "utils/macros.h" // for STR_LEN
78+
#include "video.h" // for get_video_desc_from_string
7879
#include "video_codec.h" // for get_codec_name, codec_is_planar, vc_d...
7980
#include "video_display.h" // for display_property, get_splashscreen
8081
#include "video_frame.h" // for vf_free, vf_alloc_desc, video_desc_fr...
@@ -373,7 +374,8 @@ show_help(const char *driver)
373374
"position\n"
374375
" "
375376
"(syntax: " TBOLD(
376-
"[<W>x<H>][{+-}<X>[{+-}<Y>]]") ")\n");
377+
"[<W>x<H>][{+-}<X>[{+-}<Y>]]")
378+
" or mode name)\n");
377379
color_printf(TBOLD("\t <renderer>") " - renderer, one of:");
378380
for (int i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
379381
SDL_RendererInfo renderer_info;
@@ -596,6 +598,13 @@ static bool set_size(struct state_sdl2 *s, const char *tok)
596598
}
597599
tok = strchr(tok, '=') + 1;
598600
if (strpbrk(tok, "x+-") == NULL) {
601+
struct video_desc desc = get_video_desc_from_string(tok);
602+
if (desc.width != 0) {
603+
s->fixed_size = true;
604+
s->fixed_w = desc.width;
605+
s->fixed_h = desc.height;
606+
return true;
607+
}
599608
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Wrong size spec: %s\n", tok);
600609
return false;
601610
}

src/video_display/sdl3.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
* 3. p010 works just on macOS/Metal, crashes on Vulkan (see previous point)
5151
* 4. p010 corrupted on d3d[12] - pixfmts skipped in query*() as a workaround
5252
* 5. see todo in @ref ../audio/capture/sdl_mixer.c
53+
* 6. size= option doesn't seem to work with YCbCr formats
5354
*/
5455

5556
#include <SDL3/SDL.h>
@@ -78,6 +79,7 @@
7879
#include "utils/color_out.h" // for color_printf, TBOLD, TRED
7980
#include "utils/list.h" // for simple_linked_list_append, simple_lin...
8081
#include "utils/macros.h" // for STR_LEN
82+
#include "video.h" // for get_video_desc_from_string
8183
#include "video_codec.h" // for get_codec_name, codec_is_planar, vc_d...
8284
#include "video_display.h" // for display_property, get_splashscreen
8385
#include "video_frame.h" // for vf_free, vf_alloc_desc, video_desc_fr...
@@ -517,7 +519,8 @@ show_help(const char *driver, bool full)
517519
"position\n"
518520
" "
519521
"(syntax: " TBOLD(
520-
"[<W>x<H>][{+-}<X>[{+-}<Y>]]") ")\n");
522+
"[<W>x<H>][{+-}<X>[{+-}<Y>]]")
523+
" or mode name)\n");
521524
color_printf(TBOLD(" <renderer>") " - renderer, one or more of:");
522525
for (int i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
523526
const char *renderer_name = SDL_GetRenderDriver(i);
@@ -886,6 +889,13 @@ set_size(struct state_sdl3 *s, const char *tok)
886889
}
887890
tok = strchr(tok, '=') + 1;
888891
if (strpbrk(tok, "x+-") == NULL) {
892+
struct video_desc desc = get_video_desc_from_string(tok);
893+
if (desc.width != 0) {
894+
s->fixed_size = true;
895+
s->fixed_w = desc.width;
896+
s->fixed_h = desc.height;
897+
return true;
898+
}
889899
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Wrong size spec: %s\n", tok);
890900
return false;
891901
}

0 commit comments

Comments
 (0)