From 6ab72f976035f094406584795f680d2de8761c2b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 14 Jun 2014 09:58:48 +0200 Subject: video: automatically strip "le" and "be" suffix from pixle format names These suffixes are annoying when they're redundant, so strip them automatically. On little endian machines, always strip the "le" suffix, and on big endian machines vice versa (although I don't think anyone ever tried to run mpv on a big endian machine). Since pixel format strings are returned by a certain function and we can't just change static strings, use a trick to pass a stack buffer transparently. But this also means the string can't be permanently stored by the caller, so vf_dlopen.c has to be updated. There seems to be no other case where this is done, though. --- video/img_format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'video/img_format.h') diff --git a/video/img_format.h b/video/img_format.h index 9277b0698c..64662aba08 100644 --- a/video/img_format.h +++ b/video/img_format.h @@ -71,7 +71,6 @@ struct mp_imgfmt_desc { int id; // IMGFMT_* int avformat; // AV_PIX_FMT_* (or AV_PIX_FMT_NONE) - const char *name; // e.g. "420p16" int flags; // MP_IMGFLAG_* bitfield int8_t num_planes; int8_t chroma_xs, chroma_ys; // chroma shift (i.e. log2 of chroma pixel size) @@ -335,7 +334,8 @@ static inline bool IMGFMT_IS_RGB(int fmt) (fmt) == IMGFMT_VAAPI || (fmt) == IMGFMT_VDA) int mp_imgfmt_from_name(bstr name, bool allow_hwaccel); -const char *mp_imgfmt_to_name(int fmt); +char *mp_imgfmt_to_name_buf(char *buf, size_t buf_size, int fmt); +#define mp_imgfmt_to_name(fmt) mp_imgfmt_to_name_buf((char[16]){0}, 16, (fmt)) char **mp_imgfmt_name_list(void); -- cgit v1.2.3