[FFmpeg-devel] [PATCH 2/2] libx265: Enable 12-bit encoding

Stephen Hutchinson qyot27 at gmail.com
Sat Aug 22 20:17:42 CEST 2015


This was introduced in x265 in July, and the experimental warnings
about it in libx265 were recently removed, so there shouldn't be
any reason to have it as experimental here.

The configure detection is bumped to X265_BUILD >= 60, as the
requisite 12-bit querying ability in x265_api_get was added in
API version 59, on May 15th (a month and a half before 12-bit
encoding was added to x265).
---
 configure            |  4 ++--
 libavcodec/libx265.c | 20 +++++++++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index e67ddf6..9f14bd1 100755
--- a/configure
+++ b/configure
@@ -5306,8 +5306,8 @@ enabled libx264           && { use_pkg_config x264 "stdint.h x264.h" x264_encode
                              { check_cpp_condition x264.h "X264_MPEG2" &&
                                enable libx262; }
 enabled libx265           && require_pkg_config x265 x265.h x265_api_get &&
-                             { check_cpp_condition x265.h "X265_BUILD >= 57" ||
-                               die "ERROR: libx265 version must be >= 57."; }
+                             { check_cpp_condition x265.h "X265_BUILD >= 60" ||
+                               die "ERROR: libx265 version must be >= 60."; }
 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
 enabled libzmq            && require_pkg_config libzmq zmq.h zmq_ctx_new
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 40a8daf..8dbbdd7 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -146,14 +146,17 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
     switch (avctx->pix_fmt) {
     case AV_PIX_FMT_YUV420P:
     case AV_PIX_FMT_YUV420P10:
+    case AV_PIX_FMT_YUV420P12:
         ctx->params->internalCsp = X265_CSP_I420;
         break;
     case AV_PIX_FMT_YUV422P:
     case AV_PIX_FMT_YUV422P10:
+    case AV_PIX_FMT_YUV422P12:
         ctx->params->internalCsp = X265_CSP_I422;
         break;
     case AV_PIX_FMT_YUV444P:
     case AV_PIX_FMT_YUV444P10:
+    case AV_PIX_FMT_YUV444P12:
         ctx->params->internalCsp = X265_CSP_I444;
         break;
     }
@@ -318,6 +321,16 @@ static const enum AVPixelFormat x265_csp_eight[] = {
     AV_PIX_FMT_NONE
 };
 
+static const enum AVPixelFormat x265_csp_ten[] = {
+    AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV422P,
+    AV_PIX_FMT_YUV444P,
+    AV_PIX_FMT_YUV420P10,
+    AV_PIX_FMT_YUV422P10,
+    AV_PIX_FMT_YUV444P10,
+    AV_PIX_FMT_NONE
+};
+
 static const enum AVPixelFormat x265_csp_twelve[] = {
     AV_PIX_FMT_YUV420P,
     AV_PIX_FMT_YUV422P,
@@ -325,13 +338,18 @@ static const enum AVPixelFormat x265_csp_twelve[] = {
     AV_PIX_FMT_YUV420P10,
     AV_PIX_FMT_YUV422P10,
     AV_PIX_FMT_YUV444P10,
+    AV_PIX_FMT_YUV420P12,
+    AV_PIX_FMT_YUV422P12,
+    AV_PIX_FMT_YUV444P12,
     AV_PIX_FMT_NONE
 };
 
 static av_cold void libx265_encode_init_csp(AVCodec *codec)
 {
-    if (x265_api_get(10))
+    if (x265_api_get(12))
         codec->pix_fmts = x265_csp_twelve;
+    else if (x265_api_get(10))
+        codec->pix_fmts = x265_csp_ten;
     else if (x265_api_get(8))
         codec->pix_fmts = x265_csp_eight;
 }
-- 
2.1.4



More information about the ffmpeg-devel mailing list