summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorStephen Hutchinson <qyot27@gmail.com>2012-11-27 04:39:09 -0500
committerwm4 <wm4@nowhere>2012-12-03 21:08:51 +0100
commitc082240c62cb8855e55c0dbe88b8591458599ce9 (patch)
tree78dd20bfc585fb710857b39474b6ef20d2e8f1de /video
parent54ce8af6e0dbf41d9463ca38a5fdc33bd6ed913f (diff)
downloadmpv-c082240c62cb8855e55c0dbe88b8591458599ce9.tar.bz2
mpv-c082240c62cb8855e55c0dbe88b8591458599ce9.tar.xz
video: add support for 12 and 14 bit YUV pixel formats
Based on a patch by qyot27. Add the missing parts in mp_get_chroma_shift(), which allow allocation of such images, and which make vo_opengl automatically accept the new formats. Change the IMGFMT_IS_YUVP16_LE/BE macros to properly report IMGFMT_444P14 as supported: this pixel format has the highest numerical bit width identifier (0x55), which is not covered by the mask ~0xfc. Remove 1 bit from the mask (makes it 0xf8) so that IMGFMT_IS_YUVP16(IMGFMT_444P14) is 1. This is slightly risky, as the organization of the image format IDs (actually FourCCs + mplayer internal IDs) is messy at best, but it should be ok.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf_scale.c12
-rw-r--r--video/fmt-conversion.c12
-rw-r--r--video/img_format.c24
-rw-r--r--video/img_format.h30
-rw-r--r--video/mp_image.c12
5 files changed, 87 insertions, 3 deletions
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c
index 58664b8ae1..52994762eb 100644
--- a/video/filter/vf_scale.c
+++ b/video/filter/vf_scale.c
@@ -74,6 +74,10 @@ static const unsigned int outfmt_list[]={
IMGFMT_444P,
IMGFMT_444P16_LE,
IMGFMT_444P16_BE,
+ IMGFMT_444P14_LE,
+ IMGFMT_444P14_BE,
+ IMGFMT_444P12_LE,
+ IMGFMT_444P12_BE,
IMGFMT_444P10_LE,
IMGFMT_444P10_BE,
IMGFMT_444P9_LE,
@@ -81,6 +85,10 @@ static const unsigned int outfmt_list[]={
IMGFMT_422P,
IMGFMT_422P16_LE,
IMGFMT_422P16_BE,
+ IMGFMT_422P14_LE,
+ IMGFMT_422P14_BE,
+ IMGFMT_422P12_LE,
+ IMGFMT_422P12_BE,
IMGFMT_422P10_LE,
IMGFMT_422P10_BE,
IMGFMT_422P9_LE,
@@ -89,6 +97,10 @@ static const unsigned int outfmt_list[]={
IMGFMT_I420,
IMGFMT_420P16_LE,
IMGFMT_420P16_BE,
+ IMGFMT_420P14_LE,
+ IMGFMT_420P14_BE,
+ IMGFMT_420P12_LE,
+ IMGFMT_420P12_BE,
IMGFMT_420P10_LE,
IMGFMT_420P10_BE,
IMGFMT_420P9_LE,
diff --git a/video/fmt-conversion.c b/video/fmt-conversion.c
index 736af8701c..cd223fd525 100644
--- a/video/fmt-conversion.c
+++ b/video/fmt-conversion.c
@@ -82,12 +82,24 @@ static const struct {
{IMGFMT_420P9_BE, PIX_FMT_YUV420P9BE},
{IMGFMT_420P10_LE, PIX_FMT_YUV420P10LE},
{IMGFMT_420P10_BE, PIX_FMT_YUV420P10BE},
+ {IMGFMT_420P12_LE, PIX_FMT_YUV420P12LE},
+ {IMGFMT_420P12_BE, PIX_FMT_YUV420P12BE},
+ {IMGFMT_420P14_LE, PIX_FMT_YUV420P14LE},
+ {IMGFMT_420P14_BE, PIX_FMT_YUV420P14BE},
{IMGFMT_422P10_LE, PIX_FMT_YUV422P10LE},
{IMGFMT_422P10_BE, PIX_FMT_YUV422P10BE},
+ {IMGFMT_422P12_LE, PIX_FMT_YUV422P12LE},
+ {IMGFMT_422P12_BE, PIX_FMT_YUV422P12BE},
+ {IMGFMT_422P14_LE, PIX_FMT_YUV422P14LE},
+ {IMGFMT_422P14_BE, PIX_FMT_YUV422P14BE},
{IMGFMT_444P9_BE , PIX_FMT_YUV444P9BE},
{IMGFMT_444P9_LE , PIX_FMT_YUV444P9LE},
{IMGFMT_444P10_BE, PIX_FMT_YUV444P10BE},
{IMGFMT_444P10_LE, PIX_FMT_YUV444P10LE},
+ {IMGFMT_444P12_BE, PIX_FMT_YUV444P12BE},
+ {IMGFMT_444P12_LE, PIX_FMT_YUV444P12LE},
+ {IMGFMT_444P14_BE, PIX_FMT_YUV444P14BE},
+ {IMGFMT_444P14_LE, PIX_FMT_YUV444P14LE},
{IMGFMT_422P16_LE, PIX_FMT_YUV422P16LE},
{IMGFMT_422P16_BE, PIX_FMT_YUV422P16BE},
{IMGFMT_422P9_LE, PIX_FMT_YUV422P9LE},
diff --git a/video/img_format.c b/video/img_format.c
index 42df721435..203c8746db 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -49,6 +49,12 @@ int mp_get_chroma_shift(int format, int *x_shift, int *y_shift,
case 0x51:
bits = 16;
break;
+ case 0x55:
+ bits = 14;
+ break;
+ case 0x54:
+ bits = 12;
+ break;
case 0x52:
bits = 10;
break;
@@ -129,27 +135,45 @@ int mp_get_chroma_shift(int format, int *x_shift, int *y_shift,
struct mp_imgfmt_entry mp_imgfmt_list[] = {
{"444p16le", IMGFMT_444P16_LE},
{"444p16be", IMGFMT_444P16_BE},
+ {"444p14le", IMGFMT_444P14_LE},
+ {"444p14be", IMGFMT_444P14_BE},
+ {"444p12le", IMGFMT_444P12_LE},
+ {"444p12be", IMGFMT_444P12_BE},
{"444p10le", IMGFMT_444P10_LE},
{"444p10be", IMGFMT_444P10_BE},
{"444p9le", IMGFMT_444P9_LE},
{"444p9be", IMGFMT_444P9_BE},
{"422p16le", IMGFMT_422P16_LE},
{"422p16be", IMGFMT_422P16_BE},
+ {"422p14le", IMGFMT_422P14_LE},
+ {"422p14be", IMGFMT_422P14_BE},
+ {"422p12le", IMGFMT_422P12_LE},
+ {"422p12be", IMGFMT_422P12_BE},
{"422p10le", IMGFMT_422P10_LE},
{"422p10be", IMGFMT_422P10_BE},
{"422p9le", IMGFMT_422P9_LE},
{"422p9be", IMGFMT_422P9_BE},
{"420p16le", IMGFMT_420P16_LE},
{"420p16be", IMGFMT_420P16_BE},
+ {"420p14le", IMGFMT_420P14_LE},
+ {"420p14be", IMGFMT_420P14_BE},
+ {"420p12le", IMGFMT_420P12_LE},
+ {"420p12be", IMGFMT_420P12_BE},
{"420p10le", IMGFMT_420P10_LE},
{"420p10be", IMGFMT_420P10_BE},
{"420p9le", IMGFMT_420P9_LE},
{"420p9be", IMGFMT_420P9_BE},
{"444p16", IMGFMT_444P16},
+ {"444p14", IMGFMT_444P14},
+ {"444p12", IMGFMT_444P12},
{"444p10", IMGFMT_444P10},
{"444p9", IMGFMT_444P9},
{"422p16", IMGFMT_422P16},
+ {"422p14", IMGFMT_422P14},
+ {"422p12", IMGFMT_422P12},
{"422p10", IMGFMT_422P10},
+ {"420p14", IMGFMT_420P14},
+ {"420p12", IMGFMT_420P12},
{"420p10", IMGFMT_420P10},
{"420p9", IMGFMT_420P9},
{"420p16", IMGFMT_420P16},
diff --git a/video/img_format.h b/video/img_format.h
index f3611a5fab..ab657a22d0 100644
--- a/video/img_format.h
+++ b/video/img_format.h
@@ -143,45 +143,69 @@
#define IMGFMT_444P10_BE 0x34343452
#define IMGFMT_444P9_LE 0x53343434
#define IMGFMT_444P9_BE 0x34343453
+#define IMGFMT_444P12_LE 0x54343434
+#define IMGFMT_444P12_BE 0x34343454
+#define IMGFMT_444P14_LE 0x55343434
+#define IMGFMT_444P14_BE 0x34343455
#define IMGFMT_422P16_LE 0x51323234
#define IMGFMT_422P16_BE 0x34323251
#define IMGFMT_422P10_LE 0x52323234
#define IMGFMT_422P10_BE 0x34323252
#define IMGFMT_422P9_LE 0x53323234
#define IMGFMT_422P9_BE 0x34323253
+#define IMGFMT_422P12_LE 0x54323234
+#define IMGFMT_422P12_BE 0x34323254
+#define IMGFMT_422P14_LE 0x55323234
+#define IMGFMT_422P14_BE 0x34323255
#define IMGFMT_420P16_LE 0x51303234
#define IMGFMT_420P16_BE 0x34323051
#define IMGFMT_420P10_LE 0x52303234
#define IMGFMT_420P10_BE 0x34323052
#define IMGFMT_420P9_LE 0x53303234
#define IMGFMT_420P9_BE 0x34323053
+#define IMGFMT_420P12_LE 0x54303234
+#define IMGFMT_420P12_BE 0x34323054
+#define IMGFMT_420P14_LE 0x55303234
+#define IMGFMT_420P14_BE 0x34323055
#if BYTE_ORDER == BIG_ENDIAN
#define IMGFMT_444P16 IMGFMT_444P16_BE
+#define IMGFMT_444P14 IMGFMT_444P14_BE
+#define IMGFMT_444P12 IMGFMT_444P12_BE
#define IMGFMT_444P10 IMGFMT_444P10_BE
#define IMGFMT_444P9 IMGFMT_444P9_BE
#define IMGFMT_422P16 IMGFMT_422P16_BE
+#define IMGFMT_422P14 IMGFMT_422P14_BE
+#define IMGFMT_422P12 IMGFMT_422P12_BE
#define IMGFMT_422P10 IMGFMT_422P10_BE
#define IMGFMT_422P9 IMGFMT_422P9_BE
#define IMGFMT_420P16 IMGFMT_420P16_BE
+#define IMGFMT_420P14 IMGFMT_420P14_BE
+#define IMGFMT_420P12 IMGFMT_420P12_BE
#define IMGFMT_420P10 IMGFMT_420P10_BE
#define IMGFMT_420P9 IMGFMT_420P9_BE
#define IMGFMT_IS_YUVP16_NE(fmt) IMGFMT_IS_YUVP16_BE(fmt)
#else
#define IMGFMT_444P16 IMGFMT_444P16_LE
+#define IMGFMT_444P14 IMGFMT_444P14_LE
+#define IMGFMT_444P12 IMGFMT_444P12_LE
#define IMGFMT_444P10 IMGFMT_444P10_LE
#define IMGFMT_444P9 IMGFMT_444P9_LE
#define IMGFMT_422P16 IMGFMT_422P16_LE
+#define IMGFMT_422P14 IMGFMT_422P14_LE
+#define IMGFMT_422P12 IMGFMT_422P12_LE
#define IMGFMT_422P10 IMGFMT_422P10_LE
#define IMGFMT_422P9 IMGFMT_422P9_LE
#define IMGFMT_420P16 IMGFMT_420P16_LE
+#define IMGFMT_420P14 IMGFMT_420P14_LE
+#define IMGFMT_420P12 IMGFMT_420P12_LE
#define IMGFMT_420P10 IMGFMT_420P10_LE
#define IMGFMT_420P9 IMGFMT_420P9_LE
#define IMGFMT_IS_YUVP16_NE(fmt) IMGFMT_IS_YUVP16_LE(fmt)
#endif
-// These macros are misnamed - they actually match 9, 10 or 16 bits
-#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt - 0x51000034) & 0xfc0000ff) == 0 || fmt == IMGFMT_Y16LE)
-#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000fc) == 0 || fmt == IMGFMT_Y16BE)
+// These macros are misnamed - they actually match 9 to 16 bits (inclusive)
+#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt - 0x51000034) & 0xf80000ff) == 0 || fmt == IMGFMT_Y16LE)
+#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt - 0x34000051) & 0xff0000f8) == 0 || fmt == IMGFMT_Y16BE)
#define IMGFMT_IS_YUVP16(fmt) (IMGFMT_IS_YUVP16_LE(fmt) || IMGFMT_IS_YUVP16_BE(fmt))
/* Packed YUV Formats */
diff --git a/video/mp_image.c b/video/mp_image.c
index 7cfceca1c2..e4e862208b 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -164,18 +164,30 @@ void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
case IMGFMT_440P:
case IMGFMT_444P16_LE:
case IMGFMT_444P16_BE:
+ case IMGFMT_444P14_LE:
+ case IMGFMT_444P14_BE:
+ case IMGFMT_444P12_LE:
+ case IMGFMT_444P12_BE:
case IMGFMT_444P10_LE:
case IMGFMT_444P10_BE:
case IMGFMT_444P9_LE:
case IMGFMT_444P9_BE:
case IMGFMT_422P16_LE:
case IMGFMT_422P16_BE:
+ case IMGFMT_422P14_LE:
+ case IMGFMT_422P14_BE:
+ case IMGFMT_422P12_LE:
+ case IMGFMT_422P12_BE:
case IMGFMT_422P10_LE:
case IMGFMT_422P10_BE:
case IMGFMT_422P9_LE:
case IMGFMT_422P9_BE:
case IMGFMT_420P16_LE:
case IMGFMT_420P16_BE:
+ case IMGFMT_420P14_LE:
+ case IMGFMT_420P14_BE:
+ case IMGFMT_420P12_LE:
+ case IMGFMT_420P12_BE:
case IMGFMT_420P10_LE:
case IMGFMT_420P10_BE:
case IMGFMT_420P9_LE: