Merge branch 'master' of ssh://houllier/home/carl/git/dvdomatic
[dcpomatic.git] / src / lib / ffmpeg_decoder.h
index 89e42f9786e33e584d88417aaf4d51fabc091ae4..0c89b973dfbb9b47c237cd2e9ade391327758fd9 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdint.h>
 #include <boost/shared_ptr.hpp>
 #include <boost/optional.hpp>
+#include <boost/thread/mutex.hpp>
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libpostproc/postprocess.h>
@@ -34,6 +35,7 @@ extern "C" {
 #include "decoder.h"
 #include "video_decoder.h"
 #include "audio_decoder.h"
+#include "film.h"
 
 struct AVFilterGraph;
 struct AVCodecContext;
@@ -56,7 +58,7 @@ public:
                , _name (n)
                , _id (i)
        {}
-                 
+
        std::string to_string () const;
 
        std::string name () const {
@@ -84,11 +86,12 @@ private:
 class FFmpegDecoder : public VideoDecoder, public AudioDecoder
 {
 public:
-       FFmpegDecoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *);
+       FFmpegDecoder (boost::shared_ptr<Film>, DecodeOptions);
        ~FFmpegDecoder ();
 
        float frames_per_second () const;
-       Size native_size () const;
+       libdcp::Size native_size () const;
+       SourceFrame length () const;
        int time_base_numerator () const;
        int time_base_denominator () const;
        int sample_aspect_ratio_numerator () const;
@@ -97,25 +100,32 @@ public:
        void set_audio_stream (boost::shared_ptr<AudioStream>);
        void set_subtitle_stream (boost::shared_ptr<SubtitleStream>);
 
-       bool seek (SourceFrame);
+       bool seek (double);
+       bool seek_to_last ();
+       void seek_forward ();
+       void seek_back ();
 
 private:
 
        bool pass ();
+       bool do_seek (double p, bool, bool);
        PixelFormat pixel_format () const;
        AVSampleFormat audio_sample_format () const;
        int bytes_per_audio_sample () const;
 
-       void out_careful ();
-       void filter_and_emit_video (AVFrame *);
+       void filter_and_emit_video ();
 
        void setup_general ();
        void setup_video ();
        void setup_audio ();
        void setup_subtitle ();
 
+       void decode_audio_packet ();
+
        void maybe_add_subtitle ();
-       boost::shared_ptr<AudioBuffers> deinterleave_audio (uint8_t* data, int size);
+       boost::shared_ptr<AudioBuffers> deinterleave_audio (uint8_t** data, int size);
+
+       void film_changed (Film::Property);
 
        std::string stream_name (AVStream* s) const;
 
@@ -133,8 +143,6 @@ private:
 
        AVPacket _packet;
 
-       boost::optional<double> _first_video;
-       boost::optional<double> _first_audio;
-
        std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
+       boost::mutex _filter_graphs_mutex;
 };