Move things round a bit.
[dcpomatic.git] / src / lib / ffmpeg_decoder.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 /** @file  src/ffmpeg_decoder.h
21  *  @brief A decoder using FFmpeg to decode content.
22  */
23
24 #include <vector>
25 #include <string>
26 #include <stdint.h>
27 #include <boost/shared_ptr.hpp>
28 extern "C" {
29 #include <libavcodec/avcodec.h>
30 #include <libpostproc/postprocess.h>
31 }
32 #include "util.h"
33 #include "decoder.h"
34
35 struct AVFilterGraph;
36 struct AVCodecContext;
37 struct AVFilterContext;
38 struct AVFormatContext;
39 struct AVFrame;
40 struct AVBufferContext;
41 struct AVCodec;
42 class Job;
43 class FilmState;
44 class Options;
45 class Image;
46 class Log;
47
48 /** @class FFmpegDecoder
49  *  @brief A decoder using FFmpeg to decode content.
50  */
51 class FFmpegDecoder : public Decoder
52 {
53 public:
54         FFmpegDecoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Job *, Log *, bool, bool);
55         ~FFmpegDecoder ();
56
57         /* Methods to query our input video */
58         int length_in_frames () const;
59         int decoding_frames () const;
60         float frames_per_second () const;
61         Size native_size () const;
62         int audio_channels () const;
63         int audio_sample_rate () const;
64         AVSampleFormat audio_sample_format () const;
65
66 private:
67
68         bool do_pass ();
69         PixelFormat pixel_format () const;
70         int time_base_numerator () const;
71         int time_base_denominator () const;
72         int sample_aspect_ratio_numerator () const;
73         int sample_aspect_ratio_denominator () const;
74
75         void setup_general ();
76         void setup_video ();
77         void setup_audio ();
78
79         AVFormatContext* _format_context;
80         int _video_stream;
81         int _audio_stream;
82         AVFrame* _frame;
83         
84         AVCodecContext* _video_codec_context;
85         AVCodec* _video_codec;
86         AVCodecContext* _audio_codec_context;
87         AVCodec* _audio_codec;
88
89         AVPacket _packet;
90 };