SVN commit 1205249 by scherfa: Version 2.0.2 Fixed compilation error against latest ffmpeg Size of the filmstrip overlay is dependant on thumbnail size http://reviewboard.kde.org/r/5937/ M +1 -1 CMakeLists.txt A cmake/modules/FindFFMPEG.cmake M +0 -11 ffmpegthumbs/CMakeLists.txt M +4 -0 ffmpegthumbs/ffmpegthumbnailer/ChangeLog A ffmpegthumbs/ffmpegthumbnailer/filmstrip.h [License: GPL (v2+) (wrong address)] M +47 -16 ffmpegthumbs/ffmpegthumbnailer/filmstripfilter.cpp M +4 -12 ffmpegthumbs/ffmpegthumbnailer/moviedecoder.cpp M +3 -19 ffmpegthumbs/ffmpegthumbnailer/moviedecoder.h M +2 -1 ffmpegthumbs/ffmpegthumbnailer/videoframe.h M +1 -1 ffmpegthumbs/ffmpegthumbnailer/videothumbnailer.h --- trunk/KDE/kdemultimedia/CMakeLists.txt #1205248:1205249 @@ -17,7 +17,7 @@ alsa_configure_file(${CMAKE_BINARY_DIR}/config-alsa.h) -macro_optional_find_package(FFmpeg) +macro_optional_find_package(FFMPEG) macro_log_feature(FFMPEG_FOUND "FFmpeg" "FFmpeg libraries" "FFmpeg" FALSE "http://www.ffmpeg.org" "FFmpeg required for FFMpegVideoPreview backend") macro_optional_find_package(Swscale) macro_log_feature(SWSCALE_FOUND "swscale" "FFmpeg video scaling libraries" "swscale" FALSE "" "swscale required for FFMpegVideoPreview backend") --- trunk/KDE/kdemultimedia/ffmpegthumbs/CMakeLists.txt #1205248:1205249 @@ -4,15 +4,6 @@ ${FFMPEG_INCLUDE_DIR} ) -if (FFMPEG_INCLUDE_DIR_OLD_STYLE) - SET( CMAKE_CXX_FLAGS "-D FFMPEG_AVFORMAT_API=1" ) - SET( CMAKE_CXX_FLAGS "-D FFMPEG_AVCODEC_API=1" ) -endif(FFMPEG_INCLUDE_DIR_OLD_STYLE) - -if (SWSCALE_INCLUDE_DIR) - SET( CMAKE_CXX_FLAGS "-D FFMPEG_SWSCALE_API=1" ) -endif(SWSCALE_INCLUDE_DIR) - # Certain versions of FFMPEG need this to be defined SET( CMAKE_CXX_FLAGS "-D __STDC_CONSTANT_MACROS" ) @@ -26,12 +17,10 @@ kde4_add_plugin(ffmpegthumbs ${ffmpegthumbs_PART_SRCS}) - 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}) --- trunk/KDE/kdemultimedia/ffmpegthumbs/ffmpegthumbnailer/ChangeLog #1205248:1205249 @@ -1,5 +1,9 @@ FFmpegThumbnailer +version 2.0.2 +- Fixed compilation error against latest ffmpeg +- Size of the filmstrip overlay is dependant on thumbnail size + Version 2.0.1 - Setting the thumbnail size to 0 will use the original video size (thanks to John Fremlin) - Fix for video files containing lots of audio packets before a video packet --- trunk/KDE/kdemultimedia/ffmpegthumbs/ffmpegthumbnailer/filmstripfilter.cpp #1205248:1205249 @@ -14,6 +14,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#include "filmstrip.h" #include "filmstripfilter.h" namespace ffmpegthumbnailer @@ -22,23 +23,51 @@ static const int FILMHOLE_WIDTH = 12; static const int FILMHOLE_HEIGHT = 10; -static const uint8_t filmHole[FILMHOLE_WIDTH * FILMHOLE_HEIGHT * 3] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x23, 0x23, 0x7a, 0x7a, 0x7a, 0x83, 0x83, 0x83, 0x8c, 0x8c, 0x8c, 0x90, 0x90, 0x90, 0x8e, 0x8e, 0x8e, 0x52, 0x52, 0x52, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x6e, 0x6e, 0x83, 0x83, 0x83, 0x93, 0x93, 0x93, 0xa3, 0xa3, 0xa3, 0xab, 0xab, 0xab, 0xa8, 0xa8, 0xa8, 0x9b, 0x9b, 0x9b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x72, 0x72, 0x8e, 0x8e, 0x8e, 0xa4, 0xa4, 0xa4, 0xbb, 0xbb, 0xbb, 0xc4, 0xc4, 0xc4, 0xc1, 0xc1, 0xc1, 0xaf, 0xaf, 0xaf, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e, 0x90, 0x90, 0x90, 0xa6, 0xa6, 0xa6, 0xbe, 0xbe, 0xbe, 0xc8, 0xc8, 0xc8, 0xc4, 0xc4, 0xc4, 0x8e, 0x8e, 0x8e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x09, 0x09, 0x09, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; +static const quint8* determineFilmStrip(quint32 videoWidth, quint32& filmStripWidth, quint32& filmStripHeight) +{ + if (videoWidth <= SMALLEST_FILM_STRIP_WIDTH * 2) + { + return NULL; + } + if (videoWidth <= 96) + { + filmStripWidth = filmStripHeight = 4; + return filmStrip4; + } + if (videoWidth <= 192) + { + filmStripWidth = filmStripHeight = 8; + return filmStrip8; + } + + if (videoWidth <= 384) + { + filmStripWidth = filmStripHeight = 16; + return filmStrip16; + } + + if (videoWidth <= 768) + { + filmStripWidth = filmStripHeight = 32; + return filmStrip32; + } + + filmStripWidth = filmStripHeight = 64; + return filmStrip64; +} + + + void FilmStripFilter::process(VideoFrame& videoFrame) { - if (videoFrame.width < FILMHOLE_WIDTH * 2) { + quint32 filmStripWidth; + quint32 filmStripHeight; + const quint8* filmHole = determineFilmStrip(videoFrame.width, filmStripWidth, filmStripHeight); + + if (!filmHole) + { return; } @@ -46,8 +75,10 @@ int filmHoleIndex = 0; int offset = (videoFrame.width * 3) - 3; - for (int i = 0; i < videoFrame.height; ++i) { - for (int j = 0; j < FILMHOLE_WIDTH * 3; j += 3) { + for (quint32 i = 0; i < videoFrame.height; ++i) + { + for (quint32 j = 0; j < filmStripWidth * 3; j+=3) + { int currentFilmHoleIndex = filmHoleIndex + j; videoFrame.frameData[frameIndex + j] = filmHole[currentFilmHoleIndex]; @@ -59,7 +90,7 @@ videoFrame.frameData[frameIndex + offset - j + 2] = filmHole[currentFilmHoleIndex + 2]; } frameIndex += videoFrame.lineSize; - filmHoleIndex = (i % FILMHOLE_HEIGHT) * FILMHOLE_WIDTH * 3; + filmHoleIndex = (i % filmStripHeight) * filmStripWidth * 3; } } --- trunk/KDE/kdemultimedia/ffmpegthumbs/ffmpegthumbnailer/moviedecoder.cpp #1205248:1205249 @@ -19,16 +19,8 @@ #include #include -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - extern "C" { -#ifdef FFMPEG_SWSCALE_API -#include -#else #include -#endif } using namespace std; @@ -192,7 +184,7 @@ return; } - int64_t timestamp = AV_TIME_BASE * static_cast(timeInSeconds); + qint64 timestamp = AV_TIME_BASE * static_cast(timeInSeconds); if (timestamp < 0) { timestamp = 0; @@ -250,7 +242,7 @@ avcodec_get_frame_defaults(m_pFrame); - int frameFinished; + int frameFinished = 0; #if LIBAVCODEC_VERSION_MAJOR < 53 int bytesDecoded = avcodec_decode_video(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket->data, m_pPacket->size); @@ -364,12 +356,12 @@ } } -void MovieDecoder::createAVFrame(AVFrame** avFrame, uint8_t** frameBuffer, int width, int height, PixelFormat format) +void MovieDecoder::createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, PixelFormat format) { *avFrame = avcodec_alloc_frame(); int numBytes = avpicture_get_size(format, width, height); - *frameBuffer = reinterpret_cast(av_malloc(numBytes)); + *frameBuffer = reinterpret_cast(av_malloc(numBytes)); avpicture_fill((AVPicture*) *avFrame, *frameBuffer, format, width, height); } --- trunk/KDE/kdemultimedia/ffmpegthumbs/ffmpegthumbnailer/moviedecoder.h #1205248:1205249 @@ -17,30 +17,14 @@ #ifndef MOVIEDECODER_H #define MOVIEDECODER_H -#include -#include - #include "videoframe.h" +#include -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - extern "C" { -#ifdef FFMPEG_AVCODEC_API -#include -#else #include -#endif -#ifdef FFMPEG_AVFORMAT_API -#include -#else #include -#endif } -#include - namespace ffmpegthumbnailer { @@ -69,7 +53,7 @@ bool decodeVideoPacket(); bool getVideoPacket(); void convertAndScaleFrame(PixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight); - void createAVFrame(AVFrame** avFrame, uint8_t** frameBuffer, int width, int height, PixelFormat format); + void createAVFrame(AVFrame** avFrame, quint8** frameBuffer, int width, int height, PixelFormat format); void calculateDimensions(int squareSize, bool maintainAspectRatio, int& destWidth, int& destHeight); private: @@ -79,7 +63,7 @@ AVCodec* m_pVideoCodec; AVStream* m_pVideoStream; AVFrame* m_pFrame; - uint8_t* m_pFrameBuffer; + quint8* m_pFrameBuffer; AVPacket* m_pPacket; bool m_FormatContextWasGiven; bool m_AllowSeek; --- trunk/KDE/kdemultimedia/ffmpegthumbs/ffmpegthumbnailer/videoframe.h #1205248:1205249 @@ -19,6 +19,7 @@ #include #include +#include namespace ffmpegthumbnailer { @@ -34,7 +35,7 @@ int height; int lineSize; - std::vector frameData; + std::vector frameData; }; } --- trunk/KDE/kdemultimedia/ffmpegthumbs/ffmpegthumbnailer/videothumbnailer.h #1205248:1205249 @@ -67,7 +67,7 @@ private: int m_ThumbnailSize; - uint16_t m_SeekPercentage; + quint16 m_SeekPercentage; bool m_OverlayFilmStrip; bool m_WorkAroundIssues; bool m_MaintainAspectRatio;