[SCM] ffmpegthumbs packaging branch, master, updated. debian/15.12.0-1-13-g4868f1e

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 30 07:58:17 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ffmpegthumbs.git;a=commitdiff;h=799e007

The following commit has been merged in the master branch:
commit 799e007ee34d009cc8aec61ebd881524832fc3c6
Author: Maximiliano Curia <maxy at gnuservers.com.ar>
Date:   Sun May 29 14:02:30 2016 +0200

    Use upstream ffmpeg 2.9 patch
---
 debian/patches/ffmpeg_2.9.patch                   | 252 ------------------
 debian/patches/series                             |   2 +-
 debian/patches/upstream_port_to_libavfilter.patch | 310 ++++++++++++++++++++++
 3 files changed, 311 insertions(+), 253 deletions(-)

diff --git a/debian/patches/ffmpeg_2.9.patch b/debian/patches/ffmpeg_2.9.patch
deleted file mode 100644
index efd22e8..0000000
--- a/debian/patches/ffmpeg_2.9.patch
+++ /dev/null
@@ -1,252 +0,0 @@
-Description: Replace deprecated FFmpeg API
-Author: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
-Last-Update: <2015-11-02>
-
-Index: ffmpegthumbs/CMakeLists.txt
-===================================================================
---- ffmpegthumbs.orig/CMakeLists.txt	2016-02-05 10:36:04.441640346 +0100
-+++ ffmpegthumbs/CMakeLists.txt	2016-02-05 10:39:00.494448489 +0100
-@@ -36,7 +36,7 @@
- 
- add_library(ffmpegthumbs MODULE ${ffmpegthumbs_PART_SRCS})
- 
--target_link_libraries(ffmpegthumbs Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} )
-+target_link_libraries(ffmpegthumbs Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} )
- 
- install(TARGETS ffmpegthumbs DESTINATION ${PLUGIN_INSTALL_DIR})
- 
-Index: ffmpegthumbs/cmake/FindFFmpeg.cmake
-===================================================================
---- ffmpegthumbs.orig/cmake/FindFFmpeg.cmake	2016-02-05 10:36:04.441640346 +0100
-+++ ffmpegthumbs/cmake/FindFFmpeg.cmake	2016-02-05 10:36:04.413641490 +0100
-@@ -99,6 +99,7 @@
- 
-   # Check for all possible component.
-   find_component(AVCODEC  libavcodec  avcodec  libavcodec/avcodec.h)
-+  find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
-   find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
-   find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
-   find_component(AVUTIL   libavutil   avutil   libavutil/avutil.h)
-Index: ffmpegthumbs/ffmpegthumbnailer/moviedecoder.cpp
-===================================================================
---- ffmpegthumbs.orig/ffmpegthumbnailer/moviedecoder.cpp	2016-02-05 10:36:04.441640346 +0100
-+++ ffmpegthumbs/ffmpegthumbnailer/moviedecoder.cpp	2016-02-05 10:36:04.413641490 +0100
-@@ -51,6 +51,9 @@
- 
- void MovieDecoder::initialize(const QString& filename)
- {
-+    m_last_width = -1;
-+    m_last_height = -1;
-+    m_last_pixfmt = AV_PIX_FMT_NONE;
-     av_register_all();
-     avcodec_register_all();
- 
-@@ -67,7 +70,7 @@
-     }
- 
-     initializeVideo();
--    m_pFrame = avcodec_alloc_frame();
-+    m_pFrame = av_frame_alloc();
- 
-     if (m_pFrame) {
-         m_initialized=true;
-@@ -82,6 +85,7 @@
- 
- void MovieDecoder::destroy()
- {
-+    delete_filter_graph();
-     if (m_pVideoCodecContext) {
-         avcodec_close(m_pVideoCodecContext);
-         m_pVideoCodecContext = NULL;
-@@ -99,7 +103,7 @@
-     }
- 
-     if (m_pFrame) {
--        av_free(m_pFrame);
-+        av_frame_free(&m_pFrame);
-         m_pFrame = NULL;
-     }
- 
-@@ -239,7 +243,7 @@
-         return false;
-     }
- 
--    avcodec_get_frame_defaults(m_pFrame);
-+    av_frame_unref(m_pFrame);
- 
-     int frameFinished = 0;
- 
-@@ -283,15 +287,83 @@
-     return frameDecoded;
- }
- 
-+void MovieDecoder::delete_filter_graph() {
-+    if (m_filter_graph) {
-+        av_frame_free(&m_filter_frame);
-+        avfilter_graph_free(&m_filter_graph);
-+    }
-+}
-+
-+int MovieDecoder::init_filter_graph(enum AVPixelFormat pixfmt, int width, int height) {
-+    AVFilterInOut *inputs = NULL, *outputs = NULL;
-+    char args[512];
-+    int res;
-+
-+    delete_filter_graph();
-+    m_filter_graph = avfilter_graph_alloc();
-+    snprintf(args, sizeof(args),
-+             "buffer=video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=0/1[in];"
-+             "[in]yadif[out];"
-+             "[out]buffersink",
-+             width, height, pixfmt);
-+    res = avfilter_graph_parse2(m_filter_graph, args, &inputs, &outputs);
-+    if (res < 0)
-+        return res;
-+    if(inputs || outputs)
-+        return -1;
-+    res = avfilter_graph_config(m_filter_graph, NULL);
-+    if (res < 0)
-+        return res;
-+
-+    m_buffersrc_ctx = avfilter_graph_get_filter(m_filter_graph, "Parsed_buffer_0");
-+    m_buffersink_ctx = avfilter_graph_get_filter(m_filter_graph, "Parsed_buffersink_2");
-+    if (!m_buffersrc_ctx || !m_buffersink_ctx)
-+        return -1;
-+    m_filter_frame = av_frame_alloc();
-+    m_last_width = width;
-+    m_last_height = height;
-+    m_last_pixfmt = pixfmt;
-+
-+    return 0;
-+}
-+
-+int MovieDecoder::process_filter_graph(AVPicture *dst, const AVPicture *src,
-+                                enum AVPixelFormat pixfmt, int width, int height) {
-+    int res;
-+
-+    if (!m_filter_graph || width != m_last_width ||
-+        height != m_last_height || pixfmt != m_last_pixfmt) {
-+        res = init_filter_graph(pixfmt, width, height);
-+        if (res < 0)
-+            return res;
-+    }
-+
-+    memcpy(m_filter_frame->data, src->data, sizeof(src->data));
-+    memcpy(m_filter_frame->linesize, src->linesize, sizeof(src->linesize));
-+    m_filter_frame->width = width;
-+    m_filter_frame->height = height;
-+    m_filter_frame->format = pixfmt;
-+    res = av_buffersrc_add_frame(m_buffersrc_ctx, m_filter_frame);
-+    if (res < 0)
-+        return res;
-+    res = av_buffersink_get_frame(m_buffersink_ctx, m_filter_frame);
-+    if (res < 0)
-+        return res;
-+    av_picture_copy(dst, (const AVPicture *) m_filter_frame, pixfmt, width, height);
-+    av_frame_unref(m_filter_frame);
-+
-+    return 0;
-+}
-+
- void MovieDecoder::getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame)
- {
-     if (m_pFrame->interlaced_frame) {
--        avpicture_deinterlace((AVPicture*) m_pFrame, (AVPicture*) m_pFrame, m_pVideoCodecContext->pix_fmt,
-+        process_filter_graph((AVPicture*) m_pFrame, (AVPicture*) m_pFrame, m_pVideoCodecContext->pix_fmt,
-                               m_pVideoCodecContext->width, m_pVideoCodecContext->height);
-     }
- 
-     int scaledWidth, scaledHeight;
--    convertAndScaleFrame(PIX_FMT_RGB24, scaledSize, maintainAspectRatio, scaledWidth, scaledHeight);
-+    convertAndScaleFrame(AV_PIX_FMT_RGB24, scaledSize, maintainAspectRatio, scaledWidth, scaledHeight);
- 
-     videoFrame.width = scaledWidth;
-     videoFrame.height = scaledHeight;
-@@ -302,7 +374,7 @@
-     memcpy((&(videoFrame.frameData.front())), m_pFrame->data[0], videoFrame.lineSize * videoFrame.height);
- }
- 
--void MovieDecoder::convertAndScaleFrame(PixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight)
-+void MovieDecoder::convertAndScaleFrame(AVPixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight)
- {
-     calculateDimensions(scaledSize, maintainAspectRatio, scaledWidth, scaledHeight);
-     SwsContext* scaleContext = sws_getContext(m_pVideoCodecContext->width, m_pVideoCodecContext->height,
-@@ -323,7 +395,7 @@
-               convertedFrame->data, convertedFrame->linesize);
-     sws_freeContext(scaleContext);
- 
--    av_free(m_pFrame);
-+    av_frame_free(&m_pFrame);
-     av_free(m_pFrameBuffer);
- 
-     m_pFrame        = convertedFrame;
-@@ -355,9 +427,9 @@
-     }
- }
- 
--void MovieDecoder::createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, PixelFormat format)
-+void MovieDecoder::createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, AVPixelFormat format)
- {
--    *avFrame = avcodec_alloc_frame();
-+    *avFrame = av_frame_alloc();
- 
-     int numBytes = avpicture_get_size(format, width, height);
-     *frameBuffer = reinterpret_cast<quint8*>(av_malloc(numBytes));
-Index: ffmpegthumbs/ffmpegthumbnailer/moviedecoder.h
-===================================================================
---- ffmpegthumbs.orig/ffmpegthumbnailer/moviedecoder.h	2016-02-05 10:36:04.441640346 +0100
-+++ ffmpegthumbs/ffmpegthumbnailer/moviedecoder.h	2016-02-05 10:36:04.413641490 +0100
-@@ -23,6 +23,9 @@
- extern "C" {
- #include <libavcodec/avcodec.h>
- #include <libavformat/avformat.h>
-+#include <libavfilter/avfilter.h>
-+#include <libavfilter/buffersrc.h>
-+#include <libavfilter/buffersink.h>
- }
- 
- namespace ffmpegthumbnailer
-@@ -52,10 +55,14 @@
- 
-     bool decodeVideoPacket();
-     bool getVideoPacket();
--    void convertAndScaleFrame(PixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight);
--    void createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, PixelFormat format);
-+    void convertAndScaleFrame(AVPixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight);
-+    void createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, AVPixelFormat format);
-     void calculateDimensions(int squareSize, bool maintainAspectRatio, int& destWidth, int& destHeight);
- 
-+    void delete_filter_graph();
-+    int init_filter_graph(enum AVPixelFormat pixfmt, int width, int height);
-+    int process_filter_graph(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pixfmt, int width, int height);
-+
- private:
-     int                     m_VideoStream;
-     AVFormatContext*        m_pFormatContext;
-@@ -68,6 +75,13 @@
-     bool                    m_FormatContextWasGiven;
-     bool                    m_AllowSeek;
-     bool                    m_initialized;
-+    AVFilterContext*        m_buffersink_ctx;
-+    AVFilterContext*        m_buffersrc_ctx;
-+    AVFilterGraph*          m_filter_graph;
-+    AVFrame*                m_filter_frame;
-+    int                     m_last_width;
-+    int                     m_last_height;
-+    enum AVPixelFormat      m_last_pixfmt;
- };
- 
- }
-Index: ffmpegthumbs/tests/CMakeLists.txt
-===================================================================
---- ffmpegthumbs.orig/tests/CMakeLists.txt	2016-02-05 10:36:04.441640346 +0100
-+++ ffmpegthumbs/tests/CMakeLists.txt	2016-02-05 10:40:53.101848212 +0100
-@@ -19,7 +19,7 @@
- 
- add_executable(ffmpegthumbtest ${ffmpegthumbtest_SRCS} )
- 
--target_link_libraries(ffmpegthumbtest Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES})
-+target_link_libraries(ffmpegthumbtest Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES})
- 
- 
- 
diff --git a/debian/patches/series b/debian/patches/series
index a827249..b9788e9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1 @@
-ffmpeg_2.9.patch
+upstream_port_to_libavfilter.patch
diff --git a/debian/patches/upstream_port_to_libavfilter.patch b/debian/patches/upstream_port_to_libavfilter.patch
new file mode 100644
index 0000000..12190ae
--- /dev/null
+++ b/debian/patches/upstream_port_to_libavfilter.patch
@@ -0,0 +1,310 @@
+commit 3978c762072b7bc16b2096819b7cfa2052deaf5e
+Author: Martin T. H. Sandsmark <martin.sandsmark at kde.org>
+Date:   Fri May 27 22:29:11 2016 +0200
+
+    Port to libavfilter for deinterlacing.
+    
+    Based on a patch from Andreas Cadhalpun
+    <andreas.cadhalpun at googlemail.com>.
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 48eed64..3c761fa 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -36,7 +36,7 @@ set( ffmpegthumbs_PART_SRCS
+ 
+ add_library(ffmpegthumbs MODULE ${ffmpegthumbs_PART_SRCS})
+ 
+-target_link_libraries(ffmpegthumbs Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} )
++target_link_libraries(ffmpegthumbs Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} )
+ 
+ install(TARGETS ffmpegthumbs DESTINATION ${PLUGIN_INSTALL_DIR})
+ 
+diff --git a/cmake/FindFFmpeg.cmake b/cmake/FindFFmpeg.cmake
+index 27c6b16..915ab5f 100644
+--- a/cmake/FindFFmpeg.cmake
++++ b/cmake/FindFFmpeg.cmake
+@@ -99,6 +99,7 @@ if (NOT FFMPEG_LIBRARIES)
+ 
+   # Check for all possible component.
+   find_component(AVCODEC  libavcodec  avcodec  libavcodec/avcodec.h)
++  find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
+   find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
+   find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
+   find_component(AVUTIL   libavutil   avutil   libavutil/avutil.h)
+diff --git a/ffmpegthumbnailer/moviedecoder.cpp b/ffmpegthumbnailer/moviedecoder.cpp
+index c8ae6d1..b2e7551 100644
+--- a/ffmpegthumbnailer/moviedecoder.cpp
++++ b/ffmpegthumbnailer/moviedecoder.cpp
+@@ -40,6 +40,10 @@ MovieDecoder::MovieDecoder(const QString& filename, AVFormatContext* pavContext)
+         , m_FormatContextWasGiven(pavContext != NULL)
+         , m_AllowSeek(true)
+         , m_initialized(false)
++        , m_bufferSinkContext(nullptr)
++        , m_bufferSourceContext(nullptr)
++        , m_filterGraph(nullptr)
++        , m_filterFrame(nullptr)
+ {
+     initialize(filename);
+ }
+@@ -51,6 +55,9 @@ MovieDecoder::~MovieDecoder()
+ 
+ void MovieDecoder::initialize(const QString& filename)
+ {
++    m_lastWidth = -1;
++    m_lastHeight = -1;
++    m_lastPixfmt = AV_PIX_FMT_NONE;
+     av_register_all();
+     avcodec_register_all();
+ 
+@@ -67,7 +74,7 @@ void MovieDecoder::initialize(const QString& filename)
+     }
+ 
+     initializeVideo();
+-    m_pFrame = avcodec_alloc_frame();
++    m_pFrame = av_frame_alloc();
+ 
+     if (m_pFrame) {
+         m_initialized=true;
+@@ -82,6 +89,7 @@ bool MovieDecoder::getInitialized()
+ 
+ void MovieDecoder::destroy()
+ {
++    deleteFilterGraph();
+     if (m_pVideoCodecContext) {
+         avcodec_close(m_pVideoCodecContext);
+         m_pVideoCodecContext = NULL;
+@@ -93,13 +101,13 @@ void MovieDecoder::destroy()
+     }
+ 
+     if (m_pPacket) {
+-        av_free_packet(m_pPacket);
++        av_packet_unref(m_pPacket);
+         delete m_pPacket;
+         m_pPacket = NULL;
+     }
+ 
+     if (m_pFrame) {
+-        av_free(m_pFrame);
++        av_frame_free(&m_pFrame);
+         m_pFrame = NULL;
+     }
+ 
+@@ -239,7 +247,7 @@ bool MovieDecoder::decodeVideoPacket()
+         return false;
+     }
+ 
+-    avcodec_get_frame_defaults(m_pFrame);
++    av_frame_unref(m_pFrame);
+ 
+     int frameFinished = 0;
+ 
+@@ -264,7 +272,7 @@ bool MovieDecoder::getVideoPacket()
+     int attempts = 0;
+ 
+     if (m_pPacket) {
+-        av_free_packet(m_pPacket);
++        av_packet_unref(m_pPacket);
+         delete m_pPacket;
+     }
+ 
+@@ -275,7 +283,7 @@ bool MovieDecoder::getVideoPacket()
+         if (framesAvailable) {
+             frameDecoded = m_pPacket->stream_index == m_VideoStream;
+             if (!frameDecoded) {
+-                av_free_packet(m_pPacket);
++                av_packet_unref(m_pPacket);
+             }
+         }
+     }
+@@ -283,15 +291,100 @@ bool MovieDecoder::getVideoPacket()
+     return frameDecoded;
+ }
+ 
++void MovieDecoder::deleteFilterGraph()
++{
++    if (m_filterGraph) {
++        av_frame_free(&m_filterFrame);
++        avfilter_graph_free(&m_filterGraph);
++        m_filterGraph = nullptr;
++    }
++}
++
++bool MovieDecoder::initFilterGraph(enum AVPixelFormat pixfmt, int width, int height)
++{
++    AVFilterInOut *inputs = nullptr, *outputs = nullptr;
++
++    deleteFilterGraph();
++    m_filterGraph = avfilter_graph_alloc();
++
++    QByteArray arguments("buffer=");
++    arguments += "video_size=" + QByteArray::number(width) + "x" + QByteArray::number(height) + ":";
++    arguments += "pix_fmt=" + QByteArray::number(pixfmt) + ":";
++    arguments += "time_base=1/1:pixel_aspect=0/1[in];";
++    arguments += "[in]yadif[out];";
++    arguments += "[out]buffersink";
++
++    int ret = avfilter_graph_parse2(m_filterGraph, arguments.constData(), &inputs, &outputs);
++    if (ret < 0) {
++        qWarning() << "Unable to parse filter graph";
++        return false;
++    }
++
++    if(inputs || outputs)
++        return -1;
++
++    ret = avfilter_graph_config(m_filterGraph, nullptr);
++    if (ret < 0) {
++        qWarning() << "Unable to validate filter graph";
++        return false;
++    }
++
++    m_bufferSourceContext = avfilter_graph_get_filter(m_filterGraph, "Parsed_buffer_0");
++    m_bufferSinkContext = avfilter_graph_get_filter(m_filterGraph, "Parsed_buffersink_2");
++    if (!m_bufferSourceContext || !m_bufferSinkContext) {
++        qWarning() << "Unable to get source or sink";
++        return false;
++    }
++    m_filterFrame = av_frame_alloc();
++    m_lastWidth = width;
++    m_lastHeight = height;
++    m_lastPixfmt = pixfmt;
++
++    return true;
++}
++
++bool MovieDecoder::processFilterGraph(AVPicture *dst, const AVPicture *src,
++                                enum AVPixelFormat pixfmt, int width, int height)
++{
++    if (!m_filterGraph || width != m_lastWidth ||
++        height != m_lastHeight || pixfmt != m_lastPixfmt) {
++
++        if (!initFilterGraph(pixfmt, width, height)) {
++            return false;
++        }
++    }
++
++    memcpy(m_filterFrame->data, src->data, sizeof(src->data));
++    memcpy(m_filterFrame->linesize, src->linesize, sizeof(src->linesize));
++    m_filterFrame->width = width;
++    m_filterFrame->height = height;
++    m_filterFrame->format = pixfmt;
++
++    int ret = av_buffersrc_add_frame(m_bufferSourceContext, m_filterFrame);
++    if (ret < 0) {
++        return false;
++    }
++
++    ret = av_buffersink_get_frame(m_bufferSinkContext, m_filterFrame);
++    if (ret < 0) {
++        return false;
++    }
++
++    av_picture_copy(dst, (const AVPicture *) m_filterFrame, pixfmt, width, height);
++    av_frame_unref(m_filterFrame);
++
++    return true;
++}
++
+ void MovieDecoder::getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame)
+ {
+     if (m_pFrame->interlaced_frame) {
+-        avpicture_deinterlace((AVPicture*) m_pFrame, (AVPicture*) m_pFrame, m_pVideoCodecContext->pix_fmt,
++        processFilterGraph((AVPicture*) m_pFrame, (AVPicture*) m_pFrame, m_pVideoCodecContext->pix_fmt,
+                               m_pVideoCodecContext->width, m_pVideoCodecContext->height);
+     }
+ 
+     int scaledWidth, scaledHeight;
+-    convertAndScaleFrame(PIX_FMT_RGB24, scaledSize, maintainAspectRatio, scaledWidth, scaledHeight);
++    convertAndScaleFrame(AV_PIX_FMT_RGB24, scaledSize, maintainAspectRatio, scaledWidth, scaledHeight);
+ 
+     videoFrame.width = scaledWidth;
+     videoFrame.height = scaledHeight;
+@@ -302,7 +395,7 @@ void MovieDecoder::getScaledVideoFrame(int scaledSize, bool maintainAspectRatio,
+     memcpy((&(videoFrame.frameData.front())), m_pFrame->data[0], videoFrame.lineSize * videoFrame.height);
+ }
+ 
+-void MovieDecoder::convertAndScaleFrame(PixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight)
++void MovieDecoder::convertAndScaleFrame(AVPixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight)
+ {
+     calculateDimensions(scaledSize, maintainAspectRatio, scaledWidth, scaledHeight);
+     SwsContext* scaleContext = sws_getContext(m_pVideoCodecContext->width, m_pVideoCodecContext->height,
+@@ -323,7 +416,7 @@ void MovieDecoder::convertAndScaleFrame(PixelFormat format, int scaledSize, bool
+               convertedFrame->data, convertedFrame->linesize);
+     sws_freeContext(scaleContext);
+ 
+-    av_free(m_pFrame);
++    av_frame_free(&m_pFrame);
+     av_free(m_pFrameBuffer);
+ 
+     m_pFrame        = convertedFrame;
+@@ -355,9 +448,9 @@ void MovieDecoder::calculateDimensions(int squareSize, bool maintainAspectRatio,
+     }
+ }
+ 
+-void MovieDecoder::createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, PixelFormat format)
++void MovieDecoder::createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, AVPixelFormat format)
+ {
+-    *avFrame = avcodec_alloc_frame();
++    *avFrame = av_frame_alloc();
+ 
+     int numBytes = avpicture_get_size(format, width, height);
+     *frameBuffer = reinterpret_cast<quint8*>(av_malloc(numBytes));
+diff --git a/ffmpegthumbnailer/moviedecoder.h b/ffmpegthumbnailer/moviedecoder.h
+index 2888926..788ce43 100644
+--- a/ffmpegthumbnailer/moviedecoder.h
++++ b/ffmpegthumbnailer/moviedecoder.h
+@@ -23,6 +23,9 @@
+ extern "C" {
+ #include <libavcodec/avcodec.h>
+ #include <libavformat/avformat.h>
++#include <libavfilter/avfilter.h>
++#include <libavfilter/buffersrc.h>
++#include <libavfilter/buffersink.h>
+ }
+ 
+ namespace ffmpegthumbnailer
+@@ -52,10 +55,14 @@ private:
+ 
+     bool decodeVideoPacket();
+     bool getVideoPacket();
+-    void convertAndScaleFrame(PixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight);
+-    void createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, PixelFormat format);
++    void convertAndScaleFrame(AVPixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight);
++    void createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, AVPixelFormat format);
+     void calculateDimensions(int squareSize, bool maintainAspectRatio, int& destWidth, int& destHeight);
+ 
++    void deleteFilterGraph();
++    bool initFilterGraph(enum AVPixelFormat pixfmt, int width, int height);
++    bool processFilterGraph(AVPicture *dst, const AVPicture *src, enum AVPixelFormat pixfmt, int width, int height);
++
+ private:
+     int                     m_VideoStream;
+     AVFormatContext*        m_pFormatContext;
+@@ -68,6 +75,13 @@ private:
+     bool                    m_FormatContextWasGiven;
+     bool                    m_AllowSeek;
+     bool                    m_initialized;
++    AVFilterContext*        m_bufferSinkContext;
++    AVFilterContext*        m_bufferSourceContext;
++    AVFilterGraph*          m_filterGraph;
++    AVFrame*                m_filterFrame;
++    int                     m_lastWidth;
++    int                     m_lastHeight;
++    enum AVPixelFormat      m_lastPixfmt;
+ };
+ 
+ }
+diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
+index 1728fcd..b46169a 100644
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -19,7 +19,7 @@ set(ffmpegthumbtest_SRCS ffmpegthumbtest.cpp
+ 
+ add_executable(ffmpegthumbtest ${ffmpegthumbtest_SRCS} )
+ 
+-target_link_libraries(ffmpegthumbtest Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES})
++target_link_libraries(ffmpegthumbtest Qt5::Gui KF5::KIOWidgets ${AVUTIL_LIBRARIES} ${AVFILTER_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES})
+ 
+ 
+ 

-- 
ffmpegthumbs packaging



More information about the pkg-kde-commits mailing list