1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
|
From 5552d0bde9ec84c42ef7a72972179f99755a2618 Mon Sep 17 00:00:00 2001
From: Vasyl Gello <vasek.gello@gmail.com>
Date: Fri, 9 Aug 2024 07:11:41 +0000
Subject: [PATCH] Port FFmpeg 7.0 to ffmpegdirect Omega
From https://github.com/xbmc/xbmc/pull/24972
Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
---
FindFFMPEG.cmake | 16 ++--
depends/common/ffmpeg/CMakeLists.txt | 4 +-
depends/common/ffmpeg/ffmpeg.sha256 | 2 +-
depends/common/ffmpeg/ffmpeg.txt | 2 +-
src/stream/FFmpegStream.cpp | 125 ++++++++-------------------
5 files changed, 46 insertions(+), 103 deletions(-)
diff --git a/FindFFMPEG.cmake b/FindFFMPEG.cmake
index d03f329..8b20538 100644
--- a/FindFFMPEG.cmake
+++ b/FindFFMPEG.cmake
@@ -33,14 +33,14 @@
#
# required ffmpeg library versions
-set(REQUIRED_FFMPEG_VERSION 5.0.0)
-set(_avcodec_ver ">=59.18.100")
-set(_avfilter_ver ">=8.24.100")
-set(_avformat_ver ">=59.16.100")
-set(_avutil_ver ">=57.17.100")
-set(_postproc_ver ">=56.3.100")
-set(_swresample_ver ">=4.3.100")
-set(_swscale_ver ">=6.4.100")
+set(REQUIRED_FFMPEG_VERSION 7.0.0)
+set(_avcodec_ver ">=61.3.100")
+set(_avfilter_ver ">=10.1.100")
+set(_avformat_ver ">=61.1.100")
+set(_avutil_ver ">=59.8.100")
+set(_postproc_ver ">=58.1.100")
+set(_swresample_ver ">=5.1.100")
+set(_swscale_ver ">=8.1.100")
# Allows building with external ffmpeg not found in system paths,
# without library version checks
diff --git a/src/stream/FFmpegStream.cpp b/src/stream/FFmpegStream.cpp
index 8bf474f..c77e09d 100644
--- a/src/stream/FFmpegStream.cpp
+++ b/src/stream/FFmpegStream.cpp
@@ -1012,74 +1012,7 @@ bool FFmpegStream::OpenWithCURL(const AVInputFormat* iformat)
if (iformat == nullptr)
{
// let ffmpeg decide which demuxer we have to open
- bool trySPDIFonly = (m_curlInput->GetContent() == "audio/x-spdif-compressed");
-
- if (!trySPDIFonly)
- av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
-
- // Use the more low-level code in case we have been built against an old
- // FFmpeg without the above av_probe_input_buffer(), or in case we only
- // want to probe for spdif (DTS or IEC 61937) compressed audio
- // specifically, or in case the file is a wav which may contain DTS or
- // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
- if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
- {
- AVProbeData pd;
- int probeBufferSize = 32768;
- std::unique_ptr<uint8_t[]> probe_buffer (new uint8_t[probeBufferSize + AVPROBE_PADDING_SIZE]);
-
- // init probe data
- pd.buf = probe_buffer.get();
- pd.filename = strFile.c_str();
-
- // read data using avformat's buffers
- pd.buf_size = avio_read(m_ioContext, pd.buf, probeBufferSize);
- if (pd.buf_size <= 0)
- {
- Log(LOGLEVEL_ERROR, "%s - error reading from input stream, %s", __FUNCTION__, CURL::GetRedacted(strFile).c_str());
- return false;
- }
- memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
-
- // restore position again
- avio_seek(m_ioContext , 0, SEEK_SET);
-
- // the advancedsetting is for allowing the user to force outputting the
- // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
- // it (this is temporary until we handle 44.1 kHz passthrough properly)
- if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0)) // && !CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_VideoPlayerIgnoreDTSinWAV))
- {
- // check for spdif and dts
- // This is used with wav files and audio CDs that may contain
- // a DTS or AC3 track padded for S/PDIF playback. If neither of those
- // is present, we assume it is PCM audio.
- // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS
- // may be just padded.
- const AVInputFormat* iformat2 = av_find_input_format("spdif");
-
- if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
- {
- iformat = iformat2;
- }
- else
- {
- // not spdif or no spdif demuxer, try dts
- iformat2 = av_find_input_format("dts");
-
- if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
- {
- iformat = iformat2;
- }
- else if (trySPDIFonly)
- {
- // not dts either, return false in case we were explicitly
- // requested to only check for S/PDIF padded compressed audio
- Log(LOGLEVEL_DEBUG, "%s - not spdif or dts file, falling back", __FUNCTION__);
- return false;
- }
- }
- }
- }
+ av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
if (!iformat)
{
@@ -1535,7 +1468,7 @@ bool FFmpegStream::SeekTime(double time, bool backwards, double* startpts)
if (ret >= 0)
{
- if (m_pFormatContext->iformat->read_seek)
+ if (!(m_pFormatContext->iformat->flags & AVFMT_NOTIMESTAMPS))
m_seekToKeyFrame = true;
m_currentPts = STREAM_NOPTS_VALUE;
@@ -2059,43 +1992,49 @@ DemuxStream* FFmpegStream::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
- size_t size = 0;
- uint8_t* side_data = nullptr;
+ // https://github.com/FFmpeg/FFmpeg/blob/release/7.0/doc/APIchanges
+ const AVPacketSideData* sideData = nullptr;
if (st->hdr_type == StreamHdrType::HDR_TYPE_DOLBYVISION)
{
- side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, &size);
- if (side_data && size)
+
+ sideData =
+ av_packet_side_data_get(pStream->codecpar->coded_side_data,
+ pStream->codecpar->nb_coded_side_data, AV_PKT_DATA_DOVI_CONF);
+ if (sideData && sideData->size)
{
- st->dovi = *reinterpret_cast<AVDOVIDecoderConfigurationRecord*>(side_data);
+ st->dovi = *reinterpret_cast<const AVDOVIDecoderConfigurationRecord*>(sideData->data);
}
}
- side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size);
- if (side_data && size)
+ sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
+ pStream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA);
+ if (sideData && sideData->size)
{
st->masteringMetaData = std::make_shared<AVMasteringDisplayMetadata>(
- *reinterpret_cast<AVMasteringDisplayMetadata*>(side_data));
+ *reinterpret_cast<const AVMasteringDisplayMetadata*>(sideData->data));
}
- side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, &size);
- if (side_data && size)
+ sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
+ pStream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_CONTENT_LIGHT_LEVEL);
+ if (sideData && sideData->size)
{
st->contentLightMetaData = std::make_shared<AVContentLightMetadata>(
- *reinterpret_cast<AVContentLightMetadata*>(side_data));
+ *reinterpret_cast<const AVContentLightMetadata*>(sideData->data));
}
- AVDictionaryEntry* rtag = av_dict_get(pStream->metadata, "rotate", NULL, 0);
- uint8_t* displayMatrixSideData =
- av_stream_get_side_data(pStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr);
- if (displayMatrixSideData)
+ sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
+ pStream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_DISPLAYMATRIX);
+ if (sideData)
{
- const double tetha =
- av_display_rotation_get(reinterpret_cast<int32_t*>(displayMatrixSideData));
- if (!std::isnan(tetha))
+ const double theta =
+ av_display_rotation_get(reinterpret_cast<const int32_t*>(sideData->data));
+ if (!std::isnan(theta))
{
- st->iOrientation = ((static_cast<int>(-tetha) % 360) + 360) % 360;
+ st->iOrientation = ((static_cast<int>(-theta) % 360) + 360) % 360;
}
}
@@ -2271,7 +2210,9 @@ StreamHdrType FFmpegStream::DetermineHdrType(AVStream* pStream)
{
StreamHdrType hdrType = StreamHdrType::HDR_TYPE_NONE;
- if (av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, nullptr)) // DoVi
+ if (av_packet_side_data_get(pStream->codecpar->coded_side_data,
+ pStream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_DOVI_CONF)) // DoVi
hdrType = StreamHdrType::HDR_TYPE_DOLBYVISION;
else if (pStream->codecpar->color_trc == AVCOL_TRC_SMPTE2084) // HDR10
hdrType = StreamHdrType::HDR_TYPE_HDR10;
@@ -2279,7 +2220,9 @@ StreamHdrType FFmpegStream::DetermineHdrType(AVStream* pStream)
hdrType = StreamHdrType::HDR_TYPE_HLG;
// file could be SMPTE2086 which FFmpeg currently returns as unknown
// so use the presence of static metadata to detect it
- else if (av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, nullptr))
+ else if (av_packet_side_data_get(pStream->codecpar->coded_side_data,
+ pStream->codecpar->nb_coded_side_data,
+ AV_PKT_DATA_MASTERING_DISPLAY_METADATA))
hdrType = StreamHdrType::HDR_TYPE_HDR10;
return hdrType;
--
2.43.0
|