~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libmedia/ffmpeg/VideoDecoderFfmpeg.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// VideoDecoderFfmpeg.h: Video decoding using the FFMPEG library.
2
2
// 
3
 
//   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
3
//     Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4
4
// 
5
5
// This program is free software; you can redistribute it and/or modify
6
6
// it under the terms of the GNU General Public License as published by
9
9
// 
10
10
// This program is distributed in the hope that it will be useful,
11
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
13
13
// GNU General Public License for more details.
14
14
//
15
15
// You should have received a copy of the GNU General Public License
16
16
// along with this program; if not, write to the Free Software
17
 
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 
19
 
// $Id: VideoDecoderFfmpeg.h,v 1.1.2.2 2008/02/27 20:55:02 bjacques Exp $
20
 
 
21
 
#ifndef __VIDEODECODERFFMPEG_H__
22
 
#define __VIDEODECODERFFMPEG_H__
 
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA    02110-1301    USA
 
18
 
 
19
 
 
20
#ifndef GNASH_VIDEODECODERFFMPEG_H
 
21
#define GNASH_VIDEODECODERFFMPEG_H
23
22
 
24
23
#ifdef HAVE_CONFIG_H
25
24
#include "gnashconfig.h"
26
25
#endif
27
26
 
 
27
#include <memory>
 
28
#include "dsodefs.h" //For DSOEXPORT
28
29
#include "log.h"
29
30
#include "VideoDecoder.h"
30
 
 
31
 
extern "C" {
32
 
#include <ffmpeg/avcodec.h>
33
 
}
 
31
#include "MediaParser.h" // for videoCodecType enum
 
32
#include "ffmpegHeaders.h"
34
33
 
35
34
 
36
35
namespace gnash {
37
36
namespace media {
38
37
 
39
38
 
 
39
/// Forward declarations
 
40
class CodecContextWrapper;
 
41
#ifdef HAVE_SWSCALE_H
 
42
class SwsContextWrapper;
 
43
#endif
 
44
 
 
45
 
40
46
class VideoDecoderFfmpeg : public VideoDecoder {
41
 
  
 
47
    
42
48
public:
43
 
  VideoDecoderFfmpeg(videoCodecType format, int width, int height);
44
 
  ~VideoDecoderFfmpeg();
45
 
  
46
 
  void push(const EncodedVideoFrame& buffer);
47
 
 
48
 
  std::auto_ptr<image::rgb> pop();
49
 
  
50
 
  bool peek();
51
 
  
52
 
  
53
 
  /// \brief converts an video frame from (almost) any type to RGB24.
54
 
  ///
55
 
  /// @param srcCtx The source context that was used to decode srcFrame.
56
 
  /// @param srcFrame the source frame to be converted.
57
 
  /// @return an AVPicture containing the converted image. Please be advised
58
 
  ///         that the RGB data pointer is stored in AVPicture::data[0]. The
59
 
  ///         caller owns that pointer, which must be freed with delete [].
60
 
  ///         It is advised to wrap the pointer in a boost::scoped_array.
61
 
  ///         If conversion fails, AVPicture::data[0] will be NULL.
62
 
  static AVPicture convertRGB24(AVCodecContext* srcCtx, const AVFrame& srcFrame);
63
 
 
64
 
private:
65
 
 
66
 
  std::auto_ptr<image::rgb> decode(boost::uint8_t* input, boost::uint32_t input_size);
67
 
private:
68
 
 
69
 
  AVCodec* _videoCodec;
70
 
  AVCodecContext* _videoCodecCtx;
71
 
  std::vector<const EncodedVideoFrame*> _video_frames;
 
49
 
 
50
    DSOEXPORT VideoDecoderFfmpeg(videoCodecType format, int width, int height);
 
51
 
 
52
    DSOEXPORT VideoDecoderFfmpeg(VideoInfo& info);
 
53
 
 
54
    DSOEXPORT ~VideoDecoderFfmpeg();
 
55
    
 
56
    void push(const EncodedVideoFrame& buffer);
 
57
 
 
58
    std::auto_ptr<image::ImageBase> pop();
 
59
    
 
60
    bool peek();
 
61
    
 
62
    
 
63
    /// \brief converts an video frame from (almost) any type to RGB24.
 
64
    ///
 
65
    /// @param srcCtx The source context that was used to decode srcFrame.
 
66
    /// @param srcFrame the source frame to be converted.
 
67
    /// @return an AVPicture containing the converted image. Please be advised
 
68
    ///                 that the RGB data pointer is stored in AVPicture::data[0]. The
 
69
    ///                 caller owns that pointer, which must be freed with delete [].
 
70
    ///                 It is advised to wrap the pointer in a boost::scoped_array.
 
71
    ///                 If conversion fails, AVPicture::data[0] will be NULL.
 
72
    std::auto_ptr<image::ImageBase> frameToImage(AVCodecContext* srcCtx, const AVFrame& srcFrame);
 
73
 
 
74
    /// Convert FLASH codec id to FFMPEG codec id
 
75
    //
 
76
    /// @return CODEC_ID_NONE for unsupported flash codecs
 
77
    ///
 
78
    DSOEXPORT static enum CodecID flashToFfmpegCodec(videoCodecType format);
 
79
 
 
80
private:
 
81
 
 
82
    void init(enum CodecID format, int width, int height, boost::uint8_t* extradata=0, int extradataSize=0);
 
83
 
 
84
    std::auto_ptr<image::ImageBase> decode(const boost::uint8_t* input, boost::uint32_t input_size);
 
85
 
 
86
    std::auto_ptr<image::ImageBase> decode(const EncodedVideoFrame* vf)
 
87
    {
 
88
        return decode(vf->data(), vf->dataSize());
 
89
    }
 
90
 
 
91
    AVCodec* _videoCodec;
 
92
    std::auto_ptr<CodecContextWrapper> _videoCodecCtx;
 
93
 
 
94
#if HAVE_SWSCALE_H
 
95
    /// A pointer to a wrapper round an SwsContext
 
96
    //
 
97
    /// This is constructed with a SwsContext*, which
 
98
    /// can be NULL, so it is important to check
 
99
    /// not only that the wrapper exists, but also
 
100
    /// the context inside it.    
 
101
    std::auto_ptr<SwsContextWrapper> _swsContext;
 
102
#endif
 
103
 
 
104
    std::vector<const EncodedVideoFrame*> _video_frames;
72
105
};
73
 
  
 
106
    
74
107
} // gnash.media namespace 
75
108
} // gnash namespace
76
109