1
mirror of https://github.com/mpv-player/mpv synced 2024-11-03 03:19:24 +01:00

imgfmt: add more ffmpeg pixel formats

Most of these probably don't have much actual use, but at least allow
images of these formats to be handed to swscale, should any decoder
output them.
This commit is contained in:
wm4 2012-12-27 00:58:45 +01:00
parent 4950513ffe
commit 61e59cd92c
3 changed files with 136 additions and 2 deletions

View File

@ -55,11 +55,20 @@ static const struct {
{IMGFMT_RGB4, PIX_FMT_BGR4},
{IMGFMT_PAL8, PIX_FMT_PAL8},
{IMGFMT_GBRP, PIX_FMT_GBRP},
{IMGFMT_GBRP9_BE, PIX_FMT_GBRP9BE},
{IMGFMT_GBRP9_LE, PIX_FMT_GBRP9LE},
{IMGFMT_GBRP10_BE, PIX_FMT_GBRP10BE},
{IMGFMT_GBRP10_LE, PIX_FMT_GBRP10LE},
{IMGFMT_GBRP16_BE, PIX_FMT_GBRP16BE},
{IMGFMT_GBRP16_LE, PIX_FMT_GBRP16LE},
{IMGFMT_YUYV, PIX_FMT_YUYV422},
{IMGFMT_UYVY, PIX_FMT_UYVY422},
{IMGFMT_NV12, PIX_FMT_NV12},
{IMGFMT_NV21, PIX_FMT_NV21},
{IMGFMT_Y8, PIX_FMT_GRAY8},
// Support really ancient ffmpeg versions (before e91946ed23dfbb)
// Newer versions use PIX_FMT_GRAY8A
{IMGFMT_YA8, PIX_FMT_Y400A},
{IMGFMT_Y16_LE, PIX_FMT_GRAY16LE},
{IMGFMT_Y16_BE, PIX_FMT_GRAY16BE},
{IMGFMT_410P, PIX_FMT_YUV410P},
@ -69,8 +78,6 @@ static const struct {
{IMGFMT_444P, PIX_FMT_YUV444P},
{IMGFMT_440P, PIX_FMT_YUV440P},
{IMGFMT_420AP, PIX_FMT_YUVA420P},
{IMGFMT_420P16_LE, PIX_FMT_YUV420P16LE},
{IMGFMT_420P16_BE, PIX_FMT_YUV420P16BE},
{IMGFMT_420P9_LE, PIX_FMT_YUV420P9LE},
@ -97,6 +104,34 @@ static const struct {
{IMGFMT_444P, PIX_FMT_YUVJ444P},
{IMGFMT_440P, PIX_FMT_YUVJ440P},
{IMGFMT_420AP, PIX_FMT_YUVA420P},
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(52, 10, 0)
{IMGFMT_422AP, PIX_FMT_YUVA422P},
{IMGFMT_444AP, PIX_FMT_YUVA444P},
{IMGFMT_420AP9_BE, AV_PIX_FMT_YUVA420P9BE},
{IMGFMT_420AP9_LE, AV_PIX_FMT_YUVA420P9LE},
{IMGFMT_420AP10_BE, AV_PIX_FMT_YUVA420P10BE},
{IMGFMT_420AP10_LE, AV_PIX_FMT_YUVA420P10LE},
{IMGFMT_420AP16_BE, AV_PIX_FMT_YUVA420P16BE},
{IMGFMT_420AP16_LE, AV_PIX_FMT_YUVA420P16LE},
{IMGFMT_422AP9_BE, AV_PIX_FMT_YUVA422P9BE},
{IMGFMT_422AP9_LE, AV_PIX_FMT_YUVA422P9LE},
{IMGFMT_422AP10_BE, AV_PIX_FMT_YUVA422P10BE},
{IMGFMT_422AP10_LE, AV_PIX_FMT_YUVA422P10LE},
{IMGFMT_422AP16_BE, AV_PIX_FMT_YUVA422P16BE},
{IMGFMT_422AP16_LE, AV_PIX_FMT_YUVA422P16LE},
{IMGFMT_444AP9_BE, AV_PIX_FMT_YUVA444P9BE},
{IMGFMT_444AP9_LE, AV_PIX_FMT_YUVA444P9LE},
{IMGFMT_444AP10_BE, AV_PIX_FMT_YUVA444P10BE},
{IMGFMT_444AP10_LE, AV_PIX_FMT_YUVA444P10LE},
{IMGFMT_444AP16_BE, AV_PIX_FMT_YUVA444P16BE},
{IMGFMT_444AP16_LE, AV_PIX_FMT_YUVA444P16LE},
#endif
// ffmpeg only
#if LIBAVUTIL_VERSION_MICRO >= 100
{IMGFMT_420P12_LE, PIX_FMT_YUV420P12LE},
@ -112,7 +147,21 @@ static const struct {
{IMGFMT_444P14_BE, PIX_FMT_YUV444P14BE},
{IMGFMT_444P14_LE, PIX_FMT_YUV444P14LE},
{IMGFMT_GBRP12_BE, PIX_FMT_GBRP12BE},
{IMGFMT_GBRP12_LE, PIX_FMT_GBRP12LE},
{IMGFMT_GBRP14_BE, PIX_FMT_GBRP14BE},
{IMGFMT_GBRP14_LE, PIX_FMT_GBRP14LE},
{IMGFMT_BGR0, PIX_FMT_BGR0},
{IMGFMT_0RGB, PIX_FMT_0RGB},
{IMGFMT_RGB0, PIX_FMT_RGB0},
{IMGFMT_0BGR, PIX_FMT_0BGR},
{IMGFMT_BGR0, PIX_FMT_BGR0},
{IMGFMT_RGBA64_BE, PIX_FMT_RGBA64BE},
{IMGFMT_RGBA64_LE, PIX_FMT_RGBA64LE},
{IMGFMT_BGRA64_BE, PIX_FMT_BGRA64BE},
{IMGFMT_BGRA64_LE, PIX_FMT_BGRA64LE},
#endif
{IMGFMT_VDPAU_MPEG1, PIX_FMT_VDPAU_MPEG1},

View File

@ -37,6 +37,7 @@
struct mp_imgfmt_entry mp_imgfmt_list[] = {
FMT("y8", IMGFMT_Y8)
FMT_ENDIAN("y16", IMGFMT_Y16)
FMT("ya8", IMGFMT_YA8)
FMT("yuyv", IMGFMT_YUYV)
FMT("uyvy", IMGFMT_UYVY)
FMT("nv12", IMGFMT_NV12)
@ -63,17 +64,33 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = {
FMT_ENDIAN("420p12", IMGFMT_420P12)
FMT_ENDIAN("420p10", IMGFMT_420P10)
FMT_ENDIAN("420p9", IMGFMT_420P9)
FMT("444ap", IMGFMT_444AP)
FMT("422ap", IMGFMT_422AP)
FMT("420ap", IMGFMT_420AP)
FMT_ENDIAN("444ap9", IMGFMT_444AP9)
FMT_ENDIAN("444ap10", IMGFMT_444AP10)
FMT_ENDIAN("444ap16", IMGFMT_444AP16)
FMT_ENDIAN("422ap9", IMGFMT_422AP9)
FMT_ENDIAN("422ap10", IMGFMT_422AP10)
FMT_ENDIAN("422ap16", IMGFMT_422AP16)
FMT_ENDIAN("420ap9", IMGFMT_420AP9)
FMT_ENDIAN("420ap10", IMGFMT_420AP10)
FMT_ENDIAN("420ap16", IMGFMT_420AP16)
FMT("argb", IMGFMT_ARGB)
FMT("0rgb", IMGFMT_0RGB)
FMT("bgra", IMGFMT_BGRA)
FMT("bgr0", IMGFMT_BGR0)
FMT("abgr", IMGFMT_ABGR)
FMT("0bgr", IMGFMT_0BGR)
FMT("rgba", IMGFMT_RGBA)
FMT("rgb0", IMGFMT_RGB0)
FMT("rgb32", IMGFMT_RGB32)
FMT("bgr32", IMGFMT_BGR32)
FMT("bgr24", IMGFMT_BGR24)
FMT("rgb24", IMGFMT_RGB24)
FMT_ENDIAN("rgb48", IMGFMT_RGB48)
FMT_ENDIAN("rgba64", IMGFMT_RGBA64)
FMT_ENDIAN("bgra64", IMGFMT_BGRA64)
FMT("rgb8", IMGFMT_RGB8)
FMT("bgr8", IMGFMT_BGR8)
FMT("rgb4_byte", IMGFMT_RGB4_BYTE)
@ -89,6 +106,11 @@ struct mp_imgfmt_entry mp_imgfmt_list[] = {
FMT_ENDIAN("bgr16", IMGFMT_BGR16)
FMT("pal8", IMGFMT_PAL8)
FMT("gbrp", IMGFMT_GBRP)
FMT_ENDIAN("gbrp9", IMGFMT_GBRP9)
FMT_ENDIAN("gbrp10", IMGFMT_GBRP10)
FMT_ENDIAN("gbrp12", IMGFMT_GBRP12)
FMT_ENDIAN("gbrp14", IMGFMT_GBRP14)
FMT_ENDIAN("gbrp16", IMGFMT_GBRP16)
FMT("vdpau_mpeg1", IMGFMT_VDPAU_MPEG1)
FMT("vdpau_mpeg2", IMGFMT_VDPAU_MPEG2)
FMT("vdpau_h264", IMGFMT_VDPAU_H264)

View File

@ -129,13 +129,39 @@ enum mp_imgfmt {
IMGFMT_420P9_BE,
// Planar YUV with alpha (4th plane)
IMGFMT_444AP,
IMGFMT_422AP,
IMGFMT_420AP,
IMGFMT_444AP16_LE,
IMGFMT_444AP16_BE,
IMGFMT_444AP10_LE,
IMGFMT_444AP10_BE,
IMGFMT_444AP9_LE,
IMGFMT_444AP9_BE,
IMGFMT_422AP16_LE,
IMGFMT_422AP16_BE,
IMGFMT_422AP10_LE,
IMGFMT_422AP10_BE,
IMGFMT_422AP9_LE,
IMGFMT_422AP9_BE,
IMGFMT_420AP16_LE,
IMGFMT_420AP16_BE,
IMGFMT_420AP10_LE,
IMGFMT_420AP10_BE,
IMGFMT_420AP9_LE,
IMGFMT_420AP9_BE,
// Gray
IMGFMT_Y8,
IMGFMT_Y16_LE,
IMGFMT_Y16_BE,
// Gray with alpha (packed)
IMGFMT_YA8,
// Packed YUV formats (components are byte-accessed)
IMGFMT_YUYV, // Y0 U Y1 V
IMGFMT_UYVY, // U Y0 V Y1
@ -148,14 +174,21 @@ enum mp_imgfmt {
// Byte accessed (low address to high address)
IMGFMT_ARGB,
IMGFMT_0RGB,
IMGFMT_BGRA,
IMGFMT_BGR0,
IMGFMT_ABGR,
IMGFMT_0BGR,
IMGFMT_RGBA,
IMGFMT_RGB0,
IMGFMT_BGR24,
IMGFMT_RGB24,
IMGFMT_RGB48_LE,
IMGFMT_RGB48_BE,
IMGFMT_RGBA64_LE,
IMGFMT_RGBA64_BE,
IMGFMT_BGRA64_LE,
IMGFMT_BGRA64_BE,
// Accessed with bit-shifts (components ordered from LSB to MSB)
IMGFMT_RGB8, // r3 g3 b2
@ -184,6 +217,16 @@ enum mp_imgfmt {
// Planar RGB (planes are shuffled: plane 0 is G, etc.)
IMGFMT_GBRP,
IMGFMT_GBRP9_LE,
IMGFMT_GBRP9_BE,
IMGFMT_GBRP10_LE,
IMGFMT_GBRP10_BE,
IMGFMT_GBRP12_LE,
IMGFMT_GBRP12_BE,
IMGFMT_GBRP14_LE,
IMGFMT_GBRP14_BE,
IMGFMT_GBRP16_LE,
IMGFMT_GBRP16_BE,
// Hardware acclerated formats. Plane data points to special data
// structures, instead of pixel data.
@ -218,6 +261,8 @@ enum mp_imgfmt {
IMGFMT_BGR15 = MP_SELECT_LE_BE(IMGFMT_BGR15_LE, IMGFMT_BGR15_BE),
IMGFMT_BGR16 = MP_SELECT_LE_BE(IMGFMT_BGR16_LE, IMGFMT_BGR16_BE),
IMGFMT_RGB48 = MP_SELECT_LE_BE(IMGFMT_RGB48_LE, IMGFMT_RGB48_BE),
IMGFMT_RGBA64 = MP_SELECT_LE_BE(IMGFMT_RGBA64_LE, IMGFMT_RGBA64_BE),
IMGFMT_BGRA64 = MP_SELECT_LE_BE(IMGFMT_BGRA64_LE, IMGFMT_BGRA64_BE),
IMGFMT_444P16 = MP_SELECT_LE_BE(IMGFMT_444P16_LE, IMGFMT_444P16_BE),
IMGFMT_444P14 = MP_SELECT_LE_BE(IMGFMT_444P14_LE, IMGFMT_444P14_BE),
@ -237,7 +282,25 @@ enum mp_imgfmt {
IMGFMT_420P10 = MP_SELECT_LE_BE(IMGFMT_420P10_LE, IMGFMT_420P10_BE),
IMGFMT_420P9 = MP_SELECT_LE_BE(IMGFMT_420P9_LE, IMGFMT_420P9_BE),
IMGFMT_444AP16 = MP_SELECT_LE_BE(IMGFMT_444AP16_LE, IMGFMT_444AP16_BE),
IMGFMT_444AP10 = MP_SELECT_LE_BE(IMGFMT_444AP10_LE, IMGFMT_444AP10_BE),
IMGFMT_444AP9 = MP_SELECT_LE_BE(IMGFMT_444AP9_LE, IMGFMT_444AP9_BE),
IMGFMT_422AP16 = MP_SELECT_LE_BE(IMGFMT_422AP16_LE, IMGFMT_422AP16_BE),
IMGFMT_422AP10 = MP_SELECT_LE_BE(IMGFMT_422AP10_LE, IMGFMT_422AP10_BE),
IMGFMT_422AP9 = MP_SELECT_LE_BE(IMGFMT_422AP9_LE, IMGFMT_422AP9_BE),
IMGFMT_420AP16 = MP_SELECT_LE_BE(IMGFMT_420AP16_LE, IMGFMT_420AP16_BE),
IMGFMT_420AP10 = MP_SELECT_LE_BE(IMGFMT_420AP10_LE, IMGFMT_420AP10_BE),
IMGFMT_420AP9 = MP_SELECT_LE_BE(IMGFMT_420AP9_LE, IMGFMT_420AP9_BE),
IMGFMT_Y16 = MP_SELECT_LE_BE(IMGFMT_Y16_LE, IMGFMT_Y16_BE),
IMGFMT_GBRP9 = MP_SELECT_LE_BE(IMGFMT_GBRP9_LE, IMGFMT_GBRP9_BE),
IMGFMT_GBRP10 = MP_SELECT_LE_BE(IMGFMT_GBRP10_LE, IMGFMT_GBRP10_BE),
IMGFMT_GBRP12 = MP_SELECT_LE_BE(IMGFMT_GBRP12_LE, IMGFMT_GBRP12_BE),
IMGFMT_GBRP14 = MP_SELECT_LE_BE(IMGFMT_GBRP14_LE, IMGFMT_GBRP14_BE),
IMGFMT_GBRP16 = MP_SELECT_LE_BE(IMGFMT_GBRP16_LE, IMGFMT_GBRP16_BE),
};
static inline bool IMGFMT_IS_RGB(unsigned int fmt)