[FFmpeg-cvslog] libx264: support 9- and 10-bit output.

Anton Khirnov git at videolan.org
Fri Oct 7 03:49:15 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Oct  5 21:09:51 2011 +0200| [d97efd7f879779034cca0bd16acceed47718e04e] | committer: Anton Khirnov

libx264: support 9- and 10-bit output.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d97efd7f879779034cca0bd16acceed47718e04e
---

 libavcodec/avcodec.h |    5 +++++
 libavcodec/libx264.c |   29 ++++++++++++++++++++++++++++-
 libavcodec/utils.c   |    3 +++
 libavcodec/version.h |    2 +-
 4 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2e37f5a..5a69c24 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2984,6 +2984,11 @@ typedef struct AVCodec {
      * Private codec-specific defaults.
      */
     const AVCodecDefault *defaults;
+
+    /**
+     * Initialize codec static data, called from avcodec_register().
+     */
+    void (*init_static_data)(struct AVCodec *codec);
 } AVCodec;
 
 /**
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 5331bc9..f2c836e 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 #include "avcodec.h"
 #include "internal.h"
 #include <x264.h>
@@ -123,6 +124,8 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
 
     x264_picture_init( &x4->pic );
     x4->pic.img.i_csp   = X264_CSP_I420;
+    if (x264_bit_depth > 8)
+        x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
     x4->pic.img.i_plane = 3;
 
     if (frame) {
@@ -456,6 +459,30 @@ static av_cold int X264_init(AVCodecContext *avctx)
     return 0;
 }
 
+static const enum PixelFormat pix_fmts_8bit[] = {
+    PIX_FMT_YUV420P,
+    PIX_FMT_YUVJ420P,
+    PIX_FMT_NONE
+};
+static const enum PixelFormat pix_fmts_9bit[] = {
+    PIX_FMT_YUV420P9,
+    PIX_FMT_NONE
+};
+static const enum PixelFormat pix_fmts_10bit[] = {
+    PIX_FMT_YUV420P10,
+    PIX_FMT_NONE
+};
+
+static av_cold void X264_init_static(AVCodec *codec)
+{
+    if (x264_bit_depth == 8)
+        codec->pix_fmts = pix_fmts_8bit;
+    else if (x264_bit_depth == 9)
+        codec->pix_fmts = pix_fmts_9bit;
+    else if (x264_bit_depth == 10)
+        codec->pix_fmts = pix_fmts_10bit;
+}
+
 #define OFFSET(x) offsetof(X264Context, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -544,8 +571,8 @@ AVCodec ff_libx264_encoder = {
     .encode         = X264_frame,
     .close          = X264_close,
     .capabilities   = CODEC_CAP_DELAY,
-    .pix_fmts       = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, PIX_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
     .priv_class     = &class,
     .defaults       = x264_defaults,
+    .init_static_data = X264_init_static,
 };
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b598942..1c95fa1 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -107,6 +107,9 @@ void avcodec_register(AVCodec *codec)
     while (*p != NULL) p = &(*p)->next;
     *p = codec;
     codec->next = NULL;
+
+    if (codec->init_static_data)
+        codec->init_static_data(codec);
 }
 
 unsigned avcodec_get_edge_width(void)
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d745fae..d9e60cc 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -22,7 +22,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 53
 #define LIBAVCODEC_VERSION_MINOR  12
-#define LIBAVCODEC_VERSION_MICRO  0
+#define LIBAVCODEC_VERSION_MICRO  1
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list