add mpv patches, via Brad:

- upstream commits to eliminate deprecated FFmpeg API
- upstream gpu_next fixes for crashing due to a bug with usage of lcms2
- fix over-zealous detection of libatomic (it was picked up at configure
time if present at all, rather than only if needed)
This commit is contained in:
sthen 2022-12-09 10:33:04 +00:00
parent 0843885092
commit b4681f9196
12 changed files with 595 additions and 3 deletions

View File

@ -3,7 +3,7 @@ COMMENT = movie player based on MPlayer/mplayer2
GH_ACCOUNT = mpv-player
GH_PROJECT = mpv
GH_TAGNAME = v0.35.0
REVISION = 2
REVISION = 3
SHARED_LIBS += mpv 1.0 # 2.0

View File

@ -0,0 +1,43 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: audio/decode/ad_lavc.c
--- audio/decode/ad_lavc.c.orig
+++ audio/decode/ad_lavc.c
@@ -46,6 +46,7 @@
struct priv {
AVCodecContext *avctx;
AVFrame *avframe;
+ AVPacket *avpkt;
struct mp_chmap force_channel_map;
uint32_t skip_samples, trim_samples;
bool preroll_done;
@@ -104,6 +105,7 @@ static bool init(struct mp_filter *da, struct mp_codec
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
ctx->avframe = av_frame_alloc();
+ ctx->avpkt = av_packet_alloc();
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id;
lavc_context->pkt_timebase = ctx->codec_timebase;
@@ -160,6 +162,7 @@ static void destroy(struct mp_filter *da)
avcodec_free_context(&ctx->avctx);
av_frame_free(&ctx->avframe);
+ mp_free_av_packet(&ctx->avpkt);
}
static void reset(struct mp_filter *da)
@@ -185,10 +188,9 @@ static int send_packet(struct mp_filter *da, struct de
if (mpkt && priv->next_pts == MP_NOPTS_VALUE)
priv->next_pts = mpkt->pts;
- AVPacket pkt;
- mp_set_av_packet(&pkt, mpkt, &priv->codec_timebase);
+ mp_set_av_packet(priv->avpkt, mpkt, &priv->codec_timebase);
- int ret = avcodec_send_packet(avctx, mpkt ? &pkt : NULL);
+ int ret = avcodec_send_packet(avctx, mpkt ? priv->avpkt : NULL);
if (ret < 0)
MP_ERR(da, "Error decoding audio.\n");
return ret;

View File

@ -0,0 +1,53 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: audio/decode/ad_spdif.c
--- audio/decode/ad_spdif.c.orig
+++ audio/decode/ad_spdif.c
@@ -41,6 +41,7 @@ struct spdifContext {
struct mp_log *log;
enum AVCodecID codec_id;
AVFormatContext *lavf_ctx;
+ AVPacket *avpkt;
int out_buffer_len;
uint8_t out_buffer[OUTBUF_SIZE];
bool need_close;
@@ -82,6 +83,7 @@ static void destroy(struct mp_filter *da)
avformat_free_context(lavf_ctx);
spdif_ctx->lavf_ctx = NULL;
}
+ mp_free_av_packet(&spdif_ctx->avpkt);
}
static void determine_codec_params(struct mp_filter *da, AVPacket *pkt,
@@ -295,15 +297,14 @@ static void process(struct mp_filter *da)
struct mp_aframe *out = NULL;
double pts = mpkt->pts;
- AVPacket pkt;
- mp_set_av_packet(&pkt, mpkt, NULL);
- pkt.pts = pkt.dts = 0;
+ mp_set_av_packet(spdif_ctx->avpkt, mpkt, NULL);
+ spdif_ctx->avpkt->pts = spdif_ctx->avpkt->dts = 0;
if (!spdif_ctx->lavf_ctx) {
- if (init_filter(da, &pkt) < 0)
+ if (init_filter(da, spdif_ctx->avpkt) < 0)
goto done;
}
spdif_ctx->out_buffer_len = 0;
- int ret = av_write_frame(spdif_ctx->lavf_ctx, &pkt);
+ int ret = av_write_frame(spdif_ctx->lavf_ctx, spdif_ctx->avpkt);
avio_flush(spdif_ctx->lavf_ctx->pb);
if (ret < 0) {
MP_ERR(da, "spdif mux error: '%s'\n", mp_strerror(AVUNERROR(ret)));
@@ -424,6 +425,10 @@ static struct mp_decoder *create(struct mp_filter *par
talloc_free(da);
return NULL;
}
+
+ spdif_ctx->avpkt = av_packet_alloc();
+ MP_HANDLE_OOM(spdif_ctx->avpkt);
+
return &spdif_ctx->public;
}

View File

@ -0,0 +1,42 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: common/av_common.c
--- common/av_common.c.orig
+++ common/av_common.c
@@ -196,7 +196,11 @@ double mp_pts_from_av(int64_t av_pts, AVRational *tb)
// Set duration field only if tb is set.
void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb)
{
- av_init_packet(dst);
+ dst->side_data = NULL;
+ dst->side_data_elems = 0;
+ dst->buf = NULL;
+ av_packet_unref(dst);
+
dst->data = mpkt ? mpkt->buffer : NULL;
dst->size = mpkt ? mpkt->len : 0;
/* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info
@@ -393,4 +397,22 @@ int mp_set_avopts_pos(struct mp_log *log, void *avobj,
}
}
return success;
+}
+
+/**
+ * Must be used to free an AVPacket that was used with mp_set_av_packet().
+ *
+ * We have a particular pattern where we "borrow" buffers and set them
+ * into an AVPacket to pass data to ffmpeg without extra copies.
+ * This applies to buf and side_data, so this function clears them before
+ * freeing.
+ */
+void mp_free_av_packet(AVPacket **pkt)
+{
+ if (*pkt) {
+ (*pkt)->side_data = NULL;
+ (*pkt)->side_data_elems = 0;
+ (*pkt)->buf = NULL;
+ }
+ av_packet_free(pkt);
}

View File

@ -0,0 +1,13 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: common/av_common.h
--- common/av_common.h.orig
+++ common/av_common.h
@@ -50,5 +50,6 @@ void mp_set_avdict(struct AVDictionary **dict, char **
void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d);
int mp_set_avopts(struct mp_log *log, void *avobj, char **kv);
int mp_set_avopts_pos(struct mp_log *log, void *avobj, void *posargs, char **kv);
+void mp_free_av_packet(AVPacket **pkt);
#endif

View File

@ -0,0 +1,56 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: common/recorder.c
--- common/recorder.c.orig
+++ common/recorder.c
@@ -64,6 +64,7 @@ struct mp_recorder_sink {
struct mp_recorder *owner;
struct sh_stream *sh;
AVStream *av_stream;
+ AVPacket *avpkt;
double max_out_pts;
bool discont;
bool proper_eof;
@@ -82,10 +83,11 @@ static int add_stream(struct mp_recorder *priv, struct
.owner = priv,
.sh = sh,
.av_stream = avformat_new_stream(priv->mux, NULL),
+ .avpkt = av_packet_alloc(),
.max_out_pts = MP_NOPTS_VALUE,
};
- if (!rst->av_stream)
+ if (!rst->av_stream || !rst->avpkt)
return -1;
AVCodecParameters *avp = mp_codec_params_to_av(sh->codec);
@@ -237,15 +239,14 @@ static void mux_packet(struct mp_recorder_sink *rst,
rst->max_out_pts = MP_PTS_MAX(rst->max_out_pts, pkt->pts);
- AVPacket avpkt;
- mp_set_av_packet(&avpkt, &mpkt, &rst->av_stream->time_base);
+ mp_set_av_packet(rst->avpkt, &mpkt, &rst->av_stream->time_base);
- avpkt.stream_index = rst->av_stream->index;
+ rst->avpkt->stream_index = rst->av_stream->index;
- if (avpkt.duration < 0 && rst->sh->type != STREAM_SUB)
- avpkt.duration = 0;
+ if (rst->avpkt->duration < 0 && rst->sh->type != STREAM_SUB)
+ rst->avpkt->duration = 0;
- AVPacket *new_packet = av_packet_clone(&avpkt);
+ AVPacket *new_packet = av_packet_clone(rst->avpkt);
if (!new_packet) {
MP_ERR(priv, "Failed to allocate packet.\n");
return;
@@ -319,6 +320,7 @@ void mp_recorder_destroy(struct mp_recorder *priv)
for (int n = 0; n < priv->num_streams; n++) {
struct mp_recorder_sink *rst = priv->streams[n];
mux_packets(rst);
+ mp_free_av_packet(&rst->avpkt);
}
if (av_write_trailer(priv->mux) < 0)

View File

@ -1,5 +1,7 @@
- meson: unbreak dl check on BSDs without libdl
04f765da6fb407c7ebe1833403a6049e2c9df6ce
- meson: fix stdatomic detection on bsd
ead8469454afa63e6e1fdd9e978af765f89379ce
Index: meson.build
--- meson.build.orig
@ -13,13 +15,25 @@ Index: meson.build
if features['libdl']
dependencies += libdl_dep
endif
@@ -716,10 +716,11 @@ if features['sdl2-gamepad']
@@ -716,10 +716,23 @@ if features['sdl2-gamepad']
sources += files('input/sdl_gamepad.c')
endif
-stdatomic = cc.find_library('atomic', required: get_option('stdatomic'))
-features += {'stdatomic': stdatomic.found()}
+stdatomic_dep = cc.find_library('atomic', required: false)
+if cc.links('''
+#include <stdint.h>
+int main(void) {
+ uint32_t x32 = 0;
+ uint64_t x64 = 0;
+ __atomic_load_n(&x32, __ATOMIC_SEQ_CST);
+ __atomic_load_n(&x64, __ATOMIC_SEQ_CST);
+ return 0;
+}''', name : 'built-in atomics')
+ stdatomic_dep = dependency('', required : false)
+else
+ stdatomic_dep = cc.find_library('atomic')
+endif
+features += {'stdatomic': cc.has_header_symbol('stdatomic.h', 'atomic_int', dependencies: stdatomic_dep,
+ required: get_option('stdatomic'))}
if features['stdatomic']

View File

@ -0,0 +1,87 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: sub/lavc_conv.c
--- sub/lavc_conv.c.orig
+++ sub/lavc_conv.c
@@ -34,6 +34,8 @@
struct lavc_conv {
struct mp_log *log;
AVCodecContext *avctx;
+ AVPacket *avpkt;
+ AVPacket *avpkt_vtt;
char *codec;
char *extradata;
AVSubtitle cur;
@@ -84,6 +86,11 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log,
if (mp_lavc_set_extradata(avctx, extradata, extradata_len) < 0)
goto error;
+ priv->avpkt = av_packet_alloc();
+ priv->avpkt_vtt = av_packet_alloc();
+ if (!priv->avpkt || !priv->avpkt_vtt)
+ goto error;
+
#if LIBAVCODEC_VERSION_MAJOR < 59
av_dict_set(&opts, "sub_text_format", "ass", 0);
#endif
@@ -107,6 +114,8 @@ struct lavc_conv *lavc_conv_create(struct mp_log *log,
MP_FATAL(priv, "Could not open libavcodec subtitle converter\n");
av_dict_free(&opts);
av_free(avctx);
+ mp_free_av_packet(&priv->avpkt);
+ mp_free_av_packet(&priv->avpkt_vtt);
talloc_free(priv);
return NULL;
}
@@ -224,26 +233,25 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct
double *sub_pts, double *sub_duration)
{
AVCodecContext *avctx = priv->avctx;
- AVPacket pkt;
- AVPacket parsed_pkt = {0};
+ AVPacket *curr_pkt = priv->avpkt;
int ret, got_sub;
int num_cur = 0;
avsubtitle_free(&priv->cur);
- mp_set_av_packet(&pkt, packet, &avctx->time_base);
- if (pkt.pts < 0)
- pkt.pts = 0;
+ mp_set_av_packet(priv->avpkt, packet, &avctx->time_base);
+ if (priv->avpkt->pts < 0)
+ priv->avpkt->pts = 0;
if (strcmp(priv->codec, "webvtt-webm") == 0) {
- if (parse_webvtt(&pkt, &parsed_pkt) < 0) {
+ if (parse_webvtt(priv->avpkt, priv->avpkt_vtt) < 0) {
MP_ERR(priv, "Error parsing subtitle\n");
goto done;
}
- pkt = parsed_pkt;
+ curr_pkt = priv->avpkt_vtt;
}
- ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, &pkt);
+ ret = avcodec_decode_subtitle2(avctx, &priv->cur, &got_sub, curr_pkt);
if (ret < 0) {
MP_ERR(priv, "Error decoding subtitle\n");
} else if (got_sub) {
@@ -266,7 +274,7 @@ char **lavc_conv_decode(struct lavc_conv *priv, struct
}
done:
- av_packet_unref(&parsed_pkt);
+ av_packet_unref(priv->avpkt_vtt);
MP_TARRAY_APPEND(priv, priv->cur_list, num_cur, NULL);
return priv->cur_list;
}
@@ -280,5 +288,7 @@ void lavc_conv_uninit(struct lavc_conv *priv)
{
avsubtitle_free(&priv->cur);
avcodec_free_context(&priv->avctx);
+ mp_free_av_packet(&priv->avpkt);
+ mp_free_av_packet(&priv->avpkt_vtt);
talloc_free(priv);
}

View File

@ -0,0 +1,66 @@
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: sub/sd_lavc.c
--- sub/sd_lavc.c.orig
+++ sub/sd_lavc.c
@@ -59,6 +59,7 @@ struct seekpoint {
struct sd_lavc_priv {
AVCodecContext *avctx;
+ AVPacket *avpkt;
AVRational pkt_timebase;
struct sub subs[MAX_QUEUE]; // most recent event first
struct sub_bitmap *outbitmaps;
@@ -97,6 +98,9 @@ static int init(struct sd *sd)
ctx = avcodec_alloc_context3(sub_codec);
if (!ctx)
goto error;
+ priv->avpkt = av_packet_alloc();
+ if (!priv->avpkt)
+ goto error;
mp_lavc_set_extradata(ctx, sd->codec->extradata, sd->codec->extradata_size);
priv->pkt_timebase = mp_get_codec_timebase(sd->codec);
ctx->pkt_timebase = priv->pkt_timebase;
@@ -112,6 +116,7 @@ static int init(struct sd *sd)
error:
MP_FATAL(sd, "Could not open libavcodec subtitle decoder\n");
avcodec_free_context(&ctx);
+ mp_free_av_packet(&priv->avpkt);
talloc_free(priv);
return -1;
}
@@ -298,7 +303,6 @@ static void decode(struct sd *sd, struct demux_packet
double endpts = MP_NOPTS_VALUE;
double duration = packet->duration;
AVSubtitle sub;
- AVPacket pkt;
// libavformat sets duration==0, even if the duration is unknown. Some files
// also have actually subtitle packets with duration explicitly set to 0
@@ -311,7 +315,7 @@ static void decode(struct sd *sd, struct demux_packet
if (pts == MP_NOPTS_VALUE)
MP_WARN(sd, "Subtitle with unknown start time.\n");
- mp_set_av_packet(&pkt, packet, &priv->pkt_timebase);
+ mp_set_av_packet(priv->avpkt, packet, &priv->pkt_timebase);
if (ctx->codec_id == AV_CODEC_ID_DVB_TELETEXT) {
char page[4];
@@ -320,7 +324,7 @@ static void decode(struct sd *sd, struct demux_packet
}
int got_sub;
- int res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, &pkt);
+ int res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, priv->avpkt);
if (res < 0 || !got_sub)
return;
@@ -588,6 +592,7 @@ static void uninit(struct sd *sd)
for (int n = 0; n < MAX_QUEUE; n++)
clear_sub(&priv->subs[n]);
avcodec_free_context(&priv->avctx);
+ mp_free_av_packet(&priv->avpkt);
talloc_free(priv);
}

View File

@ -0,0 +1,80 @@
- vd_lavc: update to handle deprecation of `pkt_duration`
83257be693967415f1160f2fa37de9de677c1cab
- ffmpeg: update to handle deprecation of `av_init_packet`
4574dd5dc6ff75b1fc693afceec59fbcd51ccd4c
Index: video/decode/vd_lavc.c
--- video/decode/vd_lavc.c.orig
+++ video/decode/vd_lavc.c
@@ -23,6 +23,7 @@
#include <stdbool.h>
#include <libavcodec/avcodec.h>
+#include <libavformat/version.h>
#include <libavutil/common.h>
#include <libavutil/hwcontext.h>
#include <libavutil/opt.h>
@@ -172,6 +173,7 @@ typedef struct lavc_ctx {
struct mp_codec_params *codec;
AVCodecContext *avctx;
AVFrame *pic;
+ AVPacket *avpkt;
bool use_hwdec;
struct hwdec_info hwdec; // valid only if use_hwdec==true
AVRational codec_timebase;
@@ -650,6 +652,10 @@ static void init_avctx(struct mp_filter *vd)
if (!ctx->pic)
goto error;
+ ctx->avpkt = av_packet_alloc();
+ if (!ctx->avpkt)
+ goto error;
+
if (ctx->use_hwdec) {
avctx->opaque = vd;
avctx->thread_count = 1;
@@ -751,9 +757,8 @@ static void init_avctx(struct mp_filter *vd)
// x264 build number (encoded in a SEI element), needed to enable a
// workaround for broken 4:4:4 streams produced by older x264 versions.
if (lavc_codec->id == AV_CODEC_ID_H264 && c->first_packet) {
- AVPacket avpkt;
- mp_set_av_packet(&avpkt, c->first_packet, &ctx->codec_timebase);
- avcodec_send_packet(avctx, &avpkt);
+ mp_set_av_packet(ctx->avpkt, c->first_packet, &ctx->codec_timebase);
+ avcodec_send_packet(avctx, ctx->avpkt);
avcodec_receive_frame(avctx, ctx->pic);
av_frame_unref(ctx->pic);
avcodec_flush_buffers(ctx->avctx);
@@ -801,6 +806,7 @@ static void uninit_avctx(struct mp_filter *vd)
flush_all(vd);
av_frame_free(&ctx->pic);
+ mp_free_av_packet(&ctx->avpkt);
av_buffer_unref(&ctx->cached_hw_frames_ctx);
avcodec_free_context(&ctx->avctx);
@@ -1066,10 +1072,9 @@ static int send_packet(struct mp_filter *vd, struct de
if (avctx->skip_frame == AVDISCARD_ALL)
return 0;
- AVPacket avpkt;
- mp_set_av_packet(&avpkt, pkt, &ctx->codec_timebase);
+ mp_set_av_packet(ctx->avpkt, pkt, &ctx->codec_timebase);
- int ret = avcodec_send_packet(avctx, pkt ? &avpkt : NULL);
+ int ret = avcodec_send_packet(avctx, pkt ? ctx->avpkt : NULL);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return ret;
@@ -1153,7 +1158,11 @@ static int decode_frame(struct mp_filter *vd)
mpi->dts = mp_pts_from_av(ctx->pic->pkt_dts, &ctx->codec_timebase);
mpi->pkt_duration =
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 30, 100)
+ mp_pts_from_av(ctx->pic->duration, &ctx->codec_timebase);
+#else
mp_pts_from_av(ctx->pic->pkt_duration, &ctx->codec_timebase);
+#endif
av_frame_unref(ctx->pic);

View File

@ -0,0 +1,97 @@
- lcms: always parse lcms2-related options
b9b3342369c3e58f9fbb4c78dedbf3418a1ebd59
- lcms: fix validate_3dlut_size_opt
e1a04cd8ac407cd188a9e6064677d232ae409e9c
Index: video/out/gpu/lcms.c
--- video/out/gpu/lcms.c.orig
+++ video/out/gpu/lcms.c
@@ -54,40 +54,6 @@ struct gl_lcms {
struct mp_icc_opts *opts;
};
-static int validate_3dlut_size_opt(struct mp_log *log, const m_option_t *opt,
- struct bstr name, const char **value)
-{
- struct bstr param = bstr0(*value);
- int p1, p2, p3;
- char s[20];
- snprintf(s, sizeof(s), "%.*s", BSTR_P(param));
- return gl_parse_3dlut_size(s, &p1, &p2, &p3);
-}
-
-#define OPT_BASE_STRUCT struct mp_icc_opts
-const struct m_sub_options mp_icc_conf = {
- .opts = (const m_option_t[]) {
- {"use-embedded-icc-profile", OPT_FLAG(use_embedded)},
- {"icc-profile", OPT_STRING(profile), .flags = M_OPT_FILE},
- {"icc-profile-auto", OPT_FLAG(profile_auto)},
- {"icc-cache-dir", OPT_STRING(cache_dir), .flags = M_OPT_FILE},
- {"icc-intent", OPT_INT(intent)},
- {"icc-force-contrast", OPT_CHOICE(contrast, {"no", 0}, {"inf", -1}),
- M_RANGE(0, 1000000)},
- {"icc-3dlut-size", OPT_STRING_VALIDATE(size_str, validate_3dlut_size_opt)},
- {"3dlut-size", OPT_REPLACED("icc-3dlut-size")},
- {"icc-cache", OPT_REMOVED("see icc-cache-dir")},
- {"icc-contrast", OPT_REMOVED("see icc-force-contrast")},
- {0}
- },
- .size = sizeof(struct mp_icc_opts),
- .defaults = &(const struct mp_icc_opts) {
- .size_str = "64x64x64",
- .intent = INTENT_RELATIVE_COLORIMETRIC,
- .use_embedded = true,
- },
-};
-
static void lcms2_error_handler(cmsContext ctx, cmsUInt32Number code,
const char *msg)
{
@@ -487,12 +453,6 @@ error_exit:
#else /* HAVE_LCMS2 */
-const struct m_sub_options mp_icc_conf = {
- .opts = (const m_option_t[]) { {0} },
- .size = sizeof(struct mp_icc_opts),
- .defaults = &(const struct mp_icc_opts) {0},
-};
-
struct gl_lcms *gl_lcms_init(void *talloc_ctx, struct mp_log *log,
struct mpv_global *global,
struct mp_icc_opts *opts)
@@ -522,3 +482,34 @@ bool gl_lcms_get_lut3d(struct gl_lcms *p, struct lut3d
}
#endif
+
+static int validate_3dlut_size_opt(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, const char **value)
+{
+ int p1, p2, p3;
+ return gl_parse_3dlut_size(*value, &p1, &p2, &p3) ? 0 : M_OPT_INVALID;
+}
+
+#define OPT_BASE_STRUCT struct mp_icc_opts
+const struct m_sub_options mp_icc_conf = {
+ .opts = (const m_option_t[]) {
+ {"use-embedded-icc-profile", OPT_FLAG(use_embedded)},
+ {"icc-profile", OPT_STRING(profile), .flags = M_OPT_FILE},
+ {"icc-profile-auto", OPT_FLAG(profile_auto)},
+ {"icc-cache-dir", OPT_STRING(cache_dir), .flags = M_OPT_FILE},
+ {"icc-intent", OPT_INT(intent)},
+ {"icc-force-contrast", OPT_CHOICE(contrast, {"no", 0}, {"inf", -1}),
+ M_RANGE(0, 1000000)},
+ {"icc-3dlut-size", OPT_STRING_VALIDATE(size_str, validate_3dlut_size_opt)},
+ {"3dlut-size", OPT_REPLACED("icc-3dlut-size")},
+ {"icc-cache", OPT_REMOVED("see icc-cache-dir")},
+ {"icc-contrast", OPT_REMOVED("see icc-force-contrast")},
+ {0}
+ },
+ .size = sizeof(struct mp_icc_opts),
+ .defaults = &(const struct mp_icc_opts) {
+ .size_str = "64x64x64",
+ .intent = MP_INTENT_RELATIVE_COLORIMETRIC,
+ .use_embedded = true,
+ },
+};

View File

@ -0,0 +1,41 @@
- sws_utils: update to handle deprecation of `avcodec_enum_to_chroma_pos`
77e7f5de2c01361a88c501fcd78b51c2fe2d9df0
Index: video/sws_utils.c
--- video/sws_utils.c.orig
+++ video/sws_utils.c
@@ -21,6 +21,9 @@
#include <libavcodec/avcodec.h>
#include <libavutil/bswap.h>
#include <libavutil/opt.h>
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100)
+#include <libavutil/pixdesc.h>
+#endif
#include "config.h"
@@ -303,6 +306,16 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
int cr_src = mp_chroma_location_to_av(src.chroma_location);
int cr_dst = mp_chroma_location_to_av(dst.chroma_location);
int cr_xpos, cr_ypos;
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100)
+ if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) {
+ av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0);
+ av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0);
+ }
+ if (av_chroma_location_enum_to_pos(&cr_xpos, &cr_ypos, cr_dst) >= 0) {
+ av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0);
+ av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0);
+ }
+#else
if (avcodec_enum_to_chroma_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) {
av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0);
av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0);
@@ -311,6 +324,7 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0);
av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0);
}
+#endif
// This can fail even with normal operation, e.g. if a conversion path
// simply does not support these settings.