Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions libffmpegthumbnailer/moviedecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ void MovieDecoder::destroy()
avformat_network_deinit();
}

bool MovieDecoder::embeddedMetaDataIsAvailable()
bool MovieDecoder::embeddedMetaDataIsAvailable() const
{
return m_UseEmbeddedData;
}

string MovieDecoder::getCodec()
string MovieDecoder::getCodec() const
{
if (m_pVideoCodec) {
return m_pVideoCodec->name;
Expand Down Expand Up @@ -374,7 +374,7 @@ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::
checkRc(avfilter_graph_config(m_pFilterGraph, nullptr), "Failed to configure filter graph");
}

int MovieDecoder::getWidth()
int MovieDecoder::getWidth() const
{
if (m_pVideoCodecContext) {
return m_pVideoCodecContext->width;
Expand All @@ -383,7 +383,7 @@ int MovieDecoder::getWidth()
return -1;
}

int MovieDecoder::getHeight()
int MovieDecoder::getHeight() const
{
if (m_pVideoCodecContext) {
return m_pVideoCodecContext->height;
Expand All @@ -392,7 +392,7 @@ int MovieDecoder::getHeight()
return -1;
}

int MovieDecoder::getDuration()
int MovieDecoder::getDuration() const
{
if (m_pFormatContext) {
return static_cast<int>(m_pFormatContext->duration / AV_TIME_BASE);
Expand Down Expand Up @@ -540,7 +540,7 @@ void MovieDecoder::getScaledVideoFrame(const std::string& scaledSize, bool maint
}
}

void MovieDecoder::checkRc(int ret, const std::string& message)
void MovieDecoder::checkRc(int ret, const std::string& message) const
{
if (ret < 0) {
char buf[256];
Expand All @@ -550,7 +550,7 @@ void MovieDecoder::checkRc(int ret, const std::string& message)
}
}

int32_t MovieDecoder::getStreamRotation()
int32_t MovieDecoder::getStreamRotation() const
{
if (!m_pVideoStream || !m_pVideoStream->codecpar) {
return -1;
Expand Down
14 changes: 7 additions & 7 deletions libffmpegthumbnailer/moviedecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ class MovieDecoder
MovieDecoder(AVFormatContext* pavContext = nullptr);
~MovieDecoder();

std::string getCodec();
std::string getCodec() const;
void seek(int timeInSeconds);
void decodeVideoFrame();
void getScaledVideoFrame(const std::string& scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame);

int getWidth();
int getHeight();
int getDuration();
int getWidth() const;
int getHeight() const;
int getDuration() const;

void initialize(const std::string& filename, bool preferEmbeddedMetadata);
void destroy();

bool embeddedMetaDataIsAvailable();
bool embeddedMetaDataIsAvailable() const;

private:
int32_t findPreferredVideoStream(bool preferEmbeddedMetadata);
Expand All @@ -68,10 +68,10 @@ class MovieDecoder

bool decodeVideoPacket();
bool getVideoPacket();
int32_t getStreamRotation();
int32_t getStreamRotation() const;
std::string createScaleString(const std::string& size, bool maintainAspectRatio);

void checkRc(int ret, const std::string& message);
void checkRc(int ret, const std::string& message) const;

private:
int m_VideoStream;
Expand Down
8 changes: 4 additions & 4 deletions libffmpegthumbnailer/videothumbnailer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ VideoFrameInfo VideoThumbnailer::generateThumbnail(const string& videoFile, Imag
return info;
}

void VideoThumbnailer::generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame)
void VideoThumbnailer::generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame) const
{
vector<VideoFrame> videoFrames(SMART_FRAME_ATTEMPTS);
vector<Histogram<int>> histograms(SMART_FRAME_ATTEMPTS);
Expand Down Expand Up @@ -262,7 +262,7 @@ void VideoThumbnailer::writeImage(const string& videoFile, ImageWriter& imageWri
imageWriter.writeFrame(&(rowPointers.front()), videoFrame.width, videoFrame.height, m_ImageQuality);
}

string VideoThumbnailer::getMimeType(const string& videoFile)
string VideoThumbnailer::getMimeType(const string& videoFile) const
{
string extension = getExtension(videoFile);

Expand All @@ -289,7 +289,7 @@ string VideoThumbnailer::getMimeType(const string& videoFile)
}
}

string VideoThumbnailer::getExtension(const string& videoFilename)
string VideoThumbnailer::getExtension(const string& videoFilename) const
{
string extension;
auto pos = videoFilename.rfind('.');
Expand Down Expand Up @@ -328,7 +328,7 @@ void VideoThumbnailer::applyFilters(VideoFrame& frameData)
}
}

int VideoThumbnailer::getBestThumbnailIndex(vector<VideoFrame>& videoFrames, const vector<Histogram<int>>& histograms)
int VideoThumbnailer::getBestThumbnailIndex(vector<VideoFrame>& videoFrames, const vector<Histogram<int>>& histograms) const
{
Histogram<float> avgHistogram;
for (auto&& histogram : histograms) {
Expand Down
8 changes: 4 additions & 4 deletions libffmpegthumbnailer/videothumbnailer.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ class VideoThumbnailer

private:
VideoFrameInfo generateThumbnail(const std::string& videoFile, ImageWriter& imageWriter, AVFormatContext* pAvContext = nullptr);
void generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame);
void generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame) const;
void writeImage(const std::string& videoFile, ImageWriter& imageWriter, const VideoFrame& videoFrame, int duration, std::vector<uint8_t*>& rowPointers);

std::string getMimeType(const std::string& videoFile);
std::string getExtension(const std::string& videoFilename);
std::string getMimeType(const std::string& videoFile) const;
std::string getExtension(const std::string& videoFilename) const;

int getBestThumbnailIndex(std::vector<VideoFrame>& videoFrames, const std::vector<Histogram<int>>& histograms);
int getBestThumbnailIndex(std::vector<VideoFrame>& videoFrames, const std::vector<Histogram<int>>& histograms) const;
void applyFilters(VideoFrame& frameData);

void TraceMessage(ThumbnailerLogLevel lvl, const std::string& msg);
Expand Down