Created
January 23, 2019 17:42
-
-
Save muellermartin/ebd31a55385e6e4dbac7397e9f2631d3 to your computer and use it in GitHub Desktop.
Fixes compilation of Homebrew's Formula for mplayer 1.3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c | |
index 2d36c5e566..754383e080 100644 | |
--- a/ffmpeg/libavcodec/libx264.c | |
+++ b/ffmpeg/libavcodec/libx264.c | |
@@ -272,6 +272,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, | |
int *got_packet) | |
{ | |
X264Context *x4 = ctx->priv_data; | |
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(ctx->pix_fmt); | |
x264_nal_t *nal; | |
int nnal, i, ret; | |
x264_picture_t pic_out = {0}; | |
@@ -279,7 +280,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, | |
x264_picture_init( &x4->pic ); | |
x4->pic.img.i_csp = x4->params.i_csp; | |
- if (x264_bit_depth > 8) | |
+ if (desc->comp[0].depth > 8) | |
x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH; | |
x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); | |
@@ -724,6 +724,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 = av_pix_fmt_desc_get(avctx->pix_fmt)->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 +840,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 +895,14 @@ static const enum AVPixelFormat pix_fmts_8bit_rgb[] = { | |
static av_cold void X264_init_static(AVCodec *codec) | |
{ | |
- if (x264_bit_depth == 8) | |
+ if (X264_BIT_DEPTH == 8) | |
codec->pix_fmts = pix_fmts_8bit; | |
- else if (x264_bit_depth == 9) | |
+ else if (X264_BIT_DEPTH == 9) | |
codec->pix_fmts = pix_fmts_9bit; | |
- else if (x264_bit_depth == 10) | |
+ else if (X264_BIT_DEPTH == 10) | |
codec->pix_fmts = pix_fmts_10bit; | |
+ else /* X264_BIT_DEPTH == 0 */ | |
+ codec->pix_fmts = pix_fmts; | |
} | |
#define OFFSET(x) offsetof(X264Context, x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixes issue Homebrew/homebrew-core#36003 where following error occurs while compiling mplayer (1.3.0) with libx264 (r2917):
This patch is the aggregation of the commits 89f704cabab446afc8ba6ecea76714a51b1df32b and 2a111c99a60fdf4fe5eea2b073901630190c6c93 from ffmpeg's repository with adjusted path for mplayer.