From 1fef0d1c4a141ad2c519862c3d890cb65fe17d9b Mon Sep 17 00:00:00 2001 From: sthen Date: Mon, 30 Jan 2023 16:53:55 +0000 Subject: [PATCH] oops, only some of the mpv patches had been committed to the release branch and others were cherrypicked from devel, reinstate them --- multimedia/mpv/Makefile | 1 + .../mpv/patches/patch-audio_decode_ad_lavc_c | 43 +++++++++ .../mpv/patches/patch-audio_decode_ad_spdif_c | 53 +++++++++++ .../mpv/patches/patch-common_av_common_c | 42 +++++++++ .../mpv/patches/patch-common_av_common_h | 13 +++ multimedia/mpv/patches/patch-common_av_log_c | 23 +++++ .../mpv/patches/patch-common_recorder_c | 56 ++++++++++++ multimedia/mpv/patches/patch-player_main_c | 28 ++++++ multimedia/mpv/patches/patch-sub_lavc_conv_c | 87 +++++++++++++++++++ multimedia/mpv/patches/patch-sub_sd_lavc_c | 66 ++++++++++++++ .../mpv/patches/patch-video_decode_vd_lavc_c | 80 +++++++++++++++++ .../mpv/patches/patch-video_out_vo_gpu_next_c | 38 ++++++++ .../mpv/patches/patch-video_sws_utils_c | 41 +++++++++ 13 files changed, 571 insertions(+) create mode 100644 multimedia/mpv/patches/patch-audio_decode_ad_lavc_c create mode 100644 multimedia/mpv/patches/patch-audio_decode_ad_spdif_c create mode 100644 multimedia/mpv/patches/patch-common_av_common_c create mode 100644 multimedia/mpv/patches/patch-common_av_common_h create mode 100644 multimedia/mpv/patches/patch-common_av_log_c create mode 100644 multimedia/mpv/patches/patch-common_recorder_c create mode 100644 multimedia/mpv/patches/patch-player_main_c create mode 100644 multimedia/mpv/patches/patch-sub_lavc_conv_c create mode 100644 multimedia/mpv/patches/patch-sub_sd_lavc_c create mode 100644 multimedia/mpv/patches/patch-video_decode_vd_lavc_c create mode 100644 multimedia/mpv/patches/patch-video_out_vo_gpu_next_c create mode 100644 multimedia/mpv/patches/patch-video_sws_utils_c diff --git a/multimedia/mpv/Makefile b/multimedia/mpv/Makefile index 3addb50d83b..ec653c2c1f2 100644 --- a/multimedia/mpv/Makefile +++ b/multimedia/mpv/Makefile @@ -3,6 +3,7 @@ COMMENT = movie player based on MPlayer/mplayer2 GH_ACCOUNT = mpv-player GH_PROJECT = mpv GH_TAGNAME = v0.35.1 +REVISION = 0 SHARED_LIBS += mpv 1.0 # 2.0 diff --git a/multimedia/mpv/patches/patch-audio_decode_ad_lavc_c b/multimedia/mpv/patches/patch-audio_decode_ad_lavc_c new file mode 100644 index 00000000000..5045a95cd30 --- /dev/null +++ b/multimedia/mpv/patches/patch-audio_decode_ad_lavc_c @@ -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; diff --git a/multimedia/mpv/patches/patch-audio_decode_ad_spdif_c b/multimedia/mpv/patches/patch-audio_decode_ad_spdif_c new file mode 100644 index 00000000000..03a17ac60ee --- /dev/null +++ b/multimedia/mpv/patches/patch-audio_decode_ad_spdif_c @@ -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; + } + diff --git a/multimedia/mpv/patches/patch-common_av_common_c b/multimedia/mpv/patches/patch-common_av_common_c new file mode 100644 index 00000000000..ed7a4845155 --- /dev/null +++ b/multimedia/mpv/patches/patch-common_av_common_c @@ -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); + } diff --git a/multimedia/mpv/patches/patch-common_av_common_h b/multimedia/mpv/patches/patch-common_av_common_h new file mode 100644 index 00000000000..e8ec8395b9e --- /dev/null +++ b/multimedia/mpv/patches/patch-common_av_common_h @@ -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 diff --git a/multimedia/mpv/patches/patch-common_av_log_c b/multimedia/mpv/patches/patch-common_av_log_c new file mode 100644 index 00000000000..3720b37567d --- /dev/null +++ b/multimedia/mpv/patches/patch-common_av_log_c @@ -0,0 +1,23 @@ +- common/av_log: move general FFmpeg version before library versions + 8bbe39a8587ebc2f6c51063d004f517ac4df9646 + +Index: common/av_log.c +--- common/av_log.c.orig ++++ common/av_log.c +@@ -193,6 +193,7 @@ void check_library_versions(struct mp_log *log, int v) + {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()}, + }; + ++ mp_msg(log, v, "FFmpeg version: %s\n", av_version_info()); + mp_msg(log, v, "FFmpeg library versions:\n"); + + for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) { +@@ -209,8 +210,6 @@ void check_library_versions(struct mp_log *log, int v) + abort(); + } + } +- +- mp_msg(log, v, "FFmpeg version: %s\n", av_version_info()); + } + + #undef V diff --git a/multimedia/mpv/patches/patch-common_recorder_c b/multimedia/mpv/patches/patch-common_recorder_c new file mode 100644 index 00000000000..2fbed1583a7 --- /dev/null +++ b/multimedia/mpv/patches/patch-common_recorder_c @@ -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) diff --git a/multimedia/mpv/patches/patch-player_main_c b/multimedia/mpv/patches/patch-player_main_c new file mode 100644 index 00000000000..3cb62dab17c --- /dev/null +++ b/multimedia/mpv/patches/patch-player_main_c @@ -0,0 +1,28 @@ +- player/main: log libplacebo version if built with it + 0f0520aeca367613d313dbf2e936ea2cacdb35c9 + +Index: player/main.c +--- player/main.c.orig ++++ player/main.c +@@ -25,6 +25,11 @@ + #include + + #include "config.h" ++ ++#if HAVE_LIBPLACEBO ++#include ++#endif ++ + #include "mpv_talloc.h" + + #include "misc/dispatch.h" +@@ -144,6 +149,9 @@ void mp_print_version(struct mp_log *log, int always) + int v = always ? MSGL_INFO : MSGL_V; + mp_msg(log, v, "%s %s\n built on %s\n", + mpv_version, mpv_copyright, mpv_builddate); ++#if HAVE_LIBPLACEBO ++ mp_msg(log, v, "libplacebo version: %s\n", PL_VERSION); ++#endif + check_library_versions(log, v); + mp_msg(log, v, "\n"); + // Only in verbose mode. diff --git a/multimedia/mpv/patches/patch-sub_lavc_conv_c b/multimedia/mpv/patches/patch-sub_lavc_conv_c new file mode 100644 index 00000000000..1f470f42b8b --- /dev/null +++ b/multimedia/mpv/patches/patch-sub_lavc_conv_c @@ -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); + } diff --git a/multimedia/mpv/patches/patch-sub_sd_lavc_c b/multimedia/mpv/patches/patch-sub_sd_lavc_c new file mode 100644 index 00000000000..fab3088a7ca --- /dev/null +++ b/multimedia/mpv/patches/patch-sub_sd_lavc_c @@ -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); + } + diff --git a/multimedia/mpv/patches/patch-video_decode_vd_lavc_c b/multimedia/mpv/patches/patch-video_decode_vd_lavc_c new file mode 100644 index 00000000000..42a219e86b5 --- /dev/null +++ b/multimedia/mpv/patches/patch-video_decode_vd_lavc_c @@ -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 + + #include ++#include + #include + #include + #include +@@ -173,6 +174,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; +@@ -651,6 +653,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; +@@ -752,9 +758,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); +@@ -802,6 +807,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); +@@ -1069,10 +1075,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; + +@@ -1156,7 +1161,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); + diff --git a/multimedia/mpv/patches/patch-video_out_vo_gpu_next_c b/multimedia/mpv/patches/patch-video_out_vo_gpu_next_c new file mode 100644 index 00000000000..2230a5ba165 --- /dev/null +++ b/multimedia/mpv/patches/patch-video_out_vo_gpu_next_c @@ -0,0 +1,38 @@ +- vo_gpu_next: don't flush cache on OSD update + e97e0e4d9214ac232581cd77712e5988637ceb36 + +Index: video/out/vo_gpu_next.c +--- video/out/vo_gpu_next.c.orig ++++ video/out/vo_gpu_next.c +@@ -987,6 +987,15 @@ static void draw_frame(struct vo *vo, struct vo_frame + image->num_overlays = 0; + fp->osd_sync = 0; + } ++ ++ // Update the frame signature to include the current OSD sync ++ // value, in order to disambiguate between identical frames with ++ // modified OSD. Shift the OSD sync value by a lot to avoid ++ // collisions with low signature values. ++ // ++ // This is safe to do because `pl_frame_mix.signature` lives in ++ // temporary memory that is only valid for this `pl_queue_update`. ++ ((uint64_t *) mix.signatures)[i] ^= fp->osd_sync << 48; + } + } + +@@ -1068,7 +1077,6 @@ static void resize(struct vo *vo) + osd_res_equals(p->osd_res, osd)) + return; + +- pl_renderer_flush_cache(p->rr); + p->osd_sync++; + p->osd_res = osd; + p->src = src; +@@ -1249,7 +1257,6 @@ static int control(struct vo *vo, uint32_t request, vo + return VO_TRUE; + + case VOCTRL_OSD_CHANGED: +- pl_renderer_flush_cache(p->rr); + p->osd_sync++; + return VO_TRUE; + diff --git a/multimedia/mpv/patches/patch-video_sws_utils_c b/multimedia/mpv/patches/patch-video_sws_utils_c new file mode 100644 index 00000000000..0ccaec0137b --- /dev/null +++ b/multimedia/mpv/patches/patch-video_sws_utils_c @@ -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 + #include + #include ++#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 37, 100) ++#include ++#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.