Fix merge; other tweaks.
[dcpomatic.git] / src / lib / decoder.h
index 9c7b2de3896b9e21a2476789c1ec584d60730977..2154da8bf6183102c9963ead832b0a9077b1a406 100644 (file)
@@ -52,7 +52,7 @@ class FilterGraph;
 class Decoder
 {
 public:
-       Decoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool, bool);
+       Decoder (boost::shared_ptr<Film>, boost::shared_ptr<const Options>, Job *, bool);
        virtual ~Decoder ();
 
        /* Methods to query our input video */
@@ -76,13 +76,13 @@ public:
        virtual int sample_aspect_ratio_denominator () const = 0;
        
        void process_begin ();
-       bool pass ();
+       virtual bool pass () = 0;
        void process_end ();
        void go ();
 
-       /** @return the index of the last video frame to be processed */
-       int video_frame_index () const {
-               return _video_frame_index;
+       /** @return the number of video frames we got from the source in the last run */
+       SourceFrame video_frames_in () const {
+               return _video_frames_in;
        }
 
        virtual std::vector<AudioStream> audio_streams () const {
@@ -94,19 +94,17 @@ public:
        }
 
        /** Emitted when a video frame is ready.
-        *  First parameter is the frame.
+        *  First parameter is the frame within the source.
         *  Second parameter is its index within the content.
         *  Third parameter is either 0 or a subtitle that should be on this frame.
         */
-       boost::signals2::signal<void (boost::shared_ptr<Image>, int, boost::shared_ptr<Subtitle>)> Video;
+       boost::signals2::signal<void (boost::shared_ptr<Image>, SourceFrame, boost::shared_ptr<Subtitle>)> Video;
 
        /** Emitted when some audio data is ready */
        boost::signals2::signal<void (boost::shared_ptr<AudioBuffers>)> Audio;
 
 protected:
        
-       /** perform a single pass at our content */
-       virtual bool do_pass () = 0;
        virtual PixelFormat pixel_format () const = 0;
        
        void process_video (AVFrame *);
@@ -128,25 +126,22 @@ protected:
         */
        bool _minimal;
 
-       /** ignore_length Ignore the content's claimed length when computing progress */
-       bool _ignore_length;
-
 private:
+       void emit_video (boost::shared_ptr<Image>, boost::shared_ptr<Subtitle>);
        void emit_audio (boost::shared_ptr<AudioBuffers>);
-       
-       /** last video frame to be processed */
-       int _video_frame_index;
 
+       int64_t video_frames_to_audio_frames (SourceFrame v) const;
+       
+       SourceFrame _video_frames_in;
+       SourceFrame _video_frames_out;
+       int64_t _audio_frames_in;
+       int64_t _audio_frames_out;
+       
        std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
 
        DelayLine* _delay_line;
        int _delay_in_frames;
 
-       /* Number of audio frames that we have pushed to the encoder
-          (at the DCP sample rate).
-       */
-       int64_t _audio_frames_processed;
-
        boost::shared_ptr<TimedSubtitle> _timed_subtitle;
 
        boost::shared_ptr<Image> _last_image;