summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-16 11:37:21 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-18 00:59:07 -0800
commit2115e2306e8d7b5dcae452aa2dff37287ba4de48 (patch)
tree85038e0b982e737b552c4f81fe2d9ec7c0a91a2f
parentd652d479f1c2c6cdff1867d5be03ab9bcfb2656d (diff)
downloadmpv-2115e2306e8d7b5dcae452aa2dff37287ba4de48.tar.bz2
mpv-2115e2306e8d7b5dcae452aa2dff37287ba4de48.tar.xz
video: add utility function to pick conversion image format from a list
-rw-r--r--video/img_format.c9
-rw-r--r--video/img_format.h1
2 files changed, 10 insertions, 0 deletions
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 <libavutil/frame.h>
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 */