[FFmpeg-devel] [PATCH 2/2 v2] avcodec/libx264: fix compilation with x264 builds >= 153
James Almer
jamrial at gmail.com
Tue Dec 26 01:36:20 EET 2017
x264 now supports multibitdepth builds, with a slightly changed API to
request bitdepth during initialization.
Signed-off-by: James Almer <jamrial at gmail.com>
---
This one is a bit cleaner. I can push whichever is prefered.
libavcodec/libx264.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 2d36c5e566..90855dcd3f 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -454,6 +454,7 @@ static av_cold int X264_init(AVCodecContext *avctx)
{
X264Context *x4 = avctx->priv_data;
AVCPBProperties *cpb_props;
+ const av_unused AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
int sw,sh;
if (avctx->global_quality > 0)
@@ -724,6 +725,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
x4->params.i_width = avctx->width;
x4->params.i_height = avctx->height;
+#if X264_BUILD >= 153
+ x4->params.i_bitdepth = desc->comp[0].depth;
+#endif
av_reduce(&sw, &sh, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 4096);
x4->params.vui.i_sar_width = sw;
x4->params.vui.i_sar_height = sh;
@@ -837,6 +841,24 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
}
+static const enum AVPixelFormat pix_fmts[] = {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_YUVJ420P,
+ AV_PIX_FMT_YUV422P,
+ AV_PIX_FMT_YUVJ422P,
+ AV_PIX_FMT_YUV444P,
+ AV_PIX_FMT_YUVJ444P,
+ AV_PIX_FMT_YUV420P10,
+ AV_PIX_FMT_YUV422P10,
+ AV_PIX_FMT_YUV444P10,
+ AV_PIX_FMT_NV12,
+ AV_PIX_FMT_NV16,
+ AV_PIX_FMT_NV20,
+#ifdef X264_CSP_NV21
+ AV_PIX_FMT_NV21,
+#endif
+ AV_PIX_FMT_NONE
+};
static const enum AVPixelFormat pix_fmts_8bit[] = {
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUVJ420P,
@@ -874,12 +896,16 @@ static const enum AVPixelFormat pix_fmts_8bit_rgb[] = {
static av_cold void X264_init_static(AVCodec *codec)
{
+#if X264_BUILD >= 153
+ codec->pix_fmts = pix_fmts;
+#else
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;
+#endif
}
#define OFFSET(x) offsetof(X264Context, x)
--
2.15.0
More information about the ffmpeg-devel
mailing list