ffmpeg7-debian.patch 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. From 5f731d1c62ebee57c0a545fe255c53b8018ca754 Mon Sep 17 00:00:00 2001
  2. From: Stephan Sundermann <stephansundermann@gmail.com>
  3. Date: Thu, 11 Apr 2024 17:11:32 +0200
  4. Subject: [PATCH 1/7] [ffmpeg] Update to 7.0
  5. ---
  6. cmake/modules/FindFFMPEG.cmake | 16 +--
  7. tools/buildsteps/windows/ffmpeg_options.txt | 1 -
  8. tools/depends/target/ffmpeg/CMakeLists.txt | 6 +-
  9. tools/depends/target/ffmpeg/FFMPEG-VERSION | 4 +-
  10. xbmc/cdrip/EncoderFFmpeg.cpp | 2 +-
  11. xbmc/cdrip/EncoderFFmpeg.h | 2 +-
  12. .../ActiveAE/ActiveAEResampleFFMPEG.cpp | 110 +++++++++---------
  13. .../DVDDemuxers/DVDDemuxFFmpeg.cpp | 71 +----------
  14. 8 files changed, 69 insertions(+), 143 deletions(-)
  15. diff --git a/cmake/modules/FindFFMPEG.cmake b/cmake/modules/FindFFMPEG.cmake
  16. index 6c6bf973de..6bd05e9f3d 100644
  17. --- a/cmake/modules/FindFFMPEG.cmake
  18. +++ b/cmake/modules/FindFFMPEG.cmake
  19. @@ -163,14 +163,14 @@ if(WITH_FFMPEG)
  20. set(REQUIRED_FFMPEG_VERSION undef)
  21. else()
  22. # required ffmpeg library versions
  23. - set(REQUIRED_FFMPEG_VERSION 6.0.0)
  24. - set(_avcodec_ver ">=60.2.100")
  25. - set(_avfilter_ver ">=9.3.100")
  26. - set(_avformat_ver ">=60.3.100")
  27. - set(_avutil_ver ">=58.2.100")
  28. - set(_postproc_ver ">=57.1.100")
  29. - set(_swresample_ver ">=4.10.100")
  30. - set(_swscale_ver ">=7.1.100")
  31. + set(REQUIRED_FFMPEG_VERSION 7.0.0)
  32. + set(_avcodec_ver ">=61.3.100")
  33. + set(_avfilter_ver ">=10.1.100")
  34. + set(_avformat_ver ">=61.1.100")
  35. + set(_avutil_ver ">=59.8.100")
  36. + set(_postproc_ver ">=58.1.100")
  37. + set(_swresample_ver ">=5.1.100")
  38. + set(_swscale_ver ">=8.1.100")
  39. endif()
  40. # Allows building with external ffmpeg not found in system paths,
  41. diff --git a/tools/buildsteps/windows/ffmpeg_options.txt b/tools/buildsteps/windows/ffmpeg_options.txt
  42. index 5034ff26c4..776c0b4b35 100644
  43. --- a/tools/buildsteps/windows/ffmpeg_options.txt
  44. +++ b/tools/buildsteps/windows/ffmpeg_options.txt
  45. @@ -1,5 +1,4 @@
  46. --disable-avdevice
  47. ---disable-crystalhd
  48. --disable-cuda
  49. --disable-cuvid
  50. --disable-devices
  51. diff --git a/tools/depends/target/ffmpeg/FFMPEG-VERSION b/tools/depends/target/ffmpeg/FFMPEG-VERSION
  52. index f2ba09402e..60b8887de3 100644
  53. --- a/tools/depends/target/ffmpeg/FFMPEG-VERSION
  54. +++ b/tools/depends/target/ffmpeg/FFMPEG-VERSION
  55. @@ -1,5 +1,5 @@
  56. LIBNAME=ffmpeg
  57. -VERSION=6.0.1
  58. +VERSION=7.0.1
  59. ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz
  60. -SHA512=945e34840092dc0fd3824eb1af2be79868af2afb4fe13159b19a9bcfc464cc4d53243c13ff065199290e9393ddbf4b1c5c8abccf83a31a31d6c7490e499fd1fc
  61. +SHA512=43b639b0bc0597e95dea2dce3e925f4b71ca8c4d9eadaef614941053e287f2d5c2e78d95413f0f7142da0f6ea1dbf443457e4fa1c2296cd8cf4081c185ed9c04
  62. diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp
  63. index 85f5fa412e..907d2591dd 100644
  64. --- a/xbmc/cdrip/EncoderFFmpeg.cpp
  65. +++ b/xbmc/cdrip/EncoderFFmpeg.cpp
  66. @@ -235,7 +235,7 @@ void CEncoderFFmpeg::SetTag(const std::string& tag, const std::string& value)
  67. av_dict_set(&m_formatCtx->metadata, tag.c_str(), value.c_str(), 0);
  68. }
  69. -int CEncoderFFmpeg::avio_write_callback(void* opaque, uint8_t* buf, int buf_size)
  70. +int CEncoderFFmpeg::avio_write_callback(void* opaque, const uint8_t* buf, int buf_size)
  71. {
  72. CEncoderFFmpeg* enc = static_cast<CEncoderFFmpeg*>(opaque);
  73. if (enc->Write(buf, buf_size) != buf_size)
  74. diff --git a/xbmc/cdrip/EncoderFFmpeg.h b/xbmc/cdrip/EncoderFFmpeg.h
  75. index 48471a4b10..4e9f0f5bbb 100644
  76. --- a/xbmc/cdrip/EncoderFFmpeg.h
  77. +++ b/xbmc/cdrip/EncoderFFmpeg.h
  78. @@ -33,7 +33,7 @@ public:
  79. bool Close() override;
  80. private:
  81. - static int avio_write_callback(void* opaque, uint8_t* buf, int buf_size);
  82. + static int avio_write_callback(void* opaque, const uint8_t* buf, int buf_size);
  83. static int64_t avio_seek_callback(void* opaque, int64_t offset, int whence);
  84. void SetTag(const std::string& tag, const std::string& value);
  85. diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
  86. index e897cbd3ea..6fce0af981 100644
  87. --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
  88. +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
  89. @@ -66,51 +66,7 @@ bool CActiveAEResampleFFMPEG::Init(SampleConfig dstConfig, SampleConfig srcConfi
  90. AVChannelLayout dstChLayout = {};
  91. AVChannelLayout srcChLayout = {};
  92. - av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
  93. - av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout);
  94. -
  95. - int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt, m_dst_rate, &srcChLayout,
  96. - m_src_fmt, m_src_rate, 0, NULL);
  97. -
  98. - if (ret)
  99. - {
  100. - CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context failed");
  101. - return false;
  102. - }
  103. -
  104. - if(quality == AE_QUALITY_HIGH)
  105. - {
  106. - av_opt_set_double(m_pContext, "cutoff", 1.0, 0);
  107. - av_opt_set_int(m_pContext,"filter_size", 256, 0);
  108. - }
  109. - else if(quality == AE_QUALITY_MID)
  110. - {
  111. - // 0.97 is default cutoff so use (1.0 - 0.97) / 2.0 + 0.97
  112. - av_opt_set_double(m_pContext, "cutoff", 0.985, 0);
  113. - av_opt_set_int(m_pContext,"filter_size", 64, 0);
  114. - }
  115. - else if(quality == AE_QUALITY_LOW)
  116. - {
  117. - av_opt_set_double(m_pContext, "cutoff", 0.97, 0);
  118. - av_opt_set_int(m_pContext,"filter_size", 32, 0);
  119. - }
  120. -
  121. - if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P)
  122. - {
  123. - av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0);
  124. - }
  125. -
  126. - // tell resampler to clamp float values
  127. - // not required for sink stage (remapLayout == true)
  128. - if ((m_dst_fmt == AV_SAMPLE_FMT_FLT || m_dst_fmt == AV_SAMPLE_FMT_FLTP) &&
  129. - (m_src_fmt == AV_SAMPLE_FMT_FLT || m_src_fmt == AV_SAMPLE_FMT_FLTP) &&
  130. - !remapLayout && normalize)
  131. - {
  132. - av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0);
  133. - }
  134. -
  135. - av_opt_set_double(m_pContext, "center_mix_level", centerMix, 0);
  136. -
  137. + bool hasMatrix = false;
  138. if (remapLayout)
  139. {
  140. // one-to-one mapping of channels
  141. @@ -120,28 +76,19 @@ bool CActiveAEResampleFFMPEG::Init(SampleConfig dstConfig, SampleConfig srcConfi
  142. m_dst_chan_layout = 0;
  143. for (unsigned int out=0; out<remapLayout->Count(); out++)
  144. {
  145. - m_dst_chan_layout += ((uint64_t)1) << out;
  146. + m_dst_chan_layout += static_cast<uint64_t>(1) << out;
  147. int idx = CAEUtil::GetAVChannelIndex((*remapLayout)[out], m_src_chan_layout);
  148. if (idx >= 0)
  149. {
  150. m_rematrix[out][idx] = 1.0;
  151. }
  152. }
  153. -
  154. - av_opt_set_int(m_pContext, "out_channel_count", m_dst_channels, 0);
  155. - av_opt_set_int(m_pContext, "out_channel_layout", m_dst_chan_layout, 0);
  156. -
  157. - if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0)
  158. - {
  159. - CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - setting channel matrix failed");
  160. - return false;
  161. - }
  162. + hasMatrix = true;
  163. }
  164. // stereo upmix
  165. else if (upmix && m_src_channels == 2 && m_dst_channels > 2)
  166. {
  167. memset(m_rematrix, 0, sizeof(m_rematrix));
  168. - av_channel_layout_uninit(&dstChLayout);
  169. av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
  170. for (int out=0; out<m_dst_channels; out++)
  171. {
  172. @@ -171,15 +118,64 @@ bool CActiveAEResampleFFMPEG::Init(SampleConfig dstConfig, SampleConfig srcConfi
  173. }
  174. }
  175. + hasMatrix = true;
  176. av_channel_layout_uninit(&dstChLayout);
  177. + }
  178. +
  179. + av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
  180. + av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout);
  181. +
  182. + int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt, m_dst_rate, &srcChLayout,
  183. + m_src_fmt, m_src_rate, 0, NULL);
  184. +
  185. + if (ret)
  186. + {
  187. + CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context failed");
  188. + return false;
  189. + }
  190. - if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0)
  191. + if (hasMatrix)
  192. + {
  193. + if (swr_set_matrix(m_pContext, reinterpret_cast<const double*>(m_rematrix), AE_CH_MAX) < 0)
  194. {
  195. CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - setting channel matrix failed");
  196. return false;
  197. }
  198. }
  199. + if (quality == AE_QUALITY_HIGH)
  200. + {
  201. + av_opt_set_double(m_pContext, "cutoff", 1.0, 0);
  202. + av_opt_set_int(m_pContext, "filter_size", 256, 0);
  203. + }
  204. + else if (quality == AE_QUALITY_MID)
  205. + {
  206. + // 0.97 is default cutoff so use (1.0 - 0.97) / 2.0 + 0.97
  207. + av_opt_set_double(m_pContext, "cutoff", 0.985, 0);
  208. + av_opt_set_int(m_pContext, "filter_size", 64, 0);
  209. + }
  210. + else if (quality == AE_QUALITY_LOW)
  211. + {
  212. + av_opt_set_double(m_pContext, "cutoff", 0.97, 0);
  213. + av_opt_set_int(m_pContext, "filter_size", 32, 0);
  214. + }
  215. +
  216. + if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P)
  217. + {
  218. + av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0);
  219. + }
  220. +
  221. + // tell resampler to clamp float values
  222. + // not required for sink stage (remapLayout == true)
  223. + if ((m_dst_fmt == AV_SAMPLE_FMT_FLT || m_dst_fmt == AV_SAMPLE_FMT_FLTP) &&
  224. + (m_src_fmt == AV_SAMPLE_FMT_FLT || m_src_fmt == AV_SAMPLE_FMT_FLTP) && !remapLayout &&
  225. + normalize)
  226. + {
  227. + av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0);
  228. + }
  229. +
  230. + av_opt_set_double(m_pContext, "center_mix_level", centerMix, 0);
  231. +
  232. if(swr_init(m_pContext) < 0)
  233. {
  234. CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - init resampler failed");
  235. diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  236. index 1aebc3dcbc..174df53f16 100644
  237. --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  238. +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  239. @@ -376,74 +376,7 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr<CDVDInputStream>& pInput, bool
  240. if (iformat == nullptr)
  241. {
  242. // let ffmpeg decide which demuxer we have to open
  243. - bool trySPDIFonly = (m_pInput->GetContent() == "audio/x-spdif-compressed");
  244. -
  245. - if (!trySPDIFonly)
  246. - av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
  247. -
  248. - // Use the more low-level code in case we have been built against an old
  249. - // FFmpeg without the above av_probe_input_buffer(), or in case we only
  250. - // want to probe for spdif (DTS or IEC 61937) compressed audio
  251. - // specifically, or in case the file is a wav which may contain DTS or
  252. - // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
  253. - if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
  254. - {
  255. - AVProbeData pd;
  256. - int probeBufferSize = 32768;
  257. - std::unique_ptr<uint8_t[]> probe_buffer (new uint8_t[probeBufferSize + AVPROBE_PADDING_SIZE]);
  258. -
  259. - // init probe data
  260. - pd.buf = probe_buffer.get();
  261. - pd.filename = strFile.c_str();
  262. -
  263. - // read data using avformat's buffers
  264. - pd.buf_size = avio_read(m_ioContext, pd.buf, probeBufferSize);
  265. - if (pd.buf_size <= 0)
  266. - {
  267. - CLog::Log(LOGERROR, "{} - error reading from input stream, {}", __FUNCTION__,
  268. - CURL::GetRedacted(strFile));
  269. - return false;
  270. - }
  271. - memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
  272. -
  273. - // restore position again
  274. - avio_seek(m_ioContext , 0, SEEK_SET);
  275. -
  276. - // the advancedsetting is for allowing the user to force outputting the
  277. - // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
  278. - // it (this is temporary until we handle 44.1 kHz passthrough properly)
  279. - if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0 && !CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_VideoPlayerIgnoreDTSinWAV))
  280. - {
  281. - // check for spdif and dts
  282. - // This is used with wav files and audio CDs that may contain
  283. - // a DTS or AC3 track padded for S/PDIF playback. If neither of those
  284. - // is present, we assume it is PCM audio.
  285. - // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS
  286. - // may be just padded.
  287. - const AVInputFormat* iformat2 = av_find_input_format("spdif");
  288. - if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
  289. - {
  290. - iformat = iformat2;
  291. - }
  292. - else
  293. - {
  294. - // not spdif or no spdif demuxer, try dts
  295. - iformat2 = av_find_input_format("dts");
  296. -
  297. - if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
  298. - {
  299. - iformat = iformat2;
  300. - }
  301. - else if (trySPDIFonly)
  302. - {
  303. - // not dts either, return false in case we were explicitly
  304. - // requested to only check for S/PDIF padded compressed audio
  305. - CLog::Log(LOGDEBUG, "{} - not spdif or dts file, falling back", __FUNCTION__);
  306. - return false;
  307. - }
  308. - }
  309. - }
  310. - }
  311. + av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
  312. if (!iformat)
  313. {
  314. @@ -1353,7 +1286,7 @@ bool CDVDDemuxFFmpeg::SeekTime(double time, bool backwards, double* startpts)
  315. if (ret >= 0)
  316. {
  317. - if (m_pFormatContext->iformat->read_seek)
  318. + if (!(m_pFormatContext->iformat->flags & AVFMT_NOTIMESTAMPS))
  319. m_seekToKeyFrame = true;
  320. m_currentPts = DVD_NOPTS_VALUE;
  321. }
  322. --
  323. 2.43.0
  324. From 17ce23505f171235ac6bfff7fbaa3a5b4bc9a8bf Mon Sep 17 00:00:00 2001
  325. From: Stephan Sundermann <stephansundermann@gmail.com>
  326. Date: Thu, 11 Apr 2024 17:13:36 +0200
  327. Subject: [PATCH 2/7] [ffmpeg] Remove deprecated use of FF_API_INTERLACED_FRAME
  328. ---
  329. .../DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp | 5 +++--
  330. .../VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 9 +++++----
  331. xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 6 ++++--
  332. xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp | 2 +-
  333. 4 files changed, 13 insertions(+), 9 deletions(-)
  334. diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
  335. index eb2943bb8c..4da0722d5c 100644
  336. --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
  337. +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecDRMPRIME.cpp
  338. @@ -582,8 +582,9 @@ void CDVDVideoCodecDRMPRIME::SetPictureParams(VideoPicture* pVideoPicture)
  339. pVideoPicture->iRepeatPicture = 0;
  340. pVideoPicture->iFlags = 0;
  341. - pVideoPicture->iFlags |= m_pFrame->interlaced_frame ? DVP_FLAG_INTERLACED : 0;
  342. - pVideoPicture->iFlags |= m_pFrame->top_field_first ? DVP_FLAG_TOP_FIELD_FIRST : 0;
  343. + pVideoPicture->iFlags |= m_pFrame->flags & AV_FRAME_FLAG_INTERLACED ? DVP_FLAG_INTERLACED : 0;
  344. + pVideoPicture->iFlags |=
  345. + m_pFrame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST ? DVP_FLAG_TOP_FIELD_FIRST : 0;
  346. pVideoPicture->iFlags |= m_pFrame->data[0] ? 0 : DVP_FLAG_DROPPED;
  347. if (m_codecControlFlags & DVD_CODEC_CTRL_DROP)
  348. diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
  349. index d66378fa07..9586d211e9 100644
  350. --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
  351. +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
  352. @@ -792,12 +792,12 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecFFmpeg::GetPicture(VideoPicture* pVideoPi
  353. }
  354. m_dropCtrl.Process(framePTS, m_pCodecContext->skip_frame > AVDISCARD_DEFAULT);
  355. - if (m_pDecodedFrame->key_frame)
  356. + if (m_pDecodedFrame->flags & AV_FRAME_FLAG_KEY)
  357. {
  358. m_started = true;
  359. m_iLastKeyframe = m_pCodecContext->has_b_frames + 2;
  360. }
  361. - if (m_pDecodedFrame->interlaced_frame)
  362. + if (m_pDecodedFrame->flags & AV_FRAME_FLAG_INTERLACED)
  363. m_interlaced = true;
  364. else
  365. m_interlaced = false;
  366. @@ -1013,8 +1013,9 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(VideoPicture* pVideoPicture)
  367. pVideoPicture->iRepeatPicture = 0.5 * m_pFrame->repeat_pict;
  368. pVideoPicture->iFlags = 0;
  369. - pVideoPicture->iFlags |= m_pFrame->interlaced_frame ? DVP_FLAG_INTERLACED : 0;
  370. - pVideoPicture->iFlags |= m_pFrame->top_field_first ? DVP_FLAG_TOP_FIELD_FIRST: 0;
  371. + pVideoPicture->iFlags |= m_pFrame->flags & AV_FRAME_FLAG_INTERLACED ? DVP_FLAG_INTERLACED : 0;
  372. + pVideoPicture->iFlags |=
  373. + m_pFrame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST ? DVP_FLAG_TOP_FIELD_FIRST : 0;
  374. if (m_codecControlFlags & DVD_CODEC_CTRL_DROP)
  375. {
  376. diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
  377. index fb7606e0d0..a62fa6273d 100644
  378. --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
  379. +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
  380. @@ -3068,8 +3068,10 @@ bool CFFmpegPostproc::AddPicture(CVaapiDecodedPicture &inPic)
  381. m_pFilterFrameIn->height = m_config.vidHeight;
  382. m_pFilterFrameIn->linesize[0] = image.pitches[0];
  383. m_pFilterFrameIn->linesize[1] = image.pitches[1];
  384. - m_pFilterFrameIn->interlaced_frame = (inPic.DVDPic.iFlags & DVP_FLAG_INTERLACED) ? 1 : 0;
  385. - m_pFilterFrameIn->top_field_first = (inPic.DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST) ? 1 : 0;
  386. + if (inPic.DVDPic.iFlags & DVP_FLAG_INTERLACED)
  387. + m_pFilterFrameIn->flags |= AV_FRAME_FLAG_INTERLACED;
  388. + if (inPic.DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
  389. + m_pFilterFrameIn->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
  390. if (inPic.DVDPic.pts == DVD_NOPTS_VALUE)
  391. m_pFilterFrameIn->pts = AV_NOPTS_VALUE;
  392. diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp
  393. index 1f71f643d2..567d63559d 100644
  394. --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp
  395. +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp
  396. @@ -196,7 +196,7 @@ CDVDVideoCodec::VCReturn CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame)
  397. if(frame)
  398. {
  399. - if (frame->interlaced_frame)
  400. + if (frame->flags & AV_FRAME_FLAG_INTERLACED)
  401. return CDVDVideoCodec::VC_FATAL;
  402. if (m_renderBuffer)
  403. --
  404. 2.43.0
  405. From 01aa01d5c096ff7554c79493eab65dd41b00402f Mon Sep 17 00:00:00 2001
  406. From: Stephan Sundermann <stephansundermann@gmail.com>
  407. Date: Thu, 11 Apr 2024 17:14:48 +0200
  408. Subject: [PATCH 3/7] [ffmpeg] Remove deprecated use of avcodec_close
  409. ---
  410. xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 1 -
  411. 1 file changed, 1 deletion(-)
  412. diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
  413. index 0cdf8c3864..477a2e82ec 100644
  414. --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
  415. +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
  416. @@ -188,7 +188,6 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt)
  417. if (!avcodec_open2(stream->m_context, stream->m_context->codec, nullptr))
  418. {
  419. avcodec_send_packet(stream->m_context, avpkt);
  420. - avcodec_close(stream->m_context);
  421. }
  422. }
  423. av_packet_free(&avpkt);
  424. --
  425. 2.43.0
  426. From b509d439c18bebcf35cc80d18a0997caf6eda8a6 Mon Sep 17 00:00:00 2001
  427. From: Stephan Sundermann <stephansundermann@gmail.com>
  428. Date: Thu, 11 Apr 2024 17:15:16 +0200
  429. Subject: [PATCH 4/7] [ffmpeg] Remove deprecated use av_stream_get_side_data
  430. ---
  431. .../DVDDemuxers/DVDDemuxFFmpeg.cpp | 53 +++++++++++--------
  432. 1 file changed, 32 insertions(+), 21 deletions(-)
  433. diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  434. index 174df53f16..f917bf719f 100644
  435. --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  436. +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
  437. @@ -1630,42 +1630,49 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx)
  438. st->colorRange = pStream->codecpar->color_range;
  439. st->hdr_type = DetermineHdrType(pStream);
  440. - // https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/APIchanges
  441. - size_t size = 0;
  442. - uint8_t* side_data = nullptr;
  443. + // https://github.com/FFmpeg/FFmpeg/blob/release/7.0/doc/APIchanges
  444. + const AVPacketSideData* sideData = nullptr;
  445. if (st->hdr_type == StreamHdrType::HDR_TYPE_DOLBYVISION)
  446. {
  447. - side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, &size);
  448. - if (side_data && size)
  449. +
  450. + sideData =
  451. + av_packet_side_data_get(pStream->codecpar->coded_side_data,
  452. + pStream->codecpar->nb_coded_side_data, AV_PKT_DATA_DOVI_CONF);
  453. + if (sideData && sideData->size)
  454. {
  455. - st->dovi = *reinterpret_cast<AVDOVIDecoderConfigurationRecord*>(side_data);
  456. + st->dovi = *reinterpret_cast<const AVDOVIDecoderConfigurationRecord*>(sideData->data);
  457. }
  458. }
  459. - side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size);
  460. - if (side_data && size)
  461. + sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
  462. + pStream->codecpar->nb_coded_side_data,
  463. + AV_PKT_DATA_MASTERING_DISPLAY_METADATA);
  464. + if (sideData && sideData->size)
  465. {
  466. st->masteringMetaData = std::make_shared<AVMasteringDisplayMetadata>(
  467. - *reinterpret_cast<AVMasteringDisplayMetadata*>(side_data));
  468. + *reinterpret_cast<const AVMasteringDisplayMetadata*>(sideData->data));
  469. }
  470. - side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, &size);
  471. - if (side_data && size)
  472. + sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
  473. + pStream->codecpar->nb_coded_side_data,
  474. + AV_PKT_DATA_CONTENT_LIGHT_LEVEL);
  475. + if (sideData && sideData->size)
  476. {
  477. st->contentLightMetaData = std::make_shared<AVContentLightMetadata>(
  478. - *reinterpret_cast<AVContentLightMetadata*>(side_data));
  479. + *reinterpret_cast<const AVContentLightMetadata*>(sideData->data));
  480. }
  481. - uint8_t* displayMatrixSideData =
  482. - av_stream_get_side_data(pStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr);
  483. - if (displayMatrixSideData)
  484. + sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
  485. + pStream->codecpar->nb_coded_side_data,
  486. + AV_PKT_DATA_DISPLAYMATRIX);
  487. + if (sideData)
  488. {
  489. - const double tetha =
  490. - av_display_rotation_get(reinterpret_cast<int32_t*>(displayMatrixSideData));
  491. - if (!std::isnan(tetha))
  492. + const double theta =
  493. + av_display_rotation_get(reinterpret_cast<const int32_t*>(sideData->data));
  494. + if (!std::isnan(theta))
  495. {
  496. - st->iOrientation = ((static_cast<int>(-tetha) % 360) + 360) % 360;
  497. + st->iOrientation = ((static_cast<int>(-theta) % 360) + 360) % 360;
  498. }
  499. }
  500. @@ -2488,7 +2495,9 @@ StreamHdrType CDVDDemuxFFmpeg::DetermineHdrType(AVStream* pStream)
  501. {
  502. StreamHdrType hdrType = StreamHdrType::HDR_TYPE_NONE;
  503. - if (av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, nullptr)) // DoVi
  504. + if (av_packet_side_data_get(pStream->codecpar->coded_side_data,
  505. + pStream->codecpar->nb_coded_side_data,
  506. + AV_PKT_DATA_DOVI_CONF)) // DoVi
  507. hdrType = StreamHdrType::HDR_TYPE_DOLBYVISION;
  508. else if (pStream->codecpar->color_trc == AVCOL_TRC_SMPTE2084) // HDR10
  509. hdrType = StreamHdrType::HDR_TYPE_HDR10;
  510. @@ -2496,7 +2505,9 @@ StreamHdrType CDVDDemuxFFmpeg::DetermineHdrType(AVStream* pStream)
  511. hdrType = StreamHdrType::HDR_TYPE_HLG;
  512. // file could be SMPTE2086 which FFmpeg currently returns as unknown
  513. // so use the presence of static metadata to detect it
  514. - else if (av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, nullptr))
  515. + else if (av_packet_side_data_get(pStream->codecpar->coded_side_data,
  516. + pStream->codecpar->nb_coded_side_data,
  517. + AV_PKT_DATA_MASTERING_DISPLAY_METADATA))
  518. hdrType = StreamHdrType::HDR_TYPE_HDR10;
  519. return hdrType;
  520. --
  521. 2.43.0
  522. From 5e7609bfee5e0559d6c29b01fbc4294d27168921 Mon Sep 17 00:00:00 2001
  523. From: Stephan Sundermann <stephansundermann@gmail.com>
  524. Date: Thu, 11 Apr 2024 17:15:43 +0200
  525. Subject: [PATCH 5/7] [ffmpeg] Remove CrystalHD hw acceleration strings
  526. ---
  527. addons/resource.language.en_gb/resources/strings.po | 11 ++---------
  528. 1 file changed, 2 insertions(+), 9 deletions(-)
  529. diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po
  530. index 056b1747a0..292aae4a1b 100644
  531. --- a/addons/resource.language.en_gb/resources/strings.po
  532. +++ b/addons/resource.language.en_gb/resources/strings.po
  533. @@ -7342,10 +7342,7 @@ msgctxt "#13427"
  534. msgid "Allow hardware acceleration - DXVA2"
  535. msgstr ""
  536. -#: system/settings/settings.xml
  537. -msgctxt "#13428"
  538. -msgid "Allow hardware acceleration - CrystalHD"
  539. -msgstr ""
  540. +#empty string with id 13428
  541. #: system/settings/settings.xml
  542. msgctxt "#13429"
  543. @@ -19502,11 +19499,7 @@ msgctxt "#36158"
  544. msgid "Enable DXVA2 hardware decoding of video files."
  545. msgstr ""
  546. -#. Description of setting with label #13428 "Allow hardware acceleration (CrystalHD)"
  547. -#: system/settings/settings.xml
  548. -msgctxt "#36159"
  549. -msgid "Enable CrystalHD decoding of video files."
  550. -msgstr ""
  551. +#empty string with id 36159
  552. #. Description of setting with label #13429 "Allow hardware acceleration (VDADecoder)"
  553. #: system/settings/settings.xml
  554. --
  555. 2.43.0
  556. From 813a40bb30285b1b32a7ab6e63953eb3665f051a Mon Sep 17 00:00:00 2001
  557. From: Stephan Sundermann <stephansundermann@gmail.com>
  558. Date: Sat, 13 Apr 2024 10:31:36 +0200
  559. Subject: [PATCH 6/7] [settings] Remove VideoPlayerignoredtsinwav advanced
  560. setting
  561. ---
  562. xbmc/settings/AdvancedSettings.cpp | 2 --
  563. xbmc/settings/AdvancedSettings.h | 1 -
  564. 2 files changed, 3 deletions(-)
  565. diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp
  566. index cc06244799..4e2d6badd6 100644
  567. --- a/xbmc/settings/AdvancedSettings.cpp
  568. +++ b/xbmc/settings/AdvancedSettings.cpp
  569. @@ -129,7 +129,6 @@ void CAdvancedSettings::Initialize()
  570. return;
  571. m_audioApplyDrc = -1.0f;
  572. - m_VideoPlayerIgnoreDTSinWAV = false;
  573. //default hold time of 25 ms, this allows a 20 hertz sine to pass undistorted
  574. m_limiterHold = 0.025f;
  575. @@ -579,7 +578,6 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file)
  576. GetCustomRegexps(pAudioExcludes, m_audioExcludeFromScanRegExps);
  577. XMLUtils::GetFloat(pElement, "applydrc", m_audioApplyDrc);
  578. - XMLUtils::GetBoolean(pElement, "VideoPlayerignoredtsinwav", m_VideoPlayerIgnoreDTSinWAV);
  579. XMLUtils::GetFloat(pElement, "limiterhold", m_limiterHold, 0.0f, 100.0f);
  580. XMLUtils::GetFloat(pElement, "limiterrelease", m_limiterRelease, 0.001f, 100.0f);
  581. diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h
  582. index 3351caff55..8eabfe8240 100644
  583. --- a/xbmc/settings/AdvancedSettings.h
  584. +++ b/xbmc/settings/AdvancedSettings.h
  585. @@ -120,7 +120,6 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler
  586. std::string m_audioDefaultPlayer;
  587. float m_audioPlayCountMinimumPercent;
  588. - bool m_VideoPlayerIgnoreDTSinWAV;
  589. float m_limiterHold;
  590. float m_limiterRelease;
  591. --
  592. 2.43.0
  593. From 03449b80c2e00a56912b9612afc11f3d53dd4a05 Mon Sep 17 00:00:00 2001
  594. From: Stephan Sundermann <stephansundermann@gmail.com>
  595. Date: Sat, 13 Apr 2024 13:07:58 +0200
  596. Subject: [PATCH 7/7] [ffmpeg] Use new audio DTS and ATMOS profiles
  597. ---
  598. .../VideoPlayer/DVDDemuxers/DVDDemux.cpp | 20 +++++++++++++------
  599. .../DVDInputStreams/InputStreamAddon.cpp | 9 +++------
  600. 2 files changed, 17 insertions(+), 12 deletions(-)
  601. diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemux.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemux.cpp
  602. index 63fb9264a8..e9aa468dd0 100644
  603. --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemux.cpp
  604. +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemux.cpp
  605. @@ -15,15 +15,15 @@ std::string CDemuxStreamAudio::GetStreamType()
  606. std::string strInfo;
  607. switch (codec)
  608. {
  609. - //! @todo: With ffmpeg >= 6.1 add new AC4 codec
  610. case AV_CODEC_ID_AC3:
  611. strInfo = "AC3 ";
  612. break;
  613. + case AV_CODEC_ID_AC4:
  614. + strInfo = "AC4 ";
  615. + break;
  616. case AV_CODEC_ID_EAC3:
  617. {
  618. - //! @todo: With ffmpeg >= 6.1 add new atmos profile case
  619. - // "JOC" its EAC3 Atmos underlying profile, there is no standard codec name string
  620. - if (StringUtils::Contains(codecName, "JOC"))
  621. + if (profile == FF_PROFILE_EAC3_DDP_ATMOS)
  622. strInfo = "DD+ ATMOS ";
  623. else
  624. strInfo = "DD+ ";
  625. @@ -31,7 +31,6 @@ std::string CDemuxStreamAudio::GetStreamType()
  626. }
  627. case AV_CODEC_ID_DTS:
  628. {
  629. - //! @todo: With ffmpeg >= 6.1 add new DTSX profile cases
  630. switch (profile)
  631. {
  632. case FF_PROFILE_DTS_96_24:
  633. @@ -49,6 +48,12 @@ std::string CDemuxStreamAudio::GetStreamType()
  634. case FF_PROFILE_DTS_HD_HRA:
  635. strInfo = "DTS-HD HRA ";
  636. break;
  637. + case FF_PROFILE_DTS_HD_MA_X:
  638. + strInfo = "DTS-HD MA X ";
  639. + break;
  640. + case FF_PROFILE_DTS_HD_MA_X_IMAX:
  641. + strInfo = "DTS-HD MA X (IMAX) ";
  642. + break;
  643. default:
  644. strInfo = "DTS ";
  645. break;
  646. @@ -62,7 +67,10 @@ std::string CDemuxStreamAudio::GetStreamType()
  647. strInfo = "MP3 ";
  648. break;
  649. case AV_CODEC_ID_TRUEHD:
  650. - strInfo = "TrueHD ";
  651. + if (profile == FF_PROFILE_TRUEHD_ATMOS)
  652. + strInfo = "TrueHD ATMOS ";
  653. + else
  654. + strInfo = "TrueHD ";
  655. break;
  656. case AV_CODEC_ID_AAC:
  657. {
  658. diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp
  659. index daf66ce0cd..902f38ade2 100644
  660. --- a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp
  661. +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamAddon.cpp
  662. @@ -762,14 +762,11 @@ int CInputStreamAddon::ConvertAudioCodecProfile(STREAMCODEC_PROFILE profile)
  663. case DTSCodecProfileHDExpress:
  664. return FF_PROFILE_DTS_EXPRESS;
  665. case DTSCodecProfileHDMAX:
  666. - //! @todo: with ffmpeg >= 6.1 set the appropriate profile
  667. - return FF_PROFILE_UNKNOWN; // FF_PROFILE_DTS_HD_MA_X
  668. + return FF_PROFILE_DTS_HD_MA_X;
  669. case DTSCodecProfileHDMAIMAX:
  670. - //! @todo: with ffmpeg >= 6.1 set the appropriate profile
  671. - return FF_PROFILE_UNKNOWN; // FF_PROFILE_DTS_HD_MA_X_IMAX
  672. + return FF_PROFILE_DTS_HD_MA_X_IMAX;
  673. case DDPlusCodecProfileAtmos:
  674. - //! @todo: with ffmpeg >= 6.1 set the appropriate profile
  675. - return FF_PROFILE_UNKNOWN; // FF_PROFILE_EAC3_DDP_ATMOS
  676. + return FF_PROFILE_EAC3_DDP_ATMOS;
  677. default:
  678. return FF_PROFILE_UNKNOWN;
  679. }