View | Details | Raw Unified | Return to bug 261302 | Differences between
and this patch

Collapse All | Expand All

(-)b/audio/chromaprint/Makefile (-2 / +5 lines)
Lines 1-7 Link Here
1
PORTNAME=	chromaprint
1
PORTNAME=	chromaprint
2
PORTVERSION=	1.5.1
2
DISTVERSION=	1.5.1.a.20221217
3
CATEGORIES=	audio
3
CATEGORIES=	audio
4
MASTER_SITES=	https://github.com/acoustid/${PORTNAME}/releases/download/v${PORTVERSION}/
4
#MASTER_SITES=	https://github.com/acoustid/${PORTNAME}/releases/download/v${DISTVERSION}/
5
5
6
MAINTAINER=	jhale@FreeBSD.org
6
MAINTAINER=	jhale@FreeBSD.org
7
COMMENT=	AcoustID audio fingerprinting library
7
COMMENT=	AcoustID audio fingerprinting library
Lines 14-19 LICENSE_FILE_MIT= ${WRKSRC}/LICENSE.md Link Here
14
LIB_DEPENDS=	libavcodec.so:multimedia/ffmpeg
14
LIB_DEPENDS=	libavcodec.so:multimedia/ffmpeg
15
15
16
USES=		cmake compiler:c++11-lib pathfix
16
USES=		cmake compiler:c++11-lib pathfix
17
USE_GITHUB=	yes
18
GH_ACCOUNT=	acoustid
19
GH_TAGNAME=	aa67c95
17
USE_LDCONFIG=	yes
20
USE_LDCONFIG=	yes
18
21
19
CMAKE_ARGS=	-DBUILD_TOOLS:BOOL=true \
22
CMAKE_ARGS=	-DBUILD_TOOLS:BOOL=true \
(-)b/audio/chromaprint/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1663260813
1
TIMESTAMP = 1678719395
2
SHA256 (chromaprint-1.5.1.tar.gz) = a1aad8fa3b8b18b78d3755b3767faff9abb67242e01b478ec9a64e190f335e1c
2
SHA256 (acoustid-chromaprint-1.5.1.a.20221217-aa67c95_GH0.tar.gz) = 0893b7198121dd2add81aa1233e5312cbc7446bdd6b6418a5af6ab24e82cb6b3
3
SIZE (chromaprint-1.5.1.tar.gz) = 1581159
3
SIZE (acoustid-chromaprint-1.5.1.a.20221217-aa67c95_GH0.tar.gz) = 1581151
(-)b/audio/spek/Makefile (-10 / +5 lines)
Lines 1-8 Link Here
1
PORTNAME=	spek
1
PORTNAME=	spek
2
PORTVERSION=	0.8.2
2
DISTVERSION=	0.8.5
3
PORTREVISION=	17
4
CATEGORIES=	audio
3
CATEGORIES=	audio
5
MASTER_SITES=	https://github.com/alexkay/${PORTNAME}/releases/download/v${PORTVERSION}/
4
MASTER_SITES=	https://github.com/alexkay/${PORTNAME}/releases/download/v${DISTVERSION}/
6
5
7
MAINTAINER=	alexander@kojevnikov.com
6
MAINTAINER=	alexander@kojevnikov.com
8
COMMENT=	Acoustic spectrum analyser
7
COMMENT=	Acoustic spectrum analyser
Lines 12-21 LICENSE= GPLv3+ Link Here
12
11
13
LIB_DEPENDS=	libavcodec.so:multimedia/ffmpeg
12
LIB_DEPENDS=	libavcodec.so:multimedia/ffmpeg
14
13
15
USES=		compiler:c++11-lib desktop-file-utils gmake gnome pkgconfig \
14
USES=		compiler:c++11-lib desktop-file-utils gmake gnome \
16
		tar:xz
15
		localbase:ldflags pkgconfig tar:xz
17
USE_GNOME=	intltool
16
USE_GNOME=	intltool
18
USE_WX=		3.0
17
USE_WX=		3.2+
19
WX_CONF_ARGS=	absolute
18
WX_CONF_ARGS=	absolute
20
GNU_CONFIGURE=	yes
19
GNU_CONFIGURE=	yes
21
20
Lines 24-31 OPTIONS_SUB= yes Link Here
24
NLS_USES=	gettext
23
NLS_USES=	gettext
25
NLS_CONFIGURE_ENABLE=	nls
24
NLS_CONFIGURE_ENABLE=	nls
26
25
27
post-patch:
28
	@${REINPLACE_CMD} -e "s,^itlocaledir =.*$$,itlocaledir = ${PREFIX}/share/locale,g" \
29
		${WRKSRC}/po/Makefile.in.in
30
31
.include <bsd.port.mk>
26
.include <bsd.port.mk>
(-)b/audio/spek/distinfo (-2 / +3 lines)
Lines 1-2 Link Here
1
SHA256 (spek-0.8.2.tar.xz) = 59f69b41155ee1a4552eb9f66b602fc059de8f31e3f05889f24d362b3e6c78ae
1
TIMESTAMP = 1678742866
2
SIZE (spek-0.8.2.tar.xz) = 171628
2
SHA256 (spek-0.8.5.tar.xz) = 1bccf85a14a01af8f2f30476cbad004e8bf6031f500e562bbe5bbd1e5eb16c59
3
SIZE (spek-0.8.5.tar.xz) = 430464
(-)a/audio/spek/files/patch-src_spek-audio.cc (-58 lines)
Removed Link Here
1
Fix build with ffmpeg 3.x.
2
3
--- src/spek-audio.cc.orig	2016-12-28 01:32:07 UTC
4
+++ src/spek-audio.cc
5
@@ -199,7 +199,7 @@ AudioFileImpl::AudioFileImpl(
6
     this->packet.data = nullptr;
7
     this->packet.size = 0;
8
     this->offset = 0;
9
-    this->frame = avcodec_alloc_frame();
10
+    this->frame = av_frame_alloc();
11
     this->buffer_size = 0;
12
     this->buffer = nullptr;
13
     this->frames_per_interval = 0;
14
@@ -215,7 +215,7 @@ AudioFileImpl::~AudioFileImpl()
15
     if (this->frame) {
16
         // TODO: Remove this check after Debian switches to libav 9.
17
 #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
18
-        avcodec_free_frame(&this->frame);
19
+        av_frame_free(&this->frame);
20
 #else
21
         av_freep(&this->frame);
22
 #endif
23
@@ -224,7 +224,7 @@ AudioFileImpl::~AudioFileImpl()
24
         this->packet.data -= this->offset;
25
         this->packet.size += this->offset;
26
         this->offset = 0;
27
-        av_free_packet(&this->packet);
28
+        av_packet_unref(&this->packet);
29
     }
30
     if (this->format_context) {
31
         if (this->audio_stream >= 0) {
32
@@ -255,7 +255,7 @@ int AudioFileImpl::read()
33
 
34
     for (;;) {
35
         while (this->packet.size > 0) {
36
-            avcodec_get_frame_defaults(this->frame);
37
+            av_frame_unref(this->frame);
38
             auto codec_context = this->format_context->streams[this->audio_stream]->codec;
39
             int got_frame = 0;
40
             int len = avcodec_decode_audio4(codec_context, this->frame, &got_frame, &this->packet);
41
@@ -299,7 +299,7 @@ int AudioFileImpl::read()
42
             this->packet.data -= this->offset;
43
             this->packet.size += this->offset;
44
             this->offset = 0;
45
-            av_free_packet(&this->packet);
46
+            av_packet_unref(&this->packet);
47
         }
48
 
49
         int res = 0;
50
@@ -307,7 +307,7 @@ int AudioFileImpl::read()
51
             if (this->packet.stream_index == this->audio_stream) {
52
                 break;
53
             }
54
-            av_free_packet(&this->packet);
55
+            av_packet_unref(&this->packet);
56
         }
57
         if (res < 0) {
58
             // End of file or error.
(-)b/audio/spek/pkg-plist (+14 lines)
Lines 7-27 share/icons/hicolor/24x24/apps/spek.png Link Here
7
share/icons/hicolor/32x32/apps/spek.png
7
share/icons/hicolor/32x32/apps/spek.png
8
share/icons/hicolor/48x48/apps/spek.png
8
share/icons/hicolor/48x48/apps/spek.png
9
share/icons/hicolor/scalable/apps/spek.svg
9
share/icons/hicolor/scalable/apps/spek.svg
10
%%NLS%%share/locale/bs/LC_MESSAGES/spek.mo
11
%%NLS%%share/locale/ca/LC_MESSAGES/spek.mo
10
%%NLS%%share/locale/cs/LC_MESSAGES/spek.mo
12
%%NLS%%share/locale/cs/LC_MESSAGES/spek.mo
11
%%NLS%%share/locale/da/LC_MESSAGES/spek.mo
13
%%NLS%%share/locale/da/LC_MESSAGES/spek.mo
12
%%NLS%%share/locale/de/LC_MESSAGES/spek.mo
14
%%NLS%%share/locale/de/LC_MESSAGES/spek.mo
15
%%NLS%%share/locale/el/LC_MESSAGES/spek.mo
13
%%NLS%%share/locale/eo/LC_MESSAGES/spek.mo
16
%%NLS%%share/locale/eo/LC_MESSAGES/spek.mo
14
%%NLS%%share/locale/es/LC_MESSAGES/spek.mo
17
%%NLS%%share/locale/es/LC_MESSAGES/spek.mo
18
%%NLS%%share/locale/fi/LC_MESSAGES/spek.mo
15
%%NLS%%share/locale/fr/LC_MESSAGES/spek.mo
19
%%NLS%%share/locale/fr/LC_MESSAGES/spek.mo
20
%%NLS%%share/locale/gl/LC_MESSAGES/spek.mo
21
%%NLS%%share/locale/he/LC_MESSAGES/spek.mo
22
%%NLS%%share/locale/hr/LC_MESSAGES/spek.mo
23
%%NLS%%share/locale/hu/LC_MESSAGES/spek.mo
16
%%NLS%%share/locale/it/LC_MESSAGES/spek.mo
24
%%NLS%%share/locale/it/LC_MESSAGES/spek.mo
17
%%NLS%%share/locale/ja/LC_MESSAGES/spek.mo
25
%%NLS%%share/locale/ja/LC_MESSAGES/spek.mo
26
%%NLS%%share/locale/ko/LC_MESSAGES/spek.mo
27
%%NLS%%share/locale/lv/LC_MESSAGES/spek.mo
18
%%NLS%%share/locale/nb/LC_MESSAGES/spek.mo
28
%%NLS%%share/locale/nb/LC_MESSAGES/spek.mo
29
%%NLS%%share/locale/nn/LC_MESSAGES/spek.mo
19
%%NLS%%share/locale/nl/LC_MESSAGES/spek.mo
30
%%NLS%%share/locale/nl/LC_MESSAGES/spek.mo
20
%%NLS%%share/locale/pl/LC_MESSAGES/spek.mo
31
%%NLS%%share/locale/pl/LC_MESSAGES/spek.mo
21
%%NLS%%share/locale/pt_BR/LC_MESSAGES/spek.mo
32
%%NLS%%share/locale/pt_BR/LC_MESSAGES/spek.mo
22
%%NLS%%share/locale/ru/LC_MESSAGES/spek.mo
33
%%NLS%%share/locale/ru/LC_MESSAGES/spek.mo
34
%%NLS%%share/locale/sk/LC_MESSAGES/spek.mo
35
%%NLS%%share/locale/sr@latin/LC_MESSAGES/spek.mo
23
%%NLS%%share/locale/sv/LC_MESSAGES/spek.mo
36
%%NLS%%share/locale/sv/LC_MESSAGES/spek.mo
24
%%NLS%%share/locale/tr/LC_MESSAGES/spek.mo
37
%%NLS%%share/locale/tr/LC_MESSAGES/spek.mo
38
%%NLS%%share/locale/th/LC_MESSAGES/spek.mo
25
%%NLS%%share/locale/uk/LC_MESSAGES/spek.mo
39
%%NLS%%share/locale/uk/LC_MESSAGES/spek.mo
26
%%NLS%%share/locale/vi/LC_MESSAGES/spek.mo
40
%%NLS%%share/locale/vi/LC_MESSAGES/spek.mo
27
%%NLS%%share/locale/zh_CN/LC_MESSAGES/spek.mo
41
%%NLS%%share/locale/zh_CN/LC_MESSAGES/spek.mo
(-)b/graphics/synfig/Makefile (-11 / +13 lines)
Lines 1-7 Link Here
1
PORTNAME=	synfig
1
PORTNAME=	synfig
2
PORTVERSION=	1.4.4
2
DISTVERSIONPREFIX=	v
3
DISTVERSIONPREFIX=v
3
DISTVERSION=	1.4.4
4
PORTREVISION=	1
4
PORTREVISION=	2
5
CATEGORIES=	graphics devel multimedia
5
CATEGORIES=	graphics devel multimedia
6
6
7
MAINTAINER=	portmaster@BSDforge.com
7
MAINTAINER=	portmaster@BSDforge.com
Lines 26-47 LIB_DEPENDS= libImath.so:math/Imath \ Link Here
26
		libpng.so:graphics/png \
26
		libpng.so:graphics/png \
27
		libtiff.so:graphics/tiff
27
		libtiff.so:graphics/tiff
28
28
29
PORTSCOUT=	limitw:1,even
30
31
USES=		autoreconf compiler:c++11-lang gmake gnome iconv jpeg \
29
USES=		autoreconf compiler:c++11-lang gmake gnome iconv jpeg \
32
		libtool localbase magick:6 mlt:6 pathfix pkgconfig
30
		libtool localbase magick:7 mlt:7 pathfix pkgconfig
33
USE_CXXSTD=	c++11
31
USE_CXXSTD=	c++11
34
USE_GITHUB=	yes
32
USE_GITHUB=	yes
35
USE_GNOME=	cairo glibmm intltool libxml++26 pango
33
USE_GNOME=	cairo glibmm intltool libxml++26 pango
34
USE_LDCONFIG=	yes
35
36
PORTSCOUT=	limitw:1,even
37
36
GNU_CONFIGURE=	yes
38
GNU_CONFIGURE=	yes
37
CONFIGURE_ARGS=	${ICONV_CONFIGURE_ARG}
38
CONFIGURE_ENV+=	ac_cv_path_SED=${LOCALBASE}/bin/gsed
39
# Other spurious uses of direct sed have popped up
40
BINARY_ALIAS=	sed=${LOCALBASE}/bin/gsed
41
INSTALL_TARGET=	install-strip
39
INSTALL_TARGET=	install-strip
42
USE_LDCONFIG=	yes
43
WRKSRC_SUBDIR=	synfig-core
40
WRKSRC_SUBDIR=	synfig-core
44
41
42
BINARY_ALIAS=	sed=${LOCALBASE}/bin/gsed
43
44
CONFIGURE_ENV+=	ac_cv_path_SED=${LOCALBASE}/bin/gsed
45
CONFIGURE_ARGS=	${ICONV_CONFIGURE_ARG}
46
45
OPTIONS_DEFINE=	DOCS NLS
47
OPTIONS_DEFINE=	DOCS NLS
46
OPTIONS_SUB=	yes
48
OPTIONS_SUB=	yes
47
49
(-)b/graphics/synfig/distinfo (-2 / +1 lines)
Lines 1-4 Link Here
1
TIMESTAMP = 1673053271
1
TIMESTAMP = 1680950793
2
SHA256 (synfig-synfig-v1.4.4_GH0.tar.gz) = 83357c3282ecb4e6be46771fde1688662ca184eab8901cef66fe2bf000b99519
2
SHA256 (synfig-synfig-v1.4.4_GH0.tar.gz) = 83357c3282ecb4e6be46771fde1688662ca184eab8901cef66fe2bf000b99519
3
SHA512 (synfig-synfig-v1.4.4_GH0.tar.gz) = 1b0ef61cae21130c6d8068212cacf6d6a2d6264a06fa5275f50384a45ae1e75b2df21c11c920de42588bc924e385de5ce2b4f7565ab85026bf835c13eddb9eb5
4
SIZE (synfig-synfig-v1.4.4_GH0.tar.gz) = 12943798
3
SIZE (synfig-synfig-v1.4.4_GH0.tar.gz) = 12943798
(-)b/graphics/synfig/files/patch-src_modules_mod__libavcodec_trgt__av.cpp (+51 lines)
Added Link Here
1
--- src/modules/mod_libavcodec/trgt_av.cpp.orig	2022-12-24 14:01:41 UTC
2
+++ src/modules/mod_libavcodec/trgt_av.cpp
3
@@ -38,6 +38,7 @@
4
 extern "C"
5
 {
6
 #ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
7
+#	include <libavcodec/avcodec.h>
8
 #	include <libavformat/avformat.h>
9
 #elif defined(HAVE_AVFORMAT_H)
10
 #	include <avformat.h>
11
@@ -234,12 +235,14 @@ class Target_LibAVCodec::Internal (public)
12
 		close();
13
 
14
 		if (!av_registered) {
15
-			av_register_all();
16
+#if LIBAVCODEC_VERSION_MAJOR < 59
17
+ 			av_register_all();
18
+#endif
19
 			av_registered = true;
20
 		}
21
 
22
 		// guess format
23
-		AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
24
+		const AVOutputFormat *format = av_guess_format(NULL, filename.c_str(), NULL);
25
 		if (!format) {
26
 			synfig::warning("Target_LibAVCodec: unable to guess the output format, defaulting to MPEG");
27
 			format = av_guess_format("mpeg", NULL, NULL);
28
@@ -254,7 +257,7 @@ class Target_LibAVCodec::Internal (public)
29
 		context = avformat_alloc_context();
30
 		assert(context);
31
 		context->oformat = format;
32
-		if (filename.size() + 1 > sizeof(context->filename)) {
33
+		/*if (filename.size() + 1 > sizeof(context->filename)) {
34
 			synfig::error(
35
 				"Target_LibAVCodec: filename too long, max length is %d, filename is '%s'",
36
 				sizeof(context->filename) - 1,
37
@@ -262,7 +265,13 @@ class Target_LibAVCodec::Internal (public)
38
 			close();
39
 			return false;
40
 		}
41
-		memcpy(context->filename, filename.c_str(), filename.size() + 1);
42
+		memcpy(context->filename, filename.c_str(), filename.size() + 1);*/
43
+		context->url = av_strndup(filename.c_str(), filename.size());
44
+		if (!context->url) {
45
+			synfig::error("Target_LibAVCodec: cannot allocate space for filename");
46
+			close();
47
+			return false;
48
+		}
49
 
50
 		packet = av_packet_alloc();
51
 		assert(packet);
(-)b/graphics/synfigstudio/Makefile (-11 / +14 lines)
Lines 1-7 Link Here
1
PORTNAME=	synfigstudio
1
PORTNAME=	synfigstudio
2
PORTVERSION=	1.4.4
2
DISTVERSIONPREFIX=	v
3
DISTVERSIONPREFIX=v
3
DISTVERSION=	1.4.4
4
PORTREVISION=	2
4
PORTREVISION=	3
5
CATEGORIES=	graphics multimedia
5
CATEGORIES=	graphics multimedia
6
6
7
MAINTAINER=	portmaster@BSDforge.com
7
MAINTAINER=	portmaster@BSDforge.com
Lines 24-45 LIB_DEPENDS= libImath.so:math/Imath \ Link Here
24
		libsynfig.so:graphics/synfig
24
		libsynfig.so:graphics/synfig
25
RUN_DEPENDS=	xdg-open:devel/xdg-utils
25
RUN_DEPENDS=	xdg-open:devel/xdg-utils
26
26
27
PORTSCOUT=	limitw:1,even
27
USES=		autoreconf compiler:c++11-lang desktop-file-utils gmake \
28
28
		gnome libtool localbase magick:7 mlt:7 pathfix pkgconfig \
29
USES=		autoreconf compiler:c++11-lang desktop-file-utils \
30
		gmake gnome libtool localbase magick:6 mlt:6 pathfix pkgconfig \
31
		shared-mime-info
29
		shared-mime-info
30
USE_CXXSTD=	c++11
32
USE_GITHUB=	yes
31
USE_GITHUB=	yes
33
GH_ACCOUNT=	synfig
32
GH_ACCOUNT=	synfig
34
GH_PROJECT=	synfig
33
GH_PROJECT=	synfig
35
WRKSRC_SUBDIR=	synfig-studio
36
USE_CXXSTD=	c++11
37
USE_GNOME=	gdkpixbuf2 gtkmm30 intltool
34
USE_GNOME=	gdkpixbuf2 gtkmm30 intltool
35
USE_LDCONFIG=	yes
36
37
PORTSCOUT=	limitw:1,even
38
38
GNU_CONFIGURE=	yes
39
GNU_CONFIGURE=	yes
40
INSTALL_TARGET=	install-strip
41
WRKSRC_SUBDIR=	synfig-studio
42
39
BINARY_ALIAS=	sed=${LOCALBASE}/bin/gsed
43
BINARY_ALIAS=	sed=${LOCALBASE}/bin/gsed
44
40
CONFIGURE_ARGS=	--disable-update-mimedb
45
CONFIGURE_ARGS=	--disable-update-mimedb
41
INSTALL_TARGET=	install-strip
42
USE_LDCONFIG=	yes
43
46
44
OPTIONS_DEFINE=	DOCS JACK NLS
47
OPTIONS_DEFINE=	DOCS JACK NLS
45
OPTIONS_SUB=	yes
48
OPTIONS_SUB=	yes
(-)b/graphics/synfigstudio/distinfo (-2 / +1 lines)
Lines 1-4 Link Here
1
TIMESTAMP = 1673068380
1
TIMESTAMP = 1680950823
2
SHA256 (synfig-synfig-v1.4.4_GH0.tar.gz) = 83357c3282ecb4e6be46771fde1688662ca184eab8901cef66fe2bf000b99519
2
SHA256 (synfig-synfig-v1.4.4_GH0.tar.gz) = 83357c3282ecb4e6be46771fde1688662ca184eab8901cef66fe2bf000b99519
3
SHA512 (synfig-synfig-v1.4.4_GH0.tar.gz) = 1b0ef61cae21130c6d8068212cacf6d6a2d6264a06fa5275f50384a45ae1e75b2df21c11c920de42588bc924e385de5ce2b4f7565ab85026bf835c13eddb9eb5
4
SIZE (synfig-synfig-v1.4.4_GH0.tar.gz) = 12943798
3
SIZE (synfig-synfig-v1.4.4_GH0.tar.gz) = 12943798
(-)b/multimedia/ffmpeg/files/ffmpeg-patch-add-av_stream_get_first_dts-for-qt5-webengine (+35 lines)
Added Link Here
1
Add "av_stream_get_first_dts" symbol for www/qt5-webengine
2
3
Obtained from:
4
5
https://github.com/archlinux/svntogit-packages/blob/packages/ffmpeg/trunk/add-av_stream_get_first_dts-for-chromium.patch
6
7
--- libavformat/avformat.h.orig	2023-02-27 20:43:45 UTC
8
+++ libavformat/avformat.h
9
@@ -1019,6 +1019,10 @@ int64_t    av_stream_get_end_pts(const AVStream *st);
10
 int64_t    av_stream_get_end_pts(const AVStream *st);
11
 #endif
12
 
13
+// Chromium: We use the internal field first_dts vvv
14
+int64_t    av_stream_get_first_dts(const AVStream *st);
15
+// Chromium: We use the internal field first_dts ^^^
16
+
17
 #define AV_PROGRAM_RUNNING 1
18
 
19
 /**
20
--- libavformat/mux_utils.c.orig	2023-02-27 20:43:45 UTC
21
+++ libavformat/mux_utils.c
22
@@ -40,6 +40,13 @@ int64_t av_stream_get_end_pts(const AVStream *st)
23
 }
24
 #endif
25
 
26
+// Chromium: We use the internal field first_dts vvv
27
+int64_t av_stream_get_first_dts(const AVStream *st)
28
+{
29
+  return cffstream(st)->first_dts;
30
+}
31
+// Chromium: We use the internal field first_dts ^^^
32
+
33
 int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
34
                          int std_compliance)
35
 {
(-)b/multimedia/ffmpegthumbnailer/Makefile (-10 / +12 lines)
Lines 1-7 Link Here
1
PORTNAME=	ffmpegthumbnailer
1
PORTNAME=	ffmpegthumbnailer
2
PORTVERSION=	2.2.2
2
DISTVERSION=	2.2.2.a.20221021
3
CATEGORIES=	multimedia graphics
3
CATEGORIES=	multimedia graphics
4
MASTER_SITES=	https://github.com/dirkvdb/${PORTNAME}/releases/download/${PORTVERSION}/
4
#MASTER_SITES=	https://github.com/dirkvdb/${PORTNAME}/releases/download/${PORTVERSION}/
5
5
6
MAINTAINER=	ports@FreeBSD.org
6
MAINTAINER=	ports@FreeBSD.org
7
COMMENT=	Lightweight video thumbnailer that can be used by file managers
7
COMMENT=	Lightweight video thumbnailer that can be used by file managers
Lines 13-36 LICENSE_FILE= ${WRKSRC}/COPYING Link Here
13
LIB_DEPENDS=	libpng.so:graphics/png \
13
LIB_DEPENDS=	libpng.so:graphics/png \
14
		libavformat.so:multimedia/ffmpeg
14
		libavformat.so:multimedia/ffmpeg
15
15
16
USES=		cmake compiler:c++11-lib gnome jpeg localbase pkgconfig tar:bz2
16
USES=		cmake:testing compiler:c++11-lib gnome jpeg localbase pkgconfig tar:bz2
17
USE_GITHUB=	yes
18
GH_ACCOUNT=	dirkvdb
19
GH_TAGNAME=	e0bf01d
20
17
USE_GNOME=	glib20
21
USE_GNOME=	glib20
18
USE_LDCONFIG=	yes
22
USE_LDCONFIG=	yes
19
23
20
EXTRACT_CMD=	${SETENV} LC_ALL=en_US.UTF-8 /usr/bin/bsdtar
24
EXTRACT_CMD=	${SETENV} LC_ALL=en_US.UTF-8 /usr/bin/bsdtar
25
CMAKE_TESTING_ON=	ENABLE_TESTS
21
26
27
CMAKE_OFF=	ENABLE_TESTS
22
CMAKE_ON=	ENABLE_GIO
28
CMAKE_ON=	ENABLE_GIO
23
29
24
OPTIONS_DEFINE=	TEST THUMBNAILER
30
OPTIONS_DEFINE=	THUMBNAILER
25
THUMBNAILER_DESC=Register as a system thumbnailer
26
OPTIONS_SUB=	yes
27
OPTIONS_DEFAULT=THUMBNAILER
31
OPTIONS_DEFAULT=THUMBNAILER
32
OPTIONS_SUB=	yes
28
33
29
TEST_CMAKE_BOOL=	ENABLE_TESTS
34
THUMBNAILER_DESC=	Register as a system thumbnailer
30
35
31
THUMBNAILER_CMAKE_ON=	-DENABLE_THUMBNAILER:BOOL=ON
36
THUMBNAILER_CMAKE_ON=	-DENABLE_THUMBNAILER:BOOL=ON
32
37
33
do-test:
34
	(cd ${TEST_WRKSRC} && CTEST_OUTPUT_ON_FAILURE=1 ctest)
35
36
.include <bsd.port.mk>
38
.include <bsd.port.mk>
(-)b/multimedia/ffmpegthumbnailer/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1595238599
1
TIMESTAMP = 1678817076
2
SHA256 (ffmpegthumbnailer-2.2.2.tar.bz2) = 1cb24059c38223f657b300c84dd80491b7040d4b69471c4fea69be862bc99b5b
2
SHA256 (dirkvdb-ffmpegthumbnailer-2.2.2.a.20221021-e0bf01d_GH0.tar.gz) = 56e100ef6e6a8ce18e6015b79efad6601a636b03b6bcf9abf6b6f73c501e13e7
3
SIZE (ffmpegthumbnailer-2.2.2.tar.bz2) = 1201838
3
SIZE (dirkvdb-ffmpegthumbnailer-2.2.2.a.20221021-e0bf01d_GH0.tar.gz) = 1291600
(-)a/multimedia/ffmpegthumbnailer/files/patch-CMakeLists.txt (-52 lines)
Removed Link Here
1
--- CMakeLists.txt.orig	2019-10-03 19:51:17 UTC
2
+++ CMakeLists.txt
3
@@ -1,4 +1,4 @@
4
-cmake_minimum_required(VERSION 3.5)
5
+cmake_minimum_required(VERSION 3.12)
6
 
7
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
8
 
9
@@ -92,6 +92,15 @@ add_library(libffmpegthumbnailerobj OBJECT
10
     libffmpegthumbnailer/filmstripfilter.cpp
11
 )
12
 
13
+target_link_libraries(libffmpegthumbnailerobj
14
+    FFmpeg::avformat
15
+    FFmpeg::avcodec
16
+    FFmpeg::avutil
17
+    FFmpeg::avfilter
18
+    $<$<BOOL:${HAVE_JPEG}>:${JPEG_LIBRARIES}>
19
+    $<$<BOOL:${HAVE_PNG}>:PNG::PNG>
20
+)
21
+
22
 # we use our own deprecated struct menbers, so disable the warning about it
23
 set_source_files_properties(libffmpegthumbnailer/videothumbnailerc.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
24
 
25
@@ -118,12 +127,7 @@ set (FFMPEGTHUMBNAILER_SOVERSION_AGE 1)
26
 if (ENABLE_STATIC)
27
     add_library(libffmpegthumbnailerstatic STATIC $<TARGET_OBJECTS:libffmpegthumbnailerobj>)
28
     target_link_libraries(libffmpegthumbnailerstatic
29
-        FFmpeg::avformat
30
-        FFmpeg::avcodec
31
-        FFmpeg::avutil
32
-        FFmpeg::avfilter
33
-        $<$<BOOL:${HAVE_JPEG}>:${JPEG_LIBRARIES}>
34
-        $<$<BOOL:${HAVE_PNG}>:PNG::PNG>
35
+        libffmpegthumbnailerobj
36
         $<$<BOOL:${ENABLE_GIO}>:${CMAKE_DL_LIBS}>
37
     )
38
 
39
@@ -140,12 +144,7 @@ endif ()
40
 if (ENABLE_SHARED)
41
     add_library(libffmpegthumbnailer SHARED $<TARGET_OBJECTS:libffmpegthumbnailerobj>)
42
     target_link_libraries(libffmpegthumbnailer
43
-        FFmpeg::avformat
44
-        FFmpeg::avcodec
45
-        FFmpeg::avutil
46
-        FFmpeg::avfilter
47
-        $<$<BOOL:${HAVE_JPEG}>:${JPEG_LIBRARIES}>
48
-        $<$<BOOL:${HAVE_PNG}>:PNG::PNG>
49
+        libffmpegthumbnailerobj
50
     )
51
 
52
     set_target_properties(libffmpegthumbnailer PROPERTIES
(-)b/multimedia/kodi/files/patch-ffmpeg6 (+2114 lines)
Added Link Here
1
diff -urN cmake/modules/FindFFMPEG.cmake.orig cmake/modules/FindFFMPEG.cmake
2
--- cmake/modules/FindFFMPEG.cmake.orig	2023-03-11 22:16:38.000000000 +0000
3
+++ cmake/modules/FindFFMPEG.cmake	2023-03-16 21:56:53.268867000 +0000
4
@@ -151,14 +151,14 @@
5
   set(REQUIRED_FFMPEG_VERSION undef)
6
 else()
7
   # required ffmpeg library versions
8
-  set(REQUIRED_FFMPEG_VERSION 4.4.1)
9
-  set(_avcodec_ver ">=58.134.100")
10
-  set(_avfilter_ver ">=7.110.100")
11
-  set(_avformat_ver ">=58.76.100")
12
-  set(_avutil_ver ">=56.70.100")
13
-  set(_postproc_ver ">=55.9.100")
14
-  set(_swresample_ver ">=3.9.100")
15
-  set(_swscale_ver ">=5.9.100")
16
+  set(REQUIRED_FFMPEG_VERSION 6.0.0)
17
+  set(_avcodec_ver ">=60.2.100")
18
+  set(_avfilter_ver ">=9.3.100")
19
+  set(_avformat_ver ">=60.3.100")
20
+  set(_avutil_ver ">=58.2.100")
21
+  set(_postproc_ver ">=57.1.100")
22
+  set(_swresample_ver ">=4.10.100")
23
+  set(_swscale_ver ">=7.1.100")
24
 endif()
25
 
26
 # Allows building with external ffmpeg not found in system paths,
27
diff -urN tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch.orig tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch
28
--- tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch.orig	2023-03-11 22:16:38.000000000 +0000
29
+++ tools/buildsteps/windows/patches/0001-ffmpeg-windows-configure-detect-openssl.patch	2023-03-16 21:56:20.716741000 +0000
30
@@ -11,7 +11,7 @@
31
 index d7a3f507e8..4b85e881b1 100755
32
 --- a/configure
33
 +++ b/configure
34
-@@ -6530,6 +6530,8 @@ enabled openssl           && { check_pkg_config openssl openssl openssl/ssl.h OP
35
+@@ -6728,6 +6728,8 @@ enabled openssl           && { check_pkg_config openssl openssl openssl/ssl.h OP
36
                                 check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
37
                                 check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
38
                                 check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
39
diff -urN tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch.orig tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch
40
--- tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch.orig	2023-03-11 22:16:38.000000000 +0000
41
+++ tools/buildsteps/windows/patches/0002-ffmpeg-windows-configure-fix-zlib-conflict.patch	2023-03-16 21:56:20.716863000 +0000
42
@@ -11,16 +11,16 @@
43
 index 4b85e881b1..da457705d1 100755
44
 --- a/configure
45
 +++ b/configure
46
-@@ -7627,6 +7627,9 @@ print_config CONFIG_ "$config_files" $CONFIG_LIST       \
47
+@@ -7825,6 +7825,9 @@ print_config CONFIG_ "$config_files" $CONFIG_LIST       \
48
+ print_config CONFIG_ "$config_files" $CONFIG_LIST       \
49
                                       $CONFIG_EXTRA      \
50
-                                      $ALL_COMPONENTS    \
51
  
52
 +echo "#if defined(HAVE_UNISTD_H) && HAVE_UNISTD_H == 0" >> $TMPH
53
 +echo "#undef HAVE_UNISTD_H" >> $TMPH
54
 +echo "#endif" >> $TMPH
55
  echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
56
- echo "endif # FFMPEG_CONFIG_MAK" >> ffbuild/config.mak
57
  
58
+ # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
59
 -- 
60
 2.29.2
61
 
62
diff -urN tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch.orig tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch
63
--- tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch.orig	2023-03-11 22:16:38.000000000 +0000
64
+++ tools/buildsteps/windows/patches/0003-ffmpeg-windows-configure-allow-building-static.patch	2023-03-16 21:56:20.716987000 +0000
65
@@ -11,7 +11,7 @@
66
 index da457705d1..e3a8f45ff4 100755
67
 --- a/configure
68
 +++ b/configure
69
-@@ -5440,6 +5440,8 @@ case $target_os in
70
+@@ -5566,6 +5566,8 @@ case $target_os in
71
          enabled shared && ! enabled small && test_cmd $windres --version && enable gnu_windres
72
          enabled x86_32 && check_ldflags -Wl,--large-address-aware
73
          shlibdir_default="$bindir_default"
74
@@ -20,7 +20,7 @@
75
          SLIBPREF=""
76
          SLIBSUF=".dll"
77
          SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
78
-@@ -5489,6 +5491,8 @@ case $target_os in
79
+@@ -5615,6 +5617,8 @@ case $target_os in
80
          fi
81
          enabled x86_32 && check_ldflags -LARGEADDRESSAWARE
82
          shlibdir_default="$bindir_default"
83
diff -urN tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch.orig tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch
84
--- tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch.orig	2023-03-11 22:16:38.000000000 +0000
85
+++ tools/buildsteps/windows/patches/0004-ffmpeg-windows-configure-detect-libdav1d.patch	2023-03-16 21:56:20.717110000 +0000
86
@@ -11,7 +11,7 @@
87
 index e3a8f45ff4..983d7e1078 100755
88
 --- a/configure
89
 +++ b/configure
90
-@@ -6358,7 +6358,7 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
91
+@@ -6541,7 +6541,7 @@ enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
92
                                 die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
93
  enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
94
  enabled libcodec2         && require libcodec2 codec2/codec2.h codec2_create -lcodec2
95
diff -urN tools/depends/target/ffmpeg/CMakeLists.txt.orig tools/depends/target/ffmpeg/CMakeLists.txt
96
--- tools/depends/target/ffmpeg/CMakeLists.txt.orig	2023-03-11 22:16:38.000000000 +0000
97
+++ tools/depends/target/ffmpeg/CMakeLists.txt	2023-03-16 21:56:20.716595000 +0000
98
@@ -92,6 +92,7 @@
99
 elseif(CORE_SYSTEM_NAME STREQUAL darwin_embedded)
100
   list(APPEND ffmpeg_conf --disable-crystalhd
101
                           --enable-videotoolbox
102
+                          --disable-filter=yadif_videotoolbox
103
                           --target-os=darwin
104
               )
105
 elseif(CORE_SYSTEM_NAME STREQUAL osx)
106
diff -urN tools/depends/target/ffmpeg/FFMPEG-VERSION.orig tools/depends/target/ffmpeg/FFMPEG-VERSION
107
--- tools/depends/target/ffmpeg/FFMPEG-VERSION.orig	2023-03-11 22:16:38.000000000 +0000
108
+++ tools/depends/target/ffmpeg/FFMPEG-VERSION	2023-03-16 22:05:45.344450000 +0000
109
@@ -1,5 +1,5 @@
110
 LIBNAME=ffmpeg
111
-BASE_URL=https://github.com/xbmc/FFmpeg
112
-VERSION=4.4.1-Nexus-Alpha1
113
+VERSION=6.0
114
 ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz
115
-SHA512=8beb04d577b5251e74b0d52f4d130997a8ba94bbd488c7c8309e6b45095c27807e150212888ce3a384b23dff52f8df1a7bde5407bae924ddc363f8125c0616c5
116
+SHA512=b3214328f2792364353f38c6b46a71d4970c071d8656b20780abf0e02950167d0933eae825c09102cf8fb19fc679ac444bf1f41a448b624eaa5ea6b0f0bdf4f5
117
+
118
diff -urN xbmc/cdrip/EncoderFFmpeg.cpp.orig xbmc/cdrip/EncoderFFmpeg.cpp
119
--- xbmc/cdrip/EncoderFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
120
+++ xbmc/cdrip/EncoderFFmpeg.cpp	2023-03-16 21:56:20.710403000 +0000
121
@@ -11,6 +11,7 @@
122
 #include "ServiceBroker.h"
123
 #include "addons/Addon.h"
124
 #include "addons/AddonManager.h"
125
+#include "cores/FFmpeg.h"
126
 #include "settings/Settings.h"
127
 #include "settings/SettingsComponent.h"
128
 #include "utils/StringUtils.h"
129
@@ -19,24 +20,9 @@
130
 #include "utils/log.h"
131
 
132
 using namespace KODI::CDRIP;
133
+using FFMPEG_HELP_TOOLS::FFMpegErrorToString;
134
+using FFMPEG_HELP_TOOLS::FFMpegException;
135
 
136
-namespace
137
-{
138
-
139
-struct EncoderException : public std::exception
140
-{
141
-  std::string s;
142
-  template<typename... Args>
143
-  EncoderException(const std::string& fmt, Args&&... args)
144
-    : s(StringUtils::Format(fmt, std::forward<Args>(args)...))
145
-  {
146
-  }
147
-  ~EncoderException() throw() {} // Updated
148
-  const char* what() const throw() { return s.c_str(); }
149
-};
150
-
151
-} /* namespace */
152
-
153
 bool CEncoderFFmpeg::Init()
154
 {
155
   try
156
@@ -54,7 +40,7 @@
157
     }
158
     else
159
     {
160
-      throw EncoderException("Could not get add-on: {}", addonId);
161
+      throw FFMpegException("Could not get add-on: {}", addonId);
162
     }
163
 
164
     // Hack fix about PTS on generated files.
165
@@ -66,50 +52,50 @@
166
     else if (addonId == "audioencoder.kodi.builtin.wma")
167
       m_samplesCountMultiply = 1000;
168
     else
169
-      throw EncoderException("Internal add-on id \"{}\" not known as usable", addonId);
170
+      throw FFMpegException("Internal add-on id \"{}\" not known as usable", addonId);
171
 
172
     const std::string filename = URIUtils::GetFileName(m_strFile);
173
 
174
     m_formatCtx = avformat_alloc_context();
175
     if (!m_formatCtx)
176
-      throw EncoderException("Could not allocate output format context");
177
+      throw FFMpegException("Could not allocate output format context");
178
 
179
     m_bcBuffer = static_cast<uint8_t*>(av_malloc(BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE));
180
     if (!m_bcBuffer)
181
-      throw EncoderException("Could not allocate buffer");
182
+      throw FFMpegException("Could not allocate buffer");
183
 
184
     m_formatCtx->pb = avio_alloc_context(m_bcBuffer, BUFFER_SIZE, AVIO_FLAG_WRITE, this, nullptr,
185
                                          avio_write_callback, avio_seek_callback);
186
     if (!m_formatCtx->pb)
187
-      throw EncoderException("Failed to allocate ByteIOContext");
188
+      throw FFMpegException("Failed to allocate ByteIOContext");
189
 
190
     /* Guess the desired container format based on the file extension. */
191
     m_formatCtx->oformat = av_guess_format(nullptr, filename.c_str(), nullptr);
192
     if (!m_formatCtx->oformat)
193
-      throw EncoderException("Could not find output file format");
194
+      throw FFMpegException("Could not find output file format");
195
 
196
     m_formatCtx->url = av_strdup(filename.c_str());
197
     if (!m_formatCtx->url)
198
-      throw EncoderException("Could not allocate url");
199
+      throw FFMpegException("Could not allocate url");
200
 
201
     /* Find the encoder to be used by its name. */
202
-    AVCodec* codec = avcodec_find_encoder(m_formatCtx->oformat->audio_codec);
203
+    const AVCodec* codec = avcodec_find_encoder(m_formatCtx->oformat->audio_codec);
204
     if (!codec)
205
-      throw EncoderException("Unable to find a suitable FFmpeg encoder");
206
+      throw FFMpegException("Unable to find a suitable FFmpeg encoder");
207
 
208
     /* Create a new audio stream in the output file container. */
209
     m_stream = avformat_new_stream(m_formatCtx, nullptr);
210
     if (!m_stream)
211
-      throw EncoderException("Failed to allocate AVStream context");
212
+      throw FFMpegException("Failed to allocate AVStream context");
213
 
214
     m_codecCtx = avcodec_alloc_context3(codec);
215
     if (!m_codecCtx)
216
-      throw EncoderException("Failed to allocate the encoder context");
217
+      throw FFMpegException("Failed to allocate the encoder context");
218
 
219
     /* Set the basic encoder parameters.
220
      * The input file's sample rate is used to avoid a sample rate conversion. */
221
-    m_codecCtx->channels = m_iInChannels;
222
-    m_codecCtx->channel_layout = av_get_default_channel_layout(m_iInChannels);
223
+    av_channel_layout_uninit(&m_codecCtx->ch_layout);
224
+    av_channel_layout_default(&m_codecCtx->ch_layout, m_iInChannels);
225
     m_codecCtx->sample_rate = m_iInSampleRate;
226
     m_codecCtx->sample_fmt = codec->sample_fmts[0];
227
     m_codecCtx->bit_rate = bitrate;
228
@@ -128,14 +114,14 @@
229
 
230
     int err = avcodec_open2(m_codecCtx, codec, nullptr);
231
     if (err < 0)
232
-      throw EncoderException("Failed to open the codec {} (error '{}')",
233
-                             codec->long_name ? codec->long_name : codec->name,
234
-                             FFmpegErrorToString(err));
235
+      throw FFMpegException("Failed to open the codec {} (error '{}')",
236
+                            codec->long_name ? codec->long_name : codec->name,
237
+                            FFMpegErrorToString(err));
238
 
239
     err = avcodec_parameters_from_context(m_stream->codecpar, m_codecCtx);
240
     if (err < 0)
241
-      throw EncoderException("Failed to copy encoder parameters to output stream (error '{}')",
242
-                             FFmpegErrorToString(err));
243
+      throw FFMpegException("Failed to copy encoder parameters to output stream (error '{}')",
244
+                            FFMpegErrorToString(err));
245
 
246
     m_inFormat = GetInputFormat(m_iInBitsPerSample);
247
     m_outFormat = m_codecCtx->sample_fmt;
248
@@ -150,44 +136,48 @@
249
 
250
     m_bufferFrame = av_frame_alloc();
251
     if (!m_bufferFrame || !m_buffer)
252
-      throw EncoderException("Failed to allocate necessary buffers");
253
+      throw FFMpegException("Failed to allocate necessary buffers");
254
 
255
     m_bufferFrame->nb_samples = m_codecCtx->frame_size;
256
     m_bufferFrame->format = m_inFormat;
257
-    m_bufferFrame->channel_layout = m_codecCtx->channel_layout;
258
+
259
+    av_channel_layout_uninit(&m_bufferFrame->ch_layout);
260
+    av_channel_layout_copy(&m_bufferFrame->ch_layout, &m_codecCtx->ch_layout);
261
+
262
     m_bufferFrame->sample_rate = m_codecCtx->sample_rate;
263
 
264
     err = av_frame_get_buffer(m_bufferFrame, 0);
265
     if (err < 0)
266
-      throw EncoderException("Could not allocate output frame samples (error '{}')",
267
-                             FFmpegErrorToString(err));
268
+      throw FFMpegException("Could not allocate output frame samples (error '{}')",
269
+                            FFMpegErrorToString(err));
270
 
271
     avcodec_fill_audio_frame(m_bufferFrame, m_iInChannels, m_inFormat, m_buffer, m_neededBytes, 0);
272
 
273
     if (m_needConversion)
274
     {
275
-      m_swrCtx = swr_alloc_set_opts(nullptr, m_codecCtx->channel_layout, m_outFormat,
276
-                                    m_codecCtx->sample_rate, m_codecCtx->channel_layout, m_inFormat,
277
+      int ret = swr_alloc_set_opts2(&m_swrCtx, &m_codecCtx->ch_layout, m_outFormat,
278
+                                    m_codecCtx->sample_rate, &m_codecCtx->ch_layout, m_inFormat,
279
                                     m_codecCtx->sample_rate, 0, nullptr);
280
-      if (!m_swrCtx || swr_init(m_swrCtx) < 0)
281
-        throw EncoderException("Failed to initialize the resampler");
282
+      if (ret || swr_init(m_swrCtx) < 0)
283
+        throw FFMpegException("Failed to initialize the resampler");
284
 
285
       m_resampledBufferSize =
286
           av_samples_get_buffer_size(nullptr, m_iInChannels, m_neededFrames, m_outFormat, 0);
287
       m_resampledBuffer = static_cast<uint8_t*>(av_malloc(m_resampledBufferSize));
288
       m_resampledFrame = av_frame_alloc();
289
       if (!m_resampledBuffer || !m_resampledFrame)
290
-        throw EncoderException("Failed to allocate a frame for resampling");
291
+        throw FFMpegException("Failed to allocate a frame for resampling");
292
 
293
       m_resampledFrame->nb_samples = m_neededFrames;
294
       m_resampledFrame->format = m_outFormat;
295
-      m_resampledFrame->channel_layout = m_codecCtx->channel_layout;
296
+      av_channel_layout_uninit(&m_resampledFrame->ch_layout);
297
+      av_channel_layout_copy(&m_resampledFrame->ch_layout, &m_codecCtx->ch_layout);
298
       m_resampledFrame->sample_rate = m_codecCtx->sample_rate;
299
 
300
       err = av_frame_get_buffer(m_resampledFrame, 0);
301
       if (err < 0)
302
-        throw EncoderException("Could not allocate output resample frame samples (error '{}')",
303
-                               FFmpegErrorToString(err));
304
+        throw FFMpegException("Could not allocate output resample frame samples (error '{}')",
305
+                              FFMpegErrorToString(err));
306
 
307
       avcodec_fill_audio_frame(m_resampledFrame, m_iInChannels, m_outFormat, m_resampledBuffer,
308
                                m_resampledBufferSize, 0);
309
@@ -204,7 +194,7 @@
310
     /* write the header */
311
     err = avformat_write_header(m_formatCtx, nullptr);
312
     if (err != 0)
313
-      throw EncoderException("Failed to write the header (error '{}')", FFmpegErrorToString(err));
314
+      throw FFMpegException("Failed to write the header (error '{}')", FFMpegErrorToString(err));
315
 
316
     CLog::Log(LOGDEBUG, "CEncoderFFmpeg::{} - Successfully initialized with muxer {} and codec {}",
317
               __func__,
318
@@ -212,16 +202,19 @@
319
                                               : m_formatCtx->oformat->name,
320
               codec->long_name ? codec->long_name : codec->name);
321
   }
322
-  catch (EncoderException& caught)
323
+  catch (const FFMpegException& caught)
324
   {
325
     CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what());
326
 
327
     av_freep(&m_buffer);
328
+    av_channel_layout_uninit(&m_bufferFrame->ch_layout);
329
     av_frame_free(&m_bufferFrame);
330
     swr_free(&m_swrCtx);
331
+    av_channel_layout_uninit(&m_resampledFrame->ch_layout);
332
     av_frame_free(&m_resampledFrame);
333
     av_freep(&m_resampledBuffer);
334
     av_free(m_bcBuffer);
335
+    av_channel_layout_uninit(&m_codecCtx->ch_layout);
336
     avcodec_free_context(&m_codecCtx);
337
     if (m_formatCtx)
338
     {
339
@@ -299,7 +292,7 @@
340
       if (swr_convert(m_swrCtx, m_resampledFrame->data, m_neededFrames,
341
                       const_cast<const uint8_t**>(m_bufferFrame->extended_data),
342
                       m_neededFrames) < 0)
343
-        throw EncoderException("Error resampling audio");
344
+        throw FFMpegException("Error resampling audio");
345
 
346
       frame = m_resampledFrame;
347
     }
348
@@ -316,8 +309,8 @@
349
     m_bufferSize = 0;
350
     err = avcodec_send_frame(m_codecCtx, frame);
351
     if (err < 0)
352
-      throw EncoderException("Error sending a frame for encoding (error '{}')", __func__,
353
-                             FFmpegErrorToString(err));
354
+      throw FFMpegException("Error sending a frame for encoding (error '{}')",
355
+                            FFMpegErrorToString(err));
356
 
357
     while (err >= 0)
358
     {
359
@@ -329,19 +322,18 @@
360
       }
361
       else if (err < 0)
362
       {
363
-        throw EncoderException("Error during encoding (error '{}')", __func__,
364
-                               FFmpegErrorToString(err));
365
+        throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err));
366
       }
367
 
368
       err = av_write_frame(m_formatCtx, pkt);
369
       if (err < 0)
370
-        throw EncoderException("Failed to write the frame data (error '{}')", __func__,
371
-                               FFmpegErrorToString(err));
372
+        throw FFMpegException("Failed to write the frame data (error '{}')",
373
+                              FFMpegErrorToString(err));
374
 
375
       av_packet_unref(pkt);
376
     }
377
   }
378
-  catch (EncoderException& caught)
379
+  catch (const FFMpegException& caught)
380
   {
381
     CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what());
382
   }
383
@@ -366,8 +358,10 @@
384
 
385
     /* Flush if needed */
386
     av_freep(&m_buffer);
387
+    av_channel_layout_uninit(&m_bufferFrame->ch_layout);
388
     av_frame_free(&m_bufferFrame);
389
     swr_free(&m_swrCtx);
390
+    av_channel_layout_uninit(&m_resampledFrame->ch_layout);
391
     av_frame_free(&m_resampledFrame);
392
     av_freep(&m_resampledBuffer);
393
     m_needConversion = false;
394
@@ -379,6 +373,7 @@
395
 
396
     /* cleanup */
397
     av_free(m_bcBuffer);
398
+    av_channel_layout_uninit(&m_codecCtx->ch_layout);
399
     avcodec_free_context(&m_codecCtx);
400
     av_freep(&m_formatCtx->pb);
401
     avformat_free_context(m_formatCtx);
402
@@ -400,14 +395,6 @@
403
     case 32:
404
       return AV_SAMPLE_FMT_S32;
405
     default:
406
-      throw EncoderException("Invalid input bits per sample");
407
+      throw FFMpegException("Invalid input bits per sample");
408
   }
409
-}
410
-
411
-std::string CEncoderFFmpeg::FFmpegErrorToString(int err)
412
-{
413
-  std::string text;
414
-  text.reserve(AV_ERROR_MAX_STRING_SIZE);
415
-  av_strerror(err, text.data(), AV_ERROR_MAX_STRING_SIZE);
416
-  return text;
417
 }
418
diff -urN xbmc/cdrip/EncoderFFmpeg.h.orig xbmc/cdrip/EncoderFFmpeg.h
419
--- xbmc/cdrip/EncoderFFmpeg.h.orig	2023-03-11 22:16:38.000000000 +0000
420
+++ xbmc/cdrip/EncoderFFmpeg.h	2023-03-16 21:56:20.696794000 +0000
421
@@ -39,7 +39,6 @@
422
   void SetTag(const std::string& tag, const std::string& value);
423
   bool WriteFrame();
424
   AVSampleFormat GetInputFormat(int inBitsPerSample);
425
-  std::string FFmpegErrorToString(int err);
426
 
427
   AVFormatContext* m_formatCtx{nullptr};
428
   AVCodecContext* m_codecCtx{nullptr};
429
diff -urN xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp.orig xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp
430
--- xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
431
+++ xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp	2023-03-16 21:56:20.710706000 +0000
432
@@ -10,14 +10,25 @@
433
 #define DTS_ENCODE_BITRATE 1411200
434
 
435
 #include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h"
436
-#include "cores/AudioEngine/Utils/AEUtil.h"
437
+
438
 #include "ServiceBroker.h"
439
-#include "utils/log.h"
440
+#include "cores/AudioEngine/Utils/AEUtil.h"
441
+#include "cores/FFmpeg.h"
442
 #include "settings/Settings.h"
443
 #include "settings/SettingsComponent.h"
444
-#include <string.h>
445
+#include "utils/log.h"
446
+
447
+extern "C"
448
+{
449
+#include <libavutil/channel_layout.h>
450
+}
451
+
452
 #include <cassert>
453
+#include <string.h>
454
 
455
+using FFMPEG_HELP_TOOLS::FFMpegErrorToString;
456
+using FFMPEG_HELP_TOOLS::FFMpegException;
457
+
458
 CAEEncoderFFmpeg::CAEEncoderFFmpeg() : m_CodecCtx(NULL), m_SwrCtx(NULL)
459
 {
460
 }
461
@@ -26,6 +37,7 @@
462
 {
463
   Reset();
464
   swr_free(&m_SwrCtx);
465
+  av_channel_layout_uninit(&m_CodecCtx->ch_layout);
466
   avcodec_free_context(&m_CodecCtx);
467
 }
468
 
469
@@ -81,7 +93,7 @@
470
 
471
   bool ac3 = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_AUDIOOUTPUT_AC3PASSTHROUGH);
472
 
473
-  AVCodec *codec = NULL;
474
+  const AVCodec* codec = nullptr;
475
 
476
   /* fallback to ac3 if we support it, we might not have DTS support */
477
   if (ac3)
478
@@ -102,7 +114,8 @@
479
 
480
   m_CodecCtx->bit_rate = m_BitRate;
481
   m_CodecCtx->sample_rate = format.m_sampleRate;
482
-  m_CodecCtx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK;
483
+  av_channel_layout_uninit(&m_CodecCtx->ch_layout);
484
+  av_channel_layout_from_mask(&m_CodecCtx->ch_layout, AV_CH_LAYOUT_5POINT1_BACK);
485
 
486
   /* select a suitable data format */
487
   if (codec->sample_fmts)
488
@@ -179,22 +192,28 @@
489
           LOGERROR,
490
           "CAEEncoderFFmpeg::Initialize - Unable to find a suitable data format for the codec ({})",
491
           m_CodecName);
492
+      av_channel_layout_uninit(&m_CodecCtx->ch_layout);
493
       avcodec_free_context(&m_CodecCtx);
494
       return false;
495
     }
496
   }
497
 
498
-  m_CodecCtx->channels = BuildChannelLayout(m_CodecCtx->channel_layout, m_Layout);
499
+  uint64_t mask = m_CodecCtx->ch_layout.u.mask;
500
+  av_channel_layout_uninit(&m_CodecCtx->ch_layout);
501
+  av_channel_layout_from_mask(&m_CodecCtx->ch_layout, mask);
502
+  m_CodecCtx->ch_layout.nb_channels = BuildChannelLayout(mask, m_Layout);
503
 
504
   /* open the codec */
505
   if (avcodec_open2(m_CodecCtx, codec, NULL))
506
   {
507
+    av_channel_layout_uninit(&m_CodecCtx->ch_layout);
508
     avcodec_free_context(&m_CodecCtx);
509
     return false;
510
   }
511
 
512
   format.m_frames = m_CodecCtx->frame_size;
513
-  format.m_frameSize = m_CodecCtx->channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3);
514
+  int channels = m_CodecCtx->ch_layout.nb_channels;
515
+  format.m_frameSize = channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3);
516
   format.m_channelLayout = m_Layout;
517
 
518
   m_CurrentFormat = format;
519
@@ -204,14 +223,14 @@
520
 
521
   if (m_NeedConversion)
522
   {
523
-    m_SwrCtx = swr_alloc_set_opts(NULL,
524
-                      m_CodecCtx->channel_layout, m_CodecCtx->sample_fmt, m_CodecCtx->sample_rate,
525
-                      m_CodecCtx->channel_layout, AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate,
526
-                      0, NULL);
527
-    if (!m_SwrCtx || swr_init(m_SwrCtx) < 0)
528
+    int ret = swr_alloc_set_opts2(&m_SwrCtx, &m_CodecCtx->ch_layout, m_CodecCtx->sample_fmt,
529
+                                  m_CodecCtx->sample_rate, &m_CodecCtx->ch_layout,
530
+                                  AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate, 0, NULL);
531
+    if (ret || swr_init(m_SwrCtx) < 0)
532
     {
533
       CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Initialize - Failed to initialise resampler.");
534
       swr_free(&m_SwrCtx);
535
+      av_channel_layout_uninit(&m_CodecCtx->ch_layout);
536
       avcodec_free_context(&m_CodecCtx);
537
       return false;
538
     }
539
@@ -242,62 +261,78 @@
540
 
541
 int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_size)
542
 {
543
-  int got_output;
544
-  AVFrame *frame;
545
+  int size = 0;
546
+  int err = AVERROR_UNKNOWN;
547
+  AVFrame* frame = nullptr;
548
+  AVPacket* pkt = nullptr;
549
 
550
   if (!m_CodecCtx)
551
-    return 0;
552
+    return size;
553
 
554
-  /* allocate the input frame
555
-   * sadly, we have to alloc/dealloc it everytime since we have no guarantee the
556
-   * data argument will be constant over iterated calls and the frame needs to
557
-   * setup pointers inside data */
558
-  frame = av_frame_alloc();
559
-  if (!frame)
560
-    return 0;
561
+  try
562
+  {
563
+    /* allocate the input frame and output packet
564
+     * sadly, we have to alloc/dealloc it everytime since we have no guarantee the
565
+     * data argument will be constant over iterated calls and the frame needs to
566
+     * setup pointers inside data */
567
+    frame = av_frame_alloc();
568
+    pkt = av_packet_alloc();
569
+    if (!frame || !pkt)
570
+      throw FFMpegException(
571
+          "Failed to allocate \"AVFrame\" or \"AVPacket\" for encoding (error '{}')",
572
+          strerror(errno));
573
 
574
-  frame->nb_samples = m_CodecCtx->frame_size;
575
-  frame->format = m_CodecCtx->sample_fmt;
576
-  frame->channel_layout = m_CodecCtx->channel_layout;
577
-  frame->channels = m_CodecCtx->channels;
578
+    frame->nb_samples = m_CodecCtx->frame_size;
579
+    frame->format = m_CodecCtx->sample_fmt;
580
+    av_channel_layout_uninit(&frame->ch_layout);
581
+    av_channel_layout_copy(&frame->ch_layout, &m_CodecCtx->ch_layout);
582
+    int channelNum = m_CodecCtx->ch_layout.nb_channels;
583
 
584
-  avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt,
585
-                    in, in_size, 0);
586
+    avcodec_fill_audio_frame(frame, channelNum, m_CodecCtx->sample_fmt, in, in_size, 0);
587
 
588
-  /* initialize the output packet */
589
-  AVPacket* pkt = av_packet_alloc();
590
-  if (!pkt)
591
-  {
592
-    CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - av_packet_alloc failed: {}", __FUNCTION__,
593
-              strerror(errno));
594
-    av_frame_free(&frame);
595
-    return 0;
596
-  }
597
+    pkt->size = out_size;
598
+    pkt->data = out;
599
 
600
-  pkt->size = out_size;
601
-  pkt->data = out;
602
+    /* encode it */
603
+    err = avcodec_send_frame(m_CodecCtx, frame);
604
+    if (err < 0)
605
+      throw FFMpegException("Error sending a frame for encoding (error '{}')",
606
+                            FFMpegErrorToString(err));
607
 
608
-  /* encode it */
609
-  int ret = avcodec_encode_audio2(m_CodecCtx, pkt, frame, &got_output);
610
+    while (err >= 0)
611
+    {
612
+      err = avcodec_receive_packet(m_CodecCtx, pkt);
613
+      if (err == AVERROR(EAGAIN) || err == AVERROR_EOF)
614
+      {
615
+        av_channel_layout_uninit(&frame->ch_layout);
616
+        av_frame_free(&frame);
617
+        av_packet_free(&pkt);
618
+        return (err == AVERROR(EAGAIN)) ? -1 : 0;
619
+      }
620
+      else if (err < 0)
621
+      {
622
+        throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err));
623
+      }
624
 
625
-  int size = pkt->size;
626
+      av_packet_unref(pkt);
627
+    }
628
 
629
+    size = pkt->size;
630
+  }
631
+  catch (const FFMpegException& caught)
632
+  {
633
+    CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - {}", __func__, caught.what());
634
+  }
635
+
636
   /* free temporary data */
637
   av_frame_free(&frame);
638
 
639
   /* free the packet */
640
   av_packet_free(&pkt);
641
 
642
-  if (ret < 0 || !got_output)
643
-  {
644
-    CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Encode - Encoding failed");
645
-    return 0;
646
-  }
647
-
648
   /* return the number of frames used */
649
   return size;
650
 }
651
-
652
 
653
 int CAEEncoderFFmpeg::GetData(uint8_t **data)
654
 {
655
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
656
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp.orig	2023-03-11 22:16:38.000000000 +0000
657
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp	2023-03-16 21:56:20.711552000 +0000
658
@@ -16,17 +16,16 @@
659
 #include "ActiveAESound.h"
660
 #include "ActiveAEStream.h"
661
 #include "ServiceBroker.h"
662
+#include "cores/AudioEngine/AEResampleFactory.h"
663
+#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h"
664
 #include "cores/AudioEngine/Interfaces/IAudioCallback.h"
665
-#include "cores/AudioEngine/Utils/AEUtil.h"
666
 #include "cores/AudioEngine/Utils/AEStreamData.h"
667
 #include "cores/AudioEngine/Utils/AEStreamInfo.h"
668
-#include "cores/AudioEngine/AEResampleFactory.h"
669
-#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h"
670
-
671
+#include "cores/AudioEngine/Utils/AEUtil.h"
672
 #include "settings/Settings.h"
673
 #include "settings/SettingsComponent.h"
674
-#include "windowing/WinSystem.h"
675
 #include "utils/log.h"
676
+#include "windowing/WinSystem.h"
677
 
678
 using namespace std::chrono_literals;
679
 
680
@@ -3043,8 +3042,8 @@
681
   AVFormatContext *fmt_ctx = nullptr;
682
   AVCodecContext *dec_ctx = nullptr;
683
   AVIOContext *io_ctx;
684
-  AVInputFormat *io_fmt = nullptr;
685
-  AVCodec *dec = nullptr;
686
+  const AVInputFormat* io_fmt = nullptr;
687
+  const AVCodec* dec = nullptr;
688
   SampleConfig config;
689
 
690
   // No custom deleter until sound is registered
691
@@ -3096,8 +3095,8 @@
692
       AVCodecID codecId = fmt_ctx->streams[0]->codecpar->codec_id;
693
       dec = avcodec_find_decoder(codecId);
694
       config.sample_rate = fmt_ctx->streams[0]->codecpar->sample_rate;
695
-      config.channels = fmt_ctx->streams[0]->codecpar->channels;
696
-      config.channel_layout = fmt_ctx->streams[0]->codecpar->channel_layout;
697
+      config.channels = fmt_ctx->streams[0]->codecpar->ch_layout.nb_channels;
698
+      config.channel_layout = fmt_ctx->streams[0]->codecpar->ch_layout.u.mask;
699
     }
700
   }
701
   if (dec == nullptr)
702
@@ -3113,10 +3112,14 @@
703
 
704
   dec_ctx = avcodec_alloc_context3(dec);
705
   dec_ctx->sample_rate = config.sample_rate;
706
-  dec_ctx->channels = config.channels;
707
+  AVChannelLayout layout = {};
708
   if (!config.channel_layout)
709
-    config.channel_layout = av_get_default_channel_layout(config.channels);
710
-  dec_ctx->channel_layout = config.channel_layout;
711
+    av_channel_layout_default(&layout, config.channels);
712
+  else
713
+    av_channel_layout_from_mask(&layout, config.channel_layout);
714
+  config.channel_layout = layout.u.mask;
715
+  av_channel_layout_copy(&dec_ctx->ch_layout, &layout);
716
+  av_channel_layout_uninit(&layout);
717
 
718
   AVPacket* avpkt = av_packet_alloc();
719
   if (!avpkt)
720
@@ -3183,6 +3186,7 @@
721
 
722
   av_packet_free(&avpkt);
723
   av_frame_free(&decoded_frame);
724
+  av_channel_layout_uninit(&dec_ctx->ch_layout);
725
   avcodec_free_context(&dec_ctx);
726
   avformat_close_input(&fmt_ctx);
727
   if (io_ctx)
728
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp
729
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp.orig	2023-03-11 22:16:38.000000000 +0000
730
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp	2023-03-16 21:56:20.711812000 +0000
731
@@ -12,8 +12,8 @@
732
 #include <algorithm>
733
 
734
 extern "C" {
735
-#include <libavfilter/avfilter.h>
736
 #include <libavcodec/avcodec.h>
737
+#include <libavfilter/avfilter.h>
738
 #include <libavfilter/buffersink.h>
739
 #include <libavfilter/buffersrc.h>
740
 #include <libswresample/swresample.h>
741
@@ -171,7 +171,10 @@
742
   }
743
 
744
   if (m_pOutFrame)
745
+  {
746
+    av_channel_layout_uninit(&m_pOutFrame->ch_layout);
747
     av_frame_free(&m_pOutFrame);
748
+  }
749
 
750
   if (m_pConvertFrame)
751
     av_frame_free(&m_pConvertFrame);
752
@@ -205,10 +208,9 @@
753
     if (!frame)
754
       return -1;
755
 
756
-    int channels = av_get_channel_layout_nb_channels(m_channelLayout);
757
-
758
-    frame->channel_layout = m_channelLayout;
759
-    frame->channels = channels;
760
+    av_channel_layout_uninit(&frame->ch_layout);
761
+    av_channel_layout_from_mask(&frame->ch_layout, m_channelLayout);
762
+    int channels = frame->ch_layout.nb_channels;
763
     frame->sample_rate = m_sampleRate;
764
     frame->nb_samples = src_samples;
765
     frame->format = m_sampleFormat;
766
@@ -224,6 +226,7 @@
767
                              src_buffer[0], src_bufsize, 16);
768
     if (result < 0)
769
     {
770
+      av_channel_layout_uninit(&frame->ch_layout);
771
       av_frame_free(&frame);
772
       CLog::Log(LOGERROR, "CActiveAEFilter::ProcessFilter - avcodec_fill_audio_frame failed");
773
       m_filterEof = true;
774
@@ -231,6 +234,7 @@
775
     }
776
 
777
     result = av_buffersrc_write_frame(m_pFilterCtxIn, frame);
778
+    av_channel_layout_uninit(&frame->ch_layout);
779
     av_frame_free(&frame);
780
     if (result < 0)
781
     {
782
@@ -284,7 +288,8 @@
783
     {
784
       av_frame_unref(m_pOutFrame);
785
       m_pOutFrame->format = m_sampleFormat;
786
-      m_pOutFrame->channel_layout = m_channelLayout;
787
+      av_channel_layout_uninit(&m_pOutFrame->ch_layout);
788
+      av_channel_layout_from_mask(&m_pOutFrame->ch_layout, m_channelLayout);
789
       m_pOutFrame->sample_rate = m_sampleRate;
790
       result = swr_convert_frame(m_pConvertCtx, m_pOutFrame, m_pConvertFrame);
791
       av_frame_unref(m_pConvertFrame);
792
@@ -302,7 +307,10 @@
793
 
794
   if (m_hasData)
795
   {
796
-    int channels = av_get_channel_layout_nb_channels(m_channelLayout);
797
+    AVChannelLayout layout = {};
798
+    av_channel_layout_from_mask(&layout, m_channelLayout);
799
+    int channels = layout.nb_channels;
800
+    av_channel_layout_uninit(&layout);
801
     int planes = av_sample_fmt_is_planar(m_sampleFormat) ? channels : 1;
802
     int samples = std::min(dst_samples, m_pOutFrame->nb_samples - m_sampleOffset);
803
     int bytes = samples * av_get_bytes_per_sample(m_sampleFormat) * channels / planes;
804
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
805
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp.orig	2023-03-11 22:16:38.000000000 +0000
806
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp	2023-03-16 21:56:20.712034000 +0000
807
@@ -49,15 +49,30 @@
808
     m_doesResample = true;
809
 
810
   if (m_dst_chan_layout == 0)
811
-    m_dst_chan_layout = av_get_default_channel_layout(m_dst_channels);
812
+  {
813
+    AVChannelLayout layout = {};
814
+    av_channel_layout_default(&layout, m_dst_channels);
815
+    m_dst_chan_layout = layout.u.mask;
816
+    av_channel_layout_uninit(&layout);
817
+  }
818
   if (m_src_chan_layout == 0)
819
-    m_src_chan_layout = av_get_default_channel_layout(m_src_channels);
820
+  {
821
+    AVChannelLayout layout = {};
822
+    av_channel_layout_default(&layout, m_src_channels);
823
+    m_src_chan_layout = layout.u.mask;
824
+    av_channel_layout_uninit(&layout);
825
+  }
826
 
827
-  m_pContext = swr_alloc_set_opts(NULL, m_dst_chan_layout, m_dst_fmt, m_dst_rate,
828
-                                                        m_src_chan_layout, m_src_fmt, m_src_rate,
829
-                                                        0, NULL);
830
+  AVChannelLayout dstChLayout = {};
831
+  AVChannelLayout srcChLayout = {};
832
 
833
-  if (!m_pContext)
834
+  av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
835
+  av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout);
836
+
837
+  int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt, m_dst_rate, &srcChLayout,
838
+                                m_src_fmt, m_src_rate, 0, NULL);
839
+
840
+  if (ret)
841
   {
842
     CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context failed");
843
     return false;
844
@@ -126,10 +141,12 @@
845
   else if (upmix && m_src_channels == 2 && m_dst_channels > 2)
846
   {
847
     memset(m_rematrix, 0, sizeof(m_rematrix));
848
+    av_channel_layout_uninit(&dstChLayout);
849
+    av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
850
     for (int out=0; out<m_dst_channels; out++)
851
     {
852
-      uint64_t out_chan = av_channel_layout_extract_channel(m_dst_chan_layout, out);
853
-      switch(out_chan)
854
+      AVChannel outChan = av_channel_layout_channel_from_index(&dstChLayout, out);
855
+      switch (outChan)
856
       {
857
         case AV_CH_FRONT_LEFT:
858
         case AV_CH_BACK_LEFT:
859
@@ -153,6 +170,8 @@
860
           break;
861
       }
862
     }
863
+
864
+    av_channel_layout_uninit(&dstChLayout);
865
 
866
     if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0)
867
     {
868
diff -urN xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp.orig xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp
869
--- xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp.orig	2023-03-11 22:16:38.000000000 +0000
870
+++ xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp	2023-03-16 21:56:20.705902000 +0000
871
@@ -88,7 +88,7 @@
872
   for(unsigned int i=0; i<m_format.m_channelLayout.Count(); i++)
873
   {
874
     avLast = avCur;
875
-    avCur = CAEUtil::GetAVChannel(m_format.m_channelLayout[i]);
876
+    avCur = CAEUtil::GetAVChannelMask(m_format.m_channelLayout[i]);
877
     if(avCur < avLast)
878
     {
879
       needRemap = true;
880
diff -urN xbmc/cores/AudioEngine/Utils/AEUtil.cpp.orig xbmc/cores/AudioEngine/Utils/AEUtil.cpp
881
--- xbmc/cores/AudioEngine/Utils/AEUtil.cpp.orig	2023-03-11 22:16:38.000000000 +0000
882
+++ xbmc/cores/AudioEngine/Utils/AEUtil.cpp	2023-03-16 21:56:20.712279000 +0000
883
@@ -19,10 +19,6 @@
884
 #include <xmmintrin.h>
885
 #endif
886
 
887
-extern "C" {
888
-#include <libavutil/channel_layout.h>
889
-}
890
-
891
 void AEDelayStatus::SetDelay(double d)
892
 {
893
   delay = d;
894
@@ -550,34 +546,64 @@
895
   }
896
 }
897
 
898
-uint64_t CAEUtil::GetAVChannel(enum AEChannel aechannel)
899
+uint64_t CAEUtil::GetAVChannelMask(enum AEChannel aechannel)
900
 {
901
+  enum AVChannel ch = GetAVChannel(aechannel);
902
+  if (ch == AV_CHAN_NONE)
903
+    return 0;
904
+  return (1ULL << ch);
905
+}
906
+
907
+enum AVChannel CAEUtil::GetAVChannel(enum AEChannel aechannel)
908
+{
909
   switch (aechannel)
910
   {
911
-  case AE_CH_FL:   return AV_CH_FRONT_LEFT;
912
-  case AE_CH_FR:   return AV_CH_FRONT_RIGHT;
913
-  case AE_CH_FC:   return AV_CH_FRONT_CENTER;
914
-  case AE_CH_LFE:  return AV_CH_LOW_FREQUENCY;
915
-  case AE_CH_BL:   return AV_CH_BACK_LEFT;
916
-  case AE_CH_BR:   return AV_CH_BACK_RIGHT;
917
-  case AE_CH_FLOC: return AV_CH_FRONT_LEFT_OF_CENTER;
918
-  case AE_CH_FROC: return AV_CH_FRONT_RIGHT_OF_CENTER;
919
-  case AE_CH_BC:   return AV_CH_BACK_CENTER;
920
-  case AE_CH_SL:   return AV_CH_SIDE_LEFT;
921
-  case AE_CH_SR:   return AV_CH_SIDE_RIGHT;
922
-  case AE_CH_TC:   return AV_CH_TOP_CENTER;
923
-  case AE_CH_TFL:  return AV_CH_TOP_FRONT_LEFT;
924
-  case AE_CH_TFC:  return AV_CH_TOP_FRONT_CENTER;
925
-  case AE_CH_TFR:  return AV_CH_TOP_FRONT_RIGHT;
926
-  case AE_CH_TBL:  return AV_CH_TOP_BACK_LEFT;
927
-  case AE_CH_TBC:  return AV_CH_TOP_BACK_CENTER;
928
-  case AE_CH_TBR:  return AV_CH_TOP_BACK_RIGHT;
929
-  default:
930
-    return 0;
931
+    case AE_CH_FL:
932
+      return AV_CHAN_FRONT_LEFT;
933
+    case AE_CH_FR:
934
+      return AV_CHAN_FRONT_RIGHT;
935
+    case AE_CH_FC:
936
+      return AV_CHAN_FRONT_CENTER;
937
+    case AE_CH_LFE:
938
+      return AV_CHAN_LOW_FREQUENCY;
939
+    case AE_CH_BL:
940
+      return AV_CHAN_BACK_LEFT;
941
+    case AE_CH_BR:
942
+      return AV_CHAN_BACK_RIGHT;
943
+    case AE_CH_FLOC:
944
+      return AV_CHAN_FRONT_LEFT_OF_CENTER;
945
+    case AE_CH_FROC:
946
+      return AV_CHAN_FRONT_RIGHT_OF_CENTER;
947
+    case AE_CH_BC:
948
+      return AV_CHAN_BACK_CENTER;
949
+    case AE_CH_SL:
950
+      return AV_CHAN_SIDE_LEFT;
951
+    case AE_CH_SR:
952
+      return AV_CHAN_SIDE_RIGHT;
953
+    case AE_CH_TC:
954
+      return AV_CHAN_TOP_CENTER;
955
+    case AE_CH_TFL:
956
+      return AV_CHAN_TOP_FRONT_LEFT;
957
+    case AE_CH_TFC:
958
+      return AV_CHAN_TOP_FRONT_CENTER;
959
+    case AE_CH_TFR:
960
+      return AV_CHAN_TOP_FRONT_RIGHT;
961
+    case AE_CH_TBL:
962
+      return AV_CHAN_TOP_BACK_LEFT;
963
+    case AE_CH_TBC:
964
+      return AV_CHAN_TOP_BACK_CENTER;
965
+    case AE_CH_TBR:
966
+      return AV_CHAN_TOP_BACK_RIGHT;
967
+    default:
968
+      return AV_CHAN_NONE;
969
   }
970
 }
971
 
972
 int CAEUtil::GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout)
973
 {
974
-  return av_get_channel_layout_channel_index(layout, GetAVChannel(aechannel));
975
+  AVChannelLayout ch_layout = {};
976
+  av_channel_layout_from_mask(&ch_layout, layout);
977
+  int idx = av_channel_layout_index_from_channel(&ch_layout, GetAVChannel(aechannel));
978
+  av_channel_layout_uninit(&ch_layout);
979
+  return idx;
980
 }
981
diff -urN xbmc/cores/AudioEngine/Utils/AEUtil.h.orig xbmc/cores/AudioEngine/Utils/AEUtil.h
982
--- xbmc/cores/AudioEngine/Utils/AEUtil.h.orig	2023-03-11 22:16:38.000000000 +0000
983
+++ xbmc/cores/AudioEngine/Utils/AEUtil.h	2023-03-16 21:56:20.712441000 +0000
984
@@ -13,6 +13,7 @@
985
 #include <math.h>
986
 
987
 extern "C" {
988
+#include <libavutil/channel_layout.h>
989
 #include <libavutil/samplefmt.h>
990
 }
991
 
992
@@ -171,6 +172,7 @@
993
   static uint64_t GetAVChannelLayout(const CAEChannelInfo &info);
994
   static CAEChannelInfo GetAEChannelLayout(uint64_t layout);
995
   static AVSampleFormat GetAVSampleFormat(AEDataFormat format);
996
-  static uint64_t GetAVChannel(enum AEChannel aechannel);
997
+  static uint64_t GetAVChannelMask(enum AEChannel aechannel);
998
+  static enum AVChannel GetAVChannel(enum AEChannel aechannel);
999
   static int GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout);
1000
 };
1001
diff -urN xbmc/cores/FFmpeg.cpp.orig xbmc/cores/FFmpeg.cpp
1002
--- xbmc/cores/FFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1003
+++ xbmc/cores/FFmpeg.cpp	2023-03-16 21:56:20.712628000 +0000
1004
@@ -16,11 +16,29 @@
1005
 #include "utils/StringUtils.h"
1006
 #include "utils/log.h"
1007
 
1008
+extern "C"
1009
+{
1010
+#include <libavcodec/bsf.h>
1011
+}
1012
+
1013
 #include <map>
1014
 #include <mutex>
1015
 
1016
 static thread_local CFFmpegLog* CFFmpegLogTls;
1017
 
1018
+namespace FFMPEG_HELP_TOOLS
1019
+{
1020
+
1021
+std::string FFMpegErrorToString(int err)
1022
+{
1023
+  std::string text;
1024
+  text.resize(AV_ERROR_MAX_STRING_SIZE);
1025
+  av_strerror(err, text.data(), AV_ERROR_MAX_STRING_SIZE);
1026
+  return text;
1027
+}
1028
+
1029
+} // namespace FFMPEG_HELP_TOOLS
1030
+
1031
 void CFFmpegLog::SetLogLevel(int level)
1032
 {
1033
   CFFmpegLog::ClearLogLevel();
1034
@@ -117,3 +135,128 @@
1035
   buffer.erase(0, start);
1036
 }
1037
 
1038
+std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt,
1039
+                                             const AVCodecParserContext* parserCtx,
1040
+                                             AVCodecContext* codecCtx)
1041
+{
1042
+  constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE);
1043
+
1044
+  if (!pkt)
1045
+    return std::make_tuple(nullptr, 0);
1046
+
1047
+  uint8_t* extraData = nullptr;
1048
+  int extraDataSize = 0;
1049
+
1050
+  /* extract_extradata bitstream filter is implemented only
1051
+   * for certain codecs, as noted in discussion of PR#21248
1052
+   */
1053
+
1054
+  AVCodecID codecId = codecCtx->codec_id;
1055
+
1056
+  // clang-format off
1057
+  if (
1058
+    codecId != AV_CODEC_ID_MPEG1VIDEO &&
1059
+    codecId != AV_CODEC_ID_MPEG2VIDEO &&
1060
+    codecId != AV_CODEC_ID_H264 &&
1061
+    codecId != AV_CODEC_ID_HEVC &&
1062
+    codecId != AV_CODEC_ID_MPEG4 &&
1063
+    codecId != AV_CODEC_ID_VC1 &&
1064
+    codecId != AV_CODEC_ID_AV1 &&
1065
+    codecId != AV_CODEC_ID_AVS2 &&
1066
+    codecId != AV_CODEC_ID_AVS3 &&
1067
+    codecId != AV_CODEC_ID_CAVS
1068
+  )
1069
+    // clang-format on
1070
+    return std::make_tuple(nullptr, 0);
1071
+
1072
+  const AVBitStreamFilter* f = av_bsf_get_by_name("extract_extradata");
1073
+  if (!f)
1074
+    return std::make_tuple(nullptr, 0);
1075
+
1076
+  AVBSFContext* bsf = nullptr;
1077
+  int ret = av_bsf_alloc(f, &bsf);
1078
+  if (ret < 0)
1079
+    return std::make_tuple(nullptr, 0);
1080
+
1081
+  bsf->par_in->codec_id = codecId;
1082
+
1083
+  ret = av_bsf_init(bsf);
1084
+  if (ret < 0)
1085
+  {
1086
+    av_bsf_free(&bsf);
1087
+    return std::make_tuple(nullptr, 0);
1088
+  }
1089
+
1090
+  AVPacket* dstPkt = av_packet_alloc();
1091
+  if (!dstPkt)
1092
+  {
1093
+    CLog::LogF(LOGERROR, "failed to allocate packet");
1094
+
1095
+    av_bsf_free(&bsf);
1096
+    return std::make_tuple(nullptr, 0);
1097
+  }
1098
+  AVPacket* pktRef = dstPkt;
1099
+
1100
+  ret = av_packet_ref(pktRef, pkt);
1101
+  if (ret < 0)
1102
+  {
1103
+    av_bsf_free(&bsf);
1104
+    av_packet_free(&dstPkt);
1105
+    return std::make_tuple(nullptr, 0);
1106
+  }
1107
+
1108
+  ret = av_bsf_send_packet(bsf, pktRef);
1109
+  if (ret < 0)
1110
+  {
1111
+    av_packet_unref(pktRef);
1112
+    av_bsf_free(&bsf);
1113
+    av_packet_free(&dstPkt);
1114
+    return std::make_tuple(nullptr, 0);
1115
+  }
1116
+
1117
+  ret = 0;
1118
+  while (ret >= 0)
1119
+  {
1120
+    ret = av_bsf_receive_packet(bsf, pktRef);
1121
+    if (ret < 0)
1122
+    {
1123
+      if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
1124
+        break;
1125
+
1126
+      continue;
1127
+    }
1128
+
1129
+    size_t retExtraDataSize = 0;
1130
+    uint8_t* retExtraData =
1131
+        av_packet_get_side_data(pktRef, AV_PKT_DATA_NEW_EXTRADATA, &retExtraDataSize);
1132
+    if (retExtraData && retExtraDataSize > 0 && retExtraDataSize < FF_MAX_EXTRADATA_SIZE)
1133
+    {
1134
+      extraData = static_cast<uint8_t*>(av_malloc(retExtraDataSize + AV_INPUT_BUFFER_PADDING_SIZE));
1135
+      if (!extraData)
1136
+      {
1137
+        CLog::LogF(LOGERROR, "failed to allocate {} bytes for extradata", retExtraDataSize);
1138
+
1139
+        av_packet_unref(pktRef);
1140
+        av_bsf_free(&bsf);
1141
+        av_packet_free(&dstPkt);
1142
+        return std::make_tuple(nullptr, 0);
1143
+      }
1144
+
1145
+      CLog::LogF(LOGDEBUG, "fetching extradata, extradata_size({})", retExtraDataSize);
1146
+
1147
+      memcpy(extraData, retExtraData, retExtraDataSize);
1148
+      memset(extraData + retExtraDataSize, 0, AV_INPUT_BUFFER_PADDING_SIZE);
1149
+      extraDataSize = retExtraDataSize;
1150
+
1151
+      av_packet_unref(pktRef);
1152
+      break;
1153
+    }
1154
+
1155
+    av_packet_unref(pktRef);
1156
+  }
1157
+
1158
+  av_bsf_free(&bsf);
1159
+  av_packet_free(&dstPkt);
1160
+
1161
+  return std::make_tuple(extraData, extraDataSize);
1162
+}
1163
diff -urN xbmc/cores/FFmpeg.h.orig xbmc/cores/FFmpeg.h
1164
--- xbmc/cores/FFmpeg.h.orig	2023-03-11 22:16:38.000000000 +0000
1165
+++ xbmc/cores/FFmpeg.h	2023-03-16 21:56:20.712753000 +0000
1166
@@ -10,6 +10,7 @@
1167
 
1168
 #include "ServiceBroker.h"
1169
 #include "utils/CPUInfo.h"
1170
+#include "utils/StringUtils.h"
1171
 
1172
 extern "C" {
1173
 #include <libavcodec/avcodec.h>
1174
@@ -21,6 +22,26 @@
1175
 #include <libpostproc/postprocess.h>
1176
 }
1177
 
1178
+#include <tuple>
1179
+
1180
+namespace FFMPEG_HELP_TOOLS
1181
+{
1182
+
1183
+struct FFMpegException : public std::exception
1184
+{
1185
+  std::string s;
1186
+  template<typename... Args>
1187
+  FFMpegException(const std::string& fmt, Args&&... args)
1188
+    : s(StringUtils::Format(fmt, std::forward<Args>(args)...))
1189
+  {
1190
+  }
1191
+  const char* what() const noexcept override { return s.c_str(); }
1192
+};
1193
+
1194
+std::string FFMpegErrorToString(int err);
1195
+
1196
+} // namespace FFMPEG_HELP_TOOLS
1197
+
1198
 inline int PPCPUFlags()
1199
 {
1200
   unsigned int cpuFeatures = CServiceBroker::GetCPUInfo()->GetCPUFeatures();
1201
@@ -51,3 +72,6 @@
1202
   int level;
1203
 };
1204
 
1205
+std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt,
1206
+                                             const AVCodecParserContext* parserCtx,
1207
+                                             AVCodecContext* codecCtx);
1208
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
1209
--- xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1210
+++ xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp	2023-03-16 21:56:53.273377000 +0000
1211
@@ -7,14 +7,16 @@
1212
  */
1213
 
1214
 #include "DVDAudioCodecFFmpeg.h"
1215
-#include "ServiceBroker.h"
1216
+
1217
 #include "../../DVDStreamInfo.h"
1218
-#include "utils/log.h"
1219
+#include "DVDCodecs/DVDCodecs.h"
1220
+#include "ServiceBroker.h"
1221
+#include "cores/AudioEngine/Utils/AEUtil.h"
1222
+#include "cores/FFmpeg.h"
1223
 #include "settings/AdvancedSettings.h"
1224
 #include "settings/Settings.h"
1225
 #include "settings/SettingsComponent.h"
1226
-#include "DVDCodecs/DVDCodecs.h"
1227
-#include "cores/AudioEngine/Utils/AEUtil.h"
1228
+#include "utils/log.h"
1229
 
1230
 extern "C" {
1231
 #include <libavutil/opt.h>
1232
@@ -44,7 +46,7 @@
1233
     return false;
1234
   }
1235
 
1236
-  AVCodec* pCodec = NULL;
1237
+  const AVCodec* pCodec = nullptr;
1238
   bool allowdtshddecode = true;
1239
 
1240
   // set any special options
1241
@@ -71,13 +73,28 @@
1242
   m_pCodecContext->debug = 0;
1243
   m_pCodecContext->workaround_bugs = 1;
1244
 
1245
+#if LIBAVCODEC_VERSION_MAJOR < 60
1246
   if (pCodec->capabilities & AV_CODEC_CAP_TRUNCATED)
1247
     m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
1248
+#endif
1249
 
1250
   m_matrixEncoding = AV_MATRIX_ENCODING_NONE;
1251
   m_channels = 0;
1252
-  m_pCodecContext->channels = hints.channels;
1253
-  m_hint_layout = hints.channellayout;
1254
+  av_channel_layout_uninit(&m_pCodecContext->ch_layout);
1255
+
1256
+  if (hints.channels > 0 && hints.channellayout > 0)
1257
+  {
1258
+    m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
1259
+    m_pCodecContext->ch_layout.nb_channels = hints.channels;
1260
+    m_pCodecContext->ch_layout.u.mask = hints.channellayout;
1261
+  }
1262
+  else if (hints.channels > 0)
1263
+  {
1264
+    av_channel_layout_default(&m_pCodecContext->ch_layout, hints.channels);
1265
+  }
1266
+
1267
+  m_hint_layout = m_pCodecContext->ch_layout.u.mask;
1268
+
1269
   m_pCodecContext->sample_rate = hints.samplerate;
1270
   m_pCodecContext->block_align = hints.blockalign;
1271
   m_pCodecContext->bit_rate = hints.bitrate;
1272
@@ -259,12 +276,13 @@
1273
     m_format.m_frameSize = m_format.m_channelLayout.Count() *
1274
                            CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3;
1275
 
1276
-    int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? m_pFrame->channels : 1;
1277
+    int channels = m_pFrame->ch_layout.nb_channels;
1278
+    int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? channels : 1;
1279
+
1280
     for (int i=0; i<planes; i++)
1281
       dst[i] = m_pFrame->extended_data[i];
1282
 
1283
-    return m_pFrame->nb_samples * m_pFrame->channels *
1284
-           av_get_bytes_per_sample(m_pCodecContext->sample_fmt);
1285
+    return m_pFrame->nb_samples * channels * av_get_bytes_per_sample(m_pCodecContext->sample_fmt);
1286
   }
1287
 
1288
   return 0;
1289
@@ -278,7 +296,7 @@
1290
 
1291
 int CDVDAudioCodecFFmpeg::GetChannels()
1292
 {
1293
-  return m_pCodecContext->channels;
1294
+  return m_pCodecContext->ch_layout.nb_channels;
1295
 }
1296
 
1297
 int CDVDAudioCodecFFmpeg::GetSampleRate()
1298
@@ -345,28 +363,33 @@
1299
 
1300
 void CDVDAudioCodecFFmpeg::BuildChannelMap()
1301
 {
1302
-  if (m_channels == m_pCodecContext->channels && m_layout == m_pCodecContext->channel_layout)
1303
+  int codecChannels = m_pCodecContext->ch_layout.nb_channels;
1304
+  uint64_t codecChannelLayout = m_pCodecContext->ch_layout.u.mask;
1305
+  if (m_channels == codecChannels && m_layout == codecChannelLayout)
1306
     return; //nothing to do here
1307
 
1308
-  m_channels = m_pCodecContext->channels;
1309
-  m_layout   = m_pCodecContext->channel_layout;
1310
+  m_channels = codecChannels;
1311
+  m_layout = codecChannelLayout;
1312
 
1313
   int64_t layout;
1314
 
1315
-  int bits = count_bits(m_pCodecContext->channel_layout);
1316
-  if (bits == m_pCodecContext->channels)
1317
-    layout = m_pCodecContext->channel_layout;
1318
+  int bits = count_bits(codecChannelLayout);
1319
+  if (bits == codecChannels)
1320
+    layout = codecChannelLayout;
1321
   else
1322
   {
1323
     CLog::Log(LOGINFO,
1324
               "CDVDAudioCodecFFmpeg::GetChannelMap - FFmpeg reported {} channels, but the layout "
1325
               "contains {} - trying hints",
1326
-              m_pCodecContext->channels, bits);
1327
-    if (static_cast<int>(count_bits(m_hint_layout)) == m_pCodecContext->channels)
1328
+              codecChannels, bits);
1329
+    if (static_cast<int>(count_bits(m_hint_layout)) == codecChannels)
1330
       layout = m_hint_layout;
1331
     else
1332
     {
1333
-      layout = av_get_default_channel_layout(m_pCodecContext->channels);
1334
+      AVChannelLayout def_layout = {};
1335
+      av_channel_layout_default(&def_layout, codecChannels);
1336
+      layout = def_layout.u.mask;
1337
+      av_channel_layout_uninit(&def_layout);
1338
       CLog::Log(LOGINFO, "Using default layout...");
1339
     }
1340
   }
1341
@@ -392,7 +415,7 @@
1342
   if (layout & AV_CH_TOP_BACK_CENTER      ) m_channelLayout += AE_CH_BC  ;
1343
   if (layout & AV_CH_TOP_BACK_RIGHT       ) m_channelLayout += AE_CH_BR  ;
1344
 
1345
-  m_channels = m_pCodecContext->channels;
1346
+  m_channels = codecChannels;
1347
 }
1348
 
1349
 CAEChannelInfo CDVDAudioCodecFFmpeg::GetChannelMap()
1350
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp
1351
--- xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1352
+++ xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp	2023-03-16 21:56:20.713197000 +0000
1353
@@ -10,6 +10,7 @@
1354
 
1355
 #include "DVDOverlayImage.h"
1356
 #include "DVDStreamInfo.h"
1357
+#include "cores/FFmpeg.h"
1358
 #include "cores/VideoPlayer/Interface/DemuxPacket.h"
1359
 #include "cores/VideoPlayer/Interface/TimingConstants.h"
1360
 #include "utils/EndianSwap.h"
1361
@@ -39,7 +40,7 @@
1362
   if (hints.codec == AV_CODEC_ID_EIA_608)
1363
     return false;
1364
 
1365
-  AVCodec* pCodec = avcodec_find_decoder(hints.codec);
1366
+  const AVCodec* pCodec = avcodec_find_decoder(hints.codec);
1367
   if (!pCodec)
1368
   {
1369
     CLog::Log(LOGDEBUG, "{} - Unable to find codec {}", __FUNCTION__, hints.codec);
1370
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
1371
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1372
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp	2023-03-16 21:56:53.273710000 +0000
1373
@@ -12,6 +12,7 @@
1374
 #include "DVDCodecs/DVDFactoryCodec.h"
1375
 #include "DVDStreamInfo.h"
1376
 #include "ServiceBroker.h"
1377
+#include "cores/FFmpeg.h"
1378
 #include "cores/VideoPlayer/Interface/TimingConstants.h"
1379
 #include "cores/VideoPlayer/VideoRenderers/RenderManager.h"
1380
 #include "cores/VideoSettings.h"
1381
@@ -27,12 +28,13 @@
1382
 #include <mutex>
1383
 
1384
 extern "C" {
1385
-#include <libavutil/opt.h>
1386
-#include <libavutil/mastering_display_metadata.h>
1387
 #include <libavfilter/avfilter.h>
1388
 #include <libavfilter/buffersink.h>
1389
 #include <libavfilter/buffersrc.h>
1390
+#include <libavutil/mastering_display_metadata.h>
1391
+#include <libavutil/opt.h>
1392
 #include <libavutil/pixdesc.h>
1393
+#include <libavutil/video_enc_params.h>
1394
 }
1395
 
1396
 #ifndef TARGET_POSIX
1397
@@ -327,7 +329,7 @@
1398
   m_hints = hints;
1399
   m_options = options;
1400
 
1401
-  AVCodec* pCodec = nullptr;
1402
+  const AVCodec* pCodec = nullptr;
1403
 
1404
   m_iOrientation = hints.orientation;
1405
 
1406
@@ -367,6 +369,7 @@
1407
   m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
1408
   m_pCodecContext->get_format = GetFormat;
1409
   m_pCodecContext->codec_tag = hints.codec_tag;
1410
+  m_pCodecContext->flags = AV_CODEC_FLAG_COPY_OPAQUE;
1411
 
1412
   // setup threading model
1413
   if (!(hints.codecOptions & CODEC_FORCE_SOFTWARE))
1414
@@ -543,19 +546,6 @@
1415
   CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: {}", m_name);
1416
 }
1417
 
1418
-union pts_union
1419
-{
1420
-  double  pts_d;
1421
-  int64_t pts_i;
1422
-};
1423
-
1424
-static int64_t pts_dtoi(double pts)
1425
-{
1426
-  pts_union u;
1427
-  u.pts_d = pts;
1428
-  return u.pts_i;
1429
-}
1430
-
1431
 bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet)
1432
 {
1433
   if (!m_pCodecContext)
1434
@@ -573,7 +563,6 @@
1435
     m_started = true;
1436
 
1437
   m_dts = packet.dts;
1438
-  m_pCodecContext->reordered_opaque = pts_dtoi(packet.pts);
1439
 
1440
   AVPacket* avpkt = av_packet_alloc();
1441
   if (!avpkt)
1442
@@ -1048,24 +1037,27 @@
1443
   pVideoPicture->qscale_type = 0;
1444
 
1445
   AVFrameSideData* sd;
1446
-  sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_QP_TABLE_PROPERTIES);
1447
+
1448
+  // https://github.com/FFmpeg/FFmpeg/blob/991d417692/doc/APIchanges#L18-L20
1449
+  sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_VIDEO_ENC_PARAMS);
1450
   if (sd)
1451
   {
1452
-    struct qp_properties
1453
-    {
1454
-      int stride;
1455
-      int type;
1456
-    };
1457
+    unsigned int mb_h = (m_pFrame->height + 15) / 16;
1458
+    unsigned int mb_w = (m_pFrame->width + 15) / 16;
1459
+    unsigned int nb_mb = mb_h * mb_w;
1460
+    unsigned int block_idx;
1461
 
1462
-    auto qp = reinterpret_cast<qp_properties*>(sd->data);
1463
-
1464
-    sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_QP_TABLE_DATA);
1465
-    if (sd && sd->buf && qp)
1466
+    auto par = reinterpret_cast<AVVideoEncParams*>(sd->data);
1467
+    if (par->type == AV_VIDEO_ENC_PARAMS_MPEG2 && (par->nb_blocks == 0 || par->nb_blocks == nb_mb))
1468
     {
1469
-      // this seems wrong but it's what ffmpeg does internally
1470
-      pVideoPicture->qp_table = reinterpret_cast<int8_t*>(sd->buf->data);
1471
-      pVideoPicture->qstride = qp->stride;
1472
-      pVideoPicture->qscale_type = qp->type;
1473
+      pVideoPicture->qstride = mb_w;
1474
+      pVideoPicture->qscale_type = par->type;
1475
+      pVideoPicture->qp_table = static_cast<int8_t*>(av_malloc(nb_mb));
1476
+      for (block_idx = 0; block_idx < nb_mb; block_idx++)
1477
+      {
1478
+        AVVideoBlockParams* b = av_video_enc_params_block(par, block_idx);
1479
+        pVideoPicture->qp_table[block_idx] = par->qp + b->delta_qp;
1480
+      }
1481
     }
1482
   }
1483
 
1484
@@ -1159,8 +1151,9 @@
1485
   const AVFilter* outFilter = avfilter_get_by_name("buffersink"); // should be last filter in the graph for now
1486
 
1487
   std::string args = StringUtils::Format(
1488
-      "{}:{}:{}:{}:{}:{}:{}", m_pCodecContext->width, m_pCodecContext->height,
1489
-      m_pCodecContext->pix_fmt, m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1,
1490
+      "video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", m_pCodecContext->width,
1491
+      m_pCodecContext->height, m_pCodecContext->pix_fmt,
1492
+      m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1,
1493
       m_pCodecContext->time_base.num ? m_pCodecContext->time_base.den : 1,
1494
       m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.num : 1,
1495
       m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.den : 1);
1496
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp
1497
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1498
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp	2023-03-16 21:56:20.713709000 +0000
1499
@@ -118,6 +118,8 @@
1500
                  m_pMode, m_pContext,
1501
                  pSource->pict_type | pSource->qscale_type ? PP_PICT_TYPE_QP2 : 0);
1502
 
1503
+  // https://github.com/FFmpeg/FFmpeg/blob/991d417692/doc/APIchanges#L18-L20
1504
+  av_free(pSource->qp_table);
1505
 
1506
   pPicture->SetParams(*pSource);
1507
   if (pPicture->videoBuffer)
1508
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
1509
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1510
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp	2023-03-16 21:56:53.271687000 +0000
1511
@@ -973,7 +973,8 @@
1512
   m_event.Set();
1513
   m_avD3D11Context = av_d3d11va_alloc_context();
1514
   m_avD3D11Context->cfg = reinterpret_cast<D3D11_VIDEO_DECODER_CONFIG*>(av_mallocz(sizeof(D3D11_VIDEO_DECODER_CONFIG)));
1515
-  m_avD3D11Context->surface = reinterpret_cast<ID3D11VideoDecoderOutputView**>(av_mallocz_array(32, sizeof(ID3D11VideoDecoderOutputView*)));
1516
+  m_avD3D11Context->surface = reinterpret_cast<ID3D11VideoDecoderOutputView**>(
1517
+      av_calloc(32, sizeof(ID3D11VideoDecoderOutputView*)));
1518
   m_bufferPool.reset();
1519
 
1520
   DX::Windowing()->Register(this);
1521
@@ -1537,8 +1538,6 @@
1522
     m_state = DXVA_RESET;
1523
     return -1;
1524
   }
1525
-
1526
-  pic->reordered_opaque = avctx->reordered_opaque;
1527
 
1528
   for (unsigned i = 0; i < 4; i++)
1529
   {
1530
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
1531
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1532
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp	2023-03-16 21:56:53.274356000 +0000
1533
@@ -868,7 +868,6 @@
1534
   }
1535
   pic->buf[0] = buffer;
1536
 
1537
-  pic->reordered_opaque = avctx->reordered_opaque;
1538
   va->Acquire();
1539
   return 0;
1540
 }
1541
@@ -1259,7 +1258,9 @@
1542
 
1543
 IHardwareDecoder* CDecoder::Create(CDVDStreamInfo &hint, CProcessInfo &processInfo, AVPixelFormat fmt)
1544
 {
1545
-  if (fmt == AV_PIX_FMT_VAAPI_VLD && CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_USEVAAPI))
1546
+  // https://github.com/FFmpeg/FFmpeg/blob/56450a0ee4fdda160f4039fc2ae33edfd27765c9/doc/APIchanges#L18-L26
1547
+  if (fmt == AV_PIX_FMT_VAAPI &&
1548
+      CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_USEVAAPI))
1549
     return new VAAPI::CDecoder(processInfo);
1550
 
1551
   return nullptr;
1552
@@ -2966,10 +2967,11 @@
1553
   const AVFilter* srcFilter = avfilter_get_by_name("buffer");
1554
   const AVFilter* outFilter = avfilter_get_by_name("buffersink");
1555
 
1556
-  std::string args = StringUtils::Format("{}:{}:{}:{}:{}:{}:{}", m_config.vidWidth,
1557
-                                         m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1,
1558
-                                         (m_config.aspect.num != 0) ? m_config.aspect.num : 1,
1559
-                                         (m_config.aspect.num != 0) ? m_config.aspect.den : 1);
1560
+  std::string args =
1561
+      StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}",
1562
+                          m_config.vidWidth, m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1,
1563
+                          (m_config.aspect.num != 0) ? m_config.aspect.num : 1,
1564
+                          (m_config.aspect.num != 0) ? m_config.aspect.den : 1);
1565
 
1566
   if (avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args.c_str(), NULL, m_pFilterGraph) < 0)
1567
   {
1568
diff -urN xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp.orig xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
1569
--- xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1570
+++ xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp	2023-03-16 21:56:53.273163000 +0000
1571
@@ -1045,7 +1045,6 @@
1572
   }
1573
   pic->buf[0] = buffer;
1574
 
1575
-  pic->reordered_opaque= avctx->reordered_opaque;
1576
   return 0;
1577
 }
1578
 
1579
diff -urN xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp.orig xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
1580
--- xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1581
+++ xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp	2023-03-16 21:56:20.714592000 +0000
1582
@@ -10,13 +10,13 @@
1583
 
1584
 #include "DVDDemuxUtils.h"
1585
 #include "DVDInputStreams/DVDInputStream.h"
1586
+#include "cores/FFmpeg.h"
1587
 #include "cores/VideoPlayer/Interface/TimingConstants.h"
1588
 #include "utils/log.h"
1589
 
1590
+#include <tuple>
1591
 #include <utility>
1592
 
1593
-#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
1594
-
1595
 class CDemuxStreamClientInternal
1596
 {
1597
 public:
1598
@@ -130,7 +130,7 @@
1599
 
1600
   if (stream->m_context == nullptr)
1601
   {
1602
-    AVCodec *codec = avcodec_find_decoder(st->codec);
1603
+    const AVCodec* codec = avcodec_find_decoder(st->codec);
1604
     if (codec == nullptr)
1605
     {
1606
       CLog::Log(LOGERROR, "{} - can't find decoder", __FUNCTION__);
1607
@@ -149,17 +149,26 @@
1608
     stream->m_context->time_base.den = DVD_TIME_BASE;
1609
   }
1610
 
1611
-  if (stream->m_parser_split && stream->m_parser->parser->split)
1612
+  if (stream->m_parser_split && stream->m_parser && stream->m_parser->parser)
1613
   {
1614
-    int len = stream->m_parser->parser->split(stream->m_context, pkt->pData, pkt->iSize);
1615
-    if (len > 0 && len < FF_MAX_EXTRADATA_SIZE)
1616
+    AVPacket* avpkt = av_packet_alloc();
1617
+    if (!avpkt)
1618
     {
1619
+      CLog::LogF(LOGERROR, "av_packet_alloc failed: {}", strerror(errno));
1620
+      return false;
1621
+    }
1622
+
1623
+    avpkt->data = pkt->pData;
1624
+    avpkt->size = pkt->iSize;
1625
+    avpkt->dts = avpkt->pts = AV_NOPTS_VALUE;
1626
+
1627
+    auto [retExtraData, len] = GetPacketExtradata(avpkt, stream->m_parser, stream->m_context);
1628
+    if (len > 0)
1629
+    {
1630
       st->changes++;
1631
       st->disabled = false;
1632
       st->ExtraSize = len;
1633
-      st->ExtraData = std::make_unique<uint8_t[]>(len + AV_INPUT_BUFFER_PADDING_SIZE);
1634
-      memcpy(st->ExtraData.get(), pkt->pData, len);
1635
-      memset(st->ExtraData.get() + len, 0, AV_INPUT_BUFFER_PADDING_SIZE);
1636
+      st->ExtraData = std::unique_ptr<uint8_t[]>(retExtraData);
1637
       stream->m_parser_split = false;
1638
       change = true;
1639
       CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - split extradata");
1640
@@ -167,21 +176,12 @@
1641
       // Allow ffmpeg to transport codec information to stream->m_context
1642
       if (!avcodec_open2(stream->m_context, stream->m_context->codec, nullptr))
1643
       {
1644
-        AVPacket* avpkt = av_packet_alloc();
1645
-        if (!avpkt)
1646
-        {
1647
-          CLog::Log(LOGERROR, "CDVDDemuxClient::{} - av_packet_alloc failed: {}", __FUNCTION__,
1648
-                    strerror(errno));
1649
-          return false;
1650
-        }
1651
-        avpkt->data = pkt->pData;
1652
-        avpkt->size = pkt->iSize;
1653
-        avpkt->dts = avpkt->pts = AV_NOPTS_VALUE;
1654
         avcodec_send_packet(stream->m_context, avpkt);
1655
         avcodec_close(stream->m_context);
1656
-        av_packet_free(&avpkt);
1657
       }
1658
     }
1659
+
1660
+    av_packet_free(&avpkt);
1661
   }
1662
 
1663
   uint8_t *outbuf = nullptr;
1664
@@ -219,10 +219,12 @@
1665
       case STREAM_AUDIO:
1666
       {
1667
         CDemuxStreamClientInternalTpl<CDemuxStreamAudio>* sta = static_cast<CDemuxStreamClientInternalTpl<CDemuxStreamAudio>*>(st);
1668
-        if (stream->m_context->channels != sta->iChannels && stream->m_context->channels != 0)
1669
+        int streamChannels = stream->m_context->ch_layout.nb_channels;
1670
+        if (streamChannels != sta->iChannels && streamChannels != 0)
1671
         {
1672
-          CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - ({}) channels changed from {} to {}", st->uniqueId, sta->iChannels, stream->m_context->channels);
1673
-          sta->iChannels = stream->m_context->channels;
1674
+          CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - ({}) channels changed from {} to {}",
1675
+                    st->uniqueId, sta->iChannels, streamChannels);
1676
+          sta->iChannels = streamChannels;
1677
           sta->changes++;
1678
           sta->disabled = false;
1679
         }
1680
@@ -234,7 +236,7 @@
1681
           sta->changes++;
1682
           sta->disabled = false;
1683
         }
1684
-        if (stream->m_context->channels)
1685
+        if (streamChannels)
1686
           st->changes = -1; // stop parsing
1687
         break;
1688
       }
1689
diff -urN xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp.orig xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
1690
--- xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
1691
+++ xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp	2023-03-16 21:56:53.267762000 +0000
1692
@@ -34,10 +34,12 @@
1693
 
1694
 #include <mutex>
1695
 #include <sstream>
1696
+#include <tuple>
1697
 #include <utility>
1698
 
1699
 extern "C"
1700
 {
1701
+#include "libavutil/channel_layout.h"
1702
 #include "libavutil/pixdesc.h"
1703
 }
1704
 
1705
@@ -104,8 +106,6 @@
1706
 }
1707
 } // namespace
1708
 
1709
-#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
1710
-
1711
 std::string CDemuxStreamAudioFFmpeg::GetStreamName()
1712
 {
1713
   if (!m_stream)
1714
@@ -235,7 +235,7 @@
1715
 
1716
 bool CDVDDemuxFFmpeg::Open(const std::shared_ptr<CDVDInputStream>& pInput, bool fileinfo)
1717
 {
1718
-  AVInputFormat* iformat = NULL;
1719
+  const AVInputFormat* iformat = nullptr;
1720
   std::string strFile;
1721
   m_streaminfo = !pInput->IsRealtime() && !m_reopen;
1722
   m_reopen = false;
1723
@@ -323,7 +323,6 @@
1724
     }
1725
     if (result < 0)
1726
     {
1727
-      m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT;
1728
       if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
1729
       {
1730
         CLog::Log(LOGDEBUG, "Error, could not open file {}", CURL::GetRedacted(strFile));
1731
@@ -335,7 +334,6 @@
1732
       avformat_close_input(&m_pFormatContext);
1733
       m_pFormatContext = avformat_alloc_context();
1734
       m_pFormatContext->interrupt_callback = int_cb;
1735
-      m_pFormatContext->flags &= ~AVFMT_FLAG_PRIV_OPT;
1736
       AVDictionary* options = GetFFMpegOptionsFromInput();
1737
       av_dict_set_int(&options, "load_all_variants", 0, AV_OPT_SEARCH_CHILDREN);
1738
       if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
1739
@@ -422,9 +420,7 @@
1740
           // is present, we assume it is PCM audio.
1741
           // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS
1742
           // may be just padded.
1743
-          AVInputFormat* iformat2;
1744
-          iformat2 = av_find_input_format("spdif");
1745
-
1746
+          const AVInputFormat* iformat2 = av_find_input_format("spdif");
1747
           if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
1748
           {
1749
             iformat = iformat2;
1750
@@ -544,12 +540,6 @@
1751
     m_streaminfo = true;
1752
   }
1753
 
1754
-  if (iformat && (strcmp(iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0))
1755
-  {
1756
-    if (URIUtils::IsRemote(strFile))
1757
-      m_pFormatContext->iformat->flags |= AVFMT_NOGENSEARCH;
1758
-  }
1759
-
1760
   // we need to know if this is matroska, avi or sup later
1761
   m_bMatroska = strncmp(m_pFormatContext->iformat->name, "matroska", 8) == 0;	// for "matroska.webm"
1762
   m_bAVI = strcmp(m_pFormatContext->iformat->name, "avi") == 0;
1763
@@ -604,9 +594,6 @@
1764
   // if format can be nonblocking, let's use that
1765
   m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK;
1766
 
1767
-  // deprecated, will be always set in future versions
1768
-  m_pFormatContext->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
1769
-
1770
   UpdateCurrentPTS();
1771
 
1772
   // select the correct program if requested
1773
@@ -647,7 +634,10 @@
1774
           {
1775
             int idx = m_pFormatContext->programs[i]->stream_index[j];
1776
             AVStream* st = m_pFormatContext->streams[idx];
1777
-            if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 0) ||
1778
+            // Related to https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210429143825.53040-1-jamrial@gmail.com/
1779
+            // has been replaced with AVSTREAM_EVENT_FLAG_NEW_PACKETS.
1780
+            if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
1781
+                 (st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)) ||
1782
                 (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate > 0))
1783
             {
1784
               nProgram = i;
1785
@@ -1218,8 +1208,11 @@
1786
     else if (stream->type == STREAM_AUDIO)
1787
     {
1788
       CDemuxStreamAudioFFmpeg* audiostream = dynamic_cast<CDemuxStreamAudioFFmpeg*>(stream);
1789
-      if (audiostream && (audiostream->iChannels != m_pFormatContext->streams[pPacket->iStreamId]->codecpar->channels ||
1790
-          audiostream->iSampleRate != m_pFormatContext->streams[pPacket->iStreamId]->codecpar->sample_rate))
1791
+      int codecparChannels =
1792
+          m_pFormatContext->streams[pPacket->iStreamId]->codecpar->ch_layout.nb_channels;
1793
+      if (audiostream && (audiostream->iChannels != codecparChannels ||
1794
+                          audiostream->iSampleRate !=
1795
+                              m_pFormatContext->streams[pPacket->iStreamId]->codecpar->sample_rate))
1796
       {
1797
         // content has changed
1798
         stream = AddStream(pPacket->iStreamId);
1799
@@ -1401,9 +1394,10 @@
1800
   if (idx >= 0)
1801
   {
1802
     AVStream* stream = m_pFormatContext->streams[idx];
1803
-    if (stream && stream->cur_dts != (int64_t)AV_NOPTS_VALUE)
1804
+
1805
+    if (stream && m_pkt.pkt.dts != (int64_t)AV_NOPTS_VALUE)
1806
     {
1807
-      double ts = ConvertTimestamp(stream->cur_dts, stream->time_base.den, stream->time_base.num);
1808
+      double ts = ConvertTimestamp(m_pkt.pkt.dts, stream->time_base.den, stream->time_base.num);
1809
       m_currentPts = ts;
1810
     }
1811
   }
1812
@@ -1614,14 +1608,20 @@
1813
       {
1814
         CDemuxStreamAudioFFmpeg* st = new CDemuxStreamAudioFFmpeg(pStream);
1815
         stream = st;
1816
-        st->iChannels = pStream->codecpar->channels;
1817
+        int codecparChannels = pStream->codecpar->ch_layout.nb_channels;
1818
+        int codecparChannelLayout = pStream->codecpar->ch_layout.u.mask;
1819
+        st->iChannels = codecparChannels;
1820
+        st->iChannelLayout = codecparChannelLayout;
1821
         st->iSampleRate = pStream->codecpar->sample_rate;
1822
         st->iBlockAlign = pStream->codecpar->block_align;
1823
         st->iBitRate = static_cast<int>(pStream->codecpar->bit_rate);
1824
         st->iBitsPerSample = pStream->codecpar->bits_per_raw_sample;
1825
-        st->iChannelLayout = pStream->codecpar->channel_layout;
1826
         char buf[32] = {};
1827
-        av_get_channel_layout_string(buf, 31, st->iChannels, st->iChannelLayout);
1828
+        // https://github.com/FFmpeg/FFmpeg/blob/6ccc3989d15/doc/APIchanges#L50-L53
1829
+        AVChannelLayout layout = {};
1830
+        av_channel_layout_from_mask(&layout, st->iChannelLayout);
1831
+        av_channel_layout_describe(&layout, buf, sizeof(buf));
1832
+        av_channel_layout_uninit(&layout);
1833
         st->m_channelLayoutName = buf;
1834
         if (st->iBitsPerSample == 0)
1835
           st->iBitsPerSample = pStream->codecpar->bits_per_coded_sample;
1836
@@ -1663,16 +1663,6 @@
1837
           st->iFpsScale = 0;
1838
         }
1839
 
1840
-        if (pStream->codec_info_nb_frames > 0 &&
1841
-            pStream->codec_info_nb_frames <= 2 &&
1842
-            m_pInput->IsStreamType(DVDSTREAM_TYPE_DVD))
1843
-        {
1844
-          CLog::Log(LOGDEBUG, "{} - fps may be unreliable since ffmpeg decoded only {} frame(s)",
1845
-                    __FUNCTION__, pStream->codec_info_nb_frames);
1846
-          st->iFpsRate  = 0;
1847
-          st->iFpsScale = 0;
1848
-        }
1849
-
1850
         st->iWidth = pStream->codecpar->width;
1851
         st->iHeight = pStream->codecpar->height;
1852
         st->fAspect = SelectAspect(pStream, st->bForcedAspect);
1853
@@ -1693,7 +1683,8 @@
1854
         st->colorRange = pStream->codecpar->color_range;
1855
         st->hdr_type = DetermineHdrType(pStream);
1856
 
1857
-        int size = 0;
1858
+        // https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/APIchanges
1859
+        size_t size = 0;
1860
         uint8_t* side_data = nullptr;
1861
 
1862
         side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size);
1863
@@ -2103,7 +2094,7 @@
1864
       return strName;
1865
     }
1866
 
1867
-    AVCodec* codec = avcodec_find_decoder(stream->codec);
1868
+    const AVCodec* codec = avcodec_find_decoder(stream->codec);
1869
     if (codec)
1870
       strName = avcodec_get_name(codec->id);
1871
   }
1872
@@ -2158,8 +2149,8 @@
1873
     if (m_pFormatContext->streams[idx]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
1874
     {
1875
       CDemuxStreamAudioFFmpeg* audiostream = dynamic_cast<CDemuxStreamAudioFFmpeg*>(stream);
1876
-      if (audiostream &&
1877
-          m_pFormatContext->streams[idx]->codecpar->channels != audiostream->iChannels)
1878
+      int codecparChannels = m_pFormatContext->streams[idx]->codecpar->ch_layout.nb_channels;
1879
+      if (audiostream && codecparChannels != audiostream->iChannels)
1880
       {
1881
         return true;
1882
       }
1883
@@ -2279,7 +2270,7 @@
1884
 
1885
       parser->second->m_parserCtx = av_parser_init(st->codecpar->codec_id);
1886
 
1887
-      AVCodec* codec = avcodec_find_decoder(st->codecpar->codec_id);
1888
+      const AVCodec* codec = avcodec_find_decoder(st->codecpar->codec_id);
1889
       if (codec == nullptr)
1890
       {
1891
         CLog::Log(LOGERROR, "{} - can't find decoder", __FUNCTION__);
1892
@@ -2295,45 +2286,37 @@
1893
 
1894
     if (parser->second->m_parserCtx &&
1895
         parser->second->m_parserCtx->parser &&
1896
-        parser->second->m_parserCtx->parser->split &&
1897
         !st->codecpar->extradata)
1898
     {
1899
-      int i = parser->second->m_parserCtx->parser->split(parser->second->m_codecCtx, pkt->data, pkt->size);
1900
-      if (i > 0 && i < FF_MAX_EXTRADATA_SIZE)
1901
+      auto [retExtraData, i] =
1902
+          GetPacketExtradata(pkt, parser->second->m_parserCtx, parser->second->m_codecCtx);
1903
+      if (i > 0)
1904
       {
1905
-        st->codecpar->extradata = (uint8_t*)av_malloc(i + AV_INPUT_BUFFER_PADDING_SIZE);
1906
-        if (st->codecpar->extradata)
1907
+        st->codecpar->extradata_size = i;
1908
+        st->codecpar->extradata = retExtraData;
1909
+
1910
+        if (parser->second->m_parserCtx->parser->parser_parse)
1911
         {
1912
-          CLog::Log(LOGDEBUG,
1913
-                    "CDVDDemuxFFmpeg::ParsePacket() fetching extradata, extradata_size({})", i);
1914
-          st->codecpar->extradata_size = i;
1915
-          memcpy(st->codecpar->extradata, pkt->data, i);
1916
-          memset(st->codecpar->extradata + i, 0, AV_INPUT_BUFFER_PADDING_SIZE);
1917
+          parser->second->m_codecCtx->extradata = st->codecpar->extradata;
1918
+          parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size;
1919
+          const uint8_t* outbufptr;
1920
+          int bufSize;
1921
+          parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES;
1922
+          parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx,
1923
+                                                            parser->second->m_codecCtx, &outbufptr,
1924
+                                                            &bufSize, pkt->data, pkt->size);
1925
+          parser->second->m_codecCtx->extradata = nullptr;
1926
+          parser->second->m_codecCtx->extradata_size = 0;
1927
 
1928
-          if (parser->second->m_parserCtx->parser->parser_parse)
1929
+          if (parser->second->m_parserCtx->width != 0)
1930
           {
1931
-            parser->second->m_codecCtx->extradata = st->codecpar->extradata;
1932
-            parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size;
1933
-            const uint8_t* outbufptr;
1934
-            int bufSize;
1935
-            parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES;
1936
-            parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx,
1937
-                                                              parser->second->m_codecCtx,
1938
-                                                              &outbufptr, &bufSize,
1939
-                                                              pkt->data, pkt->size);
1940
-            parser->second->m_codecCtx->extradata = nullptr;
1941
-            parser->second->m_codecCtx->extradata_size = 0;
1942
-
1943
-            if (parser->second->m_parserCtx->width != 0)
1944
-            {
1945
-              st->codecpar->width = parser->second->m_parserCtx->width;
1946
-              st->codecpar->height = parser->second->m_parserCtx->height;
1947
-            }
1948
-            else
1949
-            {
1950
-              CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height");
1951
-            }
1952
+            st->codecpar->width = parser->second->m_parserCtx->width;
1953
+            st->codecpar->height = parser->second->m_parserCtx->height;
1954
           }
1955
+          else
1956
+          {
1957
+            CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height");
1958
+          }
1959
         }
1960
       }
1961
     }
1962
@@ -2357,7 +2340,8 @@
1963
         {
1964
           if (!m_startTime)
1965
           {
1966
-            m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001;
1967
+            m_startTime =
1968
+                av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001;
1969
             m_seekStream = idx;
1970
           }
1971
           return TRANSPORT_STREAM_STATE::READY;
1972
@@ -2377,7 +2361,8 @@
1973
         {
1974
           if (!m_startTime)
1975
           {
1976
-            m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001;
1977
+            m_startTime =
1978
+                av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001;
1979
             m_seekStream = i;
1980
           }
1981
           return TRANSPORT_STREAM_STATE::READY;
1982
@@ -2410,7 +2395,8 @@
1983
         {
1984
           if (!m_startTime)
1985
           {
1986
-            m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001;
1987
+            m_startTime =
1988
+                av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001;
1989
             m_seekStream = idx;
1990
           }
1991
           return TRANSPORT_STREAM_STATE::READY;
1992
@@ -2430,7 +2416,8 @@
1993
         {
1994
           if (!m_startTime)
1995
           {
1996
-            m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001;
1997
+            m_startTime =
1998
+                av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001;
1999
             m_seekStream = i;
2000
           }
2001
           return TRANSPORT_STREAM_STATE::READY;
2002
diff -urN xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp.orig xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp
2003
--- xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp.orig	2023-03-11 22:16:38.000000000 +0000
2004
+++ xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp	2023-03-16 21:56:20.715583000 +0000
2005
@@ -12,6 +12,7 @@
2006
 #include "addons/addoninfo/AddonType.h"
2007
 #include "addons/binary-addons/AddonDll.h"
2008
 #include "addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h"
2009
+#include "cores/FFmpeg.h"
2010
 #include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h"
2011
 #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h"
2012
 #include "cores/VideoPlayer/Interface/DemuxCrypto.h"
2013
@@ -392,7 +393,7 @@
2014
     return nullptr;
2015
 
2016
   std::string codecName(stream->m_codecName);
2017
-  AVCodec* codec = nullptr;
2018
+  const AVCodec* codec = nullptr;
2019
 
2020
   if (stream->m_streamType != INPUTSTREAM_TYPE_TELETEXT &&
2021
       stream->m_streamType != INPUTSTREAM_TYPE_RDS && stream->m_streamType != INPUTSTREAM_TYPE_ID3)
2022
diff -urN xbmc/filesystem/AudioBookFileDirectory.cpp.orig xbmc/filesystem/AudioBookFileDirectory.cpp
2023
--- xbmc/filesystem/AudioBookFileDirectory.cpp.orig	2023-03-11 22:16:38.000000000 +0000
2024
+++ xbmc/filesystem/AudioBookFileDirectory.cpp	2023-03-16 21:56:20.715726000 +0000
2025
@@ -11,6 +11,7 @@
2026
 #include "TextureDatabase.h"
2027
 #include "URL.h"
2028
 #include "Util.h"
2029
+#include "cores/FFmpeg.h"
2030
 #include "filesystem/File.h"
2031
 #include "guilib/LocalizeStrings.h"
2032
 #include "music/tags/MusicInfoTag.h"
2033
@@ -149,7 +150,7 @@
2034
 
2035
   m_ioctx->max_packet_size = 32768;
2036
 
2037
-  AVInputFormat* iformat=nullptr;
2038
+  const AVInputFormat* iformat = nullptr;
2039
   av_probe_input_buffer(m_ioctx, &iformat, url.Get().c_str(), nullptr, 0, 0);
2040
 
2041
   bool contains = false;
2042
diff -urN xbmc/guilib/FFmpegImage.cpp.orig xbmc/guilib/FFmpegImage.cpp
2043
--- xbmc/guilib/FFmpegImage.cpp.orig	2023-03-11 22:16:38.000000000 +0000
2044
+++ xbmc/guilib/FFmpegImage.cpp	2023-03-16 21:56:53.271294000 +0000
2045
@@ -52,7 +52,7 @@
2046
   AVFrame* frame_temporary = nullptr;
2047
   SwsContext* sws = nullptr;
2048
   AVCodecContext* avOutctx = nullptr;
2049
-  AVCodec* codec = nullptr;
2050
+  const AVCodec* codec = nullptr;
2051
   ~ThumbDataManagement()
2052
   {
2053
     av_free(intermediateBuffer);
2054
@@ -198,7 +198,7 @@
2055
   bool is_png = (bufSize > 3 && buffer[1] == 'P' && buffer[2] == 'N' && buffer[3] == 'G');
2056
   bool is_tiff = (bufSize > 2 && buffer[0] == 'I' && buffer[1] == 'I' && buffer[2] == '*');
2057
 
2058
-  AVInputFormat* inp = nullptr;
2059
+  const AVInputFormat* inp = nullptr;
2060
   if (is_jpeg)
2061
     inp = av_find_input_format("image2");
2062
   else if (m_strMimeType == "image/apng")
2063
@@ -236,7 +236,7 @@
2064
     return false;
2065
   }
2066
   AVCodecParameters* codec_params = m_fctx->streams[0]->codecpar;
2067
-  AVCodec* codec = avcodec_find_decoder(codec_params->codec_id);
2068
+  const AVCodec* codec = avcodec_find_decoder(codec_params->codec_id);
2069
   m_codec_ctx = avcodec_alloc_context3(codec);
2070
   if (!m_codec_ctx)
2071
   {
2072
@@ -294,7 +294,8 @@
2073
     return nullptr;
2074
   }
2075
   //we need milliseconds
2076
-  frame->pkt_duration = av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{ 1, 1000 });
2077
+  frame->duration =
2078
+      av_rescale_q(frame->duration, m_fctx->streams[0]->time_base, AVRational{1, 1000});
2079
   m_height = frame->height;
2080
   m_width = frame->width;
2081
   m_originalWidth = m_width;
2082
@@ -745,7 +746,7 @@
2083
   if (avframe == nullptr)
2084
     return nullptr;
2085
   std::shared_ptr<Frame> frame(new Frame());
2086
-  frame->m_delay = (unsigned int)avframe->pkt_duration;
2087
+  frame->m_delay = (unsigned int)avframe->duration;
2088
   frame->m_pitch = avframe->width * 4;
2089
   frame->m_pImage = (unsigned char*) av_malloc(avframe->height * frame->m_pitch);
2090
   DecodeFrame(avframe, avframe->width, avframe->height, frame->m_pitch, frame->m_pImage);
2091
diff -urN xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp.orig xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp
2092
--- xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
2093
+++ xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp	2023-03-16 21:56:20.716138000 +0000
2094
@@ -58,7 +58,7 @@
2095
   if (file.IoControl(IOCTRL_SEEK_POSSIBLE, NULL) != 1)
2096
     ioctx->seekable = 0;
2097
 
2098
-  AVInputFormat* iformat=NULL;
2099
+  const AVInputFormat* iformat = nullptr;
2100
   av_probe_input_buffer(ioctx, &iformat, strFileName.c_str(), NULL, 0, 0);
2101
 
2102
   if (avformat_open_input(&fctx, strFileName.c_str(), iformat, NULL) < 0)
2103
diff -urN xbmc/video/tags/VideoTagLoaderFFmpeg.cpp.orig xbmc/video/tags/VideoTagLoaderFFmpeg.cpp
2104
--- xbmc/video/tags/VideoTagLoaderFFmpeg.cpp.orig	2023-03-11 22:16:38.000000000 +0000
2105
+++ xbmc/video/tags/VideoTagLoaderFFmpeg.cpp	2023-03-16 21:56:20.716302000 +0000
2106
@@ -65,7 +65,7 @@
2107
   if (m_file->IoControl(IOCTRL_SEEK_POSSIBLE, nullptr) != 1)
2108
     m_ioctx->seekable = 0;
2109
 
2110
-  AVInputFormat* iformat = nullptr;
2111
+  const AVInputFormat* iformat = nullptr;
2112
   av_probe_input_buffer(m_ioctx, &iformat, m_item.GetPath().c_str(), nullptr, 0, 0);
2113
   if (avformat_open_input(&m_fctx, m_item.GetPath().c_str(), iformat, nullptr) < 0)
2114
   {
(-)b/multimedia/libxine/Makefile (-6 / +6 lines)
Lines 1-10 Link Here
1
PORTNAME=	xine
1
PORTNAME=	xine
2
DISTVERSION=	1.2.12
2
DISTVERSION=	1.2.13
3
PORTREVISION=	5
4
CATEGORIES=	multimedia
3
CATEGORIES=	multimedia
5
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-lib/${PORTVERSION}
4
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-lib/${DISTVERSION}
6
PKGNAMEPREFIX=	lib
5
PKGNAMEPREFIX=	lib
7
DISTNAME=	${PORTNAME}-lib-${PORTVERSION}
6
DISTNAME=	${PORTNAME}-lib-${DISTVERSION}
8
7
9
MAINTAINER=	ports@FreeBSD.org
8
MAINTAINER=	ports@FreeBSD.org
10
COMMENT=	Libraries for xine multimedia player
9
COMMENT=	Libraries for xine multimedia player
Lines 50-56 USE_LDCONFIG= yes Link Here
50
CONFIGURE_ARGS=	--with-libflac \
49
CONFIGURE_ARGS=	--with-libflac \
51
		--enable-musepack \
50
		--enable-musepack \
52
		--enable-real-codecs \
51
		--enable-real-codecs \
53
		--without-esound
52
		--without-esound \
53
		--disable-crypto
54
54
55
MAKE_ENV=	V=1
55
MAKE_ENV=	V=1
56
MAKE_ARGS=	pkgdatadir="${DATADIR}" \
56
MAKE_ARGS=	pkgdatadir="${DATADIR}" \
Lines 62-68 CFLAGS_i386= -fomit-frame-pointer Link Here
62
DOCSDIR=	${PREFIX}/share/doc/xine-lib
62
DOCSDIR=	${PREFIX}/share/doc/xine-lib
63
# Please sync with XINE_PLUGINSDIR in multimedia/xine
63
# Please sync with XINE_PLUGINSDIR in multimedia/xine
64
# and multimedia/vdr-plugin-xineliboutput
64
# and multimedia/vdr-plugin-xineliboutput
65
PLUGINSDIR=	lib/xine/plugins/2.10
65
PLUGINSDIR=	lib/xine/plugins/2.11
66
PLIST_SUB=	PLUGINSDIR="${PLUGINSDIR}"
66
PLIST_SUB=	PLUGINSDIR="${PLUGINSDIR}"
67
67
68
OPTIONS_DEFINE=		AALIB ALSA AOM CACA DAV1D DOCS DMX_IMAGE DVB \
68
OPTIONS_DEFINE=		AALIB ALSA AOM CACA DAV1D DOCS DMX_IMAGE DVB \
(-)b/multimedia/libxine/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1646930905
1
TIMESTAMP = 1679084820
2
SHA256 (xine-lib-1.2.12.tar.xz) = d606270468e1540c2a89c0d7f5fdf11e17ecc0c2698cc0bcb1065ff26abee098
2
SHA256 (xine-lib-1.2.13.tar.xz) = 5f10d6d718a4a51c17ed1b32b031d4f9b80b061e8276535b2be31e5ac4b75e6f
3
SIZE (xine-lib-1.2.12.tar.xz) = 5341212
3
SIZE (xine-lib-1.2.13.tar.xz) = 5004196
(-)a/multimedia/libxine/files/patch-dav1d-1.0 (-47 lines)
Removed Link Here
1
https://sourceforge.net/p/xine/tickets/11/
2
3
dav1d.c:547:12: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
4
  settings.n_frame_threads = (ncpu > 8) ? 4 : (ncpu < 2) ? 1 : ncpu/2;
5
  ~~~~~~~~ ^
6
dav1d.c:548:12: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
7
  settings.n_tile_threads = MAX(1, ncpu - settings.n_frame_threads + 1);
8
  ~~~~~~~~ ^
9
dav1d.c:548:52: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
10
  settings.n_tile_threads = MAX(1, ncpu - settings.n_frame_threads + 1);
11
                                          ~~~~~~~~ ^
12
dav1d.c:548:52: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
13
  settings.n_tile_threads = MAX(1, ncpu - settings.n_frame_threads + 1);
14
                                          ~~~~~~~~ ^
15
/usr/include/sys/param.h:306:34: note: expanded from macro 'MAX'
16
#define MAX(a,b) (((a)>(b))?(a):(b))
17
                                 ^
18
dav1d.c:551:22: error: no member named 'n_frame_threads' in 'struct Dav1dSettings'
19
            settings.n_frame_threads, settings.n_tile_threads);
20
            ~~~~~~~~ ^
21
dav1d.c:551:48: error: no member named 'n_tile_threads' in 'struct Dav1dSettings'
22
            settings.n_frame_threads, settings.n_tile_threads);
23
                                      ~~~~~~~~ ^
24
../../include/xine/xineutils.h:687:40: note: expanded from macro 'xprintf'
25
        xine_log(xine, XINE_LOG_TRACE, __VA_ARGS__);                        \
26
                                       ^~~~~~~~~~~
27
28
--- src/video_dec/dav1d.c.orig	2022-03-06 16:31:24 UTC
29
+++ src/video_dec/dav1d.c
30
@@ -544,11 +544,17 @@ static video_decoder_t *_open_plugin(video_decoder_cla
31
 
32
   /* multithreading */
33
   ncpu = xine_cpu_count();
34
+#if DAV1D_API_VERSION_MAJOR > 5
35
+  settings.n_threads = ncpu + 1;
36
+  xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": "
37
+            "Using %d threads\n", settings.n_threads);
38
+#else
39
   settings.n_frame_threads = (ncpu > 8) ? 4 : (ncpu < 2) ? 1 : ncpu/2;
40
   settings.n_tile_threads = MAX(1, ncpu - settings.n_frame_threads + 1);
41
   xprintf(stream->xine, XINE_VERBOSITY_DEBUG, LOG_MODULE ": "
42
             "Using %d frame threads, %d tile threads\n",
43
             settings.n_frame_threads, settings.n_tile_threads);
44
+#endif
45
 
46
   /* dri frame allocator */
47
   settings.allocator.cookie = this;
(-)a/multimedia/libxine/files/patch-include-xine-xineutils.h (-22 lines)
Removed Link Here
1
Unbreak build of phonon-xine
2
3
In file included from xine/plugins.c:23:
4
In file included from /usr/local/include/xine/input_plugin.h:27:
5
/usr/local/include/xine/xineutils.h:197:8: error: unknown type name 'inline'
6
static inline void _x_freep(void *ptr) {
7
       ^
8
/usr/local/include/xine/xineutils.h:197:15: error: expected identifier or '('
9
static inline void _x_freep(void *ptr) {
10
              ^
11
12
--- include/xine/xineutils.h.orig
13
+++ include/xine/xineutils.h
14
@@ -146,7 +146,7 @@ void *xine_xcalloc(size_t nmemb, size_t 
15
  * Free allocated memory and set pointer to NULL
16
  * @param ptr Pointer to the pointer to the memory block which should be freed.
17
  */
18
-static inline void _x_freep(void *ptr) {
19
+static void _x_freep(void *ptr) {
20
   void **p = (void **)ptr;
21
   free (*p);
22
   *p = NULL;
(-)b/multimedia/libxine/files/patch-src_combined_ffmpeg_demux__avformat.c (+35 lines)
Added Link Here
1
--- src/combined/ffmpeg/demux_avformat.c.orig	2022-09-08 21:43:29 UTC
2
+++ src/combined/ffmpeg/demux_avformat.c
3
@@ -1,5 +1,5 @@
4
 /*
5
- * Copyright (C) 2013-2022 the xine project
6
+ * Copyright (C) 2013-2023 the xine project
7
  * Copyright (C) 2013-2020 Petri Hintukainen <phintuka@users.sourceforge.net>
8
  *
9
  * This file is part of xine, a free video player.
10
@@ -423,8 +423,13 @@ static int find_avformat_streams(avformat_demux_plugin
11
     }
12
 
13
 #ifdef XFF_CODECPAR
14
+#  if XFF_AUDIO_CHANNEL_LAYOUT < 2
15
     if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
16
         st->codecpar->sample_rate != 0 && st->codecpar->channels != 0)
17
+#  else
18
+    if (st->codecpar && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
19
+        st->codecpar->sample_rate != 0 && st->codecpar->ch_layout.nb_channels != 0)
20
+#  endif
21
 #else
22
     if (st->codec && st->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
23
         st->codec->sample_rate != 0 && st->codec->channels != 0)
24
@@ -501,7 +506,11 @@ static void send_headers_audio(avformat_demux_plugin_t
25
   buf->size = extradata_size + sizeof(xine_waveformatex);
26
   buf->decoder_info[1] = ctx->sample_rate;
27
   buf->decoder_info[2] = ctx->bits_per_coded_sample;
28
+#if XFF_AUDIO_CHANNEL_LAYOUT < 2
29
   buf->decoder_info[3] = ctx->channels;
30
+#else
31
+  buf->decoder_info[3] = ctx->ch_layout.nb_channels;
32
+#endif
33
   buf->decoder_flags = BUF_FLAG_HEADER | BUF_FLAG_STDHEADER | BUF_FLAG_FRAME_END;
34
 
35
   this->stream->audio_fifo->put (this->stream->audio_fifo, buf);
(-)b/multimedia/libxine/files/patch-src_combined_ffmpeg_ff__audio__decoder.c (+152 lines)
Added Link Here
1
--- src/combined/ffmpeg/ff_audio_decoder.c.orig	2022-09-08 21:43:29 UTC
2
+++ src/combined/ffmpeg/ff_audio_decoder.c
3
@@ -1,5 +1,5 @@
4
 /*
5
- * Copyright (C) 2001-2022 the xine project
6
+ * Copyright (C) 2001-2023 the xine project
7
  *
8
  * This file is part of xine, a free video player.
9
  *
10
@@ -303,7 +303,11 @@ static void ff_audio_init_codec(ff_audio_decoder_t *th
11
 
12
   this->context->bits_per_sample = this->ff_bits;
13
   this->context->sample_rate = this->ff_sample_rate;
14
+#if XFF_AUDIO_CHANNEL_LAYOUT < 2
15
   this->context->channels    = this->ff_channels;
16
+#else
17
+  this->context->ch_layout.nb_channels = this->ff_channels;
18
+#endif
19
   this->context->codec_id    = this->codec->id;
20
   this->context->codec_type  = this->codec->type;
21
   this->context->codec_tag   = _x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC);
22
@@ -527,17 +531,76 @@ static void ff_audio_output_close(ff_audio_decoder_t *
23
   this->ao_mode = 0;
24
 }
25
 
26
+static unsigned int ff_list_channels (uint8_t *list, uint64_t map) {
27
+  unsigned int n, bit;
28
+
29
+  for (n = bit = 0; map; map >>= 1, bit++) {
30
+    uint32_t b = map & 1;
31
+
32
+    list[n] = bit;
33
+    n += b;
34
+  }
35
+  return n;
36
+}
37
+
38
 static void ff_map_channels (ff_audio_decoder_t *this) {
39
   uint64_t ff_map;
40
+  uint8_t ff_list[64];
41
+  unsigned int ff_num;
42
+  const char *type = "native";
43
   int caps = this->stream->audio_out->get_capabilities (this->stream->audio_out);
44
 
45
+#if XFF_AUDIO_CHANNEL_LAYOUT < 2
46
+
47
   /* safety kludge for very old libavcodec */
48
-#ifdef AV_CH_FRONT_LEFT
49
+#  ifdef AV_CH_FRONT_LEFT
50
   ff_map = this->context->channel_layout;
51
   if (!ff_map) /* wma2 bug */
52
-#endif
53
+#  endif
54
     ff_map = ((uint64_t)1 << this->context->channels) - 1;
55
+  ff_num = ff_list_channels (ff_list, ff_map);
56
 
57
+#else /* XFF_AUDIO_CHANNEL_LAYOUT == 2 */
58
+
59
+  ff_num = this->context->ch_layout.nb_channels;
60
+  if (ff_num > (int)(sizeof (ff_list) / sizeof (ff_list[0])))
61
+    ff_num = sizeof (ff_list) / sizeof (ff_list[0]);
62
+  switch (this->context->ch_layout.order) {
63
+    const AVChannelCustom *cmap;
64
+    unsigned int i;
65
+
66
+    case AV_CHANNEL_ORDER_UNSPEC:
67
+      type = "unknown";
68
+      goto _fallback;
69
+
70
+    case AV_CHANNEL_ORDER_NATIVE:
71
+      ff_map = this->context->ch_layout.u.mask;
72
+      if (!ff_map) /* wma2 bug */
73
+        ff_map = ((uint64_t)1 << ff_num) - 1;
74
+      ff_num = ff_list_channels (ff_list, ff_map);
75
+      break;
76
+
77
+    case AV_CHANNEL_ORDER_CUSTOM:
78
+      type = "custom";
79
+      if (!(cmap = this->context->ch_layout.u.map))
80
+        goto _fallback;
81
+      ff_map = 0;
82
+      for (i = 0; i < ff_num; i++) {
83
+        ff_list[i] = cmap[i].id;
84
+        ff_map |= (uint64_t)1 << ff_list[i];
85
+      }
86
+      break;
87
+
88
+    default:
89
+      type = "unsupported";
90
+      /* fall through */
91
+    _fallback:
92
+      ff_map = ((uint64_t)1 << ff_num) - 1;
93
+      ff_num = ff_list_channels (ff_list, ff_map);
94
+  }
95
+
96
+#endif
97
+
98
   if ((caps != this->ao_caps) || (ff_map != this->ff_map)) {
99
     unsigned int i, j;
100
     /* ff: see names[] below; xine: L R RL RR C LFE */
101
@@ -562,7 +625,7 @@ static void ff_map_channels (ff_audio_decoder_t *this)
102
 
103
     this->ao_caps     = caps;
104
     this->ff_map      = ff_map;
105
-    this->ff_channels = this->context->channels;
106
+    this->ff_channels = ff_num;
107
 
108
     /* silence out */
109
     for (i = 0; i < MAX_CHANNELS; i++)
110
@@ -576,20 +639,23 @@ static void ff_map_channels (ff_audio_decoder_t *this)
111
       this->left[0] = this->right[0] = 0;
112
       tries = wishlist + 0 * num_modes;
113
     } else if (this->ff_channels == 2) { /* stereo */
114
+      /* FIXME: libxine does not yet support audio selection _after_ decoding.
115
+       * For now, treat the most common "dual mono" case as stereo. */
116
       name_map[0] = 0;
117
       name_map[1] = 1;
118
       this->left[0] = 0;
119
       this->right[0] = 1;
120
       tries = wishlist + 1 * num_modes;
121
     } else {
122
-      for (i = j = 0; i < sizeof (base_map) / sizeof (base_map[0]); i++) {
123
-        if ((ff_map >> i) & 1) {
124
-          int8_t target = base_map[i];
125
-          if ((target >= 0) && (this->map[target] < 0))
126
-            this->map[target] = j;
127
-          name_map[j] = i; /* for debug output below */
128
-          j++;
129
-        }
130
+      for (i = 0; i < ff_num; i++) {
131
+        int8_t target;
132
+        uint32_t num = ff_list[i];
133
+        if (num >= sizeof (base_map) / sizeof (base_map[0]))
134
+          continue;
135
+        target = base_map[num];
136
+        if ((target >= 0) && (this->map[target] < 0))
137
+          this->map[target] = i;
138
+        name_map[i] = num; /* for debug output below */
139
       }
140
       this->left[0]  = this->map[0] < 0 ? 0 : this->map[0];
141
       this->map[0]   = -1;
142
@@ -641,8 +707,8 @@ static void ff_map_channels (ff_audio_decoder_t *this)
143
         "rear center",
144
         "side left", "side right"
145
       };
146
-      int8_t buf[200];
147
-      int p = sprintf (buf, "ff_audio_dec: channel layout: ");
148
+      int8_t buf[256];
149
+      int p = sprintf (buf, "ff_audio_dec: %s channel layout: ", type);
150
       int8_t *indx = this->left;
151
       for (i = 0; i < 2; i++) {
152
         buf[p++] = '[';
(-)b/multimedia/libxine/pkg-plist (-1 / +1 lines)
Lines 49-55 lib/libxine.la Link Here
49
lib/libxine-interface.la
49
lib/libxine-interface.la
50
lib/libxine.so
50
lib/libxine.so
51
lib/libxine.so.2
51
lib/libxine.so.2
52
lib/libxine.so.2.10.0
52
lib/libxine.so.2.11.0
53
%%PLUGINSDIR%%/mime.types
53
%%PLUGINSDIR%%/mime.types
54
%%PLUGINSDIR%%/post/xineplug_post_audio_filters.so
54
%%PLUGINSDIR%%/post/xineplug_post_audio_filters.so
55
%%PLUGINSDIR%%/post/xineplug_post_goom.so
55
%%PLUGINSDIR%%/post/xineplug_post_goom.so
(-)b/multimedia/vdr-plugin-xineliboutput/Makefile (-1 / +1 lines)
Lines 30-36 CONFIGURE_ARGS= --add-cflags=-I${VDRDIR} \ Link Here
30
PATCH_STRIP=	-p1
30
PATCH_STRIP=	-p1
31
31
32
WRKSRC=			${WRKDIR}/vdr-${PLUGIN}
32
WRKSRC=			${WRKDIR}/vdr-${PLUGIN}
33
XINE_PLUGINSDIR=	lib/xine/plugins/2.10
33
XINE_PLUGINSDIR=	lib/xine/plugins/2.11
34
34
35
PLIST_SUB=	XINE_PLUGINSDIR=${XINE_PLUGINSDIR}
35
PLIST_SUB=	XINE_PLUGINSDIR=${XINE_PLUGINSDIR}
36
PORTDOCS=	HISTORY README
36
PORTDOCS=	HISTORY README
(-)b/multimedia/vlc/Makefile (+1 lines)
Lines 85-90 OPTIONS_DEFAULT=ASS AVAHI DAV1D DBUS DVDREAD DVDNAV GNUTLS HARFBUZZ JPEG \ Link Here
85
OPTIONS_DEFAULT_powerpc=	ALTIVEC
85
OPTIONS_DEFAULT_powerpc=	ALTIVEC
86
OPTIONS_DEFAULT_powerpc64=	ALTIVEC
86
OPTIONS_DEFAULT_powerpc64=	ALTIVEC
87
OPTIONS_EXCLUDE=LIBPLACEBO # https://code.videolan.org/videolan/vlc/-/commit/8e22c39ea3c3
87
OPTIONS_EXCLUDE=LIBPLACEBO # https://code.videolan.org/videolan/vlc/-/commit/8e22c39ea3c3
88
OPTIONS_EXCLUDE+=	VAAPI # Not compatible until VLC 4
88
OPTIONS_SUB=	yes
89
OPTIONS_SUB=	yes
89
90
90
AOM_DESC=	AV1 video encoding/decoding via libaom
91
AOM_DESC=	AV1 video encoding/decoding via libaom
(-)b/multimedia/xine/Makefile (-2 / +2 lines)
Lines 1-6 Link Here
1
PORTNAME=	xine
1
PORTNAME=	xine
2
PORTVERSION=	0.99.14
2
PORTVERSION=	0.99.14
3
PORTREVISION=	1
3
PORTREVISION=	2
4
CATEGORIES=	multimedia
4
CATEGORIES=	multimedia
5
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-ui/${PORTVERSION}
5
MASTER_SITES=	SF/${PORTNAME}/${PORTNAME}-ui/${PORTVERSION}
6
DISTNAME=	${PORTNAME}-ui-${PORTVERSION}
6
DISTNAME=	${PORTNAME}-ui-${PORTVERSION}
Lines 48-54 NLS_CONFIGURE_ENABLE= nls Link Here
48
XFT_USE=		XORG=xft
48
XFT_USE=		XORG=xft
49
XFT_CONFIGURE_ENABLE=	xft
49
XFT_CONFIGURE_ENABLE=	xft
50
50
51
XINE_PLUGINSDIR=	lib/xine/plugins/2.10
51
XINE_PLUGINSDIR=	lib/xine/plugins/2.11
52
52
53
post-patch:
53
post-patch:
54
	@${REINPLACE_CMD} -e \
54
	@${REINPLACE_CMD} -e \
(-)b/www/qt5-webengine/files/patch-add-support-for-ffmpeg5-and-later (-1 / +140 lines)
Added Link Here
0
- 
1
Adds support for FFmpeg and later
2
3
Obtained from:
4
5
https://github.com/archlinux/svntogit-packages/blob/packages/qt5-webengine/trunk/qt5-webengine-ffmpeg5.patch
6
7
--- src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h.orig	2021-12-15 16:12:54 UTC
8
+++ src/3rdparty/chromium/media/ffmpeg/ffmpeg_common.h
9
@@ -29,6 +29,7 @@ extern "C" {
10
 #include <libavformat/avformat.h>
11
 #include <libavformat/avio.h>
12
 #include <libavutil/avutil.h>
13
+#include <libavutil/channel_layout.h>
14
 #include <libavutil/imgutils.h>
15
 #include <libavutil/log.h>
16
 #include <libavutil/mastering_display_metadata.h>
17
--- src/3rdparty/chromium/media/filters/audio_file_reader.cc.orig	2021-12-15 16:12:54 UTC
18
+++ src/3rdparty/chromium/media/filters/audio_file_reader.cc
19
@@ -85,7 +85,7 @@ bool AudioFileReader::OpenDecoder() {
20
 }
21
 
22
 bool AudioFileReader::OpenDecoder() {
23
-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
24
+  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
25
   if (codec) {
26
     // MP3 decodes to S16P which we don't support, tell it to use S16 instead.
27
     if (codec_context_->sample_fmt == AV_SAMPLE_FMT_S16P)
28
--- src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc.orig	2021-12-15 16:12:54 UTC
29
+++ src/3rdparty/chromium/media/filters/ffmpeg_audio_decoder.cc
30
@@ -329,7 +329,7 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioD
31
     }
32
   }
33
 
34
-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
35
+  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
36
   if (!codec ||
37
       avcodec_open2(codec_context_.get(), codec, &codec_options) < 0) {
38
     DLOG(ERROR) << "Could not initialize audio decoder: "
39
--- src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc.orig	2021-12-15 16:12:54 UTC
40
+++ src/3rdparty/chromium/media/filters/ffmpeg_demuxer.cc
41
@@ -98,12 +98,12 @@ static base::TimeDelta ExtractStartTime(AVStream* stre
42
 
43
   // Next try to use the first DTS value, for codecs where we know PTS == DTS
44
   // (excludes all H26x codecs). The start time must be returned in PTS.
45
-  if (stream->first_dts != kNoFFmpegTimestamp &&
46
+  if (av_stream_get_first_dts(stream) != kNoFFmpegTimestamp &&
47
       stream->codecpar->codec_id != AV_CODEC_ID_HEVC &&
48
       stream->codecpar->codec_id != AV_CODEC_ID_H264 &&
49
       stream->codecpar->codec_id != AV_CODEC_ID_MPEG4) {
50
     const base::TimeDelta first_pts =
51
-        ConvertFromTimeBase(stream->time_base, stream->first_dts);
52
+        ConvertFromTimeBase(stream->time_base, av_stream_get_first_dts(stream));
53
     if (first_pts < start_time)
54
       start_time = first_pts;
55
   }
56
@@ -408,11 +408,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket
57
   scoped_refptr<DecoderBuffer> buffer;
58
 
59
   if (type() == DemuxerStream::TEXT) {
60
-    int id_size = 0;
61
+    size_t id_size = 0;
62
     uint8_t* id_data = av_packet_get_side_data(
63
         packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
64
 
65
-    int settings_size = 0;
66
+    size_t settings_size = 0;
67
     uint8_t* settings_data = av_packet_get_side_data(
68
         packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
69
 
70
@@ -424,7 +424,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket
71
     buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
72
                                      side_data.data(), side_data.size());
73
   } else {
74
-    int side_data_size = 0;
75
+    size_t side_data_size = 0;
76
     uint8_t* side_data = av_packet_get_side_data(
77
         packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
78
 
79
@@ -485,7 +485,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket
80
                                        packet->size - data_offset);
81
     }
82
 
83
-    int skip_samples_size = 0;
84
+    size_t skip_samples_size = 0;
85
     const uint32_t* skip_samples_ptr =
86
         reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
87
             packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
88
--- src/3rdparty/chromium/media/filters/ffmpeg_glue.cc.orig	2021-12-15 16:12:54 UTC
89
+++ src/3rdparty/chromium/media/filters/ffmpeg_glue.cc
90
@@ -59,7 +59,6 @@ void FFmpegGlue::InitializeFFmpeg() {
91
 }
92
 
93
 void FFmpegGlue::InitializeFFmpeg() {
94
-  av_register_all();
95
 }
96
 
97
 static void LogContainer(bool is_local_file,
98
@@ -94,9 +93,6 @@ FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol) {
99
 
100
   // Enable fast, but inaccurate seeks for MP3.
101
   format_context_->flags |= AVFMT_FLAG_FAST_SEEK;
102
-
103
-  // Ensures we can read out various metadata bits like vp8 alpha.
104
-  format_context_->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
105
 
106
   // Ensures format parsing errors will bail out. From an audit on 11/2017, all
107
   // instances were real failures. Solves bugs like http://crbug.com/710791.
108
--- src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc.orig	2021-12-15 16:12:54 UTC
109
+++ src/3rdparty/chromium/media/filters/ffmpeg_video_decoder.cc
110
@@ -391,7 +391,7 @@ bool FFmpegVideoDecoder::ConfigureDecoder(const VideoD
111
   if (decode_nalus_)
112
     codec_context_->flags2 |= AV_CODEC_FLAG2_CHUNKS;
113
 
114
-  AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
115
+  const AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
116
   if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
117
     ReleaseFFmpegResources();
118
     return false;
119
--- src/3rdparty/chromium/media/filters/media_file_checker.cc.orig	2021-12-15 16:12:54 UTC
120
+++ src/3rdparty/chromium/media/filters/media_file_checker.cc
121
@@ -68,7 +68,7 @@ bool MediaFileChecker::Start(base::TimeDelta check_tim
122
       auto context = AVStreamToAVCodecContext(format_context->streams[i]);
123
       if (!context)
124
         continue;
125
-      AVCodec* codec = avcodec_find_decoder(cp->codec_id);
126
+      const AVCodec* codec = avcodec_find_decoder(cp->codec_id);
127
       if (codec && avcodec_open2(context.get(), codec, nullptr) >= 0) {
128
         auto loop = std::make_unique<FFmpegDecodingLoop>(context.get());
129
         stream_contexts[i] = {std::move(context), std::move(loop)};
130
--- src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc.orig	2021-12-15 16:12:54 UTC
131
+++ src/3rdparty/chromium/third_party/webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc
132
@@ -203,7 +203,7 @@ int32_t H264DecoderImpl::InitDecode(const VideoCodec* 
133
   // a pointer |this|.
134
   av_context_->opaque = this;
135
 
136
-  AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
137
+  const AVCodec* codec = avcodec_find_decoder(av_context_->codec_id);
138
   if (!codec) {
139
     // This is an indication that FFmpeg has not been initialized or it has not
140
     // been compiled/initialized with the correct set of codecs.

Return to bug 261302