~ubuntu-branches/ubuntu/maverick/kdemultimedia/maverick-proposed

« back to all changes in this revision

Viewing changes to ffmpegthumbs/ffmpegthumbnailer/moviedecoder.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2010-05-25 08:30:50 UTC
  • mfrom: (1.2.43 upstream)
  • Revision ID: james.westby@ubuntu.com-20100525083050-8o3otjqjwsnzjb6h
Tags: 4:4.4.80-0ubuntu1
* New upstream beta release:
  - Bump kde-sc-dev-latest to 4.4.80
  - Update various .install files
  - Refresh all patches
  - Add build-depends on libswscale-dev, libavcodec-dev, and libavformat-dev
    for new video thumbnailer backends
  - Add a new ffmpegthumbs package for the new video thumbnailer
* Switch to source format 3.0 (quilt):
  - Bump debhelper build-depend version to 7.3.16 or greater

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//    Copyright (C) 2010 Dirk Vanden Boer <dirk.vdb@gmail.com>
 
2
//
 
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.
 
7
//
 
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.
 
12
//
 
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
 
16
 
 
17
#ifndef MOVIEDECODER_H
 
18
#define MOVIEDECODER_H
 
19
 
 
20
#include <string>
 
21
#include <vector>
 
22
 
 
23
#include "videoframe.h"
 
24
 
 
25
#ifdef HAVE_CONFIG_H
 
26
#include "config.h"
 
27
#endif
 
28
 
 
29
extern "C" {
 
30
#ifdef FFMPEG_AVCODEC_API
 
31
#include <ffmpeg/avcodec.h>
 
32
#else
 
33
#include <libavcodec/avcodec.h>
 
34
#endif
 
35
#ifdef FFMPEG_AVFORMAT_API
 
36
#include <ffmpeg/avformat.h>
 
37
#else
 
38
#include <libavformat/avformat.h>
 
39
#endif
 
40
}
 
41
 
 
42
#include <QString>
 
43
 
 
44
namespace ffmpegthumbnailer
 
45
{
 
46
 
 
47
class MovieDecoder
 
48
{
 
49
public:
 
50
    MovieDecoder(const QString& filename, AVFormatContext* pavContext = NULL);
 
51
    ~MovieDecoder();
 
52
 
 
53
    QString getCodec();
 
54
    void seek(int timeInSeconds);
 
55
    void decodeVideoFrame();
 
56
    void getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame);
 
57
 
 
58
    int getWidth();
 
59
    int getHeight();
 
60
    int getDuration();
 
61
 
 
62
    void initialize(const QString& filename);
 
63
    void destroy();
 
64
    bool getInitialized();
 
65
 
 
66
private:
 
67
    void initializeVideo();
 
68
 
 
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);
 
74
 
 
75
private:
 
76
    int                     m_VideoStream;
 
77
    AVFormatContext*        m_pFormatContext;
 
78
    AVCodecContext*         m_pVideoCodecContext;
 
79
    AVCodec*                m_pVideoCodec;
 
80
    AVStream*               m_pVideoStream;
 
81
    AVFrame*                m_pFrame;
 
82
    uint8_t*                m_pFrameBuffer;
 
83
    AVPacket*               m_pPacket;
 
84
    bool                    m_FormatContextWasGiven;
 
85
    bool                    m_AllowSeek;
 
86
    bool                    m_initialized;
 
87
};
 
88
 
 
89
}
 
90
 
 
91
#endif