From 091efe9902e547172bd1a0f4afb29797c86c7c2a Mon Sep 17 00:00:00 2001 From: David Guglielmi Date: Sun, 28 Apr 2024 19:08:24 +0200 Subject: [PATCH] media-tv/kodi: removal, available in ::gentoo --- media-tv/kodi/Manifest | 21 - ...-64K-read-chunk-size-when-filesystem.patch | 36 - ...idate-previous-sync-type-after-Audio.patch | 24 - .../kodi/files/kodi-20.5-binutils-2.41.patch | 103 - media-tv/kodi/files/kodi-20.5-ffmpeg5.patch | 2429 ----------------- media-tv/kodi/files/kodi-20.5-ffmpeg6.patch | 624 ----- ...h-in-avcodec_parameters_from_context.patch | 36 - ...tom-destructor-for-AVCodecParameters.patch | 55 - media-tv/kodi/files/kodi-20.5-swig-4.2.patch | 10 - .../kodi-21.0-fix-head-use-after-free.patch | 333 --- media-tv/kodi/kodi-20.5.ebuild | 482 ---- media-tv/kodi/kodi-21.0.ebuild | 490 ---- 12 files changed, 4643 deletions(-) delete mode 100644 media-tv/kodi/Manifest delete mode 100644 media-tv/kodi/files/kodi-20.5-CDVDInputStreamFile-use-64K-read-chunk-size-when-filesystem.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-binutils-2.41.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-ffmpeg5.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-ffmpeg6.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-fix-crash-in-avcodec_parameters_from_context.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-smart_ptr-and-custom-destructor-for-AVCodecParameters.patch delete mode 100644 media-tv/kodi/files/kodi-20.5-swig-4.2.patch delete mode 100644 media-tv/kodi/files/kodi-21.0-fix-head-use-after-free.patch delete mode 100644 media-tv/kodi/kodi-20.5.ebuild delete mode 100644 media-tv/kodi/kodi-21.0.ebuild diff --git a/media-tv/kodi/Manifest b/media-tv/kodi/Manifest deleted file mode 100644 index d6ba95b..0000000 --- a/media-tv/kodi/Manifest +++ /dev/null @@ -1,21 +0,0 @@ -AUX kodi-20.5-CDVDInputStreamFile-use-64K-read-chunk-size-when-filesystem.patch 1326 BLAKE2B 0a0900e464cf92e217c0b228e1b65482894601b5f7a277cbfaa547b1540ff3a5ade7aca05d37df151d2193a58dfa70df7765e83a246992b39b5a118df3ea8a59 SHA512 b4e5ead1d582d409004a091e134d6575857456951907521d4776326315c5db5e6ae9660e2a242c2824676a3afe05fcb21afc73db44bbedc36af135be1f3a082e -AUX kodi-20.5-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch 1010 BLAKE2B e623854a71f0b53b90950fbbf71ee4d666a24c3071c6ae8489d476a8407068e01028a69c8ec5cbff909a646dd15efe7a1807aeee214995ae1486281bce309e30 SHA512 3db461ebad0f922fab7727e902beada28b5b43e2b71d9c6e39bdf9b2a7767d214ea6caf3a975649a27ba77b7a9a93d5e7b1df6c1ec0edf61223855e2463d5115 -AUX kodi-20.5-binutils-2.41.patch 3399 BLAKE2B 5608adfb32777371a71091de237e6173c72c272a5911e999c3e4bde6f0c0f788db644ccf1098ddabbbba7e6d2a0d65fbfa7570f6acf83cd351a6e779dd8b7f5f SHA512 aec2995737c78cf4ae3e9a4e9212f0481664fd91eb83e07d0bd354cede014015929628833e8b5a87fb19dda20d30abc5585d676a69bff3ee0111fb1f21bb87e7 -AUX kodi-20.5-ffmpeg5.patch 94498 BLAKE2B f8244260911df037ec6cdf945fe19dae7e71e98c052c0ce3ec4c9bf5459205bef7696af599b00a86d5b554d0cbc674fed6f7835a45dd6df40ae4e83549e55175 SHA512 9dc21d7e41eac956816330e79e826456566a88c5fdc747be234fe873ff3b9e7241d87dcc6ecd804189fff8b61c027ac4e31e1af0da5de0537f91e8f51b3d96c5 -AUX kodi-20.5-ffmpeg6.patch 24798 BLAKE2B d9ed0a7e8d0d873f46ffe95e84eefb94ca4f5328da80a447acd3996971b3b913a2ce249ddf8b5c4019db58e5fdb158b2c5d1034cd3962c8ca6d6aab34e9c6f15 SHA512 3e419a882a112bc9c12078f9c8f8c31c6eb5546f12e71e558f31a862ac8119999aa1e63c8e42cc654361534024e0483288da3bec62a45c601ecf7694c04a66c2 -AUX kodi-20.5-fix-crash-in-avcodec_parameters_from_context.patch 1351 BLAKE2B 0c1739fbda97c0e5a8064c0242a2d1d2e5db499bf336abc8d0119398aef156128a114f1f8616cee235f09e39752df156d99f3049fd2f13693246526593c5e08f SHA512 34da97b3803b585f90f2e5fced64bc0c7447c36df73384df29f539348bc8d230bbb9fcdfa7a12baf2794d0d0e1493248723e012ebe3ac0862e1d4add06f64b94 -AUX kodi-20.5-smart_ptr-and-custom-destructor-for-AVCodecParameters.patch 2113 BLAKE2B 4e6e3401c8b25297f633ff88457eda364de639e915b210d71a5905877c309bc81cf7d6e748307e76e8b9badca76024e313e7d32d88bba626642d4daa91e63357 SHA512 2b1a50e6f7f5eec62f2dc13cf3afb126cb0a05a5db7c87a5dfc9a4962b45c93c12ea71cb77fa007b4fab2a98109c08b1890a78cc5a85c99b658ac7e9648d0bcd -AUX kodi-20.5-swig-4.2.patch 446 BLAKE2B 6b11113506dce61aa951a3b8c533fa2478a6c686f309c79187dc681fa9ea7e813ac6c902f613b68293e6ce28ce81a30dd5f2705fdc58ab25984bf387a6d9b37c SHA512 8e570d10eff512f45ea926b3cf0af8167cab2ae5097d0e8602634d6948eb064e5196bc60d8a4d6b7a6145bea8a2dd295df0731b9d5e1081879f628520225e336 -AUX kodi-21.0-fix-head-use-after-free.patch 32519 BLAKE2B f5f9d4005da38381bd156307789253c358b32df3284e1eb84848f68d9c9e2b9b854c3801a5e4076ba172801dcd2e655505f446ceee89f5040e129003f85d7f84 SHA512 f654300c5d1d3d0bd49388430b843da4768c7fe225dd50f9908e0494375d22aadb3dc1251fb77af47796971769a872ee6d13ede5dc0b0aaeea07c49bc7e0b940 -DIST apache-groovy-binary-4.0.16.zip 29793704 BLAKE2B 30f77c6400c85821cf78f6ba1070da1e68644531f85f71cf7695443b13b81393cc89d4103eb869d1523f0a22a6e1c3428dcabf4f79c8a2c6eb2a6dea74e84e8f SHA512 743698979c801f3cfb36545888b5303e1e25dae5692bb45cab7ebbe102a6eda31f09abc6978349ad90ecaf630416fc87eacba7781244855e7e771a3c44041fa0 -DIST commons-lang3-3.14.0-bin.tar.gz 9442785 BLAKE2B 2ecdd06f97ac2688220055a08f67da9b859bed3ab00ff41800d5d9a1cebda599db2e816425c10c265dd6827a0ef79fc3dd094a8b3c9b9ae4ceae8f5750a59cf2 SHA512 8e7e62418a49ba810512c13a640a8bf35f878fcd54af32fdaab1111e37817f58b21b475980ba663fba4887e45ef8d88af8ff17796f20d202e929e8e2574546dc -DIST commons-text-1.11.0-bin.tar.gz 3018564 BLAKE2B c32e41c6b8c90dea876caf4c2cedc9358d5e49506bfee7aee42ac6b92dbe8505d5e5d81c860a739bb06214b832cc29e91ddb95f3cfc24515c970302a519a5e43 SHA512 2e94877000dd270b69e2e8cbf49f258a90b4c628b6b6b0814e300a2f0e9c391f0816dceb0707e596ae3b7c9532f93e7a4917df47c77f44b3a810e14042ce5f3f -DIST ffmpeg-kodi-4.4.1-Nexus-Alpha1.tar.gz 13725564 BLAKE2B 51d310e7000aeba657d55341c5fdb540474e197b85062228ab4b314c8309ec11985aa7f105193333fc6106529e8e58c86eafe268190894be8532d0e0b9065fa6 SHA512 8beb04d577b5251e74b0d52f4d130997a8ba94bbd488c7c8309e6b45095c27807e150212888ce3a384b23dff52f8df1a7bde5407bae924ddc363f8125c0616c5 -DIST ffmpeg-kodi-6.0.1-Omega.tar.gz 15437409 BLAKE2B 6424e30c6d354abbbea8a807822ae61589413189e9c4ba7aa51c307179287506b9072626e9745861fe83753c0015b50d179f9b4f298fe9abf74bee13936639af SHA512 945e34840092dc0fd3824eb1af2be79868af2afb4fe13159b19a9bcfc464cc4d53243c13ff065199290e9393ddbf4b1c5c8abccf83a31a31d6c7490e499fd1fc -DIST kodi-20.5-Nexus.tar.gz 54568445 BLAKE2B 15eb409918fa3768528d9abd24c52fd8b94c82699ef2ce10a529278fe25544dc335b66d137ae8ae304511cd92c1c0be34881937ec705ba936f5a4b0d737903f7 SHA512 a47a54ca11e1d3daeddea8c1ae716cd4461e3441de43a026a920c709b2ff5c7e0acc2a5fd4ac8c15f0da1940bd7f21a65eff32203ad8e167603c1576b21d4dcc -DIST kodi-21.0-Omega.tar.gz 40987733 BLAKE2B 33adaf588b3362dc9d184bfb66c36ad5fa2e442255da47db4813f926e73f5a607dd7de809ecf8a4982f985bc8dac53cba17fb9db6a009bb0cdb6284db3b1edb4 SHA512 9c2ca6b6e72197d2b1c26a47cf4ddc209318fcaa5a30ea20475ecc5518c7d1395c2e9cf3e3a75a13334b0505e7b417acdb0d76a20567a0c86841b3e69232625b -DIST libdvdcss-1.4.3-Next-Nexus-Alpha2-2.tar.gz 102124 BLAKE2B 2f503d3ab767094958f7ec10b4ad11ffd02665deee571c8f3c739bef5fc7e2ff84babc5a3fdee638dc095f896b72fe3ce65e6b688674cb5f7b7b77190992688c SHA512 d3be3bfc13c5ea56d8db745c2aab090c99760684fe4c8f62a13d266feb319e9180ceeecf8116bfd2ed90d9accba2c11dbbf93b61ad00f69a40812ebf4eabcdda -DIST libdvdnav-6.1.1-Next-Nexus-Alpha2-2.tar.gz 128547 BLAKE2B db4d05836d8fbb3637ae50bdbfc0e4b612ee6b3be24addfea94ce772c3bf28d58b63a3f252d6f9f016f72f8cbb841cc1820b091226b136f4c4664385a32da73c SHA512 51e6fc033121241354a5f0b3fc9a430577ae3ff6bb7f31445aa548ef4893037fb80eea3b2c6774c81e9ebaf9c45e9b490c98c2c65eb38f9f7daba84b236f7e1d -DIST libdvdread-6.1.3-Next-Nexus-Alpha2-2.tar.gz 110513 BLAKE2B c94feb5a03a12efa5b7767965118d2500a088299ea36f3b82e46d157e45893e6b04503cb50f179ca681bac914457607fab26acfa6e304752b355c407578572d1 SHA512 629a41157d07b8ec0ea1fe89ae5ec48f63047472a862782b805c531ae31a0376fc4dc15175f8280c3ef91d7fa977bacebb1b51232640034a34bab2293210fc5e -EBUILD kodi-20.5.ebuild 12607 BLAKE2B bcf5ac4df923c3c789a56bdb5d93997d3e52b63c480717d18ccd0dd1d6dfa92e309e0e2da79febba946b685295aea9791766bd20fb3ad86055aa93ba96419659 SHA512 d58c5693c42dd1ba6d41d4e8bd0986ae35edb80b63c79619659d51fac5f617bd3cb97631ecd8626d974b75d611fe88c4d53e0ed185c5b11612db9e5bd53b978e -EBUILD kodi-21.0.ebuild 12985 BLAKE2B 1f92981dbf88468dd487878635faa413606d1f23dc4f39b2feb2fabaaeb3ac93c68efd291ddbb67b80bb10fefc3fc0507862d5892d6b1c082cd319b64f845cc0 SHA512 0b5c839b0d0a82fff064ccf818141a343f01377e0644922d15a2b70710923d316f056706b3a5f25f440fa3b7519ceef2996321518e4a552f510dae8c0900b015 diff --git a/media-tv/kodi/files/kodi-20.5-CDVDInputStreamFile-use-64K-read-chunk-size-when-filesystem.patch b/media-tv/kodi/files/kodi-20.5-CDVDInputStreamFile-use-64K-read-chunk-size-when-filesystem.patch deleted file mode 100644 index b749e81..0000000 --- a/media-tv/kodi/files/kodi-20.5-CDVDInputStreamFile-use-64K-read-chunk-size-when-filesystem.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 033988b975d65b791bc4ff282b9461f2b5b1c704 Mon Sep 17 00:00:00 2001 -From: thexai <58434170+thexai@users.noreply.github.com> -Date: Wed, 8 Mar 2023 18:19:51 +0100 -Subject: [PATCH] CDVDInputStreamFile: use 64K read chunk size when filesystem - not has specific requirement - -This is used for media files as MKV, MP4, etc. but not DVD, Blu-Ray that -may have specific blocksize/sectorsize requirements. ---- - .../DVDInputStreams/DVDInputStreamFile.cpp | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFile.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFile.cpp -index bebc68324af47..4214673f081c7 100644 ---- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFile.cpp -+++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamFile.cpp -@@ -142,12 +142,15 @@ BitstreamStats CDVDInputStreamFile::GetBitstreamStats() const - return m_stats; - } - -+// Use value returned by filesystem if is > 1 -+// otherwise defaults to 64K - int CDVDInputStreamFile::GetBlockSize() - { -- if(m_pFile) -- return m_pFile->GetChunkSize(); -- else -- return 0; -+ int chunk = 0; -+ if (m_pFile) -+ chunk = m_pFile->GetChunkSize(); -+ -+ return ((chunk > 1) ? chunk : 64 * 1024); - } - - void CDVDInputStreamFile::SetReadRate(uint32_t rate) diff --git a/media-tv/kodi/files/kodi-20.5-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch b/media-tv/kodi/files/kodi-20.5-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch deleted file mode 100644 index 5992457..0000000 --- a/media-tv/kodi/files/kodi-20.5-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 52a424a3ca743c9a6ad9ab21bea8b17df7999311 Mon Sep 17 00:00:00 2001 -From: mglae -Date: Sun, 16 Apr 2023 19:38:54 +0200 -Subject: [PATCH] VideoPlayerAudio: invalidate previous sync type after Audio - Sink created - -Sync type will be set for the new created Sink ---- - xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp b/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp -index 01be866fcf9ed..2c246da6204f5 100644 ---- a/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp -+++ b/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp -@@ -526,6 +526,8 @@ bool CVideoPlayerAudio::ProcessDecoderOutput(DVDAudioFrame &audioframe) - if (!m_audioSink.Create(audioframe, m_streaminfo.codec, m_synctype == SYNC_RESAMPLE)) - CLog::Log(LOGERROR, "{} - failed to create audio renderer", __FUNCTION__); - -+ m_prevsynctype = -1; -+ - if (m_syncState == IDVDStreamPlayer::SYNC_INSYNC) - m_audioSink.Resume(); - } diff --git a/media-tv/kodi/files/kodi-20.5-binutils-2.41.patch b/media-tv/kodi/files/kodi-20.5-binutils-2.41.patch deleted file mode 100644 index 6ee7a55..0000000 --- a/media-tv/kodi/files/kodi-20.5-binutils-2.41.patch +++ /dev/null @@ -1,103 +0,0 @@ -https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/effadce6c756247ea8bae32dc13bb3e6f464f0eb - -From db99a6e0ed9490478a7af7b6a3299688b1a329e1 Mon Sep 17 00:00:00 2001 -From: Alfred Wingate -Date: Sun, 24 Dec 2023 14:02:37 +0200 -Subject: [PATCH] ffmpeg: add patch to fix build against binutils-2.41 - -Signed-off-by: Alfred Wingate ---- a/cmake/modules/FindFFMPEG.cmake -+++ b/cmake/modules/FindFFMPEG.cmake -@@ -96,7 +96,9 @@ macro(buildFFMPEG) - -DPKG_CONFIG_PATH=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/lib/pkgconfig) - set(PATCH_COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_SOURCE_DIR}/tools/depends/target/ffmpeg/CMakeLists.txt -- ) -+ && -+ # patch internal ffmpeg, fix build against binutils 2.41 -+ patch -p1 < ${CMAKE_SOURCE_DIR}/tools/depends/target/ffmpeg/build-fix-for-binutils-2.41.patch) - - if(CMAKE_GENERATOR STREQUAL Xcode) - set(FFMPEG_GENERATOR CMAKE_GENERATOR "Unix Makefiles") ---- /dev/null -+++ b/tools/depends/target/ffmpeg/build-fix-for-binutils-2.41.patch -@@ -0,0 +1,76 @@ -+From effadce6c756247ea8bae32dc13bb3e6f464f0eb Mon Sep 17 00:00:00 2001 -+From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= -+Date: Sun, 16 Jul 2023 18:18:02 +0300 -+Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift -+ instructions within inline assembly -+ -+Fixes assembling with binutil as >= 2.41 -+ -+Signed-off-by: James Almer -+--- -+ libavcodec/x86/mathops.h | 26 +++++++++++++++++++++++--- -+ 1 file changed, 23 insertions(+), 3 deletions(-) -+ -+diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h -+index 6298f5ed19..ca7e2dffc1 100644 -+--- a/libavcodec/x86/mathops.h -++++ b/libavcodec/x86/mathops.h -+@@ -35,12 +35,20 @@ -+ static av_always_inline av_const int MULL(int a, int b, unsigned shift) -+ { -+ int rt, dummy; -++ if (__builtin_constant_p(shift)) -+ __asm__ ( -+ "imull %3 \n\t" -+ "shrdl %4, %%edx, %%eax \n\t" -+ :"=a"(rt), "=d"(dummy) -+- :"a"(a), "rm"(b), "ci"((uint8_t)shift) -++ :"a"(a), "rm"(b), "i"(shift & 0x1F) -+ ); -++ else -++ __asm__ ( -++ "imull %3 \n\t" -++ "shrdl %4, %%edx, %%eax \n\t" -++ :"=a"(rt), "=d"(dummy) -++ :"a"(a), "rm"(b), "c"((uint8_t)shift) -++ ); -+ return rt; -+ } -+ -+@@ -113,19 +121,31 @@ __asm__ volatile(\ -+ // avoid +32 for shift optimization (gcc should do that ...) -+ #define NEG_SSR32 NEG_SSR32 -+ static inline int32_t NEG_SSR32( int32_t a, int8_t s){ -++ if (__builtin_constant_p(s)) -+ __asm__ ("sarl %1, %0\n\t" -+ : "+r" (a) -+- : "ic" ((uint8_t)(-s)) -++ : "i" (-s & 0x1F) -+ ); -++ else -++ __asm__ ("sarl %1, %0\n\t" -++ : "+r" (a) -++ : "c" ((uint8_t)(-s)) -++ ); -+ return a; -+ } -+ -+ #define NEG_USR32 NEG_USR32 -+ static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ -++ if (__builtin_constant_p(s)) -+ __asm__ ("shrl %1, %0\n\t" -+ : "+r" (a) -+- : "ic" ((uint8_t)(-s)) -++ : "i" (-s & 0x1F) -+ ); -++ else -++ __asm__ ("shrl %1, %0\n\t" -++ : "+r" (a) -++ : "c" ((uint8_t)(-s)) -++ ); -+ return a; -+ } -+ -+-- -+2.25.1 -+ --- -2.43.0 - diff --git a/media-tv/kodi/files/kodi-20.5-ffmpeg5.patch b/media-tv/kodi/files/kodi-20.5-ffmpeg5.patch deleted file mode 100644 index 64c31d2..0000000 --- a/media-tv/kodi/files/kodi-20.5-ffmpeg5.patch +++ /dev/null @@ -1,2429 +0,0 @@ -From 2218c1c37c16df4ce3da34c8566f5e1335a66c01 Mon Sep 17 00:00:00 2001 -From: Alwin Esch -Date: Sun, 10 Jul 2022 18:59:52 +0200 -Subject: [PATCH 1/3] FFmpeg5 port - ---- - xbmc/cdrip/EncoderFFmpeg.cpp | 95 ++++++--------- - xbmc/cdrip/EncoderFFmpeg.h | 1 - - .../AudioEngine/Encoders/AEEncoderFFmpeg.cpp | 111 +++++++++++------- - .../AudioEngine/Engines/ActiveAE/ActiveAE.cpp | 14 +-- - xbmc/cores/FFmpeg.cpp | 14 ++- - xbmc/cores/FFmpeg.h | 26 ++++ - .../DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 12 +- - .../Overlay/DVDOverlayCodecFFmpeg.cpp | 3 +- - .../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 36 +++++- - .../DVDCodecs/Video/DVDVideoPPFFmpeg.cpp | 5 + - .../VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 10 +- - .../DVDDemuxers/DVDDemuxClient.cpp | 3 +- - .../DVDDemuxers/DVDDemuxFFmpeg.cpp | 71 +++++++++-- - .../DVDInputStreams/InputStreamAddon.cpp | 3 +- - xbmc/filesystem/AudioBookFileDirectory.cpp | 3 +- - xbmc/guilib/FFmpegImage.cpp | 6 +- - xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp | 2 +- - xbmc/video/tags/VideoTagLoaderFFmpeg.cpp | 2 +- - 18 files changed, 281 insertions(+), 136 deletions(-) - -diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp -index 2867b7cb67..4c0628b5cc 100644 ---- a/xbmc/cdrip/EncoderFFmpeg.cpp -+++ b/xbmc/cdrip/EncoderFFmpeg.cpp -@@ -11,6 +11,7 @@ - #include "ServiceBroker.h" - #include "addons/Addon.h" - #include "addons/AddonManager.h" -+#include "cores/FFmpeg.h" - #include "settings/Settings.h" - #include "settings/SettingsComponent.h" - #include "utils/StringUtils.h" -@@ -19,23 +20,8 @@ - #include "utils/log.h" - - using namespace KODI::CDRIP; -- --namespace --{ -- --struct EncoderException : public std::exception --{ -- std::string s; -- template -- EncoderException(const std::string& fmt, Args&&... args) -- : s(StringUtils::Format(fmt, std::forward(args)...)) -- { -- } -- ~EncoderException() throw() {} // Updated -- const char* what() const throw() { return s.c_str(); } --}; -- --} /* namespace */ -+using FFMPEG_HELP_TOOLS::FFMpegErrorToString; -+using FFMPEG_HELP_TOOLS::FFMpegException; - - bool CEncoderFFmpeg::Init() - { -@@ -54,7 +40,7 @@ bool CEncoderFFmpeg::Init() - } - else - { -- throw EncoderException("Could not get add-on: {}", addonId); -+ throw FFMpegException("Could not get add-on: {}", addonId); - } - - // Hack fix about PTS on generated files. -@@ -66,45 +52,45 @@ bool CEncoderFFmpeg::Init() - else if (addonId == "audioencoder.kodi.builtin.wma") - m_samplesCountMultiply = 1000; - else -- throw EncoderException("Internal add-on id \"{}\" not known as usable", addonId); -+ throw FFMpegException("Internal add-on id \"{}\" not known as usable", addonId); - - const std::string filename = URIUtils::GetFileName(m_strFile); - - m_formatCtx = avformat_alloc_context(); - if (!m_formatCtx) -- throw EncoderException("Could not allocate output format context"); -+ throw FFMpegException("Could not allocate output format context"); - - m_bcBuffer = static_cast(av_malloc(BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE)); - if (!m_bcBuffer) -- throw EncoderException("Could not allocate buffer"); -+ throw FFMpegException("Could not allocate buffer"); - - m_formatCtx->pb = avio_alloc_context(m_bcBuffer, BUFFER_SIZE, AVIO_FLAG_WRITE, this, nullptr, - avio_write_callback, avio_seek_callback); - if (!m_formatCtx->pb) -- throw EncoderException("Failed to allocate ByteIOContext"); -+ throw FFMpegException("Failed to allocate ByteIOContext"); - - /* Guess the desired container format based on the file extension. */ - m_formatCtx->oformat = av_guess_format(nullptr, filename.c_str(), nullptr); - if (!m_formatCtx->oformat) -- throw EncoderException("Could not find output file format"); -+ throw FFMpegException("Could not find output file format"); - - m_formatCtx->url = av_strdup(filename.c_str()); - if (!m_formatCtx->url) -- throw EncoderException("Could not allocate url"); -+ throw FFMpegException("Could not allocate url"); - - /* Find the encoder to be used by its name. */ -- AVCodec* codec = avcodec_find_encoder(m_formatCtx->oformat->audio_codec); -+ FFMPEG_FMT_CONST AVCodec* codec = avcodec_find_encoder(m_formatCtx->oformat->audio_codec); - if (!codec) -- throw EncoderException("Unable to find a suitable FFmpeg encoder"); -+ throw FFMpegException("Unable to find a suitable FFmpeg encoder"); - - /* Create a new audio stream in the output file container. */ - m_stream = avformat_new_stream(m_formatCtx, nullptr); - if (!m_stream) -- throw EncoderException("Failed to allocate AVStream context"); -+ throw FFMpegException("Failed to allocate AVStream context"); - - m_codecCtx = avcodec_alloc_context3(codec); - if (!m_codecCtx) -- throw EncoderException("Failed to allocate the encoder context"); -+ throw FFMpegException("Failed to allocate the encoder context"); - - /* Set the basic encoder parameters. - * The input file's sample rate is used to avoid a sample rate conversion. */ -@@ -128,14 +114,14 @@ bool CEncoderFFmpeg::Init() - - int err = avcodec_open2(m_codecCtx, codec, nullptr); - if (err < 0) -- throw EncoderException("Failed to open the codec {} (error '{}')", -- codec->long_name ? codec->long_name : codec->name, -- FFmpegErrorToString(err)); -+ throw FFMpegException("Failed to open the codec {} (error '{}')", -+ codec->long_name ? codec->long_name : codec->name, -+ FFMpegErrorToString(err)); - - err = avcodec_parameters_from_context(m_stream->codecpar, m_codecCtx); - if (err < 0) -- throw EncoderException("Failed to copy encoder parameters to output stream (error '{}')", -- FFmpegErrorToString(err)); -+ throw FFMpegException("Failed to copy encoder parameters to output stream (error '{}')", -+ FFMpegErrorToString(err)); - - m_inFormat = GetInputFormat(m_iInBitsPerSample); - m_outFormat = m_codecCtx->sample_fmt; -@@ -150,7 +136,7 @@ bool CEncoderFFmpeg::Init() - - m_bufferFrame = av_frame_alloc(); - if (!m_bufferFrame || !m_buffer) -- throw EncoderException("Failed to allocate necessary buffers"); -+ throw FFMpegException("Failed to allocate necessary buffers"); - - m_bufferFrame->nb_samples = m_codecCtx->frame_size; - m_bufferFrame->format = m_inFormat; -@@ -159,8 +145,8 @@ bool CEncoderFFmpeg::Init() - - err = av_frame_get_buffer(m_bufferFrame, 0); - if (err < 0) -- throw EncoderException("Could not allocate output frame samples (error '{}')", -- FFmpegErrorToString(err)); -+ throw FFMpegException("Could not allocate output frame samples (error '{}')", -+ FFMpegErrorToString(err)); - - avcodec_fill_audio_frame(m_bufferFrame, m_iInChannels, m_inFormat, m_buffer, m_neededBytes, 0); - -@@ -170,14 +156,14 @@ bool CEncoderFFmpeg::Init() - m_codecCtx->sample_rate, m_codecCtx->channel_layout, m_inFormat, - m_codecCtx->sample_rate, 0, nullptr); - if (!m_swrCtx || swr_init(m_swrCtx) < 0) -- throw EncoderException("Failed to initialize the resampler"); -+ throw FFMpegException("Failed to initialize the resampler"); - - m_resampledBufferSize = - av_samples_get_buffer_size(nullptr, m_iInChannels, m_neededFrames, m_outFormat, 0); - m_resampledBuffer = static_cast(av_malloc(m_resampledBufferSize)); - m_resampledFrame = av_frame_alloc(); - if (!m_resampledBuffer || !m_resampledFrame) -- throw EncoderException("Failed to allocate a frame for resampling"); -+ throw FFMpegException("Failed to allocate a frame for resampling"); - - m_resampledFrame->nb_samples = m_neededFrames; - m_resampledFrame->format = m_outFormat; -@@ -186,8 +172,8 @@ bool CEncoderFFmpeg::Init() - - err = av_frame_get_buffer(m_resampledFrame, 0); - if (err < 0) -- throw EncoderException("Could not allocate output resample frame samples (error '{}')", -- FFmpegErrorToString(err)); -+ throw FFMpegException("Could not allocate output resample frame samples (error '{}')", -+ FFMpegErrorToString(err)); - - avcodec_fill_audio_frame(m_resampledFrame, m_iInChannels, m_outFormat, m_resampledBuffer, - m_resampledBufferSize, 0); -@@ -204,7 +190,7 @@ bool CEncoderFFmpeg::Init() - /* write the header */ - err = avformat_write_header(m_formatCtx, nullptr); - if (err != 0) -- throw EncoderException("Failed to write the header (error '{}')", FFmpegErrorToString(err)); -+ throw FFMpegException("Failed to write the header (error '{}')", FFMpegErrorToString(err)); - - CLog::Log(LOGDEBUG, "CEncoderFFmpeg::{} - Successfully initialized with muxer {} and codec {}", - __func__, -@@ -212,7 +198,7 @@ bool CEncoderFFmpeg::Init() - : m_formatCtx->oformat->name, - codec->long_name ? codec->long_name : codec->name); - } -- catch (EncoderException& caught) -+ catch (const FFMpegException& caught) - { - CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what()); - -@@ -299,7 +285,7 @@ bool CEncoderFFmpeg::WriteFrame() - if (swr_convert(m_swrCtx, m_resampledFrame->data, m_neededFrames, - const_cast(m_bufferFrame->extended_data), - m_neededFrames) < 0) -- throw EncoderException("Error resampling audio"); -+ throw FFMpegException("Error resampling audio"); - - frame = m_resampledFrame; - } -@@ -316,8 +302,8 @@ bool CEncoderFFmpeg::WriteFrame() - m_bufferSize = 0; - err = avcodec_send_frame(m_codecCtx, frame); - if (err < 0) -- throw EncoderException("Error sending a frame for encoding (error '{}')", __func__, -- FFmpegErrorToString(err)); -+ throw FFMpegException("Error sending a frame for encoding (error '{}')", -+ FFMpegErrorToString(err)); - - while (err >= 0) - { -@@ -329,19 +315,18 @@ bool CEncoderFFmpeg::WriteFrame() - } - else if (err < 0) - { -- throw EncoderException("Error during encoding (error '{}')", __func__, -- FFmpegErrorToString(err)); -+ throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err)); - } - - err = av_write_frame(m_formatCtx, pkt); - if (err < 0) -- throw EncoderException("Failed to write the frame data (error '{}')", __func__, -- FFmpegErrorToString(err)); -+ throw FFMpegException("Failed to write the frame data (error '{}')", -+ FFMpegErrorToString(err)); - - av_packet_unref(pkt); - } - } -- catch (EncoderException& caught) -+ catch (const FFMpegException& caught) - { - CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what()); - } -@@ -400,14 +385,6 @@ AVSampleFormat CEncoderFFmpeg::GetInputFormat(int inBitsPerSample) - case 32: - return AV_SAMPLE_FMT_S32; - default: -- throw EncoderException("Invalid input bits per sample"); -+ throw FFMpegException("Invalid input bits per sample"); - } - } -- --std::string CEncoderFFmpeg::FFmpegErrorToString(int err) --{ -- std::string text; -- text.reserve(AV_ERROR_MAX_STRING_SIZE); -- av_strerror(err, text.data(), AV_ERROR_MAX_STRING_SIZE); -- return text; --} -diff --git a/xbmc/cdrip/EncoderFFmpeg.h b/xbmc/cdrip/EncoderFFmpeg.h -index 39112ba3ba..0c2391c7ab 100644 ---- a/xbmc/cdrip/EncoderFFmpeg.h -+++ b/xbmc/cdrip/EncoderFFmpeg.h -@@ -39,7 +39,6 @@ private: - void SetTag(const std::string& tag, const std::string& value); - bool WriteFrame(); - AVSampleFormat GetInputFormat(int inBitsPerSample); -- std::string FFmpegErrorToString(int err); - - AVFormatContext* m_formatCtx{nullptr}; - AVCodecContext* m_codecCtx{nullptr}; -diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -index 09bb26a327..86f65f57f3 100644 ---- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -+++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -@@ -10,13 +10,24 @@ - #define DTS_ENCODE_BITRATE 1411200 - - #include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h" --#include "cores/AudioEngine/Utils/AEUtil.h" -+ - #include "ServiceBroker.h" --#include "utils/log.h" -+#include "cores/AudioEngine/Utils/AEUtil.h" -+#include "cores/FFmpeg.h" - #include "settings/Settings.h" - #include "settings/SettingsComponent.h" --#include -+#include "utils/log.h" -+ -+extern "C" -+{ -+#include -+} -+ - #include -+#include -+ -+using FFMPEG_HELP_TOOLS::FFMpegErrorToString; -+using FFMPEG_HELP_TOOLS::FFMpegException; - - CAEEncoderFFmpeg::CAEEncoderFFmpeg() : m_CodecCtx(NULL), m_SwrCtx(NULL) - { -@@ -81,7 +92,7 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input - - bool ac3 = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_AUDIOOUTPUT_AC3PASSTHROUGH); - -- AVCodec *codec = NULL; -+ FFMPEG_FMT_CONST AVCodec* codec = nullptr; - - /* fallback to ac3 if we support it, we might not have DTS support */ - if (ac3) -@@ -242,63 +253,77 @@ unsigned int CAEEncoderFFmpeg::GetFrames() - - int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_size) - { -- int got_output; -- AVFrame *frame; -+ int size = 0; -+ int err = AVERROR_UNKNOWN; -+ AVFrame* frame = nullptr; -+ AVPacket* pkt = nullptr; - - if (!m_CodecCtx) -- return 0; -- -- /* allocate the input frame -- * sadly, we have to alloc/dealloc it everytime since we have no guarantee the -- * data argument will be constant over iterated calls and the frame needs to -- * setup pointers inside data */ -- frame = av_frame_alloc(); -- if (!frame) -- return 0; -+ return size; - -- frame->nb_samples = m_CodecCtx->frame_size; -- frame->format = m_CodecCtx->sample_fmt; -- frame->channel_layout = m_CodecCtx->channel_layout; -- frame->channels = m_CodecCtx->channels; -+ try -+ { -+ /* allocate the input frame and output packet -+ * sadly, we have to alloc/dealloc it everytime since we have no guarantee the -+ * data argument will be constant over iterated calls and the frame needs to -+ * setup pointers inside data */ -+ frame = av_frame_alloc(); -+ pkt = av_packet_alloc(); -+ if (!frame || !pkt) -+ throw FFMpegException( -+ "Failed to allocate \"AVFrame\" or \"AVPacket\" for encoding (error '{}')", -+ strerror(errno)); -+ -+ frame->nb_samples = m_CodecCtx->frame_size; -+ frame->format = m_CodecCtx->sample_fmt; -+ frame->channel_layout = m_CodecCtx->channel_layout; -+ frame->channels = m_CodecCtx->channels; -+ -+ avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, in, in_size, 0); -+ -+ pkt->size = out_size; -+ pkt->data = out; -+ -+ /* encode it */ -+ err = avcodec_send_frame(m_CodecCtx, frame); -+ if (err < 0) -+ throw FFMpegException("Error sending a frame for encoding (error '{}')", -+ FFMpegErrorToString(err)); -+ -+ while (err >= 0) -+ { -+ err = avcodec_receive_packet(m_CodecCtx, pkt); -+ if (err == AVERROR(EAGAIN) || err == AVERROR_EOF) -+ { -+ av_frame_free(&frame); -+ av_packet_free(&pkt); -+ return (err == AVERROR(EAGAIN)) ? -1 : 0; -+ } -+ else if (err < 0) -+ { -+ throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err)); -+ } - -- avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, -- in, in_size, 0); -+ av_packet_unref(pkt); -+ } - -- /* initialize the output packet */ -- AVPacket* pkt = av_packet_alloc(); -- if (!pkt) -+ size = pkt->size; -+ } -+ catch (const FFMpegException& caught) - { -- CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - av_packet_alloc failed: {}", __FUNCTION__, -- strerror(errno)); -- av_frame_free(&frame); -- return 0; -+ CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - {}", __func__, caught.what()); - } - -- pkt->size = out_size; -- pkt->data = out; -- -- /* encode it */ -- int ret = avcodec_encode_audio2(m_CodecCtx, pkt, frame, &got_output); -- -- int size = pkt->size; -- - /* free temporary data */ - av_frame_free(&frame); - - /* free the packet */ - av_packet_free(&pkt); - -- if (ret < 0 || !got_output) -- { -- CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Encode - Encoding failed"); -- return 0; -- } -- - /* return the number of frames used */ - return size; - } - -- - int CAEEncoderFFmpeg::GetData(uint8_t **data) - { - int size; -diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -index 3947dd5523..6000fe9c63 100644 ---- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -@@ -16,17 +16,17 @@ using namespace ActiveAE; - #include "ActiveAESound.h" - #include "ActiveAEStream.h" - #include "ServiceBroker.h" -+#include "cores/AudioEngine/AEResampleFactory.h" -+#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h" - #include "cores/AudioEngine/Interfaces/IAudioCallback.h" --#include "cores/AudioEngine/Utils/AEUtil.h" - #include "cores/AudioEngine/Utils/AEStreamData.h" - #include "cores/AudioEngine/Utils/AEStreamInfo.h" --#include "cores/AudioEngine/AEResampleFactory.h" --#include "cores/AudioEngine/Encoders/AEEncoderFFmpeg.h" -- -+#include "cores/AudioEngine/Utils/AEUtil.h" -+#include "cores/FFmpeg.h" - #include "settings/Settings.h" - #include "settings/SettingsComponent.h" --#include "windowing/WinSystem.h" - #include "utils/log.h" -+#include "windowing/WinSystem.h" - - using namespace std::chrono_literals; - -@@ -3016,8 +3016,8 @@ IAE::SoundPtr CActiveAE::MakeSound(const std::string& file) - AVFormatContext *fmt_ctx = nullptr; - AVCodecContext *dec_ctx = nullptr; - AVIOContext *io_ctx; -- AVInputFormat *io_fmt = nullptr; -- AVCodec *dec = nullptr; -+ FFMPEG_FMT_CONST AVInputFormat* io_fmt = nullptr; -+ FFMPEG_FMT_CONST AVCodec* dec = nullptr; - SampleConfig config; - - // No custom deleter until sound is registered -diff --git a/xbmc/cores/FFmpeg.cpp b/xbmc/cores/FFmpeg.cpp -index 03a29f7db4..de1765ed52 100644 ---- a/xbmc/cores/FFmpeg.cpp -+++ b/xbmc/cores/FFmpeg.cpp -@@ -21,6 +21,19 @@ - - static thread_local CFFmpegLog* CFFmpegLogTls; - -+namespace FFMPEG_HELP_TOOLS -+{ -+ -+std::string FFMpegErrorToString(int err) -+{ -+ std::string text; -+ text.resize(AV_ERROR_MAX_STRING_SIZE); -+ av_strerror(err, text.data(), AV_ERROR_MAX_STRING_SIZE); -+ return text; -+} -+ -+} // namespace FFMPEG_HELP_TOOLS -+ - void CFFmpegLog::SetLogLevel(int level) - { - CFFmpegLog::ClearLogLevel(); -@@ -116,4 +129,3 @@ void ff_avutil_log(void* ptr, int level, const char* format, va_list va) - } - buffer.erase(0, start); - } -- -diff --git a/xbmc/cores/FFmpeg.h b/xbmc/cores/FFmpeg.h -index e1194d19e9..8230701ba7 100644 ---- a/xbmc/cores/FFmpeg.h -+++ b/xbmc/cores/FFmpeg.h -@@ -10,6 +10,7 @@ - - #include "ServiceBroker.h" - #include "utils/CPUInfo.h" -+#include "utils/StringUtils.h" - - extern "C" { - #include -@@ -21,6 +22,31 @@ extern "C" { - #include - } - -+// https://github.com/FFmpeg/FFmpeg/blob/56450a0ee4/doc/APIchanges#L18-L26 -+#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(59, 0, 100) -+#define FFMPEG_FMT_CONST const -+#else -+#define FFMPEG_FMT_CONST -+#endif -+ -+namespace FFMPEG_HELP_TOOLS -+{ -+ -+struct FFMpegException : public std::exception -+{ -+ std::string s; -+ template -+ FFMpegException(const std::string& fmt, Args&&... args) -+ : s(StringUtils::Format(fmt, std::forward(args)...)) -+ { -+ } -+ const char* what() const noexcept override { return s.c_str(); } -+}; -+ -+std::string FFMpegErrorToString(int err); -+ -+} // namespace FFMPEG_HELP_TOOLS -+ - inline int PPCPUFlags() - { - unsigned int cpuFeatures = CServiceBroker::GetCPUInfo()->GetCPUFeatures(); -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -index 25f3f08e1f..87e7ae2c57 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -@@ -7,14 +7,16 @@ - */ - - #include "DVDAudioCodecFFmpeg.h" --#include "ServiceBroker.h" -+ - #include "../../DVDStreamInfo.h" --#include "utils/log.h" -+#include "DVDCodecs/DVDCodecs.h" -+#include "ServiceBroker.h" -+#include "cores/AudioEngine/Utils/AEUtil.h" -+#include "cores/FFmpeg.h" - #include "settings/AdvancedSettings.h" - #include "settings/Settings.h" - #include "settings/SettingsComponent.h" --#include "DVDCodecs/DVDCodecs.h" --#include "cores/AudioEngine/Utils/AEUtil.h" -+#include "utils/log.h" - - extern "C" { - #include -@@ -44,7 +46,7 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options - return false; - } - -- AVCodec* pCodec = NULL; -+ FFMPEG_FMT_CONST AVCodec* pCodec = nullptr; - bool allowdtshddecode = true; - - // set any special options -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp -index 8c26cad306..3657fc093c 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp -@@ -10,6 +10,7 @@ - - #include "DVDOverlayImage.h" - #include "DVDStreamInfo.h" -+#include "cores/FFmpeg.h" - #include "cores/VideoPlayer/Interface/DemuxPacket.h" - #include "cores/VideoPlayer/Interface/TimingConstants.h" - #include "utils/EndianSwap.h" -@@ -39,7 +40,7 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio - if (hints.codec == AV_CODEC_ID_EIA_608) - return false; - -- AVCodec* pCodec = avcodec_find_decoder(hints.codec); -+ FFMPEG_FMT_CONST AVCodec* pCodec = avcodec_find_decoder(hints.codec); - if (!pCodec) - { - CLog::Log(LOGDEBUG, "{} - Unable to find codec {}", __FUNCTION__, hints.codec); -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -index 881c02ec12..21b5e834b2 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -@@ -12,6 +12,7 @@ - #include "DVDCodecs/DVDFactoryCodec.h" - #include "DVDStreamInfo.h" - #include "ServiceBroker.h" -+#include "cores/FFmpeg.h" - #include "cores/VideoPlayer/Interface/TimingConstants.h" - #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" - #include "cores/VideoSettings.h" -@@ -27,12 +28,13 @@ - #include - - extern "C" { --#include --#include - #include - #include - #include -+#include -+#include - #include -+#include - } - - #ifndef TARGET_POSIX -@@ -327,7 +329,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options - m_hints = hints; - m_options = options; - -- AVCodec* pCodec = nullptr; -+ FFMPEG_FMT_CONST AVCodec* pCodec = nullptr; - - m_iOrientation = hints.orientation; - -@@ -1048,6 +1050,33 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(VideoPicture* pVideoPicture) - pVideoPicture->qscale_type = 0; - - AVFrameSideData* sd; -+ -+ // https://github.com/FFmpeg/FFmpeg/blob/991d417692/doc/APIchanges#L18-L20 -+ // basilgello: AV_VIDEO_ENC_PARAMS_MPEG2 is introduced in 4.4! -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(58, 134, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(56, 45, 100) -+ sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_VIDEO_ENC_PARAMS); -+ if (sd) -+ { -+ unsigned int mb_h = (m_pFrame->height + 15) / 16; -+ unsigned int mb_w = (m_pFrame->width + 15) / 16; -+ unsigned int nb_mb = mb_h * mb_w; -+ unsigned int block_idx; -+ -+ auto par = reinterpret_cast(sd->data); -+ if (par->type == AV_VIDEO_ENC_PARAMS_MPEG2 && (par->nb_blocks == 0 || par->nb_blocks == nb_mb)) -+ { -+ pVideoPicture->qstride = mb_w; -+ pVideoPicture->qscale_type = par->type; -+ pVideoPicture->qp_table = static_cast(av_malloc(nb_mb)); -+ for (block_idx = 0; block_idx < nb_mb; block_idx++) -+ { -+ AVVideoBlockParams* b = av_video_enc_params_block(par, block_idx); -+ pVideoPicture->qp_table[block_idx] = par->qp + b->delta_qp; -+ } -+ } -+ } -+#else - sd = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_QP_TABLE_PROPERTIES); - if (sd) - { -@@ -1068,6 +1097,7 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(VideoPicture* pVideoPicture) - pVideoPicture->qscale_type = qp->type; - } - } -+#endif - - pVideoPicture->pict_type = m_pFrame->pict_type; - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp -index a98fbb1710..3b2739cd22 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoPPFFmpeg.cpp -@@ -118,6 +118,11 @@ void CDVDVideoPPFFmpeg::Process(VideoPicture* pPicture) - m_pMode, m_pContext, - pSource->pict_type | pSource->qscale_type ? PP_PICT_TYPE_QP2 : 0); - -+ // https://github.com/FFmpeg/FFmpeg/blob/991d417692/doc/APIchanges#L18-L20 -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(58, 84, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(56, 45, 100) -+ av_free(pSource->qp_table); -+#endif - - pPicture->SetParams(*pSource); - if (pPicture->videoBuffer) -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -index 7ad891083c..eaf7b78d32 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -@@ -1259,8 +1259,16 @@ void CDecoder::ReturnRenderPicture(CVaapiRenderPicture *renderPic) - - IHardwareDecoder* CDecoder::Create(CDVDStreamInfo &hint, CProcessInfo &processInfo, AVPixelFormat fmt) - { -- if (fmt == AV_PIX_FMT_VAAPI_VLD && CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_USEVAAPI)) -+ // https://github.com/FFmpeg/FFmpeg/blob/56450a0ee4fdda160f4039fc2ae33edfd27765c9/doc/APIchanges#L18-L26 -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(55, 8, 0) -+#define PIX_FMT_VAAPI AV_PIX_FMT_VAAPI -+#else -+#define PIX_FMT_VAAPI AV_PIX_FMT_VAAPI_VLD -+#endif -+ if (fmt == PIX_FMT_VAAPI && -+ CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(SETTING_VIDEOPLAYER_USEVAAPI)) - return new VAAPI::CDecoder(processInfo); -+#undef PIX_FMT_VAAPI - - return nullptr; - } -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -index 2bdc3ea5a9..5be134e381 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -@@ -10,6 +10,7 @@ - - #include "DVDDemuxUtils.h" - #include "DVDInputStreams/DVDInputStream.h" -+#include "cores/FFmpeg.h" - #include "cores/VideoPlayer/Interface/TimingConstants.h" - #include "utils/log.h" - -@@ -130,7 +131,7 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - - if (stream->m_context == nullptr) - { -- AVCodec *codec = avcodec_find_decoder(st->codec); -+ FFMPEG_FMT_CONST AVCodec* codec = avcodec_find_decoder(st->codec); - if (codec == nullptr) - { - CLog::Log(LOGERROR, "{} - can't find decoder", __FUNCTION__); -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -index 739bf51922..bf6f322274 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -@@ -38,6 +38,7 @@ - - extern "C" - { -+#include "libavutil/channel_layout.h" - #include "libavutil/pixdesc.h" - } - -@@ -235,7 +236,7 @@ bool CDVDDemuxFFmpeg::Aborted() - - bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool fileinfo) - { -- AVInputFormat* iformat = NULL; -+ FFMPEG_FMT_CONST AVInputFormat* iformat = nullptr; - std::string strFile; - m_streaminfo = !pInput->IsRealtime() && !m_reopen; - m_reopen = false; -@@ -422,9 +423,7 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool - // is present, we assume it is PCM audio. - // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS - // may be just padded. -- AVInputFormat* iformat2; -- iformat2 = av_find_input_format("spdif"); -- -+ FFMPEG_FMT_CONST AVInputFormat* iformat2 = av_find_input_format("spdif"); - if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4) - { - iformat = iformat2; -@@ -544,11 +543,14 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool - m_streaminfo = true; - } - -+ // https://github.com/FFmpeg/FFmpeg/blob/56450a0ee4/doc/APIchanges#L18-L26 -+#if LIBAVFORMAT_BUILD < AV_VERSION_INT(59, 0, 100) - if (iformat && (strcmp(iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0)) - { - if (URIUtils::IsRemote(strFile)) - m_pFormatContext->iformat->flags |= AVFMT_NOGENSEARCH; - } -+#endif - - // we need to know if this is matroska, avi or sup later - m_bMatroska = strncmp(m_pFormatContext->iformat->name, "matroska", 8) == 0; // for "matroska.webm" -@@ -604,8 +606,11 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool - // if format can be nonblocking, let's use that - m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK; - -- // deprecated, will be always set in future versions -+ // https://github.com/FFmpeg/FFmpeg/blob/d682ae70b4/doc/APIchanges#L18-L21 -+#if LIBAVFORMAT_BUILD < AV_VERSION_INT(57, 66, 105) && \ -+ LIBAVCODEC_BUILD < AV_VERSION_INT(57, 83, 101) - m_pFormatContext->flags |= AVFMT_FLAG_KEEP_SIDE_DATA; -+#endif - - UpdateCurrentPTS(); - -@@ -647,12 +652,24 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool - { - int idx = m_pFormatContext->programs[i]->stream_index[j]; - AVStream* st = m_pFormatContext->streams[idx]; -+#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(59, 3, 100) -+ // Related to https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210429143825.53040-1-jamrial@gmail.com/ -+ // has been replaced with AVSTREAM_EVENT_FLAG_NEW_PACKETS. -+ if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && -+ (st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)) || -+ (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate > 0)) -+ { -+ nProgram = i; -+ break; -+ } -+#else - if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 0) || - (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate > 0)) - { - nProgram = i; - break; - } -+#endif - } - } - } -@@ -1401,11 +1418,19 @@ void CDVDDemuxFFmpeg::UpdateCurrentPTS() - if (idx >= 0) - { - AVStream* stream = m_pFormatContext->streams[idx]; -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 17, 100) -+ if (stream && m_pkt.pkt.dts != (int64_t)AV_NOPTS_VALUE) -+ { -+ double ts = ConvertTimestamp(m_pkt.pkt.dts, stream->time_base.den, stream->time_base.num); -+ m_currentPts = ts; -+ } -+#else - if (stream && stream->cur_dts != (int64_t)AV_NOPTS_VALUE) - { - double ts = ConvertTimestamp(stream->cur_dts, stream->time_base.den, stream->time_base.num); - m_currentPts = ts; - } -+#endif - } - } - -@@ -1621,7 +1646,12 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) - st->iBitsPerSample = pStream->codecpar->bits_per_raw_sample; - st->iChannelLayout = pStream->codecpar->channel_layout; - char buf[32] = {}; -+ // https://github.com/FFmpeg/FFmpeg/blob/6ccc3989d15/doc/APIchanges#L50-L53 -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 24, 100) -+ av_channel_layout_describe(st->iChannelLayout, buf, sizeof(buf)); -+#else - av_get_channel_layout_string(buf, 31, st->iChannels, st->iChannelLayout); -+#endif - st->m_channelLayoutName = buf; - if (st->iBitsPerSample == 0) - st->iBitsPerSample = pStream->codecpar->bits_per_coded_sample; -@@ -1663,6 +1693,7 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) - st->iFpsScale = 0; - } - -+#if LIBAVFORMAT_BUILD < AV_VERSION_INT(59, 3, 100) - if (pStream->codec_info_nb_frames > 0 && - pStream->codec_info_nb_frames <= 2 && - m_pInput->IsStreamType(DVDSTREAM_TYPE_DVD)) -@@ -1672,6 +1703,7 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) - st->iFpsRate = 0; - st->iFpsScale = 0; - } -+#endif - - st->iWidth = pStream->codecpar->width; - st->iHeight = pStream->codecpar->height; -@@ -1693,7 +1725,12 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) - st->colorRange = pStream->codecpar->color_range; - st->hdr_type = DetermineHdrType(pStream); - -+ // https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/APIchanges -+#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(59, 10, 100) -+ size_t size = 0; -+#else - int size = 0; -+#endif - uint8_t* side_data = nullptr; - - side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size); -@@ -2103,7 +2140,7 @@ std::string CDVDDemuxFFmpeg::GetStreamCodecName(int iStreamId) - return strName; - } - -- AVCodec* codec = avcodec_find_decoder(stream->codec); -+ FFMPEG_FMT_CONST AVCodec* codec = avcodec_find_decoder(stream->codec); - if (codec) - strName = avcodec_get_name(codec->id); - } -@@ -2279,7 +2316,7 @@ void CDVDDemuxFFmpeg::ParsePacket(AVPacket* pkt) - - parser->second->m_parserCtx = av_parser_init(st->codecpar->codec_id); - -- AVCodec* codec = avcodec_find_decoder(st->codecpar->codec_id); -+ FFMPEG_FMT_CONST AVCodec* codec = avcodec_find_decoder(st->codecpar->codec_id); - if (codec == nullptr) - { - CLog::Log(LOGERROR, "{} - can't find decoder", __FUNCTION__); -@@ -2357,7 +2394,12 @@ TRANSPORT_STREAM_STATE CDVDDemuxFFmpeg::TransportStreamAudioState() - { - if (!m_startTime) - { -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 17, 100) -+ m_startTime = -+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; -+#else - m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; -+#endif - m_seekStream = idx; - } - return TRANSPORT_STREAM_STATE::READY; -@@ -2377,7 +2419,12 @@ TRANSPORT_STREAM_STATE CDVDDemuxFFmpeg::TransportStreamAudioState() - { - if (!m_startTime) - { -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 17, 100) -+ m_startTime = -+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; -+#else - m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; -+#endif - m_seekStream = i; - } - return TRANSPORT_STREAM_STATE::READY; -@@ -2410,7 +2457,12 @@ TRANSPORT_STREAM_STATE CDVDDemuxFFmpeg::TransportStreamVideoState() - { - if (!m_startTime) - { -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 17, 100) -+ m_startTime = -+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; -+#else - m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; -+#endif - m_seekStream = idx; - } - return TRANSPORT_STREAM_STATE::READY; -@@ -2430,7 +2482,12 @@ TRANSPORT_STREAM_STATE CDVDDemuxFFmpeg::TransportStreamVideoState() - { - if (!m_startTime) - { -+#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 17, 100) -+ m_startTime = -+ av_rescale(m_pkt.pkt.dts, st->time_base.num, st->time_base.den) - 0.000001; -+#else - m_startTime = av_rescale(st->cur_dts, st->time_base.num, st->time_base.den) - 0.000001; -+#endif - m_seekStream = i; - } - return TRANSPORT_STREAM_STATE::READY; -diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp -index b8494e504e..392853cc68 100644 ---- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp -+++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp -@@ -12,6 +12,7 @@ - #include "addons/addoninfo/AddonType.h" - #include "addons/binary-addons/AddonDll.h" - #include "addons/kodi-dev-kit/include/kodi/addon-instance/VideoCodec.h" -+#include "cores/FFmpeg.h" - #include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" - #include "cores/VideoPlayer/DVDDemuxers/DVDDemuxUtils.h" - #include "cores/VideoPlayer/Interface/DemuxCrypto.h" -@@ -392,7 +393,7 @@ KODI_HANDLE CInputStreamAddon::cb_get_stream_transfer(KODI_HANDLE handle, - return nullptr; - - std::string codecName(stream->m_codecName); -- AVCodec* codec = nullptr; -+ FFMPEG_FMT_CONST AVCodec* codec = nullptr; - - if (stream->m_streamType != INPUTSTREAM_TYPE_TELETEXT && - stream->m_streamType != INPUTSTREAM_TYPE_RDS && stream->m_streamType != INPUTSTREAM_TYPE_ID3) -diff --git a/xbmc/filesystem/AudioBookFileDirectory.cpp b/xbmc/filesystem/AudioBookFileDirectory.cpp -index 04d1c14343..d82b2a9bbd 100644 ---- a/xbmc/filesystem/AudioBookFileDirectory.cpp -+++ b/xbmc/filesystem/AudioBookFileDirectory.cpp -@@ -11,6 +11,7 @@ - #include "TextureDatabase.h" - #include "URL.h" - #include "Util.h" -+#include "cores/FFmpeg.h" - #include "filesystem/File.h" - #include "guilib/LocalizeStrings.h" - #include "music/tags/MusicInfoTag.h" -@@ -149,7 +150,7 @@ bool CAudioBookFileDirectory::ContainsFiles(const CURL& url) - - m_ioctx->max_packet_size = 32768; - -- AVInputFormat* iformat=nullptr; -+ FFMPEG_FMT_CONST AVInputFormat* iformat = nullptr; - av_probe_input_buffer(m_ioctx, &iformat, url.Get().c_str(), nullptr, 0, 0); - - bool contains = false; -diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp -index fa255278b7..9d01a21f38 100644 ---- a/xbmc/guilib/FFmpegImage.cpp -+++ b/xbmc/guilib/FFmpegImage.cpp -@@ -52,7 +52,7 @@ struct ThumbDataManagement - AVFrame* frame_temporary = nullptr; - SwsContext* sws = nullptr; - AVCodecContext* avOutctx = nullptr; -- AVCodec* codec = nullptr; -+ FFMPEG_FMT_CONST AVCodec* codec = nullptr; - ~ThumbDataManagement() - { - av_free(intermediateBuffer); -@@ -198,7 +198,7 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize) - bool is_png = (bufSize > 3 && buffer[1] == 'P' && buffer[2] == 'N' && buffer[3] == 'G'); - bool is_tiff = (bufSize > 2 && buffer[0] == 'I' && buffer[1] == 'I' && buffer[2] == '*'); - -- AVInputFormat* inp = nullptr; -+ FFMPEG_FMT_CONST AVInputFormat* inp = nullptr; - if (is_jpeg) - inp = av_find_input_format("image2"); - else if (m_strMimeType == "image/apng") -@@ -236,7 +236,7 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize) - return false; - } - AVCodecParameters* codec_params = m_fctx->streams[0]->codecpar; -- AVCodec* codec = avcodec_find_decoder(codec_params->codec_id); -+ FFMPEG_FMT_CONST AVCodec* codec = avcodec_find_decoder(codec_params->codec_id); - m_codec_ctx = avcodec_alloc_context3(codec); - if (!m_codec_ctx) - { -diff --git a/xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp b/xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp -index 9bb2cdc09b..dbd8893c97 100644 ---- a/xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp -+++ b/xbmc/music/tags/MusicInfoTagLoaderFFmpeg.cpp -@@ -58,7 +58,7 @@ bool CMusicInfoTagLoaderFFmpeg::Load(const std::string& strFileName, CMusicInfoT - if (file.IoControl(IOCTRL_SEEK_POSSIBLE, NULL) != 1) - ioctx->seekable = 0; - -- AVInputFormat* iformat=NULL; -+ FFMPEG_FMT_CONST AVInputFormat* iformat = nullptr; - av_probe_input_buffer(ioctx, &iformat, strFileName.c_str(), NULL, 0, 0); - - if (avformat_open_input(&fctx, strFileName.c_str(), iformat, NULL) < 0) -diff --git a/xbmc/video/tags/VideoTagLoaderFFmpeg.cpp b/xbmc/video/tags/VideoTagLoaderFFmpeg.cpp -index c1b0495179..5564696be6 100644 ---- a/xbmc/video/tags/VideoTagLoaderFFmpeg.cpp -+++ b/xbmc/video/tags/VideoTagLoaderFFmpeg.cpp -@@ -65,7 +65,7 @@ CVideoTagLoaderFFmpeg::CVideoTagLoaderFFmpeg(const CFileItem& item, - if (m_file->IoControl(IOCTRL_SEEK_POSSIBLE, nullptr) != 1) - m_ioctx->seekable = 0; - -- AVInputFormat* iformat = nullptr; -+ FFMPEG_FMT_CONST AVInputFormat* iformat = nullptr; - av_probe_input_buffer(m_ioctx, &iformat, m_item.GetPath().c_str(), nullptr, 0, 0); - if (avformat_open_input(&m_fctx, m_item.GetPath().c_str(), iformat, nullptr) < 0) - { --- -2.35.1 - - -From 3de036ef45b0df3368997500d210090a7f6ff5e7 Mon Sep 17 00:00:00 2001 -From: Vasyl Gello -Date: Thu, 13 Oct 2022 04:56:26 +0000 -Subject: [PATCH 2/3] Use Channel Layout API if built against FFmpeg 5.1 - -Signed-off-by: Vasyl Gello ---- - xbmc/cdrip/EncoderFFmpeg.cpp | 51 +++++++++++++ - .../AudioEngine/Encoders/AEEncoderFFmpeg.cpp | 60 ++++++++++++++- - .../AudioEngine/Engines/ActiveAE/ActiveAE.cpp | 22 ++++++ - .../Engines/ActiveAE/ActiveAEFilter.cpp | 38 +++++++++- - .../ActiveAE/ActiveAEResampleFFMPEG.cpp | 55 +++++++++++++- - .../Engines/ActiveAE/ActiveAEStream.cpp | 2 +- - xbmc/cores/AudioEngine/Utils/AEUtil.cpp | 73 +++++++++++++++++-- - xbmc/cores/AudioEngine/Utils/AEUtil.h | 9 ++- - .../DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 58 ++++++++++++--- - .../DVDDemuxers/DVDDemuxClient.cpp | 15 +++- - .../DVDDemuxers/DVDDemuxFFmpeg.cpp | 42 +++++++++-- - 11 files changed, 388 insertions(+), 37 deletions(-) - -diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp -index 4c0628b5cc..c05cdeab9e 100644 ---- a/xbmc/cdrip/EncoderFFmpeg.cpp -+++ b/xbmc/cdrip/EncoderFFmpeg.cpp -@@ -94,8 +94,14 @@ bool CEncoderFFmpeg::Init() - - /* Set the basic encoder parameters. - * The input file's sample rate is used to avoid a sample rate conversion. */ -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_codecCtx->ch_layout); -+ av_channel_layout_default(&m_codecCtx->ch_layout, m_iInChannels); -+#else - m_codecCtx->channels = m_iInChannels; - m_codecCtx->channel_layout = av_get_default_channel_layout(m_iInChannels); -+#endif - m_codecCtx->sample_rate = m_iInSampleRate; - m_codecCtx->sample_fmt = codec->sample_fmts[0]; - m_codecCtx->bit_rate = bitrate; -@@ -140,7 +146,14 @@ bool CEncoderFFmpeg::Init() - - m_bufferFrame->nb_samples = m_codecCtx->frame_size; - m_bufferFrame->format = m_inFormat; -+ -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_bufferFrame->ch_layout); -+ av_channel_layout_copy(&m_bufferFrame->ch_layout, &m_codecCtx->ch_layout); -+#else - m_bufferFrame->channel_layout = m_codecCtx->channel_layout; -+#endif - m_bufferFrame->sample_rate = m_codecCtx->sample_rate; - - err = av_frame_get_buffer(m_bufferFrame, 0); -@@ -152,10 +165,18 @@ bool CEncoderFFmpeg::Init() - - if (m_needConversion) - { -+#if LIBSWRESAMPLE_BUILD >= AV_VERSION_INT(4, 7, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int ret = swr_alloc_set_opts2(&m_swrCtx, &m_codecCtx->ch_layout, m_outFormat, -+ m_codecCtx->sample_rate, &m_codecCtx->ch_layout, m_inFormat, -+ m_codecCtx->sample_rate, 0, nullptr); -+ if (ret || swr_init(m_swrCtx) < 0) -+#else - m_swrCtx = swr_alloc_set_opts(nullptr, m_codecCtx->channel_layout, m_outFormat, - m_codecCtx->sample_rate, m_codecCtx->channel_layout, m_inFormat, - m_codecCtx->sample_rate, 0, nullptr); - if (!m_swrCtx || swr_init(m_swrCtx) < 0) -+#endif - throw FFMpegException("Failed to initialize the resampler"); - - m_resampledBufferSize = -@@ -167,7 +188,13 @@ bool CEncoderFFmpeg::Init() - - m_resampledFrame->nb_samples = m_neededFrames; - m_resampledFrame->format = m_outFormat; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_resampledFrame->ch_layout); -+ av_channel_layout_copy(&m_resampledFrame->ch_layout, &m_codecCtx->ch_layout); -+#else - m_resampledFrame->channel_layout = m_codecCtx->channel_layout; -+#endif - m_resampledFrame->sample_rate = m_codecCtx->sample_rate; - - err = av_frame_get_buffer(m_resampledFrame, 0); -@@ -203,11 +230,23 @@ bool CEncoderFFmpeg::Init() - CLog::Log(LOGERROR, "CEncoderFFmpeg::{} - {}", __func__, caught.what()); - - av_freep(&m_buffer); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_bufferFrame->ch_layout); -+#endif - av_frame_free(&m_bufferFrame); - swr_free(&m_swrCtx); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_resampledFrame->ch_layout); -+#endif - av_frame_free(&m_resampledFrame); - av_freep(&m_resampledBuffer); - av_free(m_bcBuffer); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_codecCtx->ch_layout); -+#endif - avcodec_free_context(&m_codecCtx); - if (m_formatCtx) - { -@@ -351,8 +390,16 @@ bool CEncoderFFmpeg::Close() - - /* Flush if needed */ - av_freep(&m_buffer); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_bufferFrame->ch_layout); -+#endif - av_frame_free(&m_bufferFrame); - swr_free(&m_swrCtx); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_resampledFrame->ch_layout); -+#endif - av_frame_free(&m_resampledFrame); - av_freep(&m_resampledBuffer); - m_needConversion = false; -@@ -364,6 +411,10 @@ bool CEncoderFFmpeg::Close() - - /* cleanup */ - av_free(m_bcBuffer); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_codecCtx->ch_layout); -+#endif - avcodec_free_context(&m_codecCtx); - av_freep(&m_formatCtx->pb); - avformat_free_context(m_formatCtx); -diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -index 86f65f57f3..5d8ca71de1 100644 ---- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -+++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -@@ -37,6 +37,10 @@ CAEEncoderFFmpeg::~CAEEncoderFFmpeg() - { - Reset(); - swr_free(&m_SwrCtx); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); -+#endif - avcodec_free_context(&m_CodecCtx); - } - -@@ -113,7 +117,13 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input - - m_CodecCtx->bit_rate = m_BitRate; - m_CodecCtx->sample_rate = format.m_sampleRate; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); -+ av_channel_layout_from_mask(&m_CodecCtx->ch_layout, AV_CH_LAYOUT_5POINT1_BACK); -+#else - m_CodecCtx->channel_layout = AV_CH_LAYOUT_5POINT1_BACK; -+#endif - - /* select a suitable data format */ - if (codec->sample_fmts) -@@ -190,22 +200,44 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input - LOGERROR, - "CAEEncoderFFmpeg::Initialize - Unable to find a suitable data format for the codec ({})", - m_CodecName); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); -+#endif - avcodec_free_context(&m_CodecCtx); - return false; - } - } - -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ uint64_t mask = m_CodecCtx->ch_layout.u.mask; -+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); -+ av_channel_layout_from_mask(&m_CodecCtx->ch_layout, mask); -+ m_CodecCtx->ch_layout.nb_channels = BuildChannelLayout(mask, m_Layout); -+#else - m_CodecCtx->channels = BuildChannelLayout(m_CodecCtx->channel_layout, m_Layout); -+#endif - - /* open the codec */ - if (avcodec_open2(m_CodecCtx, codec, NULL)) - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); -+#endif - avcodec_free_context(&m_CodecCtx); - return false; - } - - format.m_frames = m_CodecCtx->frame_size; -- format.m_frameSize = m_CodecCtx->channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int channels = m_CodecCtx->ch_layout.nb_channels; -+#else -+ int channels = m_CodecCtx->channels; -+#endif -+ format.m_frameSize = channels * (CAEUtil::DataFormatToBits(format.m_dataFormat) >> 3); - format.m_channelLayout = m_Layout; - - m_CurrentFormat = format; -@@ -215,14 +247,26 @@ bool CAEEncoderFFmpeg::Initialize(AEAudioFormat &format, bool allow_planar_input - - if (m_NeedConversion) - { -+#if LIBSWRESAMPLE_BUILD >= AV_VERSION_INT(4, 7, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int ret = swr_alloc_set_opts2(&m_SwrCtx, &m_CodecCtx->ch_layout, m_CodecCtx->sample_fmt, -+ m_CodecCtx->sample_rate, &m_CodecCtx->ch_layout, -+ AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate, 0, NULL); -+ if (ret || swr_init(m_SwrCtx) < 0) -+#else - m_SwrCtx = swr_alloc_set_opts(NULL, - m_CodecCtx->channel_layout, m_CodecCtx->sample_fmt, m_CodecCtx->sample_rate, - m_CodecCtx->channel_layout, AV_SAMPLE_FMT_FLT, m_CodecCtx->sample_rate, - 0, NULL); - if (!m_SwrCtx || swr_init(m_SwrCtx) < 0) -+#endif - { - CLog::Log(LOGERROR, "CAEEncoderFFmpeg::Initialize - Failed to initialise resampler."); - swr_free(&m_SwrCtx); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_CodecCtx->ch_layout); -+#endif - avcodec_free_context(&m_CodecCtx); - return false; - } -@@ -276,10 +320,18 @@ int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_siz - - frame->nb_samples = m_CodecCtx->frame_size; - frame->format = m_CodecCtx->sample_fmt; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&frame->ch_layout); -+ av_channel_layout_copy(&frame->ch_layout, &m_CodecCtx->ch_layout); -+ int channelNum = m_CodecCtx->ch_layout.nb_channels; -+#else - frame->channel_layout = m_CodecCtx->channel_layout; - frame->channels = m_CodecCtx->channels; -+ int channelNum = m_CodecCtx->channels; -+#endif - -- avcodec_fill_audio_frame(frame, m_CodecCtx->channels, m_CodecCtx->sample_fmt, in, in_size, 0); -+ avcodec_fill_audio_frame(frame, channelNum, m_CodecCtx->sample_fmt, in, in_size, 0); - - pkt->size = out_size; - pkt->data = out; -@@ -295,6 +347,10 @@ int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_siz - err = avcodec_receive_packet(m_CodecCtx, pkt); - if (err == AVERROR(EAGAIN) || err == AVERROR_EOF) - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&frame->ch_layout); -+#endif - av_frame_free(&frame); - av_packet_free(&pkt); - return (err == AVERROR(EAGAIN)) ? -1 : 0; -diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -index 6000fe9c63..9cd3bddda8 100644 ---- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp -@@ -3069,8 +3069,14 @@ IAE::SoundPtr CActiveAE::MakeSound(const std::string& file) - AVCodecID codecId = fmt_ctx->streams[0]->codecpar->codec_id; - dec = avcodec_find_decoder(codecId); - config.sample_rate = fmt_ctx->streams[0]->codecpar->sample_rate; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ config.channels = fmt_ctx->streams[0]->codecpar->ch_layout.nb_channels; -+ config.channel_layout = fmt_ctx->streams[0]->codecpar->ch_layout.u.mask; -+#else - config.channels = fmt_ctx->streams[0]->codecpar->channels; - config.channel_layout = fmt_ctx->streams[0]->codecpar->channel_layout; -+#endif - } - } - if (dec == nullptr) -@@ -3086,10 +3092,22 @@ IAE::SoundPtr CActiveAE::MakeSound(const std::string& file) - - dec_ctx = avcodec_alloc_context3(dec); - dec_ctx->sample_rate = config.sample_rate; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannelLayout layout = {}; -+ if (!config.channel_layout) -+ av_channel_layout_default(&layout, config.channels); -+ else -+ av_channel_layout_from_mask(&layout, config.channel_layout); -+ config.channel_layout = layout.u.mask; -+ av_channel_layout_copy(&dec_ctx->ch_layout, &layout); -+ av_channel_layout_uninit(&layout); -+#else - dec_ctx->channels = config.channels; - if (!config.channel_layout) - config.channel_layout = av_get_default_channel_layout(config.channels); - dec_ctx->channel_layout = config.channel_layout; -+#endif - - AVPacket* avpkt = av_packet_alloc(); - if (!avpkt) -@@ -3156,6 +3174,10 @@ IAE::SoundPtr CActiveAE::MakeSound(const std::string& file) - - av_packet_free(&avpkt); - av_frame_free(&decoded_frame); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&dec_ctx->ch_layout); -+#endif - avcodec_free_context(&dec_ctx); - avformat_close_input(&fmt_ctx); - if (io_ctx) -diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp -index 26b669a2cf..1d79dc6db4 100644 ---- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp -+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEFilter.cpp -@@ -12,10 +12,11 @@ - #include - - extern "C" { --#include - #include -+#include - #include - #include -+#include - #include - } - -@@ -171,7 +172,13 @@ void CActiveAEFilter::CloseFilter() - } - - if (m_pOutFrame) -+ { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_pOutFrame->ch_layout); -+#endif - av_frame_free(&m_pOutFrame); -+ } - - if (m_pConvertFrame) - av_frame_free(&m_pConvertFrame); -@@ -205,10 +212,17 @@ int CActiveAEFilter::ProcessFilter(uint8_t **dst_buffer, int dst_samples, uint8_ - if (!frame) - return -1; - -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&frame->ch_layout); -+ av_channel_layout_from_mask(&frame->ch_layout, m_channelLayout); -+ int channels = frame->ch_layout.nb_channels; -+#else - int channels = av_get_channel_layout_nb_channels(m_channelLayout); - - frame->channel_layout = m_channelLayout; - frame->channels = channels; -+#endif - frame->sample_rate = m_sampleRate; - frame->nb_samples = src_samples; - frame->format = m_sampleFormat; -@@ -224,6 +238,10 @@ int CActiveAEFilter::ProcessFilter(uint8_t **dst_buffer, int dst_samples, uint8_ - src_buffer[0], src_bufsize, 16); - if (result < 0) - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&frame->ch_layout); -+#endif - av_frame_free(&frame); - CLog::Log(LOGERROR, "CActiveAEFilter::ProcessFilter - avcodec_fill_audio_frame failed"); - m_filterEof = true; -@@ -231,6 +249,10 @@ int CActiveAEFilter::ProcessFilter(uint8_t **dst_buffer, int dst_samples, uint8_ - } - - result = av_buffersrc_write_frame(m_pFilterCtxIn, frame); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&frame->ch_layout); -+#endif - av_frame_free(&frame); - if (result < 0) - { -@@ -284,7 +306,13 @@ int CActiveAEFilter::ProcessFilter(uint8_t **dst_buffer, int dst_samples, uint8_ - { - av_frame_unref(m_pOutFrame); - m_pOutFrame->format = m_sampleFormat; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_pOutFrame->ch_layout); -+ av_channel_layout_from_mask(&m_pOutFrame->ch_layout, m_channelLayout); -+#else - m_pOutFrame->channel_layout = m_channelLayout; -+#endif - m_pOutFrame->sample_rate = m_sampleRate; - result = swr_convert_frame(m_pConvertCtx, m_pOutFrame, m_pConvertFrame); - av_frame_unref(m_pConvertFrame); -@@ -302,7 +330,15 @@ int CActiveAEFilter::ProcessFilter(uint8_t **dst_buffer, int dst_samples, uint8_ - - if (m_hasData) - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannelLayout layout = {}; -+ av_channel_layout_from_mask(&layout, m_channelLayout); -+ int channels = layout.nb_channels; -+ av_channel_layout_uninit(&layout); -+#else - int channels = av_get_channel_layout_nb_channels(m_channelLayout); -+#endif - int planes = av_sample_fmt_is_planar(m_sampleFormat) ? channels : 1; - int samples = std::min(dst_samples, m_pOutFrame->nb_samples - m_sampleOffset); - int bytes = samples * av_get_bytes_per_sample(m_sampleFormat) * channels / planes; -diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp -index bfef837114..379dfe6446 100644 ---- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp -+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp -@@ -11,8 +11,10 @@ - #include "utils/log.h" - - extern "C" { -+#include - #include - #include -+#include - #include - } - -@@ -49,15 +51,49 @@ bool CActiveAEResampleFFMPEG::Init(SampleConfig dstConfig, SampleConfig srcConfi - m_doesResample = true; - - if (m_dst_chan_layout == 0) -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ { -+ AVChannelLayout layout = {}; -+ av_channel_layout_default(&layout, m_dst_channels); -+ m_dst_chan_layout = layout.u.mask; -+ av_channel_layout_uninit(&layout); -+ } -+#else - m_dst_chan_layout = av_get_default_channel_layout(m_dst_channels); -+#endif - if (m_src_chan_layout == 0) -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ { -+ AVChannelLayout layout = {}; -+ av_channel_layout_default(&layout, m_src_channels); -+ m_src_chan_layout = layout.u.mask; -+ av_channel_layout_uninit(&layout); -+ } -+#else - m_src_chan_layout = av_get_default_channel_layout(m_src_channels); -+#endif -+ -+#if LIBSWRESAMPLE_BUILD >= AV_VERSION_INT(4, 7, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannelLayout dstChLayout = {}; -+ AVChannelLayout srcChLayout = {}; - -+ av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout); -+ av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout); -+ -+ int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt, m_dst_rate, &srcChLayout, -+ m_src_fmt, m_src_rate, 0, NULL); -+ -+ if (ret) -+#else - m_pContext = swr_alloc_set_opts(NULL, m_dst_chan_layout, m_dst_fmt, m_dst_rate, - m_src_chan_layout, m_src_fmt, m_src_rate, - 0, NULL); - - if (!m_pContext) -+#endif - { - CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context failed"); - return false; -@@ -126,10 +162,20 @@ bool CActiveAEResampleFFMPEG::Init(SampleConfig dstConfig, SampleConfig srcConfi - else if (upmix && m_src_channels == 2 && m_dst_channels > 2) - { - memset(m_rematrix, 0, sizeof(m_rematrix)); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&dstChLayout); -+ av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout); -+#endif - for (int out=0; out= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannel outChan = av_channel_layout_channel_from_index(&dstChLayout, out); -+#else -+ uint64_t outChan = av_channel_layout_extract_channel(m_dst_chan_layout, out); -+#endif -+ switch (outChan) - { - case AV_CH_FRONT_LEFT: - case AV_CH_BACK_LEFT: -@@ -154,6 +200,11 @@ bool CActiveAEResampleFFMPEG::Init(SampleConfig dstConfig, SampleConfig srcConfi - } - } - -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&dstChLayout); -+#endif -+ - if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0) - { - CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - setting channel matrix failed"); -diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp -index 858b0f2f22..a52ac2829f 100644 ---- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp -+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp -@@ -88,7 +88,7 @@ void CActiveAEStream::InitRemapper() - for(unsigned int i=0; i - #endif - --extern "C" { --#include --} -- - void AEDelayStatus::SetDelay(double d) - { - delay = d; -@@ -550,8 +546,15 @@ AVSampleFormat CAEUtil::GetAVSampleFormat(AEDataFormat format) - } - } - --uint64_t CAEUtil::GetAVChannel(enum AEChannel aechannel) -+uint64_t CAEUtil::GetAVChannelMask(enum AEChannel aechannel) - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ enum AVChannel ch = GetAVChannel(aechannel); -+ if (ch == AV_CHAN_NONE) -+ return 0; -+ return (1ULL << ch); -+#else - switch (aechannel) - { - case AE_CH_FL: return AV_CH_FRONT_LEFT; -@@ -575,9 +578,67 @@ uint64_t CAEUtil::GetAVChannel(enum AEChannel aechannel) - default: - return 0; - } -+#endif - } - -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+enum AVChannel CAEUtil::GetAVChannel(enum AEChannel aechannel) -+{ -+ switch (aechannel) -+ { -+ case AE_CH_FL: -+ return AV_CHAN_FRONT_LEFT; -+ case AE_CH_FR: -+ return AV_CHAN_FRONT_RIGHT; -+ case AE_CH_FC: -+ return AV_CHAN_FRONT_CENTER; -+ case AE_CH_LFE: -+ return AV_CHAN_LOW_FREQUENCY; -+ case AE_CH_BL: -+ return AV_CHAN_BACK_LEFT; -+ case AE_CH_BR: -+ return AV_CHAN_BACK_RIGHT; -+ case AE_CH_FLOC: -+ return AV_CHAN_FRONT_LEFT_OF_CENTER; -+ case AE_CH_FROC: -+ return AV_CHAN_FRONT_RIGHT_OF_CENTER; -+ case AE_CH_BC: -+ return AV_CHAN_BACK_CENTER; -+ case AE_CH_SL: -+ return AV_CHAN_SIDE_LEFT; -+ case AE_CH_SR: -+ return AV_CHAN_SIDE_RIGHT; -+ case AE_CH_TC: -+ return AV_CHAN_TOP_CENTER; -+ case AE_CH_TFL: -+ return AV_CHAN_TOP_FRONT_LEFT; -+ case AE_CH_TFC: -+ return AV_CHAN_TOP_FRONT_CENTER; -+ case AE_CH_TFR: -+ return AV_CHAN_TOP_FRONT_RIGHT; -+ case AE_CH_TBL: -+ return AV_CHAN_TOP_BACK_LEFT; -+ case AE_CH_TBC: -+ return AV_CHAN_TOP_BACK_CENTER; -+ case AE_CH_TBR: -+ return AV_CHAN_TOP_BACK_RIGHT; -+ default: -+ return AV_CHAN_NONE; -+ } -+} -+#endif -+ - int CAEUtil::GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout) - { -- return av_get_channel_layout_channel_index(layout, GetAVChannel(aechannel)); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannelLayout ch_layout = {}; -+ av_channel_layout_from_mask(&ch_layout, layout); -+ int idx = av_channel_layout_index_from_channel(&ch_layout, GetAVChannel(aechannel)); -+ av_channel_layout_uninit(&ch_layout); -+ return idx; -+#else -+ return av_get_channel_layout_channel_index(layout, GetAVChannelMask(aechannel)); -+#endif - } -diff --git a/xbmc/cores/AudioEngine/Utils/AEUtil.h b/xbmc/cores/AudioEngine/Utils/AEUtil.h -index 034e115ee8..8acbeec442 100644 ---- a/xbmc/cores/AudioEngine/Utils/AEUtil.h -+++ b/xbmc/cores/AudioEngine/Utils/AEUtil.h -@@ -13,7 +13,10 @@ - #include - - extern "C" { -+#include -+#include - #include -+#include - } - - // AV sync options -@@ -171,6 +174,10 @@ public: - static uint64_t GetAVChannelLayout(const CAEChannelInfo &info); - static CAEChannelInfo GetAEChannelLayout(uint64_t layout); - static AVSampleFormat GetAVSampleFormat(AEDataFormat format); -- static uint64_t GetAVChannel(enum AEChannel aechannel); -+ static uint64_t GetAVChannelMask(enum AEChannel aechannel); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ static enum AVChannel GetAVChannel(enum AEChannel aechannel); -+#endif - static int GetAVChannelIndex(enum AEChannel aechannel, uint64_t layout); - }; -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -index 87e7ae2c57..44dcb32620 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -@@ -78,7 +78,14 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options - - m_matrixEncoding = AV_MATRIX_ENCODING_NONE; - m_channels = 0; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&m_pCodecContext->ch_layout); -+ m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE; -+ m_pCodecContext->ch_layout.nb_channels = hints.channels; -+#else - m_pCodecContext->channels = hints.channels; -+#endif - m_hint_layout = hints.channellayout; - m_pCodecContext->sample_rate = hints.samplerate; - m_pCodecContext->block_align = hints.blockalign; -@@ -261,12 +268,18 @@ int CDVDAudioCodecFFmpeg::GetData(uint8_t** dst) - m_format.m_frameSize = m_format.m_channelLayout.Count() * - CAEUtil::DataFormatToBits(m_format.m_dataFormat) >> 3; - -- int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? m_pFrame->channels : 1; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int channels = m_pFrame->ch_layout.nb_channels; -+#else -+ int channels = m_pFrame->channels; -+#endif -+ int planes = av_sample_fmt_is_planar(m_pCodecContext->sample_fmt) ? channels : 1; -+ - for (int i=0; iextended_data[i]; - -- return m_pFrame->nb_samples * m_pFrame->channels * -- av_get_bytes_per_sample(m_pCodecContext->sample_fmt); -+ return m_pFrame->nb_samples * channels * av_get_bytes_per_sample(m_pCodecContext->sample_fmt); - } - - return 0; -@@ -280,7 +293,12 @@ void CDVDAudioCodecFFmpeg::Reset() - - int CDVDAudioCodecFFmpeg::GetChannels() - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ return m_pCodecContext->ch_layout.nb_channels; -+#else - return m_pCodecContext->channels; -+#endif - } - - int CDVDAudioCodecFFmpeg::GetSampleRate() -@@ -347,28 +365,44 @@ static unsigned count_bits(int64_t value) - - void CDVDAudioCodecFFmpeg::BuildChannelMap() - { -- if (m_channels == m_pCodecContext->channels && m_layout == m_pCodecContext->channel_layout) -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int codecChannels = m_pCodecContext->ch_layout.nb_channels; -+ uint64_t codecChannelLayout = m_pCodecContext->ch_layout.u.mask; -+#else -+ int codecChannels = m_pCodecContext->channels; -+ uint64_t codecChannelLayout = m_pCodecContext->channel_layout; -+#endif -+ if (m_channels == codecChannels && m_layout == codecChannelLayout) - return; //nothing to do here - -- m_channels = m_pCodecContext->channels; -- m_layout = m_pCodecContext->channel_layout; -+ m_channels = codecChannels; -+ m_layout = codecChannelLayout; - - int64_t layout; - -- int bits = count_bits(m_pCodecContext->channel_layout); -- if (bits == m_pCodecContext->channels) -- layout = m_pCodecContext->channel_layout; -+ int bits = count_bits(codecChannelLayout); -+ if (bits == codecChannels) -+ layout = codecChannelLayout; - else - { - CLog::Log(LOGINFO, - "CDVDAudioCodecFFmpeg::GetChannelMap - FFmpeg reported {} channels, but the layout " - "contains {} - trying hints", -- m_pCodecContext->channels, bits); -- if (static_cast(count_bits(m_hint_layout)) == m_pCodecContext->channels) -+ codecChannels, bits); -+ if (static_cast(count_bits(m_hint_layout)) == codecChannels) - layout = m_hint_layout; - else - { -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannelLayout def_layout = {}; -+ av_channel_layout_default(&def_layout, codecChannels); -+ layout = def_layout.u.mask; -+ av_channel_layout_uninit(&def_layout); -+#else - layout = av_get_default_channel_layout(m_pCodecContext->channels); -+#endif - CLog::Log(LOGINFO, "Using default layout..."); - } - } -@@ -394,7 +428,7 @@ void CDVDAudioCodecFFmpeg::BuildChannelMap() - if (layout & AV_CH_TOP_BACK_CENTER ) m_channelLayout += AE_CH_BC ; - if (layout & AV_CH_TOP_BACK_RIGHT ) m_channelLayout += AE_CH_BR ; - -- m_channels = m_pCodecContext->channels; -+ m_channels = codecChannels; - } - - CAEChannelInfo CDVDAudioCodecFFmpeg::GetChannelMap() -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -index 5be134e381..70f0562462 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -@@ -220,10 +220,17 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - case STREAM_AUDIO: - { - CDemuxStreamClientInternalTpl* sta = static_cast*>(st); -- if (stream->m_context->channels != sta->iChannels && stream->m_context->channels != 0) -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int streamChannels = stream->m_context->ch_layout.nb_channels; -+#else -+ int streamChannels = stream->m_context->channels; -+#endif -+ if (streamChannels != sta->iChannels && streamChannels != 0) - { -- CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - ({}) channels changed from {} to {}", st->uniqueId, sta->iChannels, stream->m_context->channels); -- sta->iChannels = stream->m_context->channels; -+ CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - ({}) channels changed from {} to {}", -+ st->uniqueId, sta->iChannels, streamChannels); -+ sta->iChannels = streamChannels; - sta->changes++; - sta->disabled = false; - } -@@ -235,7 +242,7 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - sta->changes++; - sta->disabled = false; - } -- if (stream->m_context->channels) -+ if (streamChannels) - st->changes = -1; // stop parsing - break; - } -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -index bf6f322274..4ad52cd32a 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -@@ -1235,8 +1235,16 @@ DemuxPacket* CDVDDemuxFFmpeg::Read() - else if (stream->type == STREAM_AUDIO) - { - CDemuxStreamAudioFFmpeg* audiostream = dynamic_cast(stream); -- if (audiostream && (audiostream->iChannels != m_pFormatContext->streams[pPacket->iStreamId]->codecpar->channels || -- audiostream->iSampleRate != m_pFormatContext->streams[pPacket->iStreamId]->codecpar->sample_rate)) -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int codecparChannels = -+ m_pFormatContext->streams[pPacket->iStreamId]->codecpar->ch_layout.nb_channels; -+#else -+ int codecparChannels = m_pFormatContext->streams[pPacket->iStreamId]->codecpar->channels; -+#endif -+ if (audiostream && (audiostream->iChannels != codecparChannels || -+ audiostream->iSampleRate != -+ m_pFormatContext->streams[pPacket->iStreamId]->codecpar->sample_rate)) - { - // content has changed - stream = AddStream(pPacket->iStreamId); -@@ -1418,6 +1426,7 @@ void CDVDDemuxFFmpeg::UpdateCurrentPTS() - if (idx >= 0) - { - AVStream* stream = m_pFormatContext->streams[idx]; -+ - #if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 17, 100) - if (stream && m_pkt.pkt.dts != (int64_t)AV_NOPTS_VALUE) - { -@@ -1639,16 +1648,28 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) - { - CDemuxStreamAudioFFmpeg* st = new CDemuxStreamAudioFFmpeg(pStream); - stream = st; -- st->iChannels = pStream->codecpar->channels; -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int codecparChannels = pStream->codecpar->ch_layout.nb_channels; -+ int codecparChannelLayout = pStream->codecpar->ch_layout.u.mask; -+#else -+ int codecparChannels = pStream->codecpar->channels; -+ int codecparChannelLayout = pStream->codecpar->channel_layout; -+#endif -+ st->iChannels = codecparChannels; -+ st->iChannelLayout = codecparChannelLayout; - st->iSampleRate = pStream->codecpar->sample_rate; - st->iBlockAlign = pStream->codecpar->block_align; - st->iBitRate = static_cast(pStream->codecpar->bit_rate); - st->iBitsPerSample = pStream->codecpar->bits_per_raw_sample; -- st->iChannelLayout = pStream->codecpar->channel_layout; - char buf[32] = {}; - // https://github.com/FFmpeg/FFmpeg/blob/6ccc3989d15/doc/APIchanges#L50-L53 --#if LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 24, 100) -- av_channel_layout_describe(st->iChannelLayout, buf, sizeof(buf)); -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ AVChannelLayout layout = {}; -+ av_channel_layout_from_mask(&layout, st->iChannelLayout); -+ av_channel_layout_describe(&layout, buf, sizeof(buf)); -+ av_channel_layout_uninit(&layout); - #else - av_get_channel_layout_string(buf, 31, st->iChannels, st->iChannelLayout); - #endif -@@ -2195,8 +2216,13 @@ bool CDVDDemuxFFmpeg::IsProgramChange() - if (m_pFormatContext->streams[idx]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) - { - CDemuxStreamAudioFFmpeg* audiostream = dynamic_cast(stream); -- if (audiostream && -- m_pFormatContext->streams[idx]->codecpar->channels != audiostream->iChannels) -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ int codecparChannels = m_pFormatContext->streams[idx]->codecpar->ch_layout.nb_channels; -+#else -+ int codecparChannels = m_pFormatContext->streams[idx]->codecpar->channels; -+#endif -+ if (audiostream && codecparChannels != audiostream->iChannels) - { - return true; - } --- -2.35.1 - - -From 0a10e05700dfd12b7f5d720588b993089ea33be4 Mon Sep 17 00:00:00 2001 -From: Vasyl Gello -Date: Sat, 15 Oct 2022 11:46:52 +0000 -Subject: [PATCH 3/3] ffmpeg5: Get extradata with extract_extradata BSF - -Fixes the transport stream playback failures described in -https://bugs.debian.org/1016925 - -Rogo95 made an excellent technical analysis of the root cause -and reported that to the bug thread. - -Later on, James Almer (jamrial) suggested the solution to use -extract_extradata bitstream filter to replace the removed split() -function. - -Finally, I adapted the following code snippet: -https://gist.github.com/moonpfe/f6795d51294d91ee0f82f62ff6985db0 -to Kodi and tested it by playing the affected files in TS format. - -HiassofT form LibreELEC found another edge case decoding HTSP -streams from pvr.hts. The comparison of log files revealed that -the split function is also used in DVDDemuxClient. - -Signed-off-by: Vasyl Gello ---- - xbmc/cores/FFmpeg.cpp | 154 ++++++++++++++++++ - xbmc/cores/FFmpeg.h | 5 + - .../DVDDemuxers/DVDDemuxClient.cpp | 37 ++--- - .../DVDDemuxers/DVDDemuxFFmpeg.cpp | 61 +++---- - 4 files changed, 203 insertions(+), 54 deletions(-) - -diff --git a/xbmc/cores/FFmpeg.cpp b/xbmc/cores/FFmpeg.cpp -index de1765ed52..eb9c653fa3 100644 ---- a/xbmc/cores/FFmpeg.cpp -+++ b/xbmc/cores/FFmpeg.cpp -@@ -16,6 +16,11 @@ - #include "utils/StringUtils.h" - #include "utils/log.h" - -+extern "C" -+{ -+#include -+} -+ - #include - #include - -@@ -129,3 +134,152 @@ void ff_avutil_log(void* ptr, int level, const char* format, va_list va) - } - buffer.erase(0, start); - } -+ -+std::tuple GetPacketExtradata(const AVPacket* pkt, -+ const AVCodecParserContext* parserCtx, -+ AVCodecContext* codecCtx) -+{ -+ constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE); -+ -+ if (!pkt) -+ return std::make_tuple(nullptr, 0); -+ -+ uint8_t* extraData = nullptr; -+ int extraDataSize = 0; -+ -+#if LIBAVFORMAT_BUILD >= AV_VERSION_INT(59, 0, 100) -+ /* extract_extradata bitstream filter is implemented only -+ * for certain codecs, as noted in discussion of PR#21248 -+ */ -+ -+ AVCodecID codecId = codecCtx->codec_id; -+ -+ // clang-format off -+ if ( -+ codecId != AV_CODEC_ID_MPEG1VIDEO && -+ codecId != AV_CODEC_ID_MPEG2VIDEO && -+ codecId != AV_CODEC_ID_H264 && -+ codecId != AV_CODEC_ID_HEVC && -+ codecId != AV_CODEC_ID_MPEG4 && -+ codecId != AV_CODEC_ID_VC1 && -+ codecId != AV_CODEC_ID_AV1 && -+ codecId != AV_CODEC_ID_AVS2 && -+ codecId != AV_CODEC_ID_AVS3 && -+ codecId != AV_CODEC_ID_CAVS -+ ) -+ // clang-format on -+ return std::make_tuple(nullptr, 0); -+ -+ const AVBitStreamFilter* f = av_bsf_get_by_name("extract_extradata"); -+ if (!f) -+ return std::make_tuple(nullptr, 0); -+ -+ AVBSFContext* bsf = nullptr; -+ int ret = av_bsf_alloc(f, &bsf); -+ if (ret < 0) -+ return std::make_tuple(nullptr, 0); -+ -+ bsf->par_in->codec_id = codecId; -+ -+ ret = av_bsf_init(bsf); -+ if (ret < 0) -+ { -+ av_bsf_free(&bsf); -+ return std::make_tuple(nullptr, 0); -+ } -+ -+ AVPacket* dstPkt = av_packet_alloc(); -+ if (!dstPkt) -+ { -+ CLog::LogF(LOGERROR, "failed to allocate packet"); -+ -+ av_bsf_free(&bsf); -+ return std::make_tuple(nullptr, 0); -+ } -+ AVPacket* pktRef = dstPkt; -+ -+ ret = av_packet_ref(pktRef, pkt); -+ if (ret < 0) -+ { -+ av_bsf_free(&bsf); -+ av_packet_free(&dstPkt); -+ return std::make_tuple(nullptr, 0); -+ } -+ -+ ret = av_bsf_send_packet(bsf, pktRef); -+ if (ret < 0) -+ { -+ av_packet_unref(pktRef); -+ av_bsf_free(&bsf); -+ av_packet_free(&dstPkt); -+ return std::make_tuple(nullptr, 0); -+ } -+ -+ ret = 0; -+ while (ret >= 0) -+ { -+ ret = av_bsf_receive_packet(bsf, pktRef); -+ if (ret < 0) -+ { -+ if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) -+ break; -+ -+ continue; -+ } -+ -+ size_t retExtraDataSize = 0; -+ uint8_t* retExtraData = -+ av_packet_get_side_data(pktRef, AV_PKT_DATA_NEW_EXTRADATA, &retExtraDataSize); -+ if (retExtraData && retExtraDataSize > 0 && retExtraDataSize < FF_MAX_EXTRADATA_SIZE) -+ { -+ extraData = static_cast(av_malloc(retExtraDataSize + AV_INPUT_BUFFER_PADDING_SIZE)); -+ if (!extraData) -+ { -+ CLog::LogF(LOGERROR, "failed to allocate {} bytes for extradata", retExtraDataSize); -+ -+ av_packet_unref(pktRef); -+ av_bsf_free(&bsf); -+ av_packet_free(&dstPkt); -+ return std::make_tuple(nullptr, 0); -+ } -+ -+ CLog::LogF(LOGDEBUG, "fetching extradata, extradata_size({})", retExtraDataSize); -+ -+ memcpy(extraData, retExtraData, retExtraDataSize); -+ memset(extraData + retExtraDataSize, 0, AV_INPUT_BUFFER_PADDING_SIZE); -+ extraDataSize = retExtraDataSize; -+ -+ av_packet_unref(pktRef); -+ break; -+ } -+ -+ av_packet_unref(pktRef); -+ } -+ -+ av_bsf_free(&bsf); -+ av_packet_free(&dstPkt); -+#else -+ if (codecCtx && parserCtx && parserCtx->parser && parserCtx->parser->split) -+ extraDataSize = parserCtx->parser->split(codecCtx, pkt->data, pkt->size); -+ -+ if (extraDataSize <= 0 || extraDataSize >= FF_MAX_EXTRADATA_SIZE) -+ { -+ CLog::LogF(LOGDEBUG, "fetched extradata of weird size {}", extraDataSize); -+ return std::make_tuple(nullptr, 0); -+ } -+ -+ extraData = static_cast(av_malloc(extraDataSize + AV_INPUT_BUFFER_PADDING_SIZE)); -+ if (!extraData) -+ { -+ CLog::LogF(LOGERROR, "failed to allocate {} bytes for extradata", extraDataSize); -+ return std::make_tuple(nullptr, 0); -+ } -+ -+ CLog::LogF(LOGDEBUG, "fetching extradata, extradata_size({})", extraDataSize); -+ -+ memcpy(extraData, pkt->data, extraDataSize); -+ memset(extraData + extraDataSize, 0, AV_INPUT_BUFFER_PADDING_SIZE); -+#endif -+ -+ return std::make_tuple(extraData, extraDataSize); -+} -diff --git a/xbmc/cores/FFmpeg.h b/xbmc/cores/FFmpeg.h -index 8230701ba7..22a253e191 100644 ---- a/xbmc/cores/FFmpeg.h -+++ b/xbmc/cores/FFmpeg.h -@@ -22,6 +22,8 @@ extern "C" { - #include - } - -+#include -+ - // https://github.com/FFmpeg/FFmpeg/blob/56450a0ee4/doc/APIchanges#L18-L26 - #if LIBAVFORMAT_BUILD >= AV_VERSION_INT(59, 0, 100) - #define FFMPEG_FMT_CONST const -@@ -77,3 +79,6 @@ public: - int level; - }; - -+std::tuple GetPacketExtradata(const AVPacket* pkt, -+ const AVCodecParserContext* parserCtx, -+ AVCodecContext* codecCtx); -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -index 70f0562462..f42710282d 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -@@ -14,10 +14,9 @@ - #include "cores/VideoPlayer/Interface/TimingConstants.h" - #include "utils/log.h" - -+#include - #include - --#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) -- - class CDemuxStreamClientInternal - { - public: -@@ -150,17 +149,26 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - stream->m_context->time_base.den = DVD_TIME_BASE; - } - -- if (stream->m_parser_split && stream->m_parser->parser->split) -+ if (stream->m_parser_split && stream->m_parser && stream->m_parser->parser) - { -- int len = stream->m_parser->parser->split(stream->m_context, pkt->pData, pkt->iSize); -- if (len > 0 && len < FF_MAX_EXTRADATA_SIZE) -+ AVPacket* avpkt = av_packet_alloc(); -+ if (!avpkt) -+ { -+ CLog::LogF(LOGERROR, "av_packet_alloc failed: {}", strerror(errno)); -+ return false; -+ } -+ -+ avpkt->data = pkt->pData; -+ avpkt->size = pkt->iSize; -+ avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; -+ -+ auto [retExtraData, len] = GetPacketExtradata(avpkt, stream->m_parser, stream->m_context); -+ if (len > 0) - { - st->changes++; - st->disabled = false; - st->ExtraSize = len; -- st->ExtraData = std::make_unique(len + AV_INPUT_BUFFER_PADDING_SIZE); -- memcpy(st->ExtraData.get(), pkt->pData, len); -- memset(st->ExtraData.get() + len, 0, AV_INPUT_BUFFER_PADDING_SIZE); -+ st->ExtraData = std::unique_ptr(retExtraData); - stream->m_parser_split = false; - change = true; - CLog::Log(LOGDEBUG, "CDVDDemuxClient::ParsePacket - split extradata"); -@@ -168,21 +176,12 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - // Allow ffmpeg to transport codec information to stream->m_context - if (!avcodec_open2(stream->m_context, stream->m_context->codec, nullptr)) - { -- AVPacket* avpkt = av_packet_alloc(); -- if (!avpkt) -- { -- CLog::Log(LOGERROR, "CDVDDemuxClient::{} - av_packet_alloc failed: {}", __FUNCTION__, -- strerror(errno)); -- return false; -- } -- avpkt->data = pkt->pData; -- avpkt->size = pkt->iSize; -- avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; - avcodec_send_packet(stream->m_context, avpkt); - avcodec_close(stream->m_context); -- av_packet_free(&avpkt); - } - } -+ -+ av_packet_free(&avpkt); - } - - uint8_t *outbuf = nullptr; -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -index 4ad52cd32a..3081dd8e9a 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -@@ -34,6 +34,7 @@ - - #include - #include -+#include - #include - - extern "C" -@@ -105,8 +106,6 @@ bool AttachmentIsFont(const AVDictionaryEntry* dict) - } - } // namespace - --#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) -- - std::string CDemuxStreamAudioFFmpeg::GetStreamName() - { - if (!m_stream) -@@ -2358,44 +2357,36 @@ void CDVDDemuxFFmpeg::ParsePacket(AVPacket* pkt) - - if (parser->second->m_parserCtx && - parser->second->m_parserCtx->parser && -- parser->second->m_parserCtx->parser->split && - !st->codecpar->extradata) - { -- int i = parser->second->m_parserCtx->parser->split(parser->second->m_codecCtx, pkt->data, pkt->size); -- if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) -+ auto [retExtraData, i] = -+ GetPacketExtradata(pkt, parser->second->m_parserCtx, parser->second->m_codecCtx); -+ if (i > 0) - { -- st->codecpar->extradata = (uint8_t*)av_malloc(i + AV_INPUT_BUFFER_PADDING_SIZE); -- if (st->codecpar->extradata) -- { -- CLog::Log(LOGDEBUG, -- "CDVDDemuxFFmpeg::ParsePacket() fetching extradata, extradata_size({})", i); -- st->codecpar->extradata_size = i; -- memcpy(st->codecpar->extradata, pkt->data, i); -- memset(st->codecpar->extradata + i, 0, AV_INPUT_BUFFER_PADDING_SIZE); -+ st->codecpar->extradata_size = i; -+ st->codecpar->extradata = retExtraData; - -- if (parser->second->m_parserCtx->parser->parser_parse) -+ if (parser->second->m_parserCtx->parser->parser_parse) -+ { -+ parser->second->m_codecCtx->extradata = st->codecpar->extradata; -+ parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size; -+ const uint8_t* outbufptr; -+ int bufSize; -+ parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES; -+ parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx, -+ parser->second->m_codecCtx, &outbufptr, -+ &bufSize, pkt->data, pkt->size); -+ parser->second->m_codecCtx->extradata = nullptr; -+ parser->second->m_codecCtx->extradata_size = 0; -+ -+ if (parser->second->m_parserCtx->width != 0) - { -- parser->second->m_codecCtx->extradata = st->codecpar->extradata; -- parser->second->m_codecCtx->extradata_size = st->codecpar->extradata_size; -- const uint8_t* outbufptr; -- int bufSize; -- parser->second->m_parserCtx->flags |= PARSER_FLAG_COMPLETE_FRAMES; -- parser->second->m_parserCtx->parser->parser_parse(parser->second->m_parserCtx, -- parser->second->m_codecCtx, -- &outbufptr, &bufSize, -- pkt->data, pkt->size); -- parser->second->m_codecCtx->extradata = nullptr; -- parser->second->m_codecCtx->extradata_size = 0; -- -- if (parser->second->m_parserCtx->width != 0) -- { -- st->codecpar->width = parser->second->m_parserCtx->width; -- st->codecpar->height = parser->second->m_parserCtx->height; -- } -- else -- { -- CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height"); -- } -+ st->codecpar->width = parser->second->m_parserCtx->width; -+ st->codecpar->height = parser->second->m_parserCtx->height; -+ } -+ else -+ { -+ CLog::Log(LOGERROR, "CDVDDemuxFFmpeg::ParsePacket() invalid width/height"); - } - } - } --- -2.35.1 - -From d61499e7f8451bf080112a3f1332c8826d6ce1ac Mon Sep 17 00:00:00 2001 -From: fritsch -Date: Tue, 17 Jan 2023 20:28:31 +0100 -Subject: [PATCH] AEEncoderFFmpeg: Break when one packet is received - ---- - .../AudioEngine/Encoders/AEEncoderFFmpeg.cpp | 23 +++++++++---------- - 1 file changed, 11 insertions(+), 12 deletions(-) - -diff --git a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -index ba35c9506395e..bc6ce300ad028 100644 ---- a/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -+++ b/xbmc/cores/AudioEngine/Encoders/AEEncoderFFmpeg.cpp -@@ -333,43 +333,42 @@ int CAEEncoderFFmpeg::Encode(uint8_t *in, int in_size, uint8_t *out, int out_siz - - avcodec_fill_audio_frame(frame, channelNum, m_CodecCtx->sample_fmt, in, in_size, 0); - -- pkt->size = out_size; -- pkt->data = out; -- - /* encode it */ - err = avcodec_send_frame(m_CodecCtx, frame); - if (err < 0) - throw FFMpegException("Error sending a frame for encoding (error '{}')", - FFMpegErrorToString(err)); - -- while (err >= 0) -+ err = avcodec_receive_packet(m_CodecCtx, pkt); -+ // err < 0 - we cannot cope with it -+ // err is EAGAIN or EOF - return to caller as well -+ if (err >= 0) - { -- err = avcodec_receive_packet(m_CodecCtx, pkt); -- if (err == AVERROR(EAGAIN) || err == AVERROR_EOF) -+ if (pkt->size <= out_size) - { --#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -- LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -- av_channel_layout_uninit(&frame->ch_layout); --#endif -- av_frame_free(&frame); -- av_packet_free(&pkt); -- return (err == AVERROR(EAGAIN)) ? -1 : 0; -+ memset(out, 0, out_size); -+ memcpy(out, pkt->data, pkt->size); -+ size = pkt->size; - } -- else if (err < 0) -+ else - { -- throw FFMpegException("Error during encoding (error '{}')", FFMpegErrorToString(err)); -+ CLog::LogF(LOGERROR, "Encoded pkt size ({}) is bigger than buffer ({})", pkt->size, -+ out_size); - } - - av_packet_unref(pkt); - } -- -- size = pkt->size; - } - catch (const FFMpegException& caught) - { - CLog::Log(LOGERROR, "CAEEncoderFFmpeg::{} - {}", __func__, caught.what()); - } - -+#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ -+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -+ av_channel_layout_uninit(&frame->ch_layout); -+#endif -+ - /* free temporary data */ - av_frame_free(&frame); diff --git a/media-tv/kodi/files/kodi-20.5-ffmpeg6.patch b/media-tv/kodi/files/kodi-20.5-ffmpeg6.patch deleted file mode 100644 index 97398ff..0000000 --- a/media-tv/kodi/files/kodi-20.5-ffmpeg6.patch +++ /dev/null @@ -1,624 +0,0 @@ -From c9e25dc15acf1214b079da7021ad89acf85fa77d Mon Sep 17 00:00:00 2001 -From: CastagnaIT -Date: Sun, 29 Jan 2023 17:51:51 +0100 -Subject: [PATCH] [VideoPlayerVideo] Log an error when codec extradata is - required - ---- - xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp -index 20f6b3b1cb51d..38f63f0766718 100644 ---- a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp -+++ b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp -@@ -114,8 +114,11 @@ bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint) - hint.codec == AV_CODEC_ID_WMV3 || - hint.codec == AV_CODEC_ID_VC1 || - hint.codec == AV_CODEC_ID_AV1) -- // clang-format on -+ { -+ CLog::LogF(LOGERROR, "Codec id {} require extradata.", hint.codec); - return false; -+ } -+ // clang-format on - } - - CLog::Log(LOGINFO, "Creating video codec with codec id: {}", hint.codec); - - -From 2559466404d342428d43076bf90fcacc24313af0 Mon Sep 17 00:00:00 2001 -From: enen92 <92enen@gmail.com> -Date: Mon, 6 Feb 2023 15:36:11 +0000 -Subject: [PATCH] video: remove ffmpeg bsf hack - -Manually setting the codecID on the bsf filter is wrong. -avcodec_parameters_copy should be used instead. ---- - xbmc/cores/FFmpeg.cpp | 13 ++++++++----- - xbmc/cores/FFmpeg.h | 3 +-- - .../VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 10 +++++++++- - .../VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 3 +-- - 4 files changed, 19 insertions(+), 10 deletions(-) - -diff --git a/xbmc/cores/FFmpeg.cpp b/xbmc/cores/FFmpeg.cpp -index d071f6d8e33a3..73b7ea2ae875c 100644 ---- a/xbmc/cores/FFmpeg.cpp -+++ b/xbmc/cores/FFmpeg.cpp -@@ -135,9 +135,7 @@ void ff_avutil_log(void* ptr, int level, const char* format, va_list va) - buffer.erase(0, start); - } - --std::tuple GetPacketExtradata(const AVPacket* pkt, -- const AVCodecParserContext* parserCtx, -- AVCodecContext* codecCtx) -+std::tuple GetPacketExtradata(const AVPacket* pkt, const AVCodecParameters* codecPar) - { - constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE); - -@@ -151,7 +149,7 @@ std::tuple GetPacketExtradata(const AVPacket* pkt, - * for certain codecs, as noted in discussion of PR#21248 - */ - -- AVCodecID codecId = codecCtx->codec_id; -+ AVCodecID codecId = codecPar->codec_id; - - // clang-format off - if ( -@@ -178,7 +176,12 @@ std::tuple GetPacketExtradata(const AVPacket* pkt, - if (ret < 0) - return std::make_tuple(nullptr, 0); - -- bsf->par_in->codec_id = codecId; -+ ret = avcodec_parameters_copy(bsf->par_in, codecPar); -+ if (ret < 0) -+ { -+ av_bsf_free(&bsf); -+ return std::make_tuple(nullptr, 0); -+ } - - ret = av_bsf_init(bsf); - if (ret < 0) -diff --git a/xbmc/cores/FFmpeg.h b/xbmc/cores/FFmpeg.h -index 05547a0ba2b5f..5e35d58c6b0a6 100644 ---- a/xbmc/cores/FFmpeg.h -+++ b/xbmc/cores/FFmpeg.h -@@ -73,5 +73,4 @@ class CFFmpegLog - }; - - std::tuple GetPacketExtradata(const AVPacket* pkt, -- const AVCodecParserContext* parserCtx, -- AVCodecContext* codecCtx); -+ const AVCodecParameters* codecPar); -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -index 052332331702a..9ca07b9a2dd39 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -@@ -162,7 +162,15 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - avpkt->size = pkt->iSize; - avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; - -- auto [retExtraData, len] = GetPacketExtradata(avpkt, stream->m_parser, stream->m_context); -+ AVCodecParameters* codecPar = nullptr; -+ int ret = avcodec_parameters_from_context(codecPar, stream->m_context); -+ if (ret < 0) -+ { -+ CLog::LogF(LOGERROR, "avcodec_parameters_from_context failed"); -+ return false; -+ } -+ -+ auto [retExtraData, len] = GetPacketExtradata(avpkt, codecPar); - if (len > 0) - { - st->changes++; -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -index 7e6a2e10616d7..bc6b54c87235d 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -@@ -2290,8 +2290,7 @@ void CDVDDemuxFFmpeg::ParsePacket(AVPacket* pkt) - parser->second->m_parserCtx->parser && - !st->codecpar->extradata) - { -- auto [retExtraData, i] = -- GetPacketExtradata(pkt, parser->second->m_parserCtx, parser->second->m_codecCtx); -+ auto [retExtraData, i] = GetPacketExtradata(pkt, st->codecpar); - if (i > 0) - { - st->codecpar->extradata_size = i; - - -From f30f1e6418ea60bc7cb081c59f5f1d9431d264e6 Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Sat, 11 Mar 2023 13:28:38 -0800 -Subject: [PATCH 01/10] CDVDAudioCodecFFmpeg: ifdef use of - AV_CODEC_FLAG_TRUNCATED for ffmpeg 6.0 - -Signed-off-by: Lukas Rusak ---- - xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -index b2849c797dbc4..325bb0b7549ab 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -@@ -73,8 +73,10 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options - m_pCodecContext->debug = 0; - m_pCodecContext->workaround_bugs = 1; - -+#if LIBAVCODEC_VERSION_MAJOR < 60 - if (pCodec->capabilities & AV_CODEC_CAP_TRUNCATED) - m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED; -+#endif - - m_matrixEncoding = AV_MATRIX_ENCODING_NONE; - m_channels = 0; - -From 3b71910ee0bb650816456ecc9a21251aff650c4d Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Sat, 11 Mar 2023 13:29:18 -0800 -Subject: [PATCH 02/10] CDVDAudioCodecFFmpeg: fix setting channel layout mask - when opening codec - -Signed-off-by: Lukas Rusak ---- - .../DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 17 ++++++++++++++--- - 1 file changed, 14 insertions(+), 3 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -index 325bb0b7549ab..d1fb2cfe96afc 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp -@@ -80,13 +80,21 @@ - m_channels = 0; - #if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \ - LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100) -- av_channel_layout_uninit(&m_pCodecContext->ch_layout); -- m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE; -- m_pCodecContext->ch_layout.nb_channels = hints.channels; -+ if (hints.channels > 0 && hints.channellayout > 0) -+ { -+ m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE; -+ m_pCodecContext->ch_layout.nb_channels = hints.channels; -+ m_pCodecContext->ch_layout.u.mask = hints.channellayout; -+ } -+ else if (hints.channels > 0) -+ { -+ av_channel_layout_default(&m_pCodecContext->ch_layout, hints.channels); -+ } -+ -+ m_hint_layout = m_pCodecContext->ch_layout.u.mask; - #else - m_pCodecContext->channels = hints.channels; - #endif -- m_hint_layout = hints.channellayout; - m_pCodecContext->sample_rate = hints.samplerate; - m_pCodecContext->block_align = hints.blockalign; - m_pCodecContext->bit_rate = hints.bitrate; - -From f4fadb3ba4583c45fb06908a3eb352be8c29f235 Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Sat, 11 Mar 2023 13:29:34 -0800 -Subject: [PATCH 03/10] CDVDAudioCodecFFmpeg: drop unneeded use of - AVFMT_FLAG_PRIV_OPT - -Signed-off-by: Lukas Rusak ---- - xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -index bc6b54c87235d..016d198206716 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp -@@ -323,7 +323,6 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool - } - if (result < 0) - { -- m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT; - if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0) - { - CLog::Log(LOGDEBUG, "Error, could not open file {}", CURL::GetRedacted(strFile)); -@@ -335,7 +334,6 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool - avformat_close_input(&m_pFormatContext); - m_pFormatContext = avformat_alloc_context(); - m_pFormatContext->interrupt_callback = int_cb; -- m_pFormatContext->flags &= ~AVFMT_FLAG_PRIV_OPT; - AVDictionary* options = GetFFMpegOptionsFromInput(); - av_dict_set_int(&options, "load_all_variants", 0, AV_OPT_SEARCH_CHILDREN); - if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0) - -From 7d03f33b83e5fb127a7495798a20c3b63ac06795 Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Wed, 15 Mar 2023 19:58:56 -0700 -Subject: [PATCH 04/10] CDVDVideoCodecFFmpeg: update filter args to use - key/value pairs - -Signed-off-by: Lukas Rusak ---- - .../VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -index bb9c20bf9d06e..c080589896ce7 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -@@ -1164,8 +1164,9 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const std::string& filters, bool scale) - const AVFilter* outFilter = avfilter_get_by_name("buffersink"); // should be last filter in the graph for now - - std::string args = StringUtils::Format( -- "{}:{}:{}:{}:{}:{}:{}", m_pCodecContext->width, m_pCodecContext->height, -- m_pCodecContext->pix_fmt, m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1, -+ "video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", m_pCodecContext->width, -+ m_pCodecContext->height, m_pCodecContext->pix_fmt, -+ m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1, - m_pCodecContext->time_base.num ? m_pCodecContext->time_base.den : 1, - m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.num : 1, - m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.den : 1); - -From 30bd7912802cf0f608751c452c48fc1a2eb8d91b Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Wed, 15 Mar 2023 19:59:27 -0700 -Subject: [PATCH 05/10] CFFmpegPostproc: update filter args to use key/value - pairs - -Signed-off-by: Lukas Rusak ---- - xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -index 81b969d119667..6c4f664591a04 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -@@ -2962,10 +2962,11 @@ bool CFFmpegPostproc::Init(EINTERLACEMETHOD method) - const AVFilter* srcFilter = avfilter_get_by_name("buffer"); - const AVFilter* outFilter = avfilter_get_by_name("buffersink"); - -- std::string args = StringUtils::Format("{}:{}:{}:{}:{}:{}:{}", m_config.vidWidth, -- m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1, -- (m_config.aspect.num != 0) ? m_config.aspect.num : 1, -- (m_config.aspect.num != 0) ? m_config.aspect.den : 1); -+ std::string args = -+ StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", -+ m_config.vidWidth, m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1, -+ (m_config.aspect.num != 0) ? m_config.aspect.num : 1, -+ (m_config.aspect.num != 0) ? m_config.aspect.den : 1); - - if (avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args.c_str(), NULL, m_pFilterGraph) < 0) - { - -From 54a21151374a2d40a2a452fae2709205ed8e8836 Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Sat, 11 Mar 2023 19:32:09 -0800 -Subject: [PATCH 08/10] DXVA: CDecoder: replace removed av_mallocz_array with - av_calloc - -ref: https://ffmpeg.org/doxygen/5.0/group__lavu__mem__funcs.html\#ga6627f140c3f70847bc6d9690a2fd001f - -Signed-off-by: Lukas Rusak ---- - xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp -index a1bc3761c59d1..c06bd1ac0c7e6 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp -@@ -972,7 +972,8 @@ CDecoder::CDecoder(CProcessInfo& processInfo) - m_event.Set(); - m_avD3D11Context = av_d3d11va_alloc_context(); - m_avD3D11Context->cfg = reinterpret_cast(av_mallocz(sizeof(D3D11_VIDEO_DECODER_CONFIG))); -- m_avD3D11Context->surface = reinterpret_cast(av_mallocz_array(32, sizeof(ID3D11VideoDecoderOutputView*))); -+ m_avD3D11Context->surface = reinterpret_cast( -+ av_calloc(32, sizeof(ID3D11VideoDecoderOutputView*))); - m_bufferPool.reset(); - - DX::Windowing()->Register(this); - -From be1247d627cee6561174467094f1e8a46357df79 Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Sat, 11 Mar 2023 19:45:46 -0800 -Subject: [PATCH 09/10] CFFmpegImage: remove deprecated use of pkt_duration - -ref: https://ffmpeg.org/doxygen/6.0/structAVFrame.html\#a91725a40000e348b0607adf7f577e646 - -Signed-off-by: Lukas Rusak ---- - xbmc/guilib/FFmpegImage.cpp | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp -index e71980998b2e5..7171c046a9ce5 100644 ---- a/xbmc/guilib/FFmpegImage.cpp -+++ b/xbmc/guilib/FFmpegImage.cpp -@@ -294,7 +294,15 @@ AVFrame* CFFmpegImage::ExtractFrame() - return nullptr; - } - //we need milliseconds -- frame->pkt_duration = av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{ 1, 1000 }); -+ -+#if LIBAVCODEC_VERSION_MAJOR < 60 -+ frame->pkt_duration = -+ av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{1, 1000}); -+#else -+ frame->duration = -+ av_rescale_q(frame->duration, m_fctx->streams[0]->time_base, AVRational{1, 1000}); -+#endif -+ - m_height = frame->height; - m_width = frame->width; - m_originalWidth = m_width; -@@ -745,7 +753,13 @@ std::shared_ptr CFFmpegImage::ReadFrame() - if (avframe == nullptr) - return nullptr; - std::shared_ptr frame(new Frame()); -+ -+#if LIBAVCODEC_VERSION_MAJOR < 60 - frame->m_delay = (unsigned int)avframe->pkt_duration; -+#else -+ frame->m_delay = (unsigned int)avframe->duration; -+#endif -+ - frame->m_pitch = avframe->width * 4; - frame->m_pImage = (unsigned char*) av_malloc(avframe->height * frame->m_pitch); - DecodeFrame(avframe, avframe->width, avframe->height, frame->m_pitch, frame->m_pImage); - -From c12af890b0973f7c86316087e823f8a31c6b2ed3 Mon Sep 17 00:00:00 2001 -From: Lukas Rusak -Date: Sat, 11 Mar 2023 19:45:01 -0800 -Subject: [PATCH 10/10] CDVDVideoCodecFFmpeg: remove deprecated use of - reordered_opaque - -ref: https://ffmpeg.org/doxygen/6.0/structAVFrame.html#a12f572ed19a2cba6be3790393cee76b5 - -Signed-off-by: Lukas Rusak ---- - .../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 11 ++++++++++- - xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp | 6 ++++-- - xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 3 +++ - xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp | 5 ++++- - 4 files changed, 21 insertions(+), 4 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -index c080589896ce7..6a53ade4a7351 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp -@@ -370,6 +370,10 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options - m_pCodecContext->get_format = GetFormat; - m_pCodecContext->codec_tag = hints.codec_tag; - -+#if LIBAVCODEC_VERSION_MAJOR >= 60 -+ m_pCodecContext->flags = AV_CODEC_FLAG_COPY_OPAQUE; -+#endif -+ - // setup threading model - if (!(hints.codecOptions & CODEC_FORCE_SOFTWARE)) - { -@@ -545,9 +549,10 @@ void CDVDVideoCodecFFmpeg::UpdateName() - CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: {}", m_name); - } - -+#if LIBAVCODEC_VERSION_MAJOR < 60 - union pts_union - { -- double pts_d; -+ double pts_d; - int64_t pts_i; - }; - -@@ -557,6 +562,7 @@ static int64_t pts_dtoi(double pts) - u.pts_d = pts; - return u.pts_i; - } -+#endif - - bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet) - { -@@ -575,7 +581,10 @@ bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet) - m_started = true; - - m_dts = packet.dts; -+ -+#if LIBAVCODEC_VERSION_MAJOR < 60 - m_pCodecContext->reordered_opaque = pts_dtoi(packet.pts); -+#endif - - AVPacket* avpkt = av_packet_alloc(); - if (!avpkt) -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp -index c06bd1ac0c7e6..81451995ca1db 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp -@@ -1538,8 +1538,6 @@ int CDecoder::GetBuffer(AVCodecContext* avctx, AVFrame* pic) - return -1; - } - -- pic->reordered_opaque = avctx->reordered_opaque; -- - for (unsigned i = 0; i < 4; i++) - { - pic->data[i] = nullptr; -@@ -1556,6 +1554,10 @@ int CDecoder::GetBuffer(AVCodecContext* avctx, AVFrame* pic) - } - pic->buf[0] = buffer; - -+#if LIBAVCODEC_VERSION_MAJOR < 60 -+ pic->reordered_opaque = avctx->reordered_opaque; -+#endif -+ - Acquire(); - - return 0; -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -index 6c4f664591a04..447a13495d4e8 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp -@@ -867,7 +867,10 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags) - } - pic->buf[0] = buffer; - -+#if LIBAVCODEC_VERSION_MAJOR < 60 - pic->reordered_opaque = avctx->reordered_opaque; -+#endif -+ - va->Acquire(); - return 0; - } -diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp -index ec07af79de819..50e16d492ebc7 100644 ---- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp -+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp -@@ -1041,7 +1041,10 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags) - } - pic->buf[0] = buffer; - -- pic->reordered_opaque= avctx->reordered_opaque; -+#if LIBAVCODEC_VERSION_MAJOR < 60 -+ pic->reordered_opaque = avctx->reordered_opaque; -+#endif -+ - return 0; - } - - -From 928a7e4196046154419727a23c734d904e5e1b6c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Markus=20H=C3=A4rer?= -Date: Sun, 23 Apr 2023 23:29:28 +0200 -Subject: [PATCH] FFmpegImage: Switch back to jpeg_pipe for FFmpeg>=6.0 - ---- - xbmc/guilib/FFmpegImage.cpp | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp -index 7171c046a9ce5..429037740a7d2 100644 ---- a/xbmc/guilib/FFmpegImage.cpp -+++ b/xbmc/guilib/FFmpegImage.cpp -@@ -198,9 +198,16 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize) - bool is_png = (bufSize > 3 && buffer[1] == 'P' && buffer[2] == 'N' && buffer[3] == 'G'); - bool is_tiff = (bufSize > 2 && buffer[0] == 'I' && buffer[1] == 'I' && buffer[2] == '*'); - -+ // See Github #19113 -+#if LIBAVCODEC_VERSION_MAJOR < 60 -+ constexpr char jpegFormat[] = "image2"; -+#else -+ constexpr char jpegFormat[] = "jpeg_pipe"; -+#endif -+ - FFMPEG_FMT_CONST AVInputFormat* inp = nullptr; - if (is_jpeg) -- inp = av_find_input_format("image2"); -+ inp = av_find_input_format(jpegFormat); - else if (m_strMimeType == "image/apng") - inp = av_find_input_format("apng"); - else if (is_png) -@@ -213,7 +220,7 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize) - inp = av_find_input_format("webp_pipe"); - // brute force parse if above check already failed - else if (m_strMimeType == "image/jpeg" || m_strMimeType == "image/jpg") -- inp = av_find_input_format("image2"); -+ inp = av_find_input_format(jpegFormat); - else if (m_strMimeType == "image/png") - inp = av_find_input_format("png_pipe"); - else if (m_strMimeType == "image/tiff") - - -From 9d7f4dfd00d89d4a5d6d8095ee9b0b746051b30c Mon Sep 17 00:00:00 2001 -From: CrystalP -Date: Mon, 1 May 2023 13:26:56 -0400 -Subject: [PATCH] [fix] extern C for ffmpeg includes - ---- - xbmc/cores/RetroPlayer/process/RPProcessInfo.h | 3 +++ - xbmc/cores/RetroPlayer/rendering/RenderTranslator.h | 3 +++ - xbmc/cores/VideoPlayer/DVDFileInfo.cpp | 4 ++-- - xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h | 4 ++++ - .../VideoPlayer/VideoRenderers/windows/RendererShaders.h | 4 ++++ - 5 files changed, 16 insertions(+), 2 deletions(-) - -diff --git a/xbmc/cores/RetroPlayer/process/RPProcessInfo.h b/xbmc/cores/RetroPlayer/process/RPProcessInfo.h -index 9f930e78e9d84..f5ffe670d68aa 100644 ---- a/xbmc/cores/RetroPlayer/process/RPProcessInfo.h -+++ b/xbmc/cores/RetroPlayer/process/RPProcessInfo.h -@@ -17,7 +17,10 @@ - #include - #include - -+extern "C" -+{ - #include -+} - - class CDataCacheCore; - -diff --git a/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h b/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h -index 575ad814fc125..d78e1c25e4070 100644 ---- a/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h -+++ b/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h -@@ -10,7 +10,10 @@ - - #include "cores/GameSettings.h" - -+extern "C" -+{ - #include -+} - - namespace KODI - { -diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp -index 0860b40475b18..c7253bbd5497f 100644 ---- a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp -+++ b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp -@@ -32,8 +32,6 @@ - #include "DVDDemuxers/DVDDemuxVobsub.h" - #include "Process/ProcessInfo.h" - --#include --#include - #include "filesystem/File.h" - #include "cores/FFmpeg.h" - #include "TextureCache.h" -@@ -44,7 +42,9 @@ - #include - - extern "C" { -+#include - #include -+#include - } - - bool CDVDFileInfo::GetFileDuration(const std::string &path, int& duration) -diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h -index 9412377157f94..0eed9503dc9ac 100644 ---- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h -+++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h -@@ -13,7 +13,11 @@ - #include - - #include -+ -+extern "C" -+{ - #include -+} - - enum RenderMethod; - -diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h -index 945cadda76841..af4d677aae923 100644 ---- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h -+++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h -@@ -13,7 +13,11 @@ - #include - - #include -+ -+extern "C" -+{ - #include -+} - - #define PLANE_Y 0 - #define PLANE_U 1 diff --git a/media-tv/kodi/files/kodi-20.5-fix-crash-in-avcodec_parameters_from_context.patch b/media-tv/kodi/files/kodi-20.5-fix-crash-in-avcodec_parameters_from_context.patch deleted file mode 100644 index 376aa59..0000000 --- a/media-tv/kodi/files/kodi-20.5-fix-crash-in-avcodec_parameters_from_context.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 3ad9588656e30abd421e48147b23aee9fb4b3557 Mon Sep 17 00:00:00 2001 -From: Miguel Borges de Freitas <92enen@gmail.com> -Date: Sun, 12 Feb 2023 12:08:36 +0000 -Subject: [PATCH] [video] fix crash in avcodec_parameters_from_context - ---- - xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -index 9ca07b9a2dd39..26fa9522eea7a 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -@@ -162,11 +162,12 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - avpkt->size = pkt->iSize; - avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; - -- AVCodecParameters* codecPar = nullptr; -+ AVCodecParameters* codecPar = avcodec_parameters_alloc(); - int ret = avcodec_parameters_from_context(codecPar, stream->m_context); - if (ret < 0) - { - CLog::LogF(LOGERROR, "avcodec_parameters_from_context failed"); -+ avcodec_parameters_free(&codecPar); - return false; - } - -@@ -188,7 +189,7 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - avcodec_close(stream->m_context); - } - } -- -+ avcodec_parameters_free(&codecPar); - av_packet_free(&avpkt); - } - diff --git a/media-tv/kodi/files/kodi-20.5-smart_ptr-and-custom-destructor-for-AVCodecParameters.patch b/media-tv/kodi/files/kodi-20.5-smart_ptr-and-custom-destructor-for-AVCodecParameters.patch deleted file mode 100644 index 2ebf378..0000000 --- a/media-tv/kodi/files/kodi-20.5-smart_ptr-and-custom-destructor-for-AVCodecParameters.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 456d6557ea570f63dc18831242b9189f96c1097d Mon Sep 17 00:00:00 2001 -From: Steve Hartwell -Date: Sun, 12 Feb 2023 18:10:45 +0000 -Subject: [PATCH] [video] use smart_ptr and custom destructor for - AVCodecParameters - -Co-authored-by: Miguel Borges de Freitas <92enen@gmail.com> ---- - .../cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -index 26fa9522eea7a..2a42244b62b68 100644 ---- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp -@@ -14,7 +14,9 @@ - #include "cores/VideoPlayer/Interface/TimingConstants.h" - #include "utils/log.h" - -+#include - #include -+#include - #include - - class CDemuxStreamClientInternal -@@ -162,16 +164,17 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - avpkt->size = pkt->iSize; - avpkt->dts = avpkt->pts = AV_NOPTS_VALUE; - -- AVCodecParameters* codecPar = avcodec_parameters_alloc(); -- int ret = avcodec_parameters_from_context(codecPar, stream->m_context); -+ constexpr auto codecParDeleter = [](AVCodecParameters* p) { avcodec_parameters_free(&p); }; -+ auto codecPar = std::unique_ptr( -+ avcodec_parameters_alloc(), codecParDeleter); -+ int ret = avcodec_parameters_from_context(codecPar.get(), stream->m_context); - if (ret < 0) - { - CLog::LogF(LOGERROR, "avcodec_parameters_from_context failed"); -- avcodec_parameters_free(&codecPar); - return false; - } - -- auto [retExtraData, len] = GetPacketExtradata(avpkt, codecPar); -+ auto [retExtraData, len] = GetPacketExtradata(avpkt, codecPar.get()); - if (len > 0) - { - st->changes++; -@@ -189,7 +192,6 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt) - avcodec_close(stream->m_context); - } - } -- avcodec_parameters_free(&codecPar); - av_packet_free(&avpkt); - } - diff --git a/media-tv/kodi/files/kodi-20.5-swig-4.2.patch b/media-tv/kodi/files/kodi-20.5-swig-4.2.patch deleted file mode 100644 index 129dc23..0000000 --- a/media-tv/kodi/files/kodi-20.5-swig-4.2.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff -dNur a/xbmc/interfaces/swig/AddonModuleXbmcaddon.i b/xbmc/interfaces/swig/AddonModuleXbmcaddon.i ---- a/xbmc/interfaces/swig/AddonModuleXbmcaddon.i 2024-01-10 04:24:09.000000000 +0100 -+++ b/xbmc/interfaces/swig/AddonModuleXbmcaddon.i 2024-01-14 21:58:20.619762773 +0100 -@@ -33,5 +33,6 @@ - %include "interfaces/legacy/AddonString.h" - - %include "interfaces/legacy/Addon.h" -+%nodefaultctor Settings; - %include "interfaces/legacy/Settings.h" - diff --git a/media-tv/kodi/files/kodi-21.0-fix-head-use-after-free.patch b/media-tv/kodi/files/kodi-21.0-fix-head-use-after-free.patch deleted file mode 100644 index 6d22f42..0000000 --- a/media-tv/kodi/files/kodi-21.0-fix-head-use-after-free.patch +++ /dev/null @@ -1,333 +0,0 @@ -From 02e6b6f9003aaf3984ccb83b91df4bf4cd183c6f Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Markus=20H=C3=A4rer?= -Date: Mon, 1 Apr 2024 19:15:07 +0200 -Subject: [PATCH 1/2] [GUIIncludes] Fix heap-use-after-free - -Only remove the child if the node is actually a child. - -==51989==ERROR: AddressSanitizer: heap-use-after-free on address 0x511003b69210 at pc 0x5ce4b249275e bp 0x7fff43e1d430 sp 0x7fff43e1d428 -READ of size 8 at 0x511003b69210 thread T0 - #0 0x5ce4b249275d in TiXmlAttributeSet::First() /usr/include/tinyxml.h:915:50 - #1 0x5ce4b2492098 in TiXmlElement::FirstAttribute() /usr/include/tinyxml.h:1087:61 - #2 0x5ce4b2bb091e in CGUIIncludes::ResolveParametersForNode(TiXmlElement*, std::map, std::allocator>, std::__cxx11::basic_string, std::allocator>, std::less, std::allocator>>, std::allocator, std::allocator> const, std::__cxx11::basic_string, std::allocator>>>> const&) xbmc/guilib/GUIIncludes.cpp:586:37 - #3 0x5ce4b2bae9bb in CGUIIncludes::ResolveIncludes(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/guilib/GUIIncludes.cpp:485:9 - #4 0x5ce4b2ba8eaf in CGUIIncludes::Resolve(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/guilib/GUIIncludes.cpp:312:3 - #5 0x5ce4b2ba8fce in CGUIIncludes::Resolve(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/guilib/GUIIncludes.cpp:318:5 - #6 0x5ce4b3e808d3 in ADDON::CSkinInfo::ResolveIncludes(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/addons/Skin.cpp:307:14 - #7 0x5ce4b2e00084 in CGUIWindow::Prepare(std::unique_ptr> const&) xbmc/guilib/GUIWindow.cpp:168:15 - #8 0x5ce4b2dff45e in CGUIWindow::LoadXML(std::__cxx11::basic_string, std::allocator> const&, std::__cxx11::basic_string, std::allocator> const&) xbmc/guilib/GUIWindow.cpp:155:15 - #9 0x5ce4b2dfd540 in CGUIWindow::Load(std::__cxx11::basic_string, std::allocator> const&, bool) xbmc/guilib/GUIWindow.cpp:109:14 - #10 0x5ce4b2e1cac5 in CGUIWindow::AllocResources(bool) xbmc/guilib/GUIWindow.cpp:765:7 - #11 0x5ce4b2e14c77 in CGUIWindow::OnMessage(CGUIMessage&) xbmc/guilib/GUIWindow.cpp:594:52 - #12 0x5ce4b19ce9d2 in CGUIWindowHome::OnMessage(CGUIMessage&) xbmc/windows/GUIWindowHome.cpp:182:22 - #13 0x5ce4b2e613a1 in CGUIWindowManager::ActivateWindow_Internal(int, std::vector, std::allocator>, std::allocator, std::allocator>>> const&, bool, bool) xbmc/guilib/GUIWindowManager.cpp:896:15 - #14 0x5ce4b2e5ce3c in CGUIWindowManager::ActivateWindow(int, std::vector, std::allocator>, std::allocator, std::allocator>>> const&, bool, bool) xbmc/guilib/GUIWindowManager.cpp:802:5 - #15 0x5ce4b683ad63 in int (anonymous namespace)::ActivateWindow(std::vector, std::allocator>, std::allocator, std::allocator>>> const&) xbmc/interfaces/builtins/GUIBuiltins.cpp:109:52 - #16 0x5ce4b6822865 in CBuiltins::Execute(std::__cxx11::basic_string, std::allocator> const&) xbmc/interfaces/builtins/Builtins.cpp:158:14 - #17 0x5ce4b34047ff in CApplication::ExecuteXBMCAction(std::__cxx11::basic_string, std::allocator>, std::shared_ptr const&) xbmc/application/Application.cpp:3037:32 - #18 0x5ce4b3400a16 in CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp:3013:14 - #19 0x5ce4b34058a0 in non-virtual thunk to CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp - #20 0x5ce4b2e52261 in CGUIWindowManager::SendMessage(CGUIMessage&) xbmc/guilib/GUIWindowManager.cpp:510:23 - #21 0x5ce4b2e7cc7f in CGUIWindowManager::DispatchThreadMessages() xbmc/guilib/GUIWindowManager.cpp:1572:7 - #22 0x5ce4b3405bfa in CApplication::Process() xbmc/application/Application.cpp:3139:48 - #23 0x5ce4b33ddc98 in CApplication::Run() xbmc/application/Application.cpp:1855:5 - #24 0x5ce4b251b323 in XBMC_Run xbmc/platform/xbmc.cpp:61:26 - #25 0x5ce4af14af0f in main xbmc/platform/posix/main.cpp:70:16 - #26 0x76d804243ccf (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - #27 0x76d804243d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - #28 0x5ce4af010b94 in _start (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi.bin+0xa317b94) (BuildId: 923aa634157be6adc50052366abd3ca0edfeffc0) - -0x511003b69210 is located 208 bytes inside of 216-byte region [0x511003b69140,0x511003b69218) -freed by thread T0 here: - #0 0x5ce4af148d72 in operator delete(void*, unsigned long) (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi.bin+0xa44fd72) (BuildId: 923aa634157be6adc50052366abd3ca0edfeffc0) - #1 0x76d80670ea48 in TiXmlNode::RemoveChild(TiXmlNode*) (/usr/lib/libtinyxml.so.0+0x8a48) (BuildId: 2f5d236264d4d695dbe432f41e1eb46c7bc2d5d4) - #2 0x5ce4b2bae9a3 in CGUIIncludes::ResolveIncludes(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/guilib/GUIIncludes.cpp:482:9 - #3 0x5ce4b2ba8eaf in CGUIIncludes::Resolve(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/guilib/GUIIncludes.cpp:312:3 - #4 0x5ce4b2ba8fce in CGUIIncludes::Resolve(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/guilib/GUIIncludes.cpp:318:5 - #5 0x5ce4b3e808d3 in ADDON::CSkinInfo::ResolveIncludes(TiXmlElement*, std::map, bool, std::less>, std::allocator const, bool>>>*) xbmc/addons/Skin.cpp:307:14 - #6 0x5ce4b2e00084 in CGUIWindow::Prepare(std::unique_ptr> const&) xbmc/guilib/GUIWindow.cpp:168:15 - #7 0x5ce4b2dff45e in CGUIWindow::LoadXML(std::__cxx11::basic_string, std::allocator> const&, std::__cxx11::basic_string, std::allocator> const&) xbmc/guilib/GUIWindow.cpp:155:15 - #8 0x5ce4b2dfd540 in CGUIWindow::Load(std::__cxx11::basic_string, std::allocator> const&, bool) xbmc/guilib/GUIWindow.cpp:109:14 - #9 0x5ce4b2e1cac5 in CGUIWindow::AllocResources(bool) xbmc/guilib/GUIWindow.cpp:765:7 - #10 0x5ce4b2e14c77 in CGUIWindow::OnMessage(CGUIMessage&) xbmc/guilib/GUIWindow.cpp:594:52 - #11 0x5ce4b19ce9d2 in CGUIWindowHome::OnMessage(CGUIMessage&) xbmc/windows/GUIWindowHome.cpp:182:22 - #12 0x5ce4b2e613a1 in CGUIWindowManager::ActivateWindow_Internal(int, std::vector, std::allocator>, std::allocator, std::allocator>>> const&, bool, bool) xbmc/guilib/GUIWindowManager.cpp:896:15 - #13 0x5ce4b2e5ce3c in CGUIWindowManager::ActivateWindow(int, std::vector, std::allocator>, std::allocator, std::allocator>>> const&, bool, bool) xbmc/guilib/GUIWindowManager.cpp:802:5 - #14 0x5ce4b683ad63 in int (anonymous namespace)::ActivateWindow(std::vector, std::allocator>, std::allocator, std::allocator>>> const&) xbmc/interfaces/builtins/GUIBuiltins.cpp:109:52 - #15 0x5ce4b6822865 in CBuiltins::Execute(std::__cxx11::basic_string, std::allocator> const&) xbmc/interfaces/builtins/Builtins.cpp:158:14 - #16 0x5ce4b34047ff in CApplication::ExecuteXBMCAction(std::__cxx11::basic_string, std::allocator>, std::shared_ptr const&) xbmc/application/Application.cpp:3037:32 - #17 0x5ce4b3400a16 in CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp:3013:14 - #18 0x5ce4b34058a0 in non-virtual thunk to CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp - #19 0x5ce4b2e52261 in CGUIWindowManager::SendMessage(CGUIMessage&) xbmc/guilib/GUIWindowManager.cpp:510:23 - #20 0x5ce4b2e7cc7f in CGUIWindowManager::DispatchThreadMessages() xbmc/guilib/GUIWindowManager.cpp:1572:7 - #21 0x5ce4b3405bfa in CApplication::Process() xbmc/application/Application.cpp:3139:48 - #22 0x5ce4b33ddc98 in CApplication::Run() xbmc/application/Application.cpp:1855:5 - #23 0x5ce4b251b323 in XBMC_Run xbmc/platform/xbmc.cpp:61:26 - #24 0x5ce4af14af0f in main xbmc/platform/posix/main.cpp:70:16 - #25 0x76d804243ccf (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - -previously allocated by thread T0 here: - #0 0x5ce4af147e12 in operator new(unsigned long) (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi.bin+0xa44ee12) (BuildId: 923aa634157be6adc50052366abd3ca0edfeffc0) - #1 0x76d806711497 in TiXmlElement::Clone() const (/usr/lib/libtinyxml.so.0+0xb497) (BuildId: 2f5d236264d4d695dbe432f41e1eb46c7bc2d5d4) - -SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/tinyxml.h:915:50 in TiXmlAttributeSet::First() -Shadow bytes around the buggy address: - 0x511003b68f80: 00 00 00 fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69100: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd - 0x511003b69180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd -=>0x511003b69200: fd fd[fd]fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69280: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69380: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x511003b69480: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa -Shadow byte legend (one shadow byte represents 8 application bytes): - Addressable: 00 - Partially addressable: 01 02 03 04 05 06 07 - Heap left redzone: fa - Freed heap region: fd - Stack left redzone: f1 - Stack mid redzone: f2 - Stack right redzone: f3 - Stack after return: f5 - Stack use after scope: f8 - Global redzone: f9 - Global init order: f6 - Poisoned by user: f7 - Container overflow: fc - Array cookie: ac - Intra object redzone: bb - ASan internal: fe - Left alloca redzone: ca - Right alloca redzone: cb -==51989==ABORTING - -(cherry picked from commit 52988c92e934e593ddb8e93d6369f0636dc7db84) ---- - xbmc/guilib/GUIIncludes.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/xbmc/guilib/GUIIncludes.cpp b/xbmc/guilib/GUIIncludes.cpp -index 55d967346f1f5..da8f3a33c943e 100644 ---- a/xbmc/guilib/GUIIncludes.cpp -+++ b/xbmc/guilib/GUIIncludes.cpp -@@ -529,7 +529,8 @@ void CGUIIncludes::InsertNested(TiXmlElement *controls, TiXmlElement *include, T - } - child = child->NextSiblingElement(); - } -- target->RemoveChild(nested); -+ if (nested != node) -+ target->RemoveChild(nested); - } - - } - -From 25dec1b0ee14b65cc44d0fd1792e4e6b583fbdcb Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Markus=20H=C3=A4rer?= -Date: Mon, 1 Apr 2024 19:24:57 +0200 -Subject: [PATCH 2/2] [GUIBaseContainer] Fix heap-use-after-free - -See comment in code for information. - -==30885==ERROR: AddressSanitizer: heap-use-after-free on address 0x51800050bbe8 at pc 0x56aa085d20db bp 0x7ffd92777f50 sp 0x7ffd92777f48 -READ of size 1 at 0x51800050bbe8 thread T0 - #0 0x56aa085d20da in CGUIAction::ExecuteActions(int, int, std::shared_ptr const&) const xbmc/guilib/GUIAction.cpp:86:9 - #1 0x56aa084b7701 in CStaticListProvider::OnClick(std::shared_ptr const&) xbmc/guilib/listproviders/StaticProvider.cpp:136:40 - #2 0x56aa0862e065 in CGUIBaseContainer::OnClick(int) xbmc/guilib/GUIBaseContainer.cpp:881:27 - #3 0x56aa0862b09c in CGUIBaseContainer::OnAction(CAction const&) xbmc/guilib/GUIBaseContainer.cpp:474:28 - #4 0x56aa08c4bdf5 in CGUIWrappingListContainer::OnAction(CAction const&) xbmc/guilib/GUIWrappingListContainer.cpp:75:29 - #5 0x56aa08b8f441 in CGUIWindow::OnAction(CAction const&) xbmc/guilib/GUIWindow.cpp:429:27 - #6 0x56aa08bee00c in CGUIWindowManager::HandleAction(CAction const&) const xbmc/guilib/GUIWindowManager.cpp:1199:20 - #7 0x56aa08bec973 in CGUIWindowManager::OnAction(CAction const&) const xbmc/guilib/GUIWindowManager.cpp:1144:11 - #8 0x56aa0912be04 in CApplication::OnAction(CAction const&) xbmc/application/Application.cpp:913:54 - #9 0x56aa0c914de1 in CInputManager::ExecuteInputAction(CAction const&) xbmc/input/InputManager.cpp:746:29 - #10 0x56aa0c921842 in CInputManager::HandleKey(CKey const&) xbmc/input/InputManager.cpp:680:10 - #11 0x56aa0c91c2ec in CInputManager::OnKeyUp(CKey const&) xbmc/input/InputManager.cpp:693:5 - #12 0x56aa0c917737 in CInputManager::OnEvent(XBMC_Event&) xbmc/input/InputManager.cpp:361:7 - #13 0x56aa090fe458 in CAppInboundProtocol::HandleEvents() xbmc/application/AppInboundProtocol.cpp:113:43 - #14 0x56aa0915b240 in CApplication::FrameMove(bool, bool) xbmc/application/Application.cpp:1756:17 - #15 0x56aa0915f200 in CApplication::Run() xbmc/application/Application.cpp:1860:7 - #16 0x56aa0829c3e3 in XBMC_Run xbmc/platform/xbmc.cpp:61:26 - #17 0x56aa04ecbfcf in main xbmc/platform/posix/main.cpp:70:16 - #18 0x7517fb043ccf (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - #19 0x7517fb043d89 in __libc_start_main (/usr/lib/libc.so.6+0x25d89) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - #20 0x56aa04d91c54 in _start (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi.bin+0xa317c54) (BuildId: 7f84180dd757174de6de03b115843129667234d3) - -0x51800050bbe8 is located 872 bytes inside of 880-byte region [0x51800050b880,0x51800050bbf0) -freed by thread T0 here: - #0 0x56aa04ec996a in operator delete(void*) (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi.bin+0xa44f96a) (BuildId: 7f84180dd757174de6de03b115843129667234d3) - #1 0x56aa08ae24d1 in CGUIStaticItem::~CGUIStaticItem() xbmc/guilib/GUIStaticItem.h:55:38 - #2 0x56aa05922763 in std::_Sp_counted_ptr::_M_dispose() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/shared_ptr_base.h:428:9 - #3 0x56aa04ecd0bc in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/shared_ptr_base.h:346:8 - #4 0x56aa04eccca9 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/shared_ptr_base.h:1071:11 - #5 0x56aa050d1c6c in std::__shared_ptr::~__shared_ptr() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/shared_ptr_base.h:1524:31 - #6 0x56aa050c6ee8 in std::shared_ptr::~shared_ptr() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/shared_ptr.h:175:11 - #7 0x56aa08465110 in void std::_Destroy>(std::shared_ptr*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_construct.h:151:19 - #8 0x56aa0846505e in void std::_Destroy_aux::__destroy*>(std::shared_ptr*, std::shared_ptr*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_construct.h:163:6 - #9 0x56aa08465024 in void std::_Destroy*>(std::shared_ptr*, std::shared_ptr*) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_construct.h:195:7 - #10 0x56aa084a624b in void std::_Destroy*, std::shared_ptr>(std::shared_ptr*, std::shared_ptr*, std::allocator>&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/alloc_traits.h:947:7 - #11 0x56aa084a624b in std::vector, std::allocator>>::~vector() /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/stl_vector.h:732:2 - #12 0x56aa086169e5 in CGUIBaseContainer::~CGUIBaseContainer() xbmc/guilib/GUIBaseContainer.cpp:117:1 - #13 0x56aa08c4a148 in CGUIWrappingListContainer::~CGUIWrappingListContainer() xbmc/guilib/GUIWrappingListContainer.cpp:26:59 - #14 0x56aa08c4a198 in CGUIWrappingListContainer::~CGUIWrappingListContainer() xbmc/guilib/GUIWrappingListContainer.cpp:26:59 - #15 0x56aa08758935 in CGUIControlGroup::ClearAll() xbmc/guilib/GUIControlGroup.cpp:525:5 - #16 0x56aa08743bb9 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:56:3 - #17 0x56aa08743c48 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:55:1 - #18 0x56aa08758935 in CGUIControlGroup::ClearAll() xbmc/guilib/GUIControlGroup.cpp:525:5 - #19 0x56aa08743bb9 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:56:3 - #20 0x56aa08743c48 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:55:1 - #21 0x56aa08758935 in CGUIControlGroup::ClearAll() xbmc/guilib/GUIControlGroup.cpp:525:5 - #22 0x56aa08743bb9 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:56:3 - #23 0x56aa08743c48 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:55:1 - #24 0x56aa08758935 in CGUIControlGroup::ClearAll() xbmc/guilib/GUIControlGroup.cpp:525:5 - #25 0x56aa08743bb9 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:56:3 - #26 0x56aa08743c48 in CGUIControlGroup::~CGUIControlGroup() xbmc/guilib/GUIControlGroup.cpp:55:1 - #27 0x56aa08758935 in CGUIControlGroup::ClearAll() xbmc/guilib/GUIControlGroup.cpp:525:5 - #28 0x56aa08b9f39d in CGUIWindow::ClearAll() xbmc/guilib/GUIWindow.cpp:816:21 - #29 0x56aa08b9ed97 in CGUIWindow::FreeResources(bool) xbmc/guilib/GUIWindow.cpp:799:53 - #30 0x56aa08bf8e34 in CGUIWindowManager::DeInitialize() xbmc/guilib/GUIWindowManager.cpp:1452:14 - #31 0x56aa09264d22 in CApplicationSkinHandling::UnloadSkin() xbmc/application/ApplicationSkinHandling.cpp:235:29 - #32 0x56aa0925e0fd in CApplicationSkinHandling::LoadSkin(std::__cxx11::basic_string, std::allocator> const&) xbmc/application/ApplicationSkinHandling.cpp:111:3 - #33 0x56aa0926a8e6 in CApplicationSkinHandling::ReloadSkin(bool) xbmc/application/ApplicationSkinHandling.cpp:390:7 - #34 0x56aa0c635399 in ReloadSkin(std::vector, std::allocator>, std::allocator, std::allocator>>> const&) xbmc/interfaces/builtins/SkinBuiltins.cpp:46:12 - #35 0x56aa0c5a39e5 in CBuiltins::Execute(std::__cxx11::basic_string, std::allocator> const&) xbmc/interfaces/builtins/Builtins.cpp:158:14 - #36 0x56aa0918597f in CApplication::ExecuteXBMCAction(std::__cxx11::basic_string, std::allocator>, std::shared_ptr const&) xbmc/application/Application.cpp:3037:32 - #37 0x56aa09181b96 in CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp:3013:14 - #38 0x56aa09186a20 in non-virtual thunk to CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp - #39 0x56aa08bd33e1 in CGUIWindowManager::SendMessage(CGUIMessage&) xbmc/guilib/GUIWindowManager.cpp:510:23 - #40 0x56aa085d2502 in CGUIAction::ExecuteActions(int, int, std::shared_ptr const&) const xbmc/guilib/GUIAction.cpp:89:52 - #41 0x56aa084b7701 in CStaticListProvider::OnClick(std::shared_ptr const&) xbmc/guilib/listproviders/StaticProvider.cpp:136:40 - #42 0x56aa0862e065 in CGUIBaseContainer::OnClick(int) xbmc/guilib/GUIBaseContainer.cpp:881:27 - #43 0x56aa0862b09c in CGUIBaseContainer::OnAction(CAction const&) xbmc/guilib/GUIBaseContainer.cpp:474:28 - #44 0x56aa08c4bdf5 in CGUIWrappingListContainer::OnAction(CAction const&) xbmc/guilib/GUIWrappingListContainer.cpp:75:29 - #45 0x56aa08b8f441 in CGUIWindow::OnAction(CAction const&) xbmc/guilib/GUIWindow.cpp:429:27 - #46 0x56aa08bee00c in CGUIWindowManager::HandleAction(CAction const&) const xbmc/guilib/GUIWindowManager.cpp:1199:20 - #47 0x56aa08bec973 in CGUIWindowManager::OnAction(CAction const&) const xbmc/guilib/GUIWindowManager.cpp:1144:11 - #48 0x56aa0912be04 in CApplication::OnAction(CAction const&) xbmc/application/Application.cpp:913:54 - #49 0x56aa0c914de1 in CInputManager::ExecuteInputAction(CAction const&) xbmc/input/InputManager.cpp:746:29 - #50 0x56aa0c921842 in CInputManager::HandleKey(CKey const&) xbmc/input/InputManager.cpp:680:10 - #51 0x56aa0c91c2ec in CInputManager::OnKeyUp(CKey const&) xbmc/input/InputManager.cpp:693:5 - #52 0x56aa0c917737 in CInputManager::OnEvent(XBMC_Event&) xbmc/input/InputManager.cpp:361:7 - #53 0x56aa090fe458 in CAppInboundProtocol::HandleEvents() xbmc/application/AppInboundProtocol.cpp:113:43 - #54 0x56aa0915b240 in CApplication::FrameMove(bool, bool) xbmc/application/Application.cpp:1756:17 - #55 0x56aa0915f200 in CApplication::Run() xbmc/application/Application.cpp:1860:7 - #56 0x56aa0829c3e3 in XBMC_Run xbmc/platform/xbmc.cpp:61:26 - #57 0x56aa04ecbfcf in main xbmc/platform/posix/main.cpp:70:16 - #58 0x7517fb043ccf (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - -previously allocated by thread T0 here: - #0 0x56aa04ec8ed2 in operator new(unsigned long) (/home/mark/Coding/Repos/kodi-git/build_clang_debug_sanitizer/kodi.bin+0xa44eed2) (BuildId: 7f84180dd757174de6de03b115843129667234d3) - #1 0x56aa084b3183 in CStaticListProvider::CStaticListProvider(TiXmlElement const*, int) xbmc/guilib/listproviders/StaticProvider.cpp:28:33 - #2 0x56aa0849c590 in std::__detail::_MakeUniq::__single_object std::make_unique(TiXmlElement const*&&, int&) /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../include/c++/13.2.1/bits/unique_ptr.h:1070:34 - #3 0x56aa0849bac7 in IListProvider::CreateSingle(TiXmlNode const*, int) xbmc/guilib/listproviders/IListProvider.cpp:34:12 - #4 0x56aa0849b582 in IListProvider::Create(TiXmlNode const*, int) xbmc/guilib/listproviders/IListProvider.cpp:25:12 - #5 0x56aa0864bbe8 in CGUIBaseContainer::LoadListProvider(TiXmlElement*, int, bool) xbmc/guilib/GUIBaseContainer.cpp:1282:20 - #6 0x56aa0871b1c3 in CGUIControlFactory::Create(int, CRectGen const&, TiXmlElement*, bool) xbmc/guilib/GUIControlFactory.cpp:1543:17 - #7 0x56aa08b884c4 in CGUIWindow::LoadControl(TiXmlElement*, CGUIControlGroup*, CRectGen const&) xbmc/guilib/GUIWindow.cpp:281:38 - #8 0x56aa08b8a088 in CGUIWindow::LoadControl(TiXmlElement*, CGUIControlGroup*, CRectGen const&) xbmc/guilib/GUIWindow.cpp:309:9 - #9 0x56aa08b8a088 in CGUIWindow::LoadControl(TiXmlElement*, CGUIControlGroup*, CRectGen const&) xbmc/guilib/GUIWindow.cpp:309:9 - #10 0x56aa08b8a088 in CGUIWindow::LoadControl(TiXmlElement*, CGUIControlGroup*, CRectGen const&) xbmc/guilib/GUIWindow.cpp:309:9 - #11 0x56aa08b8a088 in CGUIWindow::LoadControl(TiXmlElement*, CGUIControlGroup*, CRectGen const&) xbmc/guilib/GUIWindow.cpp:309:9 - #12 0x56aa08b87cf6 in CGUIWindow::Load(TiXmlElement*) xbmc/guilib/GUIWindow.cpp:264:11 - #13 0x56aa08b80657 in CGUIWindow::LoadXML(std::__cxx11::basic_string, std::allocator> const&, std::__cxx11::basic_string, std::allocator> const&) xbmc/guilib/GUIWindow.cpp:155:10 - #14 0x56aa08b7e6c0 in CGUIWindow::Load(std::__cxx11::basic_string, std::allocator> const&, bool) xbmc/guilib/GUIWindow.cpp:109:14 - #15 0x56aa08b9dc45 in CGUIWindow::AllocResources(bool) xbmc/guilib/GUIWindow.cpp:765:7 - #16 0x56aa08b95df7 in CGUIWindow::OnMessage(CGUIMessage&) xbmc/guilib/GUIWindow.cpp:594:52 - #17 0x56aa08be2521 in CGUIWindowManager::ActivateWindow_Internal(int, std::vector, std::allocator>, std::allocator, std::allocator>>> const&, bool, bool) xbmc/guilib/GUIWindowManager.cpp:896:15 - #18 0x56aa08bddfbc in CGUIWindowManager::ActivateWindow(int, std::vector, std::allocator>, std::allocator, std::allocator>>> const&, bool, bool) xbmc/guilib/GUIWindowManager.cpp:802:5 - #19 0x56aa0c5b75f3 in int (anonymous namespace)::ActivateWindow(std::vector, std::allocator>, std::allocator, std::allocator>>> const&) xbmc/interfaces/builtins/GUIBuiltins.cpp:109:52 - #20 0x56aa0c5a39e5 in CBuiltins::Execute(std::__cxx11::basic_string, std::allocator> const&) xbmc/interfaces/builtins/Builtins.cpp:158:14 - #21 0x56aa0918597f in CApplication::ExecuteXBMCAction(std::__cxx11::basic_string, std::allocator>, std::shared_ptr const&) xbmc/application/Application.cpp:3037:32 - #22 0x56aa09181b96 in CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp:3013:14 - #23 0x56aa09186a20 in non-virtual thunk to CApplication::OnMessage(CGUIMessage&) xbmc/application/Application.cpp - #24 0x56aa08bd33e1 in CGUIWindowManager::SendMessage(CGUIMessage&) xbmc/guilib/GUIWindowManager.cpp:510:23 - #25 0x56aa085d2502 in CGUIAction::ExecuteActions(int, int, std::shared_ptr const&) const xbmc/guilib/GUIAction.cpp:89:52 - #26 0x56aa0867f896 in CGUIButtonControl::OnClick() xbmc/guilib/GUIButtonControl.cpp:393:16 - #27 0x56aa08677e86 in CGUIButtonControl::OnAction(CAction const&) xbmc/guilib/GUIButtonControl.cpp:212:5 - #28 0x56aa08b8f441 in CGUIWindow::OnAction(CAction const&) xbmc/guilib/GUIWindow.cpp:429:27 - #29 0x56aa08bee00c in CGUIWindowManager::HandleAction(CAction const&) const xbmc/guilib/GUIWindowManager.cpp:1199:20 - #30 0x56aa08bec973 in CGUIWindowManager::OnAction(CAction const&) const xbmc/guilib/GUIWindowManager.cpp:1144:11 - #31 0x56aa0912be04 in CApplication::OnAction(CAction const&) xbmc/application/Application.cpp:913:54 - #32 0x56aa0c914de1 in CInputManager::ExecuteInputAction(CAction const&) xbmc/input/InputManager.cpp:746:29 - #33 0x56aa0c921842 in CInputManager::HandleKey(CKey const&) xbmc/input/InputManager.cpp:680:10 - #34 0x56aa0c91c2ec in CInputManager::OnKeyUp(CKey const&) xbmc/input/InputManager.cpp:693:5 - #35 0x56aa0c917737 in CInputManager::OnEvent(XBMC_Event&) xbmc/input/InputManager.cpp:361:7 - #36 0x56aa090fe458 in CAppInboundProtocol::HandleEvents() xbmc/application/AppInboundProtocol.cpp:113:43 - #37 0x56aa0915b240 in CApplication::FrameMove(bool, bool) xbmc/application/Application.cpp:1756:17 - #38 0x56aa0915f200 in CApplication::Run() xbmc/application/Application.cpp:1860:7 - #39 0x56aa0829c3e3 in XBMC_Run xbmc/platform/xbmc.cpp:61:26 - #40 0x56aa04ecbfcf in main xbmc/platform/posix/main.cpp:70:16 - #41 0x7517fb043ccf (/usr/lib/libc.so.6+0x25ccf) (BuildId: c0caa0b7709d3369ee575fcd7d7d0b0fc48733af) - -SUMMARY: AddressSanitizer: heap-use-after-free xbmc/guilib/GUIAction.cpp:86:9 in CGUIAction::ExecuteActions(int, int, std::shared_ptr const&) const -Shadow bytes around the buggy address: - 0x51800050b900: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd - 0x51800050b980: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd - 0x51800050ba00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd - 0x51800050ba80: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd - 0x51800050bb00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd -=>0x51800050bb80: fd fd fd fd fd fd fd fd fd fd fd fd fd[fd]fa fa - 0x51800050bc00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa - 0x51800050bc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 0x51800050bd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 0x51800050bd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 0x51800050be00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -Shadow byte legend (one shadow byte represents 8 application bytes): - Addressable: 00 - Partially addressable: 01 02 03 04 05 06 07 - Heap left redzone: fa - Freed heap region: fd - Stack left redzone: f1 - Stack mid redzone: f2 - Stack right redzone: f3 - Stack after return: f5 - Stack use after scope: f8 - Global redzone: f9 - Global init order: f6 - Poisoned by user: f7 - Container overflow: fc - Array cookie: ac - Intra object redzone: bb - ASan internal: fe - Left alloca redzone: ca - Right alloca redzone: cb -==30885==ABORTING - -(cherry picked from commit 9e4cfd2d174bd939191d64e1788835a00ffcb28f) ---- - xbmc/guilib/GUIBaseContainer.cpp | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/xbmc/guilib/GUIBaseContainer.cpp b/xbmc/guilib/GUIBaseContainer.cpp -index c22eb71284f27..897459790dd76 100644 ---- a/xbmc/guilib/GUIBaseContainer.cpp -+++ b/xbmc/guilib/GUIBaseContainer.cpp -@@ -13,6 +13,7 @@ - #include "GUIListItemLayout.h" - #include "GUIMessage.h" - #include "ServiceBroker.h" -+#include "guilib/GUIListItem.h" - #include "guilib/guiinfo/GUIInfoLabels.h" - #include "guilib/listproviders/IListProvider.h" - #include "input/actions/Action.h" -@@ -875,10 +876,16 @@ bool CGUIBaseContainer::OnClick(int actionID) - int selected = GetSelectedItem(); - if (selected >= 0 && selected < static_cast(m_items.size())) - { -+ // One of the actions could trigger a reload of the GUI which destroys -+ // this CGUIBaseContainer and therefore the m_items[selected] we are -+ // going to process. The shared_ptr ensures that item survives until -+ // it has been processed. -+ std::shared_ptr item = m_items[selected]; -+ - if (m_clickActions.HasActionsMeetingCondition()) -- m_clickActions.ExecuteActions(0, GetParentID(), m_items[selected]); -+ m_clickActions.ExecuteActions(0, GetParentID(), item); - else -- m_listProvider->OnClick(m_items[selected]); -+ m_listProvider->OnClick(item); - } - return true; - } diff --git a/media-tv/kodi/kodi-20.5.ebuild b/media-tv/kodi/kodi-20.5.ebuild deleted file mode 100644 index 62d75ed..0000000 --- a/media-tv/kodi/kodi-20.5.ebuild +++ /dev/null @@ -1,482 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -# FFmpeg can be unbundled, but is currently stuck at a very old version. -# libdvd{css,read,nav} are not unbundlable without patching the buildsystem. - -# Versions for the forked projects that are bundled -# See tools/depends/target//-VERSION -LIBDVDCSS_VERSION="1.4.3-Next-Nexus-Alpha2-2" -LIBDVDREAD_VERSION="6.1.3-Next-Nexus-Alpha2-2" -LIBDVDNAV_VERSION="6.1.1-Next-Nexus-Alpha2-2" -FFMPEG_VERSION="4.4.1" -CODENAME="Nexus" -FFMPEG_KODI_VERSION="Alpha1" - -# Doesn't build with jdk-21 -_JAVA_PKG_WANT_BUILD_VM=( {openjdk{,-jre},icedtea}{,-bin}-{8,11,17} ) -JAVA_PKG_WANT_BUILD_VM=${_JAVA_PKG_WANT_BUILD_VM[@]} -# Required to be set, but not used. -JAVA_PKG_WANT_SOURCE="17" -JAVA_PKG_WANT_TARGET="17" - -PYTHON_REQ_USE="sqlite,ssl" -PYTHON_COMPAT=( python3_{10..11} ) # python3.12 support added in 21 - -CPU_FLAGS="cpu_flags_x86_sse cpu_flags_x86_sse2 cpu_flags_x86_sse3 cpu_flags_x86_sse4_1 cpu_flags_x86_sse4_2 cpu_flags_x86_avx cpu_flags_x86_avx2 cpu_flags_arm_neon" - -inherit cmake desktop flag-o-matic java-pkg-2 linux-info optfeature pax-utils python-single-r1 xdg - -DESCRIPTION="A free and open source media-player and entertainment hub" -HOMEPAGE="https://kodi.tv/" - -SRC_URI=" - https://github.com/xbmc/libdvdnav/archive/${LIBDVDNAV_VERSION}.tar.gz - -> libdvdnav-${LIBDVDNAV_VERSION}.tar.gz - https://github.com/xbmc/libdvdread/archive/${LIBDVDREAD_VERSION}.tar.gz - -> libdvdread-${LIBDVDREAD_VERSION}.tar.gz - css? ( - https://github.com/xbmc/libdvdcss/archive/${LIBDVDCSS_VERSION}.tar.gz - -> libdvdcss-${LIBDVDCSS_VERSION}.tar.gz - ) - !system-ffmpeg? ( - https://github.com/xbmc/FFmpeg/archive/${FFMPEG_VERSION}-${CODENAME}-${FFMPEG_KODI_VERSION}.tar.gz - -> ffmpeg-${PN}-${FFMPEG_VERSION}-${CODENAME}-${FFMPEG_KODI_VERSION}.tar.gz - ) -" -if [[ ${PV} == *9999 ]] ; then - EGIT_REPO_URI="https://github.com/xbmc/xbmc.git" - if [[ ${PV} != "9999" ]]; then - EGIT_BRANCH="${CODENAME}" - fi - inherit git-r3 -else - MY_PV=${PV/_p/_r} - MY_PV=${MY_PV/_alpha/a} - MY_PV=${MY_PV/_beta/b} - MY_PV=${MY_PV/_rc/RC} - MY_PV="${MY_PV}-${CODENAME}" - MY_P="${PN}-${MY_PV}" - SRC_URI+=" https://github.com/xbmc/xbmc/archive/${MY_PV}.tar.gz -> ${MY_P}.tar.gz" - KEYWORDS="~amd64 ~arm ~arm64 ~x86" - S=${WORKDIR}/xbmc-${MY_PV} -fi - -LICENSE="GPL-2+" -SLOT="0" -# use flag is called libusb so that it doesn't fool people in thinking that -# it is _required_ for USB support. Otherwise they'll disable udev and -# that's going to be worse. -IUSE="airplay alsa bluetooth bluray caps cec +css dbus doc eventclients gbm gles lcms libusb lirc mariadb mysql nfs +optical pipewire pulseaudio raspberry-pi samba system-ffmpeg test udf udev upnp vaapi vdpau wayland webserver X +xslt zeroconf ${CPU_FLAGS}" -REQUIRED_USE=" - ${PYTHON_REQUIRED_USE} - ^^ ( gbm wayland X ) - ?? ( mariadb mysql ) - bluray? ( udf ) - gbm? ( udev ) - udev? ( !libusb ) - vdpau? ( X !gles !gbm ) - zeroconf? ( dbus ) -" -RESTRICT="!test? ( test )" - -# dev-libs/libcec[-cubox] bug #818262 -COMMON_DEPEND=" - >=dev-libs/flatbuffers-1.12.0:= - >=dev-libs/lzo-2.04:2 - media-libs/giflib:= - >=media-libs/libjpeg-turbo-2.0.4:= - >=media-libs/libpng-1.6.26:0= - wayland? ( - dev-cpp/waylandpp:= - ) -" -COMMON_TARGET_DEPEND="${PYTHON_DEPS} - >=net-misc/curl-7.68.0[http2] - >=sys-libs/zlib-1.2.11 - dev-db/sqlite:3 - dev-libs/crossguid - >=dev-libs/fribidi-1.0.5 - >=dev-libs/libcdio-2.1.0:=[cxx] - >=dev-libs/libfmt-6.1.2:= - dev-libs/libfstrcmp - dev-libs/libpcre[cxx] - >=dev-libs/openssl-1.1.1k:0= - >=dev-libs/spdlog-1.5.0:= - dev-libs/tinyxml[stl] - media-fonts/roboto - media-libs/libglvnd[X?] - >=media-libs/freetype-2.10.1 - media-libs/harfbuzz:= - >=media-libs/libass-0.13.4:= - media-libs/mesa[egl(+),gbm(+)?,wayland?,X?] - >=media-libs/taglib-1.9.0 - sci-libs/kissfft - virtual/libiconv - virtual/ttf-fonts - x11-libs/libdrm - $(python_gen_cond_dep ' - dev-python/pillow[${PYTHON_USEDEP}] - dev-python/pycryptodome[${PYTHON_USEDEP}] - ') - airplay? ( - >=app-pda/libplist-2.0.0:= - net-libs/shairplay - ) - alsa? ( - >=media-libs/alsa-lib-1.1.4.1 - ) - bluetooth? ( - net-wireless/bluez:= - ) - bluray? ( - >=media-libs/libbluray-1.1.2:= - ) - caps? ( - sys-libs/libcap - ) - cec? ( - >=dev-libs/libcec-4.0[-cubox,raspberry-pi?] - ) - dbus? ( - sys-apps/dbus - ) - gbm? ( - >=dev-libs/libinput-1.10.5:= - x11-libs/libxkbcommon - ) - gles? ( - !raspberry-pi? ( - media-libs/mesa[gles2] - ) - ) - !gles? ( - media-libs/glu - ) - lcms? ( - >=media-libs/lcms-2.10:2 - ) - libusb? ( - virtual/libusb:1 - ) - lirc? ( - app-misc/lirc - ) - mariadb? ( - dev-db/mariadb-connector-c:= - ) - mysql? ( - dev-db/mysql-connector-c:= - ) - nfs? ( - >=net-fs/libnfs-2.0.0:= - ) - pipewire? ( - >=media-video/pipewire-0.3.24:= - ) - pulseaudio? ( - media-libs/libpulse - ) - raspberry-pi? ( - || ( - media-libs/raspberrypi-userland - media-libs/raspberrypi-userland-bin - media-libs/mesa[gles2,video_cards_vc4] - ) - ) - samba? ( - >=net-fs/samba-3.4.6[smbclient(+)] - ) - system-ffmpeg? ( - media-video/ffmpeg:=[openssl,encode,postproc,vaapi?,vdpau?,X?] - ) - !system-ffmpeg? ( - app-arch/bzip2 - media-libs/dav1d:= - ) - udf? ( - >=dev-libs/libudfread-1.0.0 - ) - udev? ( - virtual/libudev:= - ) - vaapi? ( - media-libs/libva:=[wayland?,X?] - ) - vdpau? ( - || ( - >=x11-libs/libvdpau-1.1 - >=x11-drivers/nvidia-drivers-180.51 - ) - ) - wayland? ( - >=x11-libs/libxkbcommon-0.4.1[wayland] - ) - webserver? ( - >=net-libs/libmicrohttpd-0.9.55:=[messages(+)] - ) - X? ( - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXrandr - ) - xslt? ( - dev-libs/libxslt - >=dev-libs/libxml2-2.9.4 - ) - zeroconf? ( - net-dns/avahi[dbus] - ) -" -RDEPEND=" - ${COMMON_DEPEND} - ${COMMON_TARGET_DEPEND} -" -DEPEND=" - ${COMMON_DEPEND} - ${COMMON_TARGET_DEPEND} - dev-libs/rapidjson - test? ( - >=dev-cpp/gtest-1.10.0 - ) - wayland? ( - >=dev-libs/wayland-protocols-1.7 - ) - X? ( - x11-base/xorg-proto - x11-libs/libXrender - ) -" -BDEPEND=" - ${COMMON_DEPEND} - dev-build/cmake - dev-lang/swig - virtual/pkgconfig - <=virtual/jre-17:* - doc? ( - app-text/doxygen - ) -" - -# bug #544020 -CONFIG_CHECK="~IP_MULTICAST" -ERROR_IP_MULTICAST=" -In some cases Kodi needs to access multicast addresses. -Please consider enabling IP_MULTICAST under Networking options. -" - -PATCHES=( - "${FILESDIR}"/${P}-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch - "${FILESDIR}"/${P}-CDVDInputStreamFile-use-64K-read-chunk-size-when-filesystem.patch - "${FILESDIR}"/${P}-swig-4.2.patch - "${FILESDIR}"/${P}-binutils-2.41.patch -) - -pkg_setup() { - check_extra_config - java-pkg-2_pkg_setup - python-single-r1_pkg_setup -} - -src_unpack() { - if [[ ${PV} == *9999 ]] ; then - git-r3_src_unpack - else - unpack ${MY_P}.tar.gz - fi -} - -src_prepare() { - cmake_src_prepare - - # avoid long delays when powerkit isn't running #348580 - sed -i \ - -e '/dbus_connection_send_with_reply_and_block/s:-1:3000:' \ - xbmc/platform/linux/*.cpp || die - - # Add all possible names for kissfft libraries - for datatype in {float,int16,int32,simd}; do - sed -i \ - -e "s/\(find_library(KISSFFT_LIBRARY NAMES .*\)/\1 kissfft-${datatype} kissfft-${datatype}-openmp/" \ - cmake/modules/FindKissFFT.cmake || die - done - - if use system-ffmpeg; then - eapply "${FILESDIR}"/${P}-ffmpeg5.patch - eapply "${FILESDIR}"/${P}-ffmpeg6.patch - eapply "${FILESDIR}"/${P}-fix-crash-in-avcodec_parameters_from_context.patch - eapply "${FILESDIR}"/${P}-smart_ptr-and-custom-destructor-for-AVCodecParameters.patch - fi -} - -src_configure() { - local mycmakeargs=( - -Wno-dev # less noise - - -DAPP_RENDER_SYSTEM=$(usex gles gles gl) - -DCORE_PLATFORM_NAME=$(usev gbm)$(usev wayland)$(usev X x11) - -Ddocdir="${EPREFIX}/usr/share/doc/${PF}" - -DENABLE_TESTING=$(usex test) - -DVERBOSE=ON - - # Enforce use of configured python interpeter - -DPYTHON_PATH=$(python_get_library_path) - -DPYTHON_VER=${EPYTHON##python} # wont work for pypy - - # Toolchain - -DENABLE_CCACHE=OFF - -DENABLE_CLANGFORMAT=OFF - -DENABLE_CLANGTIDY=OFF - -DENABLE_CPPCHECK=OFF - -DENABLE_INCLUDEWHATYOUUSE=OFF - # https://bugs.gentoo.org/show_bug.cgi?id=606124 - -DENABLE_GOLD=OFF - -DENABLE_LLD=OFF - -DENABLE_MOLD=OFF - -DUSE_LTO=OFF - - # Features - -DENABLE_AIRTUNES=$(usex airplay) - -DENABLE_ALSA=$(usex alsa) - -DENABLE_AVAHI=$(usex zeroconf) - -DENABLE_BLUETOOTH=$(usex bluetooth) - -DENABLE_BLURAY=$(usex bluray) - -DENABLE_CAP=$(usex caps) - -DENABLE_CEC=$(usex cec) - -DENABLE_DBUS=$(usex dbus) - -DENABLE_DVDCSS=$(usex css) - -DENABLE_EVENTCLIENTS=ON # alway enable to have 'kodi-send' and filter extra staff in 'src_install()' - -DENABLE_ISO9660PP=$(usex optical) - -DENABLE_LCMS2=$(usex lcms) - -DENABLE_LIRCCLIENT=$(usex lirc) - -DENABLE_MARIADBCLIENT=$(usex mariadb) - -DENABLE_MDNS=OFF # used only on Android - -DENABLE_MICROHTTPD=$(usex webserver) - -DENABLE_MYSQLCLIENT=$(usex mysql) - -DENABLE_NFS=$(usex nfs) - -DENABLE_OPENGL=$(usex !gles) - -DENABLE_OPENGLES=$(usex gles) - -DENABLE_OPTICAL=$(usex optical) - -DENABLE_PIPEWIRE=$(usex pipewire) - -DENABLE_PLIST=$(usex airplay) - -DENABLE_PULSEAUDIO=$(usex pulseaudio) - -DENABLE_SMBCLIENT=$(usex samba) - -DENABLE_SNDIO=OFF - -DENABLE_UDEV=$(usex udev) - -DENABLE_UDFREAD=$(usex udf) - -DENABLE_UPNP=$(usex upnp) - -DENABLE_VAAPI=$(usex vaapi) - -DENABLE_VDPAU=$(usex vdpau) - -DENABLE_XSLT=$(usex xslt) - - #To bundle or not - -DENABLE_INTERNAL_CROSSGUID=OFF - -DENABLE_INTERNAL_DAV1D=OFF - -DENABLE_INTERNAL_FFMPEG="$(usex !system-ffmpeg)" - -DENABLE_INTERNAL_FLATBUFFERS=OFF - -DENABLE_INTERNAL_FMT=OFF - -DENABLE_INTERNAL_FSTRCMP=OFF - -DENABLE_INTERNAL_GTEST=OFF - -DENABLE_INTERNAL_KISSFFT=OFF - -DENABLE_INTERNAL_PCRE=OFF - -DENABLE_INTERNAL_RapidJSON=OFF - -DENABLE_INTERNAL_SPDLOG=OFF - -DENABLE_INTERNAL_TAGLIB=OFF - -DENABLE_INTERNAL_UDFREAD=OFF - - -DWITH_FFMPEG=$(usex system-ffmpeg) - - -Dlibdvdnav_URL="${DISTDIR}/libdvdnav-${LIBDVDNAV_VERSION}.tar.gz" - -Dlibdvdread_URL="${DISTDIR}/libdvdread-${LIBDVDREAD_VERSION}.tar.gz" - ) - - # Separated to avoid "Manually-specified variables were not used by the project:" - use css && mycmakeargs+=( -Dlibdvdcss_URL="${DISTDIR}/libdvdcss-${LIBDVDCSS_VERSION}.tar.gz" ) - use !system-ffmpeg && mycmakeargs+=( - -DFFMPEG_URL="${DISTDIR}/ffmpeg-${PN}-${FFMPEG_VERSION}-${CODENAME}-${FFMPEG_KODI_VERSION}.tar.gz" - ) - use nfs && mycmakeargs+=( -DENABLE_INTERNAL_NFS=OFF ) - use !udev && mycmakeargs+=( -DENABLE_LIBUSB=$(usex libusb) ) - use X && use !gles && mycmakeargs+=( -DENABLE_GLX=ON ) - - for flag in ${CPU_FLAGS[@]} ; do - local name=${flag#cpu_flags_*_} - mycmakeargs+=( -DENABLE_${name^^}=$(usex ${flag}) ) - done - - if ! is-flag -DNDEBUG && ! is-flag -D_DEBUG ; then - # Kodi requires one of the 'NDEBUG' or '_DEBUG' defines - append-cflags -DNDEBUG - append-cxxflags -DNDEBUG - fi - - # Violates ODR (bug #860984) and USE_LTO does spooky stuff - # https://github.com/xbmc/xbmc/commit/cb72a22d54a91845b1092c295f84eeb48328921e - filter-lto - - cmake_src_configure -} - -src_compile() { - cmake_src_compile all - use doc && cmake_build doc - use test && cmake_build kodi-test -} - -src_test() { - local -x CMAKE_SKIP_TESTS=( - # Known failing, unreliable test - # bug #743938 - TestCPUInfo.GetCPUFrequency - # Test failure stemming from sci-libs/kissfft - # The difference between output[2i] and (i==freq1?1.0:0.0) is inf, which exceeds 1e-7, where output[2i] - # evaluates to inf,(i==freq1?1.0:0.0) evaluates to 0, and 1e-7 evaluates to 9.9999999999999995e-08. - TestRFFT.SimpleSignal - # bug #779184 - # https://github.com/xbmc/xbmc/issues/18594 - $(usev x86 TestDateTime.SetFromDBTime) - ) - - # see https://github.com/xbmc/xbmc/issues/17860#issuecomment-630120213 - local -x KODI_HOME="${BUILD_DIR}" - - cmake_src_test -} - -src_install() { - cmake_src_install - - # bug #457588 - pax-mark Em "${ED}"/usr/$(get_libdir)/${PN}/${PN}.bin - - newicon media/icon48x48.png kodi.png - - rm "${ED}"/usr/share/kodi/addons/skin.estuary/fonts/Roboto-Thin.ttf || die - dosym ../../../../fonts/roboto/Roboto-Thin.ttf \ - usr/share/kodi/addons/skin.estuary/fonts/Roboto-Thin.ttf - - if use !eventclients ; then - rm -f "${ED}"/usr/bin/kodi-ps3remote || die - rm -f "${D}"$(python_get_sitedir)/kodi/ps3_remote.py || die - rm -rf "${D}"$(python_get_sitedir)/kodi/ps3 || die - rm -rf "${D}"$(python_get_sitedir)/kodi/bt || die - rm -rf "${ED}"/usr/share/doc/${PF}/kodi-eventclients-dev || die - fi - - python_optimize "${D}$(python_get_sitedir)" - - einstalldocs - use doc && dodoc -r "${S}"/docs/html/ -} - -pkg_postinst() { - xdg_pkg_postinst - - if use dbus ; then - optfeature "getting battery level and active power source" sys-power/upower - optfeature "control of shutdown, reboot, suspend, and hibernate" sys-auth/elogind sys-apps/systemd - optfeature "storage management support (automounting, volume monitoring, etc)" sys-fs/udisks:2 - fi -} diff --git a/media-tv/kodi/kodi-21.0.ebuild b/media-tv/kodi/kodi-21.0.ebuild deleted file mode 100644 index fde96b4..0000000 --- a/media-tv/kodi/kodi-21.0.ebuild +++ /dev/null @@ -1,490 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -# FFmpeg can be unbundled, but is currently stuck at a very old version. -# libdvd{css,read,nav} are not unbundlable without patching the buildsystem. - -# Versions for the forked projects that are bundled -# See tools/depends/target//-VERSION -APACHE_COMMONS_LANG_VERSION="3.14.0" -APACHE_COMMONS_TEXT_VERSION="1.11.0" -FFMPEG_VERSION="6.0.1" -GROOVY_VERSION="4.0.16" -LIBDVDCSS_VERSION="1.4.3-Next-Nexus-Alpha2-2" -LIBDVDREAD_VERSION="6.1.3-Next-Nexus-Alpha2-2" -LIBDVDNAV_VERSION="6.1.1-Next-Nexus-Alpha2-2" - -CODENAME="Omega" - -# Doesn't build with jdk-21 -_JAVA_PKG_WANT_BUILD_VM=( {openjdk{,-jre},icedtea}{,-bin}-{8,11,17} ) -JAVA_PKG_WANT_BUILD_VM=${_JAVA_PKG_WANT_BUILD_VM[@]} -# Required to be set, but not used. -JAVA_PKG_WANT_SOURCE="17" -JAVA_PKG_WANT_TARGET="17" - -PYTHON_REQ_USE="sqlite,ssl" -PYTHON_COMPAT=( python3_{10..12} ) - -CPU_FLAGS="cpu_flags_x86_sse cpu_flags_x86_sse2 cpu_flags_x86_sse3 cpu_flags_x86_sse4_1 cpu_flags_x86_sse4_2 cpu_flags_x86_avx cpu_flags_x86_avx2 cpu_flags_arm_neon" - -inherit cmake desktop flag-o-matic java-pkg-2 linux-info optfeature pax-utils python-single-r1 xdg - -DESCRIPTION="A free and open source media-player and entertainment hub" -HOMEPAGE="https://kodi.tv/" - -SRC_URI=" - http://mirrors.kodi.tv/build-deps/sources/apache-groovy-binary-${GROOVY_VERSION}.zip - -> apache-groovy-binary-${GROOVY_VERSION}.zip - http://mirrors.kodi.tv/build-deps/sources/commons-lang3-${APACHE_COMMONS_LANG_VERSION}-bin.tar.gz - -> commons-lang3-${APACHE_COMMONS_LANG_VERSION}-bin.tar.gz - http://mirrors.kodi.tv/build-deps/sources/commons-text-${APACHE_COMMONS_TEXT_VERSION}-bin.tar.gz - -> commons-text-${APACHE_COMMONS_TEXT_VERSION}-bin.tar.gz - https://github.com/xbmc/libdvdnav/archive/${LIBDVDNAV_VERSION}.tar.gz - -> libdvdnav-${LIBDVDNAV_VERSION}.tar.gz - https://github.com/xbmc/libdvdread/archive/${LIBDVDREAD_VERSION}.tar.gz - -> libdvdread-${LIBDVDREAD_VERSION}.tar.gz - css? ( - https://github.com/xbmc/libdvdcss/archive/${LIBDVDCSS_VERSION}.tar.gz - -> libdvdcss-${LIBDVDCSS_VERSION}.tar.gz - ) - !system-ffmpeg? ( - https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz - -> ffmpeg-${PN}-${FFMPEG_VERSION}-${CODENAME}.tar.gz - ) -" -if [[ ${PV} == *9999 ]] ; then - EGIT_REPO_URI="https://github.com/xbmc/xbmc.git" - if [[ ${PV} != "9999" ]]; then - EGIT_BRANCH="${CODENAME}" - fi - inherit git-r3 -else - MY_PV=${PV/_p/_r} - MY_PV=${MY_PV/_alpha/a} - MY_PV=${MY_PV/_beta/b} - MY_PV=${MY_PV/_rc/RC} - MY_PV="${MY_PV}-${CODENAME}" - MY_P="${PN}-${MY_PV}" - SRC_URI+=" https://github.com/xbmc/xbmc/archive/${MY_PV}.tar.gz -> ${MY_P}.tar.gz" - KEYWORDS="~amd64 ~arm ~arm64 ~x86" - S=${WORKDIR}/xbmc-${MY_PV} -fi - -LICENSE="GPL-2+" -SLOT="0" -# use flag is called libusb so that it doesn't fool people in thinking that -# it is _required_ for USB support. Otherwise they'll disable udev and -# that's going to be worse. -IUSE="airplay alsa bluetooth bluray caps cec +css dbus doc eventclients gbm gles lcms libusb lirc mariadb mysql nfs +optical pipewire pulseaudio raspberry-pi samba system-ffmpeg test udf udev upnp vaapi vdpau wayland webserver X +xslt zeroconf ${CPU_FLAGS}" -REQUIRED_USE=" - ${PYTHON_REQUIRED_USE} - ^^ ( gbm wayland X ) - ?? ( mariadb mysql ) - bluray? ( udf ) - gbm? ( udev ) - udev? ( !libusb ) - vdpau? ( X !gles !gbm ) - zeroconf? ( dbus ) -" -RESTRICT="!test? ( test )" - -# dev-libs/libcec[-cubox] bug #818262 -COMMON_DEPEND=" - >=dev-libs/flatbuffers-1.12.0:= - >=dev-libs/lzo-2.04:2 - media-libs/giflib:= - >=media-libs/libjpeg-turbo-2.0.4:= - >=media-libs/libpng-1.6.26:0= - wayland? ( - dev-cpp/waylandpp:= - ) -" -COMMON_TARGET_DEPEND="${PYTHON_DEPS} - >=net-misc/curl-7.68.0[http2] - >=sys-libs/zlib-1.2.11 - dev-db/sqlite:3 - dev-libs/crossguid - >=dev-libs/fribidi-1.0.5 - >=dev-libs/libcdio-2.1.0:=[cxx] - >=dev-libs/libfmt-6.1.2:= - dev-libs/libfstrcmp - dev-libs/libpcre[cxx] - >=dev-libs/openssl-1.1.1k:0= - >=dev-libs/spdlog-1.5.0:= - dev-libs/tinyxml[stl] - >=dev-libs/tinyxml2-9.0.0:= - media-fonts/roboto - media-libs/libglvnd[X?] - >=media-libs/freetype-2.10.1 - media-libs/harfbuzz:= - >=media-libs/libass-0.13.4:= - media-libs/mesa[egl(+),gbm(+)?,wayland?,X?] - >=media-libs/taglib-1.9.0 - sci-libs/kissfft - virtual/libiconv - virtual/ttf-fonts - x11-libs/libdrm - $(python_gen_cond_dep ' - dev-python/pillow[${PYTHON_USEDEP}] - dev-python/pycryptodome[${PYTHON_USEDEP}] - ') - airplay? ( - >=app-pda/libplist-2.0.0:= - net-libs/shairplay - ) - alsa? ( - >=media-libs/alsa-lib-1.1.4.1 - ) - bluetooth? ( - net-wireless/bluez:= - ) - bluray? ( - >=media-libs/libbluray-1.1.2:= - ) - caps? ( - sys-libs/libcap - ) - cec? ( - >=dev-libs/libcec-4.0[-cubox,raspberry-pi?] - ) - dbus? ( - sys-apps/dbus - ) - gbm? ( - >=dev-libs/libinput-1.10.5:= - x11-libs/libxkbcommon - ) - gles? ( - !raspberry-pi? ( - media-libs/mesa[gles2] - ) - ) - !gles? ( - media-libs/glu - ) - lcms? ( - >=media-libs/lcms-2.10:2 - ) - libusb? ( - virtual/libusb:1 - ) - lirc? ( - app-misc/lirc - ) - mariadb? ( - dev-db/mariadb-connector-c:= - ) - mysql? ( - dev-db/mysql-connector-c:= - ) - nfs? ( - >=net-fs/libnfs-2.0.0:= - ) - pipewire? ( - >=media-video/pipewire-0.3.24:= - ) - pulseaudio? ( - media-libs/libpulse - ) - raspberry-pi? ( - || ( - media-libs/raspberrypi-userland - media-libs/raspberrypi-userland-bin - media-libs/mesa[gles2,video_cards_vc4] - ) - ) - samba? ( - >=net-fs/samba-3.4.6[smbclient(+)] - ) - system-ffmpeg? ( - media-video/ffmpeg:=[openssl,encode,postproc,vaapi?,vdpau?,X?] - ) - !system-ffmpeg? ( - app-arch/bzip2 - media-libs/dav1d:= - ) - udf? ( - >=dev-libs/libudfread-1.0.0 - ) - udev? ( - virtual/libudev:= - ) - vaapi? ( - media-libs/libva:=[wayland?,X?] - ) - vdpau? ( - || ( - >=x11-libs/libvdpau-1.1 - >=x11-drivers/nvidia-drivers-180.51 - ) - ) - wayland? ( - >=x11-libs/libxkbcommon-0.4.1[wayland] - ) - webserver? ( - >=net-libs/libmicrohttpd-0.9.55:=[messages(+)] - ) - X? ( - x11-libs/libX11 - x11-libs/libXext - x11-libs/libXrandr - ) - xslt? ( - dev-libs/libxslt - >=dev-libs/libxml2-2.9.4 - ) - zeroconf? ( - net-dns/avahi[dbus] - ) -" -RDEPEND=" - ${COMMON_DEPEND} - ${COMMON_TARGET_DEPEND} -" -DEPEND=" - ${COMMON_DEPEND} - ${COMMON_TARGET_DEPEND} - dev-libs/rapidjson - test? ( - >=dev-cpp/gtest-1.10.0 - ) - wayland? ( - >=dev-libs/wayland-protocols-1.7 - ) - X? ( - x11-base/xorg-proto - x11-libs/libXrender - ) -" -BDEPEND=" - ${COMMON_DEPEND} - dev-build/cmake - dev-lang/swig - virtual/pkgconfig - <=virtual/jre-17:* - doc? ( - app-text/doxygen - ) -" - -# bug #544020 -CONFIG_CHECK="~IP_MULTICAST" -ERROR_IP_MULTICAST=" -In some cases Kodi needs to access multicast addresses. -Please consider enabling IP_MULTICAST under Networking options. -" - -PATCHES=( - "${FILESDIR}/${P}-fix-head-use-after-free.patch" -) - -pkg_setup() { - check_extra_config - java-pkg-2_pkg_setup - python-single-r1_pkg_setup -} - -src_unpack() { - if [[ ${PV} == *9999 ]] ; then - git-r3_src_unpack - else - unpack ${MY_P}.tar.gz - fi - - unpack apache-groovy-binary-${GROOVY_VERSION}.zip - unpack commons-lang3-${APACHE_COMMONS_LANG_VERSION}-bin.tar.gz - unpack commons-text-${APACHE_COMMONS_TEXT_VERSION}-bin.tar.gz -} - -src_prepare() { - cmake_src_prepare - - # avoid long delays when powerkit isn't running #348580 - sed -i \ - -e '/dbus_connection_send_with_reply_and_block/s:-1:3000:' \ - xbmc/platform/linux/*.cpp || die - - # Add all possible names for kissfft libraries - for datatype in {float,int16,int32,simd}; do - sed -i \ - -e "s/\(find_library(KISSFFT_LIBRARY NAMES .*\)/\1 kissfft-${datatype} kissfft-${datatype}-openmp/" \ - cmake/modules/FindKissFFT.cmake || die - done -} - -src_configure() { - local mycmakeargs=( - -Wno-dev # less noise - - -DAPP_RENDER_SYSTEM=$(usex gles gles gl) - -DCORE_PLATFORM_NAME=$(usev gbm)$(usev wayland)$(usev X x11) - -Ddocdir="${EPREFIX}/usr/share/doc/${PF}" - -DENABLE_TESTING=$(usex test) - -DVERBOSE=ON - - # Enforce use of configured python interpeter - -DPYTHON_PATH=$(python_get_library_path) - -DPYTHON_VER=${EPYTHON##python} # wont work for pypy - - # Toolchain - -DENABLE_CCACHE=OFF - -DENABLE_CLANGFORMAT=OFF - -DENABLE_CLANGTIDY=OFF - -DENABLE_CPPCHECK=OFF - -DENABLE_INCLUDEWHATYOUUSE=OFF - # https://bugs.gentoo.org/show_bug.cgi?id=606124 - -DENABLE_GOLD=OFF - -DENABLE_LLD=OFF - -DENABLE_MOLD=OFF - -DUSE_LTO=OFF - - # Features - -DENABLE_AIRTUNES=$(usex airplay) - -DENABLE_ALSA=$(usex alsa) - -DENABLE_AVAHI=$(usex zeroconf) - -DENABLE_BLUETOOTH=$(usex bluetooth) - -DENABLE_BLURAY=$(usex bluray) - -DENABLE_CAP=$(usex caps) - -DENABLE_CEC=$(usex cec) - -DENABLE_DBUS=$(usex dbus) - -DENABLE_DVDCSS=$(usex css) - -DENABLE_EVENTCLIENTS=ON # alway enable to have 'kodi-send' and filter extra staff in 'src_install()' - -DENABLE_ISO9660PP=$(usex optical) - -DENABLE_LCMS2=$(usex lcms) - -DENABLE_LIRCCLIENT=$(usex lirc) - -DENABLE_MARIADBCLIENT=$(usex mariadb) - -DENABLE_MDNS=OFF # used only on Android - -DENABLE_MICROHTTPD=$(usex webserver) - -DENABLE_MYSQLCLIENT=$(usex mysql) - -DENABLE_NFS=$(usex nfs) - -DENABLE_OPENGL=$(usex !gles) - -DENABLE_OPENGLES=$(usex gles) - -DENABLE_OPTICAL=$(usex optical) - -DENABLE_PIPEWIRE=$(usex pipewire) - -DENABLE_PLIST=$(usex airplay) - -DENABLE_PULSEAUDIO=$(usex pulseaudio) - -DENABLE_SMBCLIENT=$(usex samba) - -DENABLE_SNDIO=OFF - -DENABLE_UDEV=$(usex udev) - -DENABLE_UDFREAD=$(usex udf) - -DENABLE_UPNP=$(usex upnp) - -DENABLE_VAAPI=$(usex vaapi) - -DENABLE_VDPAU=$(usex vdpau) - -DENABLE_XSLT=$(usex xslt) - - #To bundle or not - -DENABLE_INTERNAL_CROSSGUID=OFF - -DENABLE_INTERNAL_DAV1D=OFF - -DENABLE_INTERNAL_FFMPEG="$(usex !system-ffmpeg)" - -DENABLE_INTERNAL_FLATBUFFERS=OFF - -DENABLE_INTERNAL_FMT=OFF - -DENABLE_INTERNAL_FSTRCMP=OFF - -DENABLE_INTERNAL_GTEST=OFF - -DENABLE_INTERNAL_KISSFFT=OFF - -DENABLE_INTERNAL_PCRE=OFF - -DENABLE_INTERNAL_RapidJSON=OFF - -DENABLE_INTERNAL_SPDLOG=OFF - -DENABLE_INTERNAL_TAGLIB=OFF - -DENABLE_INTERNAL_UDFREAD=OFF - - -DWITH_FFMPEG=$(usex system-ffmpeg) - - -Dlibdvdnav_URL="${DISTDIR}/libdvdnav-${LIBDVDNAV_VERSION}.tar.gz" - -Dlibdvdread_URL="${DISTDIR}/libdvdread-${LIBDVDREAD_VERSION}.tar.gz" - - -Dgroovy_SOURCE_DIR="${WORKDIR}/groovy-${GROOVY_VERSION}" - -Dapache-commons-lang_SOURCE_DIR="${WORKDIR}/commons-lang3-${APACHE_COMMONS_LANG_VERSION}" - -Dapache-commons-text_SOURCE_DIR="${WORKDIR}/commons-text-${APACHE_COMMONS_TEXT_VERSION}" - ) - - # Separated to avoid "Manually-specified variables were not used by the project:" - use css && mycmakeargs+=( -Dlibdvdcss_URL="${DISTDIR}/libdvdcss-${LIBDVDCSS_VERSION}.tar.gz" ) - use !system-ffmpeg && mycmakeargs+=( - -DFFMPEG_URL="${DISTDIR}/ffmpeg-${PN}-${FFMPEG_VERSION}-${CODENAME}.tar.gz" - ) - use nfs && mycmakeargs+=( -DENABLE_INTERNAL_NFS=OFF ) - use !udev && mycmakeargs+=( -DENABLE_LIBUSB=$(usex libusb) ) - use X && use !gles && mycmakeargs+=( -DENABLE_GLX=ON ) - - for flag in ${CPU_FLAGS[@]} ; do - local name=${flag#cpu_flags_*_} - mycmakeargs+=( -DENABLE_${name^^}=$(usex ${flag}) ) - done - - if ! is-flag -DNDEBUG && ! is-flag -D_DEBUG ; then - # Kodi requires one of the 'NDEBUG' or '_DEBUG' defines - append-cflags -DNDEBUG - append-cxxflags -DNDEBUG - fi - - # Violates ODR (bug #860984) and USE_LTO does spooky stuff - # https://github.com/xbmc/xbmc/commit/cb72a22d54a91845b1092c295f84eeb48328921e - filter-lto - - cmake_src_configure -} - -src_compile() { - cmake_src_compile all - use doc && cmake_build doc - use test && cmake_build kodi-test -} - -src_test() { - local -x CMAKE_SKIP_TESTS=( - # Known failing, unreliable test - # bug #743938 - TestCPUInfo.GetCPUFrequency - # Test failure stemming from sci-libs/kissfft - # The difference between output[2i] and (i==freq1?1.0:0.0) is inf, which exceeds 1e-7, where output[2i] - # evaluates to inf,(i==freq1?1.0:0.0) evaluates to 0, and 1e-7 evaluates to 9.9999999999999995e-08. - TestRFFT.SimpleSignal - # bug #779184 - # https://github.com/xbmc/xbmc/issues/18594 - $(usev x86 TestDateTime.SetFromDBTime) - ) - - # see https://github.com/xbmc/xbmc/issues/17860#issuecomment-630120213 - local -x KODI_HOME="${BUILD_DIR}" - - cmake_src_test -} - -src_install() { - cmake_src_install - - # bug #457588 - pax-mark Em "${ED}"/usr/$(get_libdir)/${PN}/${PN}.bin - - newicon media/icon48x48.png kodi.png - - rm "${ED}"/usr/share/kodi/addons/skin.estuary/fonts/Roboto-Thin.ttf || die - dosym ../../../../fonts/roboto/Roboto-Thin.ttf \ - usr/share/kodi/addons/skin.estuary/fonts/Roboto-Thin.ttf - - if use !eventclients ; then - rm -f "${ED}"/usr/bin/kodi-ps3remote || die - rm -f "${D}"$(python_get_sitedir)/kodi/ps3_remote.py || die - rm -rf "${D}"$(python_get_sitedir)/kodi/ps3 || die - rm -rf "${D}"$(python_get_sitedir)/kodi/bt || die - rm -rf "${ED}"/usr/share/doc/${PF}/kodi-eventclients-dev || die - fi - - python_optimize "${D}$(python_get_sitedir)" - - einstalldocs - use doc && dodoc -r "${S}"/docs/html/ -} - -pkg_postinst() { - xdg_pkg_postinst - - if use dbus ; then - optfeature "getting battery level and active power source" sys-power/upower - optfeature "control of shutdown, reboot, suspend, and hibernate" sys-auth/elogind sys-apps/systemd - optfeature "storage management support (automounting, volume monitoring, etc)" sys-fs/udisks:2 - fi -}