summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2014-05-14 12:50:27 -0700
committerKevin Mitchell <kevmitch@gmail.com>2014-05-15 10:32:16 -0700
commit125dcf306a2998248c0480000b36db7388ddf490 (patch)
treea9cc3dcc2e47a9a860ff5e0fd061206573872325
parent0128579542cf55023aa01d7d6aba8079203960ef (diff)
downloadmpv-125dcf306a2998248c0480000b36db7388ddf490.tar.bz2
mpv-125dcf306a2998248c0480000b36db7388ddf490.tar.xz
vf_dlopen: remove buggy private name -> imgfmt conversion
This was presumably for backward compatibility, but it was preventing the use of the new names.
-rw-r--r--video/filter/vf_dlopen.c45
-rw-r--r--video/filter/vf_dlopen.h7
2 files changed, 18 insertions, 34 deletions
diff --git a/video/filter/vf_dlopen.c b/video/filter/vf_dlopen.c
index 70c2c6cf24..3e72fec8a5 100644
--- a/video/filter/vf_dlopen.c
+++ b/video/filter/vf_dlopen.c
@@ -76,32 +76,8 @@ struct fmtname {
enum mp_imgfmt fmt;
};
-// This table defines the pixel format names that are guaranteed to work.
-static const struct fmtname format_names[] = {
- {"yv12", IMGFMT_420P},
- {0}
-};
-
//===========================================================================//
-static const char *imgfmt_to_name(int fmt)
-{
- for (int n = 0; format_names[n].name; n++) {
- if (format_names[n].fmt == fmt)
- return format_names[n].name;
- }
- return mp_imgfmt_to_name(fmt);
-}
-
-static int name_to_imgfmt(const char *name)
-{
- for (int n = 0; format_names[n].name; n++) {
- if (strcasecmp(format_names[n].name, name) == 0)
- return format_names[n].fmt;
- }
- return mp_imgfmt_from_name(bstr0(name), false);
-}
-
static void set_imgprop(struct vf_dlopen_picdata *out, const mp_image_t *mpi)
{
int i;
@@ -126,7 +102,7 @@ static int config(struct vf_instance *vf,
vf->priv->filter.in_height = height;
vf->priv->filter.in_d_width = d_width;
vf->priv->filter.in_d_height = d_height;
- vf->priv->filter.in_fmt = imgfmt_to_name(fmt);
+ vf->priv->filter.in_fmt = mp_imgfmt_to_name(fmt);
vf->priv->filter.out_width = width;
vf->priv->filter.out_height = height;
vf->priv->filter.out_d_width = d_width;
@@ -149,7 +125,7 @@ static int config(struct vf_instance *vf,
vf->priv->out_height = vf->priv->filter.out_height;
if (vf->priv->filter.out_fmt)
- vf->priv->outfmt = name_to_imgfmt(vf->priv->filter.out_fmt);
+ vf->priv->outfmt = mp_imgfmt_from_name(bstr0(vf->priv->filter.out_fmt), false);
else {
struct vf_dlopen_formatpair *p = vf->priv->filter.format_mapping;
vf->priv->outfmt = 0;
@@ -157,13 +133,16 @@ static int config(struct vf_instance *vf,
for (; p->from; ++p) {
// TODO support pixel format classes in matching
if (!strcmp(p->from, vf->priv->filter.in_fmt)) {
- vf->priv->outfmt = name_to_imgfmt(p->to);
+ if(p->to)
+ vf->priv->outfmt = mp_imgfmt_from_name(bstr0(p->to), false);
+ else
+ vf->priv->outfmt = mp_imgfmt_from_name(bstr0(p->from), false);
break;
}
}
} else
vf->priv->outfmt = fmt;
- vf->priv->filter.out_fmt = imgfmt_to_name(vf->priv->outfmt);
+ vf->priv->filter.out_fmt = mp_imgfmt_to_name(vf->priv->outfmt);
}
if (!vf->priv->outfmt) {
@@ -285,7 +264,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
return 0; // these can't really be filtered
if (fmt == IMGFMT_PAL8)
return 0; // we don't have palette support, sorry
- const char *fmtname = imgfmt_to_name(fmt);
+ const char *fmtname = mp_imgfmt_to_name(fmt);
if (!fmtname)
return 0;
struct vf_dlopen_formatpair *p = vf->priv->filter.format_mapping;
@@ -294,12 +273,16 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
for (; p->from; ++p) {
// TODO support pixel format classes in matching
if (!strcmp(p->from, fmtname)) {
- outfmt = name_to_imgfmt(p->to);
+ if (p->to)
+ outfmt = mp_imgfmt_from_name(bstr0(p->to), false);
+ else
+ outfmt = mp_imgfmt_from_name(bstr0(p->from), false);
break;
}
}
- } else
+ } else {
outfmt = fmt;
+ }
if (!outfmt)
return 0;
return vf_next_query_format(vf, outfmt);
diff --git a/video/filter/vf_dlopen.h b/video/filter/vf_dlopen.h
index 962605ca28..e225cd3457 100644
--- a/video/filter/vf_dlopen.h
+++ b/video/filter/vf_dlopen.h
@@ -23,11 +23,12 @@
} while (0)
#endif
-// valid pixel format names:
-// "yv12": planar YUV, U and V planes have an xshift and yshift of 1
+// some common valid pixel format names:
+// "gray": 8 bit grayscale
+// "yuv420p": planar YUV, U and V planes have an xshift and yshift of 1
// "rgb24": packed RGB24
struct vf_dlopen_formatpair {
- const char *from; // (LATER) can also be a name of a format class
+ const char *from;
const char *to; // if NULL, this means identical format as source
};