[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [digikam] core/libs/threadimageio/ffmpegthumbnailer: move Video thumbnailer historgram in private co
From: Gilles Caulier <null () kde ! org>
Date: 2018-09-08 10:19:27
Message-ID: E1fyaKt-0007MQ-OJ () code ! kde ! org
[Download RAW message or body]
Git commit 07cbb0be60c6a08551d94ad6b655d3d37f2ad8bb by Gilles Caulier.
Committed on 08/09/2018 at 10:19.
Pushed by cgilles into branch 'master'.
move Video thumbnailer historgram in private container.
M +46 -14 core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.cpp
M +0 -29 core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.h
https://commits.kde.org/digikam/07cbb0be60c6a08551d94ad6b655d3d37f2ad8bb
diff --git a/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.cpp \
b/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.cpp index \
3057b22829..0a433d92e1 100644
--- a/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.cpp
+++ b/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.cpp
@@ -48,6 +48,32 @@ namespace Digikam
class Q_DECL_HIDDEN VideoThumbnailer::Private
{
+public:
+
+ template <typename T>
+ class Q_DECL_HIDDEN Histogram
+ {
+
+ public:
+
+ explicit Histogram()
+ {
+ memset(r, 0, 255 * sizeof(T));
+ memset(g, 0, 255 * sizeof(T));
+ memset(b, 0, 255 * sizeof(T));
+ }
+
+ ~Histogram()
+ {
+ }
+
+ public:
+
+ T r[256];
+ T g[256];
+ T b[256];
+ };
+
public:
explicit Private()
@@ -61,6 +87,12 @@ public:
smartFrameSelection = false;
}
+ void generateHistogram(const VideoFrame& videoFrame, Histogram<int>& histogram);
+ int getBestThumbnailIndex(std::vector<VideoFrame>& videoFrames,
+ const std::vector<Histogram<int> >& histograms);
+
+public:
+
int thumbnailSize;
quint16 seekPercentage;
bool overlayFilmStrip;
@@ -173,16 +205,16 @@ void VideoThumbnailer::generateSmartThumbnail(MovieDecoder& \
movieDecoder, VideoFrame& videoFrame)
{
vector<VideoFrame> videoFrames(d->SMART_FRAME_ATTEMPTS);
- vector<Histogram<int> > histograms(d->SMART_FRAME_ATTEMPTS);
+ vector<Private::Histogram<int> > histograms(d->SMART_FRAME_ATTEMPTS);
- for (int i = 0 ; i < d->SMART_FRAME_ATTEMPTS ; i++)
+ for (int i = 0 ; i < d->SMART_FRAME_ATTEMPTS ; ++i)
{
movieDecoder.decodeVideoFrame();
movieDecoder.getScaledVideoFrame(d->thumbnailSize, d->maintainAspectRatio, \
videoFrames[i]);
- generateHistogram(videoFrames[i], histograms[i]);
+ d->generateHistogram(videoFrames[i], histograms[i]);
}
- int bestFrame = getBestThumbnailIndex(videoFrames, histograms);
+ int bestFrame = d->getBestThumbnailIndex(videoFrames, histograms);
Q_ASSERT(bestFrame != -1);
@@ -231,10 +263,10 @@ void VideoThumbnailer::applyFilters(VideoFrame& videoFrame)
}
}
-void VideoThumbnailer::generateHistogram(const VideoFrame& videoFrame,
- Histogram<int>& histogram)
+void VideoThumbnailer::Private::generateHistogram(const VideoFrame& videoFrame,
+ Private::Histogram<int>& \
histogram) {
- for (quint32 i = 0 ; i < videoFrame.height ; i++)
+ for (quint32 i = 0 ; i < videoFrame.height ; ++i)
{
int pixelIndex = i * videoFrame.lineSize;
@@ -247,15 +279,15 @@ void VideoThumbnailer::generateHistogram(const VideoFrame& \
videoFrame, }
}
-int VideoThumbnailer::getBestThumbnailIndex(vector<VideoFrame>& videoFrames,
- const vector<Histogram<int> >& \
histograms) +int VideoThumbnailer::Private::getBestThumbnailIndex(vector<VideoFrame>& \
videoFrames, + const \
vector<Private::Histogram<int> >& histograms) {
Q_UNUSED(videoFrames);
- Histogram<float> avgHistogram;
+ Private::Histogram<float> avgHistogram;
- for (size_t i = 0 ; i < histograms.size() ; i++)
+ for (size_t i = 0 ; i < histograms.size() ; ++i)
{
- for (int j = 0 ; j < 255 ; j++)
+ for (int j = 0 ; j < 255 ; ++j)
{
avgHistogram.r[j] += static_cast<float>(histograms[i].r[j]) / \
histograms.size();
avgHistogram.g[j] += static_cast<float>(histograms[i].g[j]) / \
histograms.size(); @@ -266,12 +298,12 @@ int \
VideoThumbnailer::getBestThumbnailIndex(vector<VideoFrame>& videoFrames, int \
bestFrame = -1; float minRMSE = FLT_MAX;
- for (size_t i = 0 ; i < histograms.size() ; i++)
+ for (size_t i = 0 ; i < histograms.size() ; ++i)
{
// calculate root mean squared error
float rmse = 0.0;
- for (int j = 0 ; j < 255 ; j++)
+ for (int j = 0 ; j < 255 ; ++j)
{
float error = qFabs(avgHistogram.r[j] - histograms[i].r[j]) +
qFabs(avgHistogram.g[j] - histograms[i].g[j]) +
diff --git a/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.h \
b/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.h index \
4e93c07e56..ac8b817bed 100644
--- a/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.h
+++ b/core/libs/threadimageio/ffmpegthumbnailer/videothumbnailer.h
@@ -67,40 +67,11 @@ public:
void removeFilter(FilmStripFilter* const filter);
void clearFilters();
-private:
-
- template <typename T>
- class Q_DECL_HIDDEN Histogram
- {
-
- public:
-
- explicit Histogram()
- {
- memset(r, 0, 255 * sizeof(T));
- memset(g, 0, 255 * sizeof(T));
- memset(b, 0, 255 * sizeof(T));
- }
-
- ~Histogram()
- {
- }
-
- public:
-
- T r[256];
- T g[256];
- T b[256];
- };
-
private:
void generateThumbnail(const QString& videoFile, ImageWriter& imageWriter, \
QImage& image);
void generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame);
- void generateHistogram(const VideoFrame& videoFrame, Histogram<int>& histogram);
- int getBestThumbnailIndex(std::vector<VideoFrame>& videoFrames,
- const std::vector<Histogram<int> >& histograms);
void applyFilters(VideoFrame& frameData);
int timeToSeconds(const QString& time) const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic