summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtem Dyomin <artem.dyomin@qt.io>2023-12-27 14:30:25 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-12-28 16:26:03 +0000
commit474962490ba59a9f27530423ae557edc474004d0 (patch)
treea14202210367a61896544843afe2b006cbec8909 /src
parent657af45e2e03d00716e73bf0b7db2c78fe391624 (diff)
Fix build with ffmpeg 6.1
In ffmpeg 6.1 stream side data is deprecated, codec params side data is supposed to be used instead. The patch applies changes of ffmpeg 6.1 and ensures compatibility with prev versions on the build step. Pick-to: 6.6 6.5 Change-Id: I65a6e21ac6500269db7866b1e8937b6c4decc90a Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> (cherry picked from commit 7715bc59e11f23cfcd1e38ba8a83c560f8bf8eee) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/multimedia/ffmpeg/playbackengine/qffmpegmediadataholder.cpp12
-rw-r--r--src/plugins/multimedia/ffmpeg/qffmpeg.cpp15
-rw-r--r--src/plugins/multimedia/ffmpeg/qffmpeg_p.h4
3 files changed, 25 insertions, 6 deletions
diff --git a/src/plugins/multimedia/ffmpeg/playbackengine/qffmpegmediadataholder.cpp b/src/plugins/multimedia/ffmpeg/playbackengine/qffmpegmediadataholder.cpp
index ad2f55f09..73a7acd7d 100644
--- a/src/plugins/multimedia/ffmpeg/playbackengine/qffmpegmediadataholder.cpp
+++ b/src/plugins/multimedia/ffmpeg/playbackengine/qffmpegmediadataholder.cpp
@@ -49,13 +49,13 @@ static std::optional<qint64> streamDuration(const AVStream &stream)
static int streamOrientation(const AVStream *stream)
{
Q_ASSERT(stream);
- using SideDataSize = decltype(AVPacketSideData::size);
- SideDataSize dataSize = 0;
- constexpr SideDataSize displayMatrixSize = sizeof(int32_t) * 9;
- const uint8_t *sideData = av_stream_get_side_data(stream, AV_PKT_DATA_DISPLAYMATRIX, &dataSize);
- if (dataSize < displayMatrixSize)
+
+ constexpr auto displayMatrixSize = sizeof(int32_t) * 9;
+ const auto *sideData = streamSideData(stream, AV_PKT_DATA_DISPLAYMATRIX);
+ if (!sideData || sideData->size < displayMatrixSize)
return 0;
- auto displayMatrix = reinterpret_cast<const int32_t *>(sideData);
+
+ auto displayMatrix = reinterpret_cast<const int32_t *>(sideData->data);
auto rotation = static_cast<int>(std::round(av_display_rotation_get(displayMatrix)));
// Convert counterclockwise rotation angle to clockwise, restricted to 0, 90, 180 and 270
if (rotation % 90 != 0)
diff --git a/src/plugins/multimedia/ffmpeg/qffmpeg.cpp b/src/plugins/multimedia/ffmpeg/qffmpeg.cpp
index f3e943e29..73c6c6788 100644
--- a/src/plugins/multimedia/ffmpeg/qffmpeg.cpp
+++ b/src/plugins/multimedia/ffmpeg/qffmpeg.cpp
@@ -412,6 +412,21 @@ AVPixelFormat pixelFormatForHwDevice(AVHWDeviceType deviceType)
}
}
+const AVPacketSideData *streamSideData(const AVStream *stream, AVPacketSideDataType type)
+{
+ Q_ASSERT(stream);
+
+#if QT_FFMPEG_STREAM_SIDE_DATA_DEPRECATED
+ return av_packet_side_data_get(stream->codecpar->coded_side_data,
+ stream->codecpar->nb_coded_side_data, type);
+#else
+ auto checkType = [type](const auto &item) { return item.type == type; };
+ const auto end = stream->side_data + stream->nb_side_data;
+ const auto found = std::find_if(stream->side_data, end, checkType);
+ return found == end ? nullptr : found;
+#endif
+}
+
#ifdef Q_OS_DARWIN
bool isCVFormatSupported(uint32_t cvFormat)
{
diff --git a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h
index f11bfbe80..b4db6e20d 100644
--- a/src/plugins/multimedia/ffmpeg/qffmpeg_p.h
+++ b/src/plugins/multimedia/ffmpeg/qffmpeg_p.h
@@ -22,6 +22,8 @@ extern "C" {
(LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(59, 18, 100)) // since ffmpeg n5.0
#define QT_FFMPEG_HAS_FRAME_DURATION \
(LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 3, 100)) // since ffmpeg n6.0
+#define QT_FFMPEG_STREAM_SIDE_DATA_DEPRECATED \
+ (LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(60, 15, 100)) // since ffmpeg n6.1
QT_BEGIN_NAMESPACE
@@ -197,6 +199,8 @@ inline bool isSwPixelFormat(AVPixelFormat format)
AVPixelFormat pixelFormatForHwDevice(AVHWDeviceType deviceType);
+const AVPacketSideData *streamSideData(const AVStream *stream, AVPacketSideDataType type);
+
#ifdef Q_OS_DARWIN
bool isCVFormatSupported(uint32_t format);