File ffmpegthumbnailer-update-for-newest-ffmpeg.patch of Package ffmpegthumbnailer

From df789ec326ae0f2c619f91c8f2fc8b5e45b50a70 Mon Sep 17 00:00:00 2001
From: FrozenGalaxy <156858866+FrozenGalaxy@users.noreply.github.com>
Date: Sun, 18 May 2025 02:03:22 +0200
Subject: [PATCH] update moviedecoder.cpp for newest ffmpeg

---
 libffmpegthumbnailer/moviedecoder.cpp | 29 +++++++++++++++++----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
index f19f082..68170df 100644
--- a/libffmpegthumbnailer/moviedecoder.cpp
+++ b/libffmpegthumbnailer/moviedecoder.cpp
@@ -406,7 +406,7 @@ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::
             "Failed to create filter sink");
 
     AVFilterContext* yadifFilter = nullptr;
-    if (m_pFrame->interlaced_frame != 0)
+    if (m_pFrame->flags & AV_FRAME_FLAG_INTERLACED)
     {
         checkRc(avfilter_graph_create_filter(&yadifFilter, avfilter_get_by_name("yadif"), "thumb_deint", "deint=1", nullptr, m_pFilterGraph),
                 "Failed to create deinterlace filter");
@@ -518,7 +518,7 @@ void MovieDecoder::seek(int timeInSeconds)
         }
 
         ++keyFrameAttempts;
-    } while ((!gotFrame || !m_pFrame->key_frame) && keyFrameAttempts < 200);
+    } while ((!gotFrame || !(m_pFrame->flags & AV_FRAME_FLAG_KEY)) && keyFrameAttempts < 200); 
 
     if (gotFrame == 0)
     {
@@ -655,20 +655,27 @@ void MovieDecoder::checkRc(int ret, const std::string& message)
 
 int32_t MovieDecoder::getStreamRotation()
 {
-    auto matrix = reinterpret_cast<int32_t*>(av_stream_get_side_data(m_pVideoStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr));
-    if (matrix)
-    {
+    if (!m_pVideoStream || !m_pVideoStream->codecpar) {
+        return -1;
+    }
+
+    // For FFmpeg 5.0+
+    const AVPacketSideData* side_data = av_packet_side_data_get(
+        m_pVideoStream->codecpar->coded_side_data,
+        m_pVideoStream->codecpar->nb_coded_side_data,
+        AV_PKT_DATA_DISPLAYMATRIX
+    );
+
+    if (side_data && side_data->size >= sizeof(int32_t) * 9) {
+        const int32_t* matrix = reinterpret_cast<const int32_t*>(side_data->data);
         auto angle = lround(av_display_rotation_get(matrix));
-        if (angle < -135)
-        {
+        if (angle < -135) {
             return 3;
         }
-        else if (angle > 45 && angle < 135)
-        {
+        else if (angle > 45 && angle < 135) {
             return 2;
         }
-        else if (angle < -45 && angle > -135)
-        {
+        else if (angle < -45 && angle > -135) {
             return 1;
         }
     }
openSUSE Build Service is sponsored by