jobextra/obs-studio/2e79d4c9.patch

97 lines
3.4 KiB
Diff
Raw Normal View History

2023-04-30 04:16:33 +02:00
From 2e79d4c902abf3e6bb4ad1b5bf779c0cc22a6fd0 Mon Sep 17 00:00:00 2001
From: pkv <pkv@obsproject.com>
Date: Tue, 28 Feb 2023 17:28:38 +0100
Subject: [PATCH] obs-ffmpeg: Fix for FFmpeg 6 deprecating a flag
Also modifies libobs & deps/media-playback.
AV_CODEC_CAP_TRUNCATED was removed in avcodec 60 [1].
We ifdef the code depending on it to allow compilation.
[1] avcodec: remove FF_API_FLAG_TRUNCATED
https://github.com/FFmpeg/FFmpeg/commit/3ceffe783965767e62d59e8e68ecd265c98460ec
Signed-off-by: pkv <pkv@obsproject.com>
---
deps/media-playback/media-playback/decode.c | 2 ++
deps/media-playback/media-playback/decode.h | 2 ++
libobs/obs-ffmpeg-compat.h | 2 ++
plugins/obs-ffmpeg/obs-ffmpeg-compat.h | 2 ++
plugins/win-dshow/ffmpeg-decode.c | 2 ++
5 files changed, 10 insertions(+)
diff --git a/deps/media-playback/media-playback/decode.c b/deps/media-playback/media-playback/decode.c
index 05d6afcc649a2..e1aa9aec0577b 100644
--- a/deps/media-playback/media-playback/decode.c
+++ b/deps/media-playback/media-playback/decode.c
@@ -230,8 +230,10 @@ bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw)
d->in_frame = d->sw_frame;
}
+#if LIBAVCODEC_VERSION_MAJOR < 60
if (d->codec->capabilities & CODEC_CAP_TRUNC)
d->decoder->flags |= CODEC_FLAG_TRUNC;
+#endif
d->orig_pkt = av_packet_alloc();
d->pkt = av_packet_alloc();
diff --git a/deps/media-playback/media-playback/decode.h b/deps/media-playback/media-playback/decode.h
index 1ca271b419fbd..6da34061b3dee 100644
--- a/deps/media-playback/media-playback/decode.h
+++ b/deps/media-playback/media-playback/decode.h
@@ -37,8 +37,10 @@ extern "C" {
#endif
#if LIBAVCODEC_VERSION_MAJOR >= 58
+#if LIBAVCODEC_VERSION_MAJOR < 60
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
+#endif
#else
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC CODEC_FLAG_TRUNCATED
diff --git a/libobs/obs-ffmpeg-compat.h b/libobs/obs-ffmpeg-compat.h
index c4e23b9851242..ad633521e3b0b 100644
--- a/libobs/obs-ffmpeg-compat.h
+++ b/libobs/obs-ffmpeg-compat.h
@@ -23,8 +23,10 @@
#endif
#if LIBAVCODEC_VERSION_MAJOR >= 58
+#if LIBAVCODEC_VERSION_MAJOR < 60
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
+#endif
#define INPUT_BUFFER_PADDING_SIZE AV_INPUT_BUFFER_PADDING_SIZE
#else
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-compat.h b/plugins/obs-ffmpeg/obs-ffmpeg-compat.h
index 181167aff383d..39efa00c774b3 100644
--- a/plugins/obs-ffmpeg/obs-ffmpeg-compat.h
+++ b/plugins/obs-ffmpeg/obs-ffmpeg-compat.h
@@ -27,8 +27,10 @@
#endif
#if LIBAVCODEC_VERSION_MAJOR >= 58
+#if LIBAVCODEC_VERSION_MAJOR < 60
#define CODEC_CAP_TRUNC AV_CODEC_CAP_TRUNCATED
#define CODEC_FLAG_TRUNC AV_CODEC_FLAG_TRUNCATED
+#endif
#define CODEC_FLAG_GLOBAL_H AV_CODEC_FLAG_GLOBAL_HEADER
#else
#define CODEC_CAP_TRUNC CODEC_CAP_TRUNCATED
diff --git a/plugins/win-dshow/ffmpeg-decode.c b/plugins/win-dshow/ffmpeg-decode.c
index d27c98441da15..49df62b7a79f2 100644
--- a/plugins/win-dshow/ffmpeg-decode.c
+++ b/plugins/win-dshow/ffmpeg-decode.c
@@ -105,8 +105,10 @@ int ffmpeg_decode_init(struct ffmpeg_decode *decode, enum AVCodecID id,
return ret;
}
+#if LIBAVCODEC_VERSION_MAJOR < 60
if (decode->codec->capabilities & CODEC_CAP_TRUNC)
decode->decoder->flags |= CODEC_FLAG_TRUNC;
+#endif
return 0;
}