From 2115e2306e8d7b5dcae452aa2dff37287ba4de48 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 16 Jan 2018 11:37:21 +0100 Subject: video: add utility function to pick conversion image format from a list --- video/img_format.c | 9 +++++++++ video/img_format.h | 1 + 2 files changed, 10 insertions(+) (limited to 'video') diff --git a/video/img_format.c b/video/img_format.c index 12822b176f..131ff4cb11 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -486,6 +486,15 @@ int mp_imgfmt_select_best(int dst1, int dst2, int src) return pixfmt2imgfmt(avcodec_find_best_pix_fmt_of_list(dstlist, srcpxf, 1, 0)); } +// Same as mp_imgfmt_select_best(), but with a list of dst formats. +int mp_imgfmt_select_best_list(int *dst, int num_dst, int src) +{ + int best = 0; + for (int n = 0; n < num_dst; n++) + best = best ? mp_imgfmt_select_best(best, dst[n], src) : dst[n]; + return best; +} + #if 0 #include diff --git a/video/img_format.h b/video/img_format.h index 123c8ba55e..c8f60f0414 100644 --- a/video/img_format.h +++ b/video/img_format.h @@ -244,5 +244,6 @@ char **mp_imgfmt_name_list(void); int mp_imgfmt_find(int xs, int ys, int planes, int component_bits, int flags); int mp_imgfmt_select_best(int dst1, int dst2, int src); +int mp_imgfmt_select_best_list(int *dst, int num_dst, int src); #endif /* MPLAYER_IMG_FORMAT_H */ -- cgit v1.2.3