[MPlayer-dev-eng] [PATCH] Add support for 9-bit/10-bit H.264

Arne Bochem arneb.mp at ccan.de
Sun May 8 18:23:58 CEST 2011


Okay, turns out the first patch worked mostly by coincidence and the
second one was broken anyway, so I went through the colorspace related
files and did it thoroughly and correctly. Hopefully.

This patch adds support for displaying 9-bit and 10-bit H.264 video and
support for ffmpeg's new YUV420P10, YUV420P9, and YUV422P10 colorspaces
in general.

I was not quite sure how to go about adding 4CCs for the new
colorspaces, since there don't seem to be any official ones. In the end
I set the second and fourth bit P16's 'Q' byte for P10 and P9
respectively, which makes for 422S, 420S and 420Y, and allows the
adjusted masks in IMGFMT_IS_YUVP16_* to still uniquely identify the high
bit-depth YUV formats.

Regards,
Arne Bochem
-------------- next part --------------
Index: libmpcodecs/mp_image.c
===================================================================
--- libmpcodecs/mp_image.c	(revision 33445)
+++ libmpcodecs/mp_image.c	(working copy)
@@ -147,8 +147,14 @@
     case IMGFMT_444P16_BE:
     case IMGFMT_422P16_LE:
     case IMGFMT_422P16_BE:
+    case IMGFMT_422P10_LE:
+    case IMGFMT_422P10_BE:
     case IMGFMT_420P16_LE:
     case IMGFMT_420P16_BE:
+    case IMGFMT_420P10_LE:
+    case IMGFMT_420P10_BE:
+    case IMGFMT_420P9_LE:
+    case IMGFMT_420P9_BE:
         return;
     case IMGFMT_Y800:
     case IMGFMT_Y8:
Index: libmpcodecs/img_format.c
===================================================================
--- libmpcodecs/img_format.c	(revision 33445)
+++ libmpcodecs/img_format.c	(working copy)
@@ -59,8 +59,14 @@
     case IMGFMT_Y8: return "Planar Y8";
     case IMGFMT_420P16_LE: return "Planar 420P 16-bit little-endian";
     case IMGFMT_420P16_BE: return "Planar 420P 16-bit big-endian";
+    case IMGFMT_420P10_LE: return "Planar 420P 10-bit little-endian";
+    case IMGFMT_420P10_BE: return "Planar 420P 10-bit big-endian";
+    case IMGFMT_420P9_LE: return "Planar 420P 9-bit little-endian";
+    case IMGFMT_420P9_BE: return "Planar 420P 9-bit big-endian";
     case IMGFMT_422P16_LE: return "Planar 422P 16-bit little-endian";
     case IMGFMT_422P16_BE: return "Planar 422P 16-bit big-endian";
+    case IMGFMT_422P10_LE: return "Planar 422P 10-bit little-endian";
+    case IMGFMT_422P10_BE: return "Planar 422P 10-bit big-endian";
     case IMGFMT_444P16_LE: return "Planar 444P 16-bit little-endian";
     case IMGFMT_444P16_BE: return "Planar 444P 16-bit big-endian";
     case IMGFMT_420A: return "Planar 420P with alpha";
@@ -116,6 +122,10 @@
     switch (format) {
     case IMGFMT_420P16_LE:
     case IMGFMT_420P16_BE:
+    case IMGFMT_420P10_LE:
+    case IMGFMT_420P10_BE:
+    case IMGFMT_420P9_LE:
+    case IMGFMT_420P9_BE:
         bpp_factor = 2;
     case IMGFMT_420A:
     case IMGFMT_I420:
@@ -138,6 +148,8 @@
         break;
     case IMGFMT_422P16_LE:
     case IMGFMT_422P16_BE:
+    case IMGFMT_422P10_LE:
+    case IMGFMT_422P10_BE:
         bpp_factor = 2;
     case IMGFMT_422P:
         xs = 1;
Index: libmpcodecs/img_format.h
===================================================================
--- libmpcodecs/img_format.h	(revision 33445)
+++ libmpcodecs/img_format.h	(working copy)
@@ -125,21 +125,33 @@
 #define IMGFMT_444P16_BE 0x34343451
 #define IMGFMT_422P16_LE 0x51323234
 #define IMGFMT_422P16_BE 0x34323251
+#define IMGFMT_422P10_LE 0x53323234
+#define IMGFMT_422P10_BE 0x34323253
 #define IMGFMT_420P16_LE 0x51303234
 #define IMGFMT_420P16_BE 0x34323051
+#define IMGFMT_420P10_LE 0x53303234
+#define IMGFMT_420P10_BE 0x34323053
+#define IMGFMT_420P9_LE 0x59303234
+#define IMGFMT_420P9_BE 0x34323059
 #if HAVE_BIGENDIAN
 #define IMGFMT_444P16 IMGFMT_444P16_BE
 #define IMGFMT_422P16 IMGFMT_422P16_BE
+#define IMGFMT_422P10 IMGFMT_422P10_BE
 #define IMGFMT_420P16 IMGFMT_420P16_BE
+#define IMGFMT_420P10 IMGFMT_420P10_BE
+#define IMGFMT_420P9 IMGFMT_420P9_BE
 #else
 #define IMGFMT_444P16 IMGFMT_444P16_LE
 #define IMGFMT_422P16 IMGFMT_422P16_LE
+#define IMGFMT_422P10 IMGFMT_422P10_LE
 #define IMGFMT_420P16 IMGFMT_420P16_LE
+#define IMGFMT_420P10 IMGFMT_420P10_LE
+#define IMGFMT_420P9 IMGFMT_420P9_LE
 #endif
 
-#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt  ^ IMGFMT_420P16_LE) & 0xff0000ff) == 0)
-#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt  ^ IMGFMT_420P16_BE) & 0xff0000ff) == 0)
-#define IMGFMT_IS_YUVP16_NE(fmt) (((fmt  ^ IMGFMT_420P16   ) & 0xff0000ff) == 0)
+#define IMGFMT_IS_YUVP16_LE(fmt) (((fmt  ^ IMGFMT_420P16_LE) & 0xf50000f5) == 0)
+#define IMGFMT_IS_YUVP16_BE(fmt) (((fmt  ^ IMGFMT_420P16_BE) & 0xf50000f5) == 0)
+#define IMGFMT_IS_YUVP16_NE(fmt) (((fmt  ^ IMGFMT_420P16   ) & 0xf50000f5) == 0)
 #define IMGFMT_IS_YUVP16(fmt)    (IMGFMT_IS_YUVP16_LE(fmt) || IMGFMT_IS_YUVP16_BE(fmt))
 
 /* Packed YUV Formats */
Index: libmpcodecs/vf_scale.c
===================================================================
--- libmpcodecs/vf_scale.c	(revision 33445)
+++ libmpcodecs/vf_scale.c	(working copy)
@@ -71,10 +71,16 @@
     IMGFMT_422P,
     IMGFMT_422P16_LE,
     IMGFMT_422P16_BE,
+    IMGFMT_422P10_LE,
+    IMGFMT_422P10_BE,
     IMGFMT_YV12,
     IMGFMT_I420,
     IMGFMT_420P16_LE,
     IMGFMT_420P16_BE,
+    IMGFMT_420P10_LE,
+    IMGFMT_420P10_BE,
+    IMGFMT_420P9_LE,
+    IMGFMT_420P9_BE,
     IMGFMT_420A,
     IMGFMT_IYUV,
     IMGFMT_YVU9,
Index: fmt-conversion.c
===================================================================
--- fmt-conversion.c	(revision 33445)
+++ fmt-conversion.c	(working copy)
@@ -76,8 +76,14 @@
 
     {IMGFMT_420P16_LE,  PIX_FMT_YUV420P16LE},
     {IMGFMT_420P16_BE,  PIX_FMT_YUV420P16BE},
+    {IMGFMT_420P10_LE,  PIX_FMT_YUV420P10LE},
+    {IMGFMT_420P10_BE,  PIX_FMT_YUV420P10BE},
+    {IMGFMT_420P9_LE,   PIX_FMT_YUV420P9LE},
+    {IMGFMT_420P9_BE,   PIX_FMT_YUV420P9BE},
     {IMGFMT_422P16_LE,  PIX_FMT_YUV422P16LE},
     {IMGFMT_422P16_BE,  PIX_FMT_YUV422P16BE},
+    {IMGFMT_422P10_LE,  PIX_FMT_YUV422P10LE},
+    {IMGFMT_422P10_BE,  PIX_FMT_YUV422P10BE},
     {IMGFMT_444P16_LE,  PIX_FMT_YUV444P16LE},
     {IMGFMT_444P16_BE,  PIX_FMT_YUV444P16BE},
 
Index: codec-cfg.c
===================================================================
--- codec-cfg.c	(revision 33445)
+++ codec-cfg.c	(working copy)
@@ -179,7 +179,10 @@
     {"420P16BE", IMGFMT_420P16_BE},
     {"444P16", IMGFMT_444P16},
     {"422P16", IMGFMT_422P16},
+    {"422P10", IMGFMT_422P10},
     {"420P16", IMGFMT_420P16},
+    {"420P10", IMGFMT_420P10},
+    {"420P9", IMGFMT_420P9},
     {"420A",  IMGFMT_420A},
     {"444P",  IMGFMT_444P},
     {"422P",  IMGFMT_422P},
Index: m_option.c
===================================================================
--- m_option.c	(revision 33445)
+++ m_option.c	(working copy)
@@ -1054,11 +1054,20 @@
   {"444p16be", IMGFMT_444P16_BE},
   {"422p16le", IMGFMT_422P16_LE},
   {"422p16be", IMGFMT_422P16_BE},
+  {"422p10le", IMGFMT_422P10_LE},
+  {"422p10be", IMGFMT_422P10_BE},
   {"420p16le", IMGFMT_420P16_LE},
   {"420p16be", IMGFMT_420P16_BE},
+  {"420p10le", IMGFMT_420P10_LE},
+  {"420p10be", IMGFMT_420P10_BE},
+  {"420p9le", IMGFMT_420P9_LE},
+  {"420p9be", IMGFMT_420P9_BE},
   {"444p16", IMGFMT_444P16},
   {"422p16", IMGFMT_422P16},
+  {"422p10", IMGFMT_422P10},
   {"420p16", IMGFMT_420P16},
+  {"420p10", IMGFMT_420P10},
+  {"420p9", IMGFMT_420P9},
   {"420a", IMGFMT_420A},
   {"444p", IMGFMT_444P},
   {"422p", IMGFMT_422P},
Index: etc/codecs.conf
===================================================================
--- etc/codecs.conf	(revision 33445)
+++ etc/codecs.conf	(working copy)
@@ -1064,7 +1064,7 @@
   format 0x10000005
   driver ffmpeg
   dll h264
-  out YV12,I420,IYUV
+  out YV12,I420,IYUV,420P10,420P9
 
 videocodec ffh264vdpau
   info "FFmpeg H.264 (VDPAU)"


More information about the MPlayer-dev-eng mailing list