mirror of https://github.com/mpv-player/mpv
video: drop some more IMGFMT aliases
For vo_opengl and vo_direct3d, these are supported in a generic way. For vf_vapoursynth, we could probably map its VSFormat struct in a generic way, but for now do some bullshit. vf_eq.c actually loses support for these formats. We could add generic support too (anything that has 8 bit planes will work), but why bother. The filter is deprecated anyway.
This commit is contained in:
parent
af5a71f52e
commit
300f6a3344
|
@ -364,11 +364,7 @@ int query_format (vf_instance_t *vf, unsigned fmt)
|
|||
switch (fmt) {
|
||||
case IMGFMT_Y8:
|
||||
case IMGFMT_444P:
|
||||
case IMGFMT_422P:
|
||||
case IMGFMT_440P:
|
||||
case IMGFMT_420P:
|
||||
case IMGFMT_411P:
|
||||
case IMGFMT_410P:
|
||||
return vf_next_query_format (vf, fmt);
|
||||
}
|
||||
|
||||
|
|
|
@ -97,44 +97,73 @@ struct script_driver {
|
|||
|
||||
struct mpvs_fmt {
|
||||
VSPresetFormat vs;
|
||||
int mp;
|
||||
int bits, cw, ch;
|
||||
};
|
||||
|
||||
static const struct mpvs_fmt mpvs_fmt_table[] = {
|
||||
{pfYUV420P8, IMGFMT_420P},
|
||||
{pfYUV422P8, IMGFMT_422P},
|
||||
{pfYUV444P8, IMGFMT_444P},
|
||||
{pfYUV410P8, IMGFMT_410P},
|
||||
{pfYUV411P8, IMGFMT_411P},
|
||||
{pfYUV440P8, IMGFMT_440P},
|
||||
{pfYUV420P9, IMGFMT_420P9},
|
||||
{pfYUV422P9, IMGFMT_422P9},
|
||||
{pfYUV444P9, IMGFMT_444P9},
|
||||
{pfYUV420P10, IMGFMT_420P10},
|
||||
{pfYUV422P10, IMGFMT_422P10},
|
||||
{pfYUV444P10, IMGFMT_444P10},
|
||||
{pfYUV420P16, IMGFMT_420P16},
|
||||
{pfYUV422P16, IMGFMT_422P16},
|
||||
{pfYUV444P16, IMGFMT_444P16},
|
||||
{pfYUV420P8, 8, 2, 2},
|
||||
{pfYUV420P9, 9, 2, 2},
|
||||
{pfYUV420P10, 10, 2, 2},
|
||||
{pfYUV420P16, 16, 2, 2},
|
||||
{pfYUV422P8, 8, 2, 1},
|
||||
{pfYUV422P9, 9, 2, 1},
|
||||
{pfYUV422P10, 10, 2, 1},
|
||||
{pfYUV422P16, 16, 2, 1},
|
||||
{pfYUV410P8, 8, 4, 4},
|
||||
{pfYUV411P8, 8, 4, 1},
|
||||
{pfYUV440P8, 8, 1, 2},
|
||||
{pfYUV444P8, 8, 1, 1},
|
||||
{pfYUV444P9, 9, 1, 1},
|
||||
{pfYUV444P10, 10, 1, 1},
|
||||
{pfYUV444P16, 16, 1, 1},
|
||||
{pfNone}
|
||||
};
|
||||
|
||||
static bool compare_fmt(int imgfmt, const struct mpvs_fmt *vs)
|
||||
{
|
||||
struct mp_regular_imgfmt rfmt;
|
||||
if (!mp_get_regular_imgfmt(&rfmt, imgfmt))
|
||||
return false;
|
||||
if (rfmt.component_pad > 0)
|
||||
return false;
|
||||
if (rfmt.chroma_w != vs->cw || rfmt.chroma_h != vs->ch)
|
||||
return false;
|
||||
if (rfmt.component_size * 8 - rfmt.component_pad != vs->bits)
|
||||
return false;
|
||||
if (rfmt.num_planes != 3)
|
||||
return false;
|
||||
for (int n = 0; n < 3; n++) {
|
||||
if (rfmt.planes[n].num_components != 1)
|
||||
return false;
|
||||
if (rfmt.planes[n].components[0] != n + 1)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static VSPresetFormat mp_to_vs(int imgfmt)
|
||||
{
|
||||
for (int n = 0; mpvs_fmt_table[n].mp; n++) {
|
||||
if (mpvs_fmt_table[n].mp == imgfmt)
|
||||
return mpvs_fmt_table[n].vs;
|
||||
for (int n = 0; mpvs_fmt_table[n].bits; n++) {
|
||||
const struct mpvs_fmt *vsentry = &mpvs_fmt_table[n];
|
||||
if (compare_fmt(imgfmt, vsentry))
|
||||
return vsentry->vs;
|
||||
}
|
||||
return pfNone;
|
||||
}
|
||||
|
||||
static int mp_from_vs(VSPresetFormat vs)
|
||||
{
|
||||
for (int n = 0; mpvs_fmt_table[n].mp; n++) {
|
||||
if (mpvs_fmt_table[n].vs == vs)
|
||||
return mpvs_fmt_table[n].mp;
|
||||
for (int n = 0; mpvs_fmt_table[n].bits; n++) {
|
||||
const struct mpvs_fmt *vsentry = &mpvs_fmt_table[n];
|
||||
if (vsentry->vs == vs) {
|
||||
for (int imgfmt = IMGFMT_START; imgfmt < IMGFMT_END; imgfmt++) {
|
||||
if (compare_fmt(imgfmt, vsentry))
|
||||
return imgfmt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pfNone;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void copy_mp_to_vs_frame_props_map(struct vf_priv_s *p, VSMap *map,
|
||||
|
|
|
@ -40,29 +40,13 @@ static const struct {
|
|||
// FFmpeg prefers AV_PIX_FMT_GRAY8A, but Libav has only Y400A
|
||||
{IMGFMT_YA8, AV_PIX_FMT_Y400A},
|
||||
{IMGFMT_Y16, AV_PIX_FMT_GRAY16},
|
||||
{IMGFMT_410P, AV_PIX_FMT_YUV410P},
|
||||
{IMGFMT_420P, AV_PIX_FMT_YUV420P},
|
||||
{IMGFMT_411P, AV_PIX_FMT_YUV411P},
|
||||
{IMGFMT_422P, AV_PIX_FMT_YUV422P},
|
||||
{IMGFMT_444P, AV_PIX_FMT_YUV444P},
|
||||
{IMGFMT_440P, AV_PIX_FMT_YUV440P},
|
||||
|
||||
{IMGFMT_420P16, AV_PIX_FMT_YUV420P16},
|
||||
{IMGFMT_420P9, AV_PIX_FMT_YUV420P9},
|
||||
{IMGFMT_420P10, AV_PIX_FMT_YUV420P10},
|
||||
{IMGFMT_422P10, AV_PIX_FMT_YUV422P10},
|
||||
{IMGFMT_444P9, AV_PIX_FMT_YUV444P9},
|
||||
{IMGFMT_444P10, AV_PIX_FMT_YUV444P10},
|
||||
{IMGFMT_422P16, AV_PIX_FMT_YUV422P16},
|
||||
{IMGFMT_422P9, AV_PIX_FMT_YUV422P9},
|
||||
{IMGFMT_444P16, AV_PIX_FMT_YUV444P16},
|
||||
|
||||
// YUVJ are YUV formats that use the full Y range. Decoder color range
|
||||
// information is used instead. Deprecated in ffmpeg.
|
||||
{IMGFMT_420P, AV_PIX_FMT_YUVJ420P},
|
||||
{IMGFMT_422P, AV_PIX_FMT_YUVJ422P},
|
||||
{IMGFMT_444P, AV_PIX_FMT_YUVJ444P},
|
||||
{IMGFMT_440P, AV_PIX_FMT_YUVJ440P},
|
||||
|
||||
#if LIBAVUTIL_VERSION_MICRO >= 100
|
||||
{IMGFMT_BGR0, AV_PIX_FMT_BGR0},
|
||||
|
@ -95,9 +79,6 @@ static const struct {
|
|||
{IMGFMT_CUDA, AV_PIX_FMT_CUDA},
|
||||
#endif
|
||||
{IMGFMT_P010, AV_PIX_FMT_P010},
|
||||
#ifdef AV_PIX_FMT_P016
|
||||
{IMGFMT_P016, AV_PIX_FMT_P016},
|
||||
#endif
|
||||
|
||||
{0, AV_PIX_FMT_NONE}
|
||||
};
|
||||
|
|
|
@ -142,26 +142,7 @@ enum mp_imgfmt {
|
|||
|
||||
// Planar YUV formats
|
||||
IMGFMT_444P, // 1x1
|
||||
IMGFMT_422P, // 2x1
|
||||
IMGFMT_440P, // 1x2
|
||||
IMGFMT_420P, // 2x2
|
||||
IMGFMT_411P, // 4x1
|
||||
IMGFMT_410P, // 4x4
|
||||
|
||||
// YUV formats with 2 bytes per plane-pixel. Formats with 9-15 bits pad the
|
||||
// most significant bits with 0 (use shifts to expand them to 16 bits).
|
||||
|
||||
IMGFMT_444P16,
|
||||
IMGFMT_444P10,
|
||||
IMGFMT_444P9,
|
||||
|
||||
IMGFMT_422P16,
|
||||
IMGFMT_422P10,
|
||||
IMGFMT_422P9,
|
||||
|
||||
IMGFMT_420P16,
|
||||
IMGFMT_420P10,
|
||||
IMGFMT_420P9,
|
||||
|
||||
// Gray
|
||||
IMGFMT_Y8,
|
||||
|
@ -179,8 +160,6 @@ enum mp_imgfmt {
|
|||
|
||||
// Like IMGFMT_NV12, but with 10 bits per component (and 6 bits of padding)
|
||||
IMGFMT_P010,
|
||||
// Like IMGFMT_NV12, but with 16 bits per component
|
||||
IMGFMT_P016,
|
||||
|
||||
// RGB/BGR Formats
|
||||
|
||||
|
|
Loading…
Reference in New Issue