1
// Copyright (C) 2010 Dirk Vanden Boer <dirk.vdb@gmail.com>
3
// This program is free software; you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation; either version 2 of the License, or
6
// (at your option) any later version.
8
// This program is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
// GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
#ifndef MOVIEDECODER_H
18
#define MOVIEDECODER_H
23
#include "videoframe.h"
30
#ifdef FFMPEG_AVCODEC_API
31
#include <ffmpeg/avcodec.h>
33
#include <libavcodec/avcodec.h>
35
#ifdef FFMPEG_AVFORMAT_API
36
#include <ffmpeg/avformat.h>
38
#include <libavformat/avformat.h>
44
namespace ffmpegthumbnailer
50
MovieDecoder(const QString& filename, AVFormatContext* pavContext = NULL);
54
void seek(int timeInSeconds);
55
void decodeVideoFrame();
56
void getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame);
62
void initialize(const QString& filename);
64
bool getInitialized();
67
void initializeVideo();
69
bool decodeVideoPacket();
70
bool getVideoPacket();
71
void convertAndScaleFrame(PixelFormat format, int scaledSize, bool maintainAspectRatio, int& scaledWidth, int& scaledHeight);
72
void createAVFrame(AVFrame** avFrame, uint8_t** frameBuffer, int width, int height, PixelFormat format);
73
void calculateDimensions(int squareSize, bool maintainAspectRatio, int& destWidth, int& destHeight);
77
AVFormatContext* m_pFormatContext;
78
AVCodecContext* m_pVideoCodecContext;
79
AVCodec* m_pVideoCodec;
80
AVStream* m_pVideoStream;
82
uint8_t* m_pFrameBuffer;
84
bool m_FormatContextWasGiven;