mirror of https://github.com/mpv-player/mpv
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".)
This commit is contained in:
parent
a410d82ade
commit
52d1f3cc53
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue