OSDN Git Service

ffmpegthumbs: cleanup and fix build with recenet versions of FFmpeg
authorIvailo Monev <xakepa10@gmail.com>
Sun, 3 Apr 2016 04:56:28 +0000 (04:56 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 3 Apr 2016 04:56:28 +0000 (04:56 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
ffmpegthumbs/CMakeLists.txt
ffmpegthumbs/ffmpegthumbnailer/moviedecoder.cpp
ffmpegthumbs/ffmpegthumbnailer/moviedecoder.h

index 1ef629a..4dee492 100644 (file)
@@ -1,5 +1,14 @@
 project(ffmpegthumbs)
 
+if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
+    find_package(KDE4 4.14.3 REQUIRED)
+    include(KDE4Defaults)
+    include_directories(${KDE4_INCLUDES})
+
+    add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+    add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+endif()
+
 find_package(FFmpeg COMPONENTS AVCODEC AVFORMAT SWSCALE)
 
 include_directories(
@@ -23,14 +32,20 @@ set(ffmpegthumbs_PART_SRCS
 
 kde4_add_plugin(ffmpegthumbs ${ffmpegthumbs_PART_SRCS})
 
-target_link_libraries(ffmpegthumbs  ${KDE4_KIO_LIBS} ${AVUTIL_LIBRARIES} ${AVFORMAT_LIBRARIES} ${AVCODEC_LIBRARIES} ${SWSCALE_LIBRARIES} )
+target_link_libraries(ffmpegthumbs
+    ${KDE4_KIO_LIBS}
+    ${AVUTIL_LIBRARIES}
+    ${AVFORMAT_LIBRARIES}
+    ${AVCODEC_LIBRARIES}
+    ${SWSCALE_LIBRARIES}
+)
 
 install(TARGETS ffmpegthumbs DESTINATION ${PLUGIN_INSTALL_DIR})
 
 ########### install files ###############
 
-install(FILES  ffmpegthumbs.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+install(FILES ffmpegthumbs.desktop DESTINATION ${SERVICES_INSTALL_DIR})
 
-if (KDE4_BUILD_TESTS)
+if(ENABLE_TESTING)
     add_subdirectory(tests)
-endif (KDE4_BUILD_TESTS)
+endif()
index 7c64b76..b1a27ae 100644 (file)
@@ -285,13 +285,15 @@ bool MovieDecoder::getVideoPacket()
 
 void MovieDecoder::getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame)
 {
+#ifdef FF_API_DEINTERLACE
     if (m_pFrame->interlaced_frame) {
         avpicture_deinterlace((AVPicture*) m_pFrame, (AVPicture*) m_pFrame, m_pVideoCodecContext->pix_fmt,
                               m_pVideoCodecContext->width, m_pVideoCodecContext->height);
     }
+#endif
 
     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 +304,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,
@@ -355,7 +357,7 @@ 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 = av_frame_alloc();
 
index 2888926..cb49670 100644 (file)
@@ -52,8 +52,8 @@ 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);
 
 private: