I spotted this one in portroach, haven't tested beyond build yet but
the patch merges are fiddly enough that I thought I'd send it out to
avoid anyone doing duplicate work. Runtime tests welcome!

Index: Makefile
===================================================================
RCS file: /cvs/ports/multimedia/mpv/Makefile,v
retrieving revision 1.97
diff -u -p -r1.97 Makefile
--- Makefile    18 Jun 2023 04:46:33 -0000      1.97
+++ Makefile    24 Jul 2023 07:57:41 -0000
@@ -2,8 +2,7 @@ COMMENT =               movie player based on MPlayer
 
 GH_ACCOUNT =           mpv-player
 GH_PROJECT =           mpv
-GH_TAGNAME =           v0.35.1
-REVISION =             5
+GH_TAGNAME =           v0.36.0
 USE_NOBTCFI =          Yes
 
 SHARED_LIBS +=         mpv             1.0 # 2.0
@@ -70,6 +69,7 @@ CONFIGURE_ARGS =      -Dlua=lua${MODLUA_DEP_V
                        -Dd3d11=disabled \
                        -Dd3d-hwaccel=disabled \
                        -Ddirect3d=disabled \
+                       -Ddmabuf-wayland=disabled \
                        -Degl-android=disabled \
                        -Degl-angle=disabled  \
                        -Degl-angle-lib=disabled \
@@ -83,6 +83,7 @@ CONFIGURE_ARGS =      -Dlua=lua${MODLUA_DEP_V
                        -Dios-gl=disabled \
                        -Djack=disabled \
                        -Djavascript=disabled \
+                       -Dlibplacebo-next=disabled \
                        -Dmacos-10-11-features=disabled \
                        -Dmacos-10-12-2-features=disabled \
                        -Dmacos-10-14-features=disabled \
@@ -112,6 +113,7 @@ CONFIGURE_ARGS =    -Dlua=lua${MODLUA_DEP_V
                        -Dvdpau-gl-x11=disabled \
                        -Dvideotoolbox-gl=disabled \
                        -Dvulkan=disabled \
+                       -Dvulkan-interop=disabled \
                        -Dwayland=disabled \
                        -Dwin32-internal-pthreads=disabled \
                        -Dwasapi=disabled
Index: distinfo
===================================================================
RCS file: /cvs/ports/multimedia/mpv/distinfo,v
retrieving revision 1.33
diff -u -p -r1.33 distinfo
--- distinfo    31 Jan 2023 10:19:28 -0000      1.33
+++ distinfo    24 Jul 2023 07:57:41 -0000
@@ -1,2 +1,2 @@
-SHA256 (mpv-0.35.1.tar.gz) = Qd+YG3uE4zou9EeKr4HW9PXIuc0sDTN6wUL8ILOH0ak=
-SIZE (mpv-0.35.1.tar.gz) = 3367913
+SHA256 (mpv-0.36.0.tar.gz) = KavET46+4BO7L5/hTYCzDbGbU0xnkFbkhRzq31pei/Y=
+SIZE (mpv-0.36.0.tar.gz) = 3409178
Index: patches/patch-audio_decode_ad_lavc_c
===================================================================
RCS file: patches/patch-audio_decode_ad_lavc_c
diff -N patches/patch-audio_decode_ad_lavc_c
--- patches/patch-audio_decode_ad_lavc_c        30 Jan 2023 16:53:55 -0000      
1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,43 +0,0 @@
-- 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;
Index: patches/patch-audio_decode_ad_spdif_c
===================================================================
RCS file: patches/patch-audio_decode_ad_spdif_c
diff -N patches/patch-audio_decode_ad_spdif_c
--- patches/patch-audio_decode_ad_spdif_c       30 Jan 2023 16:53:55 -0000      
1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-- 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;
- }
- 
Index: patches/patch-audio_out_ao_sndio_c
===================================================================
RCS file: patches/patch-audio_out_ao_sndio_c
diff -N patches/patch-audio_out_ao_sndio_c
--- patches/patch-audio_out_ao_sndio_c  20 Nov 2022 07:22:59 -0000      1.9
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,16 +0,0 @@
-Use sio_flush() instead of sio_stop() to improve controls responsiveness
-
-Index: audio/out/ao_sndio.c
---- audio/out/ao_sndio.c.orig
-+++ audio/out/ao_sndio.c
-@@ -237,8 +237,8 @@ static void reset(struct ao *ao)
-     if (p->playing) {
-         p->playing = false;
- 
--        if (!sio_stop(p->hdl)) {
--            MP_ERR(ao, "reset: couldn't sio_stop()\n");
-+        if (!sio_flush(p->hdl)) {
-+            MP_ERR(ao, "reset: couldn't sio_flush()\n");
-         }
-         p->delay = 0;
-         if (!sio_start(p->hdl)) {
Index: patches/patch-common_av_common_c
===================================================================
RCS file: patches/patch-common_av_common_c
diff -N patches/patch-common_av_common_c
--- patches/patch-common_av_common_c    30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,42 +0,0 @@
-- 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);
- }
Index: patches/patch-common_av_common_h
===================================================================
RCS file: patches/patch-common_av_common_h
diff -N patches/patch-common_av_common_h
--- patches/patch-common_av_common_h    30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-- 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
Index: patches/patch-common_av_log_c
===================================================================
RCS file: patches/patch-common_av_log_c
diff -N patches/patch-common_av_log_c
--- patches/patch-common_av_log_c       30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,23 +0,0 @@
-- 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
Index: patches/patch-common_recorder_c
===================================================================
RCS file: patches/patch-common_recorder_c
diff -N patches/patch-common_recorder_c
--- patches/patch-common_recorder_c     30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,56 +0,0 @@
-- 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)
Index: patches/patch-meson_build
===================================================================
RCS file: /cvs/ports/multimedia/mpv/patches/patch-meson_build,v
retrieving revision 1.5
diff -u -p -r1.5 patch-meson_build
--- patches/patch-meson_build   18 Jun 2023 04:46:33 -0000      1.5
+++ patches/patch-meson_build   24 Jul 2023 07:57:41 -0000
@@ -1,51 +1,10 @@
-- fix over-zealous detection of libatomic (it was picked up at configure
+fix over-zealous detection of libatomic (it was picked up at configure
 time if present at all, rather than only if needed)
 
-- meson: check pthread provider with has_function
-  bf3228142521b0bec633b741c0c97042bb20fe93
-
 Index: meson.build
 --- meson.build.orig
 +++ meson.build
-@@ -520,27 +520,27 @@ features += {'vt.h': cc.has_header_symbol('sys/vt.h', 
- 
- features += {'consio.h': not features['vt.h'] and 
cc.has_header_symbol('sys/consio.h', 'VT_GETMODE')}
- 
--fragments = join_paths(source_root, 'waftools', 'fragments')
-+# macOS's pthread_setname_np is a special snowflake and differs from 
literally every other platform.
-+features += {'osx-thread-name': darwin}
- 
--features += {'glibc-thread-name': cc.compiles(files(join_paths(fragments, 
'glibc_thread_name.c')),
--                                              name: 'glibc-thread-name 
check') and posix}
--
--features += {'osx-thread-name': false}
--if not features['glibc-thread-name']
--    features += {'osx-thread-name': cc.compiles(files(join_paths(fragments, 
'osx_thread_name.c')),
--                                                name: 'osx-thread-name 
check')}
-+features += {'glibc-thread-name': false}
-+if not features['osx-thread-name']
-+    features += {'glibc-thread-name': posix and 
cc.has_function('pthread_setname_np', args: '-D_GNU_SOURCE',
-+                                                                dependencies: 
pthreads, prefix: '#include <pthread.h>')}
- endif
- 
- features += {'bsd-thread-name': false}
- if not features['osx-thread-name'] and not features['glibc-thread-name']
--    features += {'bsd-thread-name': cc.compiles(files(join_paths(fragments, 
'bsd_thread_name.c')),
--                                                name: 'bsd-thread-name 
check')}
-+    features += {'bsd-thread-name': posix and 
cc.has_function('pthread_set_name_np', dependencies: pthreads,
-+                                                              prefix: 
'#include <pthread.h>\n#include <pthread_np.h>')}
- endif
- 
- features += {'bsd-fstatfs': cc.has_function('fstatfs', prefix: '#include 
<sys/mount.h>\n#include <sys/param.h>')}
- 
- features += {'linux-fstatfs': cc.has_function('fstatfs', prefix: '#include 
<sys/vfs.h>')}
- 
-+fragments = join_paths(source_root, 'waftools', 'fragments')
-+
- vector = get_option('vector').require(
-     cc.compiles(files(join_paths(fragments, 'vector.c')), name: 'vector 
check'),
-     error_message: 'the compiler does not support gcc vectors!',
-@@ -716,7 +716,19 @@ if features['sdl2-gamepad']
+@@ -720,7 +720,19 @@ if features['sdl2-gamepad']
      sources += files('input/sdl_gamepad.c')
  endif
  
Index: patches/patch-player_lua_ytdl_hook_lua
===================================================================
RCS file: patches/patch-player_lua_ytdl_hook_lua
diff -N patches/patch-player_lua_ytdl_hook_lua
--- patches/patch-player_lua_ytdl_hook_lua      1 May 2023 09:46:39 -0000       
1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,14 +0,0 @@
-backport of https://github.com/mpv-player/mpv/commit/94c189dae7
-
-Index: player/lua/ytdl_hook.lua
---- player/lua/ytdl_hook.lua.orig
-+++ player/lua/ytdl_hook.lua
-@@ -295,7 +295,7 @@ local function edl_track_joined(fragments, protocol, i
-         local args = ""
- 
-         -- assume MP4 DASH initialization segment
--        if not fragments[1].duration then
-+        if not fragments[1].duration and #fragments > 1 then
-             msg.debug("Using init segment")
-             args = args .. ",init=" .. edl_escape(join_url(base, 
fragments[1]))
-             offset = 2
Index: patches/patch-player_main_c
===================================================================
RCS file: patches/patch-player_main_c
diff -N patches/patch-player_main_c
--- patches/patch-player_main_c 30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,28 +0,0 @@
-- 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 <locale.h>
- 
- #include "config.h"
-+
-+#if HAVE_LIBPLACEBO
-+#include <libplacebo/config.h>
-+#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.
Index: patches/patch-sub_lavc_conv_c
===================================================================
RCS file: patches/patch-sub_lavc_conv_c
diff -N patches/patch-sub_lavc_conv_c
--- patches/patch-sub_lavc_conv_c       30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-- 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);
- }
Index: patches/patch-sub_sd_lavc_c
===================================================================
RCS file: patches/patch-sub_sd_lavc_c
diff -N patches/patch-sub_sd_lavc_c
--- patches/patch-sub_sd_lavc_c 30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-- 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);
- }
- 
Index: patches/patch-video_decode_vd_lavc_c
===================================================================
RCS file: patches/patch-video_decode_vd_lavc_c
diff -N patches/patch-video_decode_vd_lavc_c
--- patches/patch-video_decode_vd_lavc_c        30 Jan 2023 16:53:55 -0000      
1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-- 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>
-@@ -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);
- 
Index: patches/patch-video_out_vo_gpu_next_c
===================================================================
RCS file: patches/patch-video_out_vo_gpu_next_c
diff -N patches/patch-video_out_vo_gpu_next_c
--- patches/patch-video_out_vo_gpu_next_c       30 Jan 2023 16:53:55 -0000      
1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-- 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;
- 
Index: patches/patch-video_sws_utils_c
===================================================================
RCS file: patches/patch-video_sws_utils_c
diff -N patches/patch-video_sws_utils_c
--- patches/patch-video_sws_utils_c     30 Jan 2023 16:53:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,41 +0,0 @@
-- 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.

Reply via email to