summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-01-17 16:10:26 +0100
committerwm4 <wm4@nowhere>2013-01-17 16:39:26 +0100
commit52d1f3cc533e28c81cd9807ddb0a51d0de543b9d (patch)
tree877197ebe1fd599069be1bfd0ba36479de24266d /video
parenta410d82adeef52354f819d53c988cf48fa575f65 (diff)
downloadmpv-52d1f3cc533e28c81cd9807ddb0a51d0de543b9d.tar.bz2
mpv-52d1f3cc533e28c81cd9807ddb0a51d0de543b9d.tar.xz
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".)
Diffstat (limited to 'video')
-rw-r--r--video/fmt-conversion.c6
-rw-r--r--video/img_format.c20
2 files changed, 20 insertions, 6 deletions
diff --git a/video/fmt-conversion.c b/video/fmt-conversion.c
index c20097224e..b37bd6c441 100644
--- a/video/fmt-conversion.c
+++ b/video/fmt-conversion.c
@@ -175,6 +175,9 @@ static const struct {
enum PixelFormat imgfmt2pixfmt(int fmt)
{
+ if (fmt == IMGFMT_NONE)
+ return PIX_FMT_NONE;
+
int i;
enum PixelFormat pix_fmt;
for (i = 0; conversion_map[i].fmt; i++)
@@ -188,6 +191,9 @@ enum PixelFormat imgfmt2pixfmt(int fmt)
int pixfmt2imgfmt(enum PixelFormat pix_fmt)
{
+ if (pix_fmt == PIX_FMT_NONE)
+ return IMGFMT_NONE;
+
int i;
for (i = 0; conversion_map[i].pix_fmt != PIX_FMT_NONE; i++)
if (conversion_map[i].pix_fmt == pix_fmt)
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)