From 52d1f3cc533e28c81cd9807ddb0a51d0de543b9d Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 17 Jan 2013 16:10:26 +0100 Subject: options: also accept ffmpeg pixel format names Options that take pixel format names now also accept ffmpeg names. mpv internal names are preferred. We leave this undocumented intentionally, and may be removed once libswscale stops printing ffmpeg pixel format names to the terminal (or if we stop passing the SWS_PRINT_INFO flag to it, which makes it print these). (We insist on keeping the mpv specific names instead of dropping them in favor of ffmpeg's name due to NIH, and also because ffmpeg always appends the endian suffixes "le" and "be".) --- video/img_format.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'video/img_format.c') diff --git a/video/img_format.c b/video/img_format.c index 88cd6e80a2..51fa1fc1ea 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -46,7 +46,6 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = { FMT("422p", IMGFMT_422P) FMT("440p", IMGFMT_440P) FMT("420p", IMGFMT_420P) - FMT("yv12", IMGFMT_420P) // old alias for UI FMT("411p", IMGFMT_411P) FMT("410p", IMGFMT_410P) FMT_ENDIAN("444p16", IMGFMT_444P16) @@ -122,14 +121,23 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = { unsigned int mp_imgfmt_from_name(bstr name, bool allow_hwaccel) { + int img_fmt = 0; for(struct mp_imgfmt_entry *p = mp_imgfmt_list; p->name; ++p) { - if(!bstrcasecmp0(name, p->name)) { - if (!allow_hwaccel && IMGFMT_IS_HWACCEL(p->fmt)) - return 0; - return p->fmt; + if(bstr_equals0(name, p->name)) { + img_fmt = p->fmt; + break; } } - return 0; + if (!img_fmt) { + char *t = bstrdup0(NULL, name); + img_fmt = pixfmt2imgfmt(av_get_pix_fmt(t)); + talloc_free(t); + } + if (!img_fmt && bstr_equals0(name, "yv12")) + img_fmt = IMGFMT_420P; // old alias for UI + if (!allow_hwaccel && IMGFMT_IS_HWACCEL(img_fmt)) + return 0; + return img_fmt; } const char *mp_imgfmt_to_name(unsigned int fmt) -- cgit v1.2.3