[FFmpeg-cvslog] libx264: support yuv422/444 output.
Anton Khirnov
git at videolan.org
Thu Oct 13 06:01:44 CEST 2011
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Oct 9 19:34:20 2011 +0200| [46c3c53baedffd34742ba93189b7e7a2b7b3e530] | committer: Anton Khirnov
libx264: support yuv422/444 output.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=46c3c53baedffd34742ba93189b7e7a2b7b3e530
---
configure | 4 ++--
libavcodec/libx264.c | 24 +++++++++++++++++++++++-
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index f5a285e..dbbb86c 100755
--- a/configure
+++ b/configure
@@ -2905,8 +2905,8 @@ enabled libvpx && {
enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
die "ERROR: libvpx encoder version must be >=0.9.1"; } }
enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
- { check_cpp_condition x264.h "X264_BUILD >= 115" ||
- die "ERROR: libx264 version must be >= 0.115."; }
+ { check_cpp_condition x264.h "X264_BUILD >= 118" ||
+ die "ERROR: libx264 version must be >= 0.118."; }
enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index f2c836e..d8c4b5f 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -123,7 +123,7 @@ static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
x264_picture_t pic_out;
x264_picture_init( &x4->pic );
- x4->pic.img.i_csp = X264_CSP_I420;
+ x4->pic.img.i_csp = x4->params.i_csp;
if (x264_bit_depth > 8)
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH;
x4->pic.img.i_plane = 3;
@@ -192,6 +192,22 @@ static av_cold int X264_close(AVCodecContext *avctx)
return 0;
}
+static int convert_pix_fmt(enum PixelFormat pix_fmt)
+{
+ switch (pix_fmt) {
+ case PIX_FMT_YUV420P:
+ case PIX_FMT_YUVJ420P:
+ case PIX_FMT_YUV420P9:
+ case PIX_FMT_YUV420P10: return X264_CSP_I420;
+ case PIX_FMT_YUV422P:
+ case PIX_FMT_YUV422P10: return X264_CSP_I422;
+ case PIX_FMT_YUV444P:
+ case PIX_FMT_YUV444P9:
+ case PIX_FMT_YUV444P10: return X264_CSP_I444;
+ };
+ return 0;
+}
+
#define PARSE_X264_OPT(name, var)\
if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\
av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\
@@ -218,6 +234,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.pf_log = X264_log;
x4->params.p_log_private = avctx;
x4->params.i_log_level = X264_LOG_DEBUG;
+ x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt);
if (avctx->bit_rate) {
x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
@@ -462,14 +479,19 @@ static av_cold int X264_init(AVCodecContext *avctx)
static const enum PixelFormat pix_fmts_8bit[] = {
PIX_FMT_YUV420P,
PIX_FMT_YUVJ420P,
+ PIX_FMT_YUV422P,
+ PIX_FMT_YUV444P,
PIX_FMT_NONE
};
static const enum PixelFormat pix_fmts_9bit[] = {
PIX_FMT_YUV420P9,
+ PIX_FMT_YUV444P9,
PIX_FMT_NONE
};
static const enum PixelFormat pix_fmts_10bit[] = {
PIX_FMT_YUV420P10,
+ PIX_FMT_YUV422P10,
+ PIX_FMT_YUV444P10,
PIX_FMT_NONE
};
More information about the ffmpeg-cvslog
mailing list