mirror of https://github.com/mpv-player/mpv
video: batch query_format calls
There are currently 568 pixel formats (actually fewer, but the namespace is this big), and for each format elaborate synchronization was done to call it synchronously on the VO. This is completely unnecessary, and we can do with just a single call.
This commit is contained in:
parent
411109f484
commit
a7dddbacc6
|
@ -848,8 +848,10 @@ void handle_force_window(struct MPContext *mpctx, bool reconfig)
|
|||
MP_INFO(mpctx, "Creating non-video VO window.\n");
|
||||
// Pick whatever works
|
||||
int config_format = 0;
|
||||
uint8_t fmts[IMGFMT_END - IMGFMT_START] = {0};
|
||||
vo_query_formats(vo, fmts);
|
||||
for (int fmt = IMGFMT_START; fmt < IMGFMT_END; fmt++) {
|
||||
if (vo_query_format(vo, fmt)) {
|
||||
if (fmts[fmt - IMGFMT_START]) {
|
||||
config_format = fmt;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -88,8 +88,7 @@ void update_fps(struct MPContext *mpctx)
|
|||
|
||||
static void set_allowed_vo_formats(struct vf_chain *c, struct vo *vo)
|
||||
{
|
||||
for (int fmt = IMGFMT_START; fmt < IMGFMT_END; fmt++)
|
||||
c->allowed_output_formats[fmt - IMGFMT_START] = vo_query_format(vo, fmt);
|
||||
vo_query_formats(vo, c->allowed_output_formats);
|
||||
}
|
||||
|
||||
static int try_filter(struct MPContext *mpctx, struct mp_image_params params,
|
||||
|
|
|
@ -782,15 +782,17 @@ static void run_query_format(void *p)
|
|||
{
|
||||
void **pp = p;
|
||||
struct vo *vo = pp[0];
|
||||
*(int *)pp[2] = vo->driver->query_format(vo, *(int *)pp[1]);
|
||||
uint8_t *list = pp[1];
|
||||
for (int format = IMGFMT_START; format < IMGFMT_END; format++)
|
||||
list[format - IMGFMT_START] = vo->driver->query_format(vo, format);
|
||||
}
|
||||
|
||||
int vo_query_format(struct vo *vo, int format)
|
||||
// For each item in the list (allocated as uint8_t[IMGFMT_END - IMGFMT_START]),
|
||||
// set the supported format flags.
|
||||
void vo_query_formats(struct vo *vo, uint8_t *list)
|
||||
{
|
||||
int ret;
|
||||
void *p[] = {vo, &format, &ret};
|
||||
void *p[] = {vo, list};
|
||||
mp_dispatch_run(vo->in->dispatch, run_query_format, p);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Calculate the appropriate source and destination rectangle to
|
||||
|
|
|
@ -319,7 +319,7 @@ void vo_seek_reset(struct vo *vo);
|
|||
void vo_destroy(struct vo *vo);
|
||||
void vo_set_paused(struct vo *vo, bool paused);
|
||||
int64_t vo_get_drop_count(struct vo *vo);
|
||||
int vo_query_format(struct vo *vo, int format);
|
||||
void vo_query_formats(struct vo *vo, uint8_t *list);
|
||||
void vo_event(struct vo *vo, int event);
|
||||
int vo_query_and_reset_events(struct vo *vo, int events);
|
||||
|
||||
|
|
Loading…
Reference in New Issue