Repair very bad merge. Mysterious.
authorCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2013 15:24:03 +0000 (16:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 15 Apr 2013 15:24:03 +0000 (16:24 +0100)
18 files changed:
src/lib/ab_transcoder.cc
src/lib/audio_decoder.h
src/lib/audio_sink.h
src/lib/audio_source.cc
src/lib/audio_source.h
src/lib/combiner.cc
src/lib/combiner.h
src/lib/delay_line.cc
src/lib/delay_line.h
src/lib/matcher.cc
src/lib/matcher.h
src/lib/processor.h
src/lib/sndfile_decoder.cc
src/lib/transcoder.cc
src/lib/video_decoder.h
src/lib/video_sink.h
src/lib/video_source.cc
src/lib/video_source.h

index 7db13afcc0c0ae491b5abf54b91890140d2f587b..6eef397c245e69db4700ccc4454964b49ffabc33 100644 (file)
@@ -70,8 +70,8 @@ ABTranscoder::ABTranscoder (
        _db.video->set_subtitle_stream (_film_a->subtitle_stream ());
        _da.audio->set_audio_stream (_film_a->audio_stream ());
 
-       _da.video->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3));
-       _db.video->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3));
+       _da.video->Video.connect (bind (&Combiner::process_video, _combiner, _1, _2, _3, _4));
+       _db.video->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3, _4));
 
        _combiner->connect_video (_delay_line);
        _delay_line->connect_video (_matcher);
index 9bef8e0e7cf579f9903a3abed1dd7b684d739860..cfe94b5283dc48c06a83e516b526c789dae46861 100644 (file)
@@ -31,7 +31,7 @@
 /** @class AudioDecoder.
  *  @brief Parent class for audio decoders.
  */
-class AudioDecoder : public AudioSource, public virtual Decoder
+class AudioDecoder : public TimedAudioSource, public virtual Decoder
 {
 public:
        AudioDecoder (boost::shared_ptr<Film>, DecodeOptions);
index 11d578a6035b449c55c95c8301dda82418dee226..f34b24f88369feef2b23729390c9ec13b7818e9a 100644 (file)
@@ -27,4 +27,11 @@ public:
        virtual void process_audio (boost::shared_ptr<AudioBuffers>) = 0;
 };
 
+class TimedAudioSink
+{
+public:
+        /** Call with some audio data */
+        virtual void process_audio (boost::shared_ptr<AudioBuffers>, double t) = 0;
+};
+
 #endif
index 53b0dda1500a705ac314d9a5c5bd314c896140ba..bca3562cf974f36ea45077b1a08ed01142ea79a2 100644 (file)
@@ -28,3 +28,9 @@ AudioSource::connect_audio (shared_ptr<AudioSink> s)
 {
        Audio.connect (bind (&AudioSink::process_audio, s, _1));
 }
+
+void
+TimedAudioSource::connect_audio (shared_ptr<TimedAudioSink> s)
+{
+       Audio.connect (bind (&TimedAudioSink::process_audio, s, _1, _2));
+}
index 5a1510d3ce5fd242980d88ead686d249a5efed42..3dc998ccacd7156cf2f766b7f40dff009791fcb2 100644 (file)
@@ -28,6 +28,7 @@
 
 class AudioBuffers;
 class AudioSink;
+class TimedAudioSink;
 
 /** A class that emits audio data */
 class AudioSource
@@ -39,4 +40,15 @@ public:
        void connect_audio (boost::shared_ptr<AudioSink>);
 };
 
+
+/** A class that emits audio data with timestamps */
+class TimedAudioSource
+{
+public:
+       /** Emitted when some audio data is ready */
+       boost::signals2::signal<void (boost::shared_ptr<AudioBuffers>, double)> Audio;
+
+       void connect_audio (boost::shared_ptr<TimedAudioSink>);
+};
+
 #endif
index 12ce4a96e289b6c09da748808f28dac6ed629526..006dd2697e7946d34746db2097c0bed8772277ff 100644 (file)
@@ -23,7 +23,7 @@
 using boost::shared_ptr;
 
 Combiner::Combiner (shared_ptr<Log> log)
-       : VideoProcessor (log)
+       : TimedVideoProcessor (log)
 {
 
 }
@@ -33,7 +33,7 @@ Combiner::Combiner (shared_ptr<Log> log)
  *  @param image Frame image.
  */
 void
-Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>)
+Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>, double t)
 {
        _image = image;
 }
@@ -43,7 +43,7 @@ Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>)
  *  @param sub Subtitle (which will be put onto the whole frame)
  */
 void
-Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub)
+Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub, double t)
 {
        /* Copy the right half of this image into our _image */
        /* XXX: this should probably be in the Image class */
@@ -62,6 +62,6 @@ Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> s
                }
        }
 
-       Video (_image, false, sub);
+       Video (_image, false, sub, t);
        _image.reset ();
 }
index 68026eaff7eec0814f7017f140ac1c8b8ed12095..a8f1fa804e9bd1549e4dbb727875b71e3c353bcc 100644 (file)
  *  one image used for the left half of the screen and the other for
  *  the right.
  */
-class Combiner : public VideoProcessor
+class Combiner : public TimedVideoProcessor
 {
 public:
        Combiner (boost::shared_ptr<Log> log);
 
-       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
-       void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
+       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double);
+       void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double);
 
 private:
        /** The image that we are currently working on */
index c8e593a185c905bce974a9196b581beb0c5d6ea2..9e6baeba8131f0ebe671f0b9d3112466bfe1e5f8 100644 (file)
@@ -30,14 +30,14 @@ using boost::shared_ptr;
 /*  @param seconds Delay in seconds, +ve to move audio later.
  */
 DelayLine::DelayLine (shared_ptr<Log> log, double seconds)
-       : Processor (log)
+       : TimedAudioVideoProcessor (log)
        , _seconds (seconds)
 {
        
 }
 
 void
-DelayLine::process_audio (shared_ptr<AudioBuffers> data)
+DelayLine::process_audio (shared_ptr<AudioBuffers> data, double t)
 {
        if (_seconds > 0) {
                t += _seconds;
index 7a8b11c690bf92cabf0d046594066dc0d809cfe1..90f1dcfa7b55b56fd1c42442d3b7fa0311a2fa56 100644 (file)
@@ -20,8 +20,8 @@
 #include <boost/shared_ptr.hpp>
 #include "processor.h"
 
-/** A delay line for audio */
-class DelayLine : public Processor, public TimedAudioSink, public TimedAudioSource, public TimedVideoSink, public TimedVideoSource
+/** A delay line */
+class DelayLine : public TimedAudioVideoProcessor
 {
 public:
        DelayLine (boost::shared_ptr<Log> log, double);
index 69d12e2c4ebebf7d0c2d27b767e199bb8c615f5e..34ddc86d6d931eb0b6f61e8eba4c7abd0d68f651 100644 (file)
@@ -29,7 +29,7 @@ using std::list;
 using boost::shared_ptr;
 
 Matcher::Matcher (shared_ptr<Log> log, int sample_rate, float frames_per_second)
-       : AudioVideoProcessor (log)
+       : Processor (log)
        , _sample_rate (sample_rate)
        , _frames_per_second (frames_per_second)
        , _video_frames (0)
index 4ec0a3e96710bbc99ddda2330081ee23f3c5558a..f54aa4b6a7c9c37815697fcd03c55b9936936353 100644 (file)
 #include "processor.h"
 #include "ffmpeg_compatibility.h"
 
-class Matcher : public AudioVideoProcessor
+class Matcher : public Processor, public TimedAudioSink, public TimedVideoSink, public AudioSource, public VideoSource 
 {
 public:
        Matcher (boost::shared_ptr<Log> log, int sample_rate, float frames_per_second);
-       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
-       void process_audio (boost::shared_ptr<AudioBuffers>);
+       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double);
+       void process_audio (boost::shared_ptr<AudioBuffers>, double);
        void process_end ();
 
 private:
index 1ba396f2f5decc945e339ba0a633ff4751bf3ef9..603239f8ff7094ebadb0a09d22304654d88cb427 100644 (file)
@@ -67,6 +67,15 @@ public:
        {}
 };
 
+class TimedAudioVideoProcessor : public Processor, public TimedVideoSource, public TimedVideoSink, public TimedAudioSource, public TimedAudioSink
+{
+public:
+       TimedAudioVideoProcessor (boost::shared_ptr<Log> log)
+               : Processor (log)
+       {}
+};
+                               
+
 /** @class AudioProcessor
  *  @brief A processor which handles just audio data.
  */
@@ -95,4 +104,12 @@ public:
        {}
 };
 
+class TimedVideoProcessor : public Processor, public TimedVideoSource, public TimedVideoSink
+{
+public:
+       TimedVideoProcessor (boost::shared_ptr<Log> log)
+               : Processor (log)
+       {}
+};     
+
 #endif
index 0e3e5e2345a9538b2267493762a88d1485ff15da..af59c049c31dba1acc59d9dad4132a2de5b8dcaa 100644 (file)
@@ -113,8 +113,8 @@ SndfileDecoder::pass ()
           to what FFmpeg (and in particular the resampler) can cope with.
        */
        sf_count_t const block = _audio_stream->sample_rate() / 2;
-
        shared_ptr<AudioBuffers> audio (new AudioBuffers (_audio_stream->channels(), block));
+       sf_count_t done = 0;
        while (frames > 0) {
                sf_count_t const this_time = min (block, frames);
                for (size_t i = 0; i < sndfiles.size(); ++i) {
@@ -126,7 +126,8 @@ SndfileDecoder::pass ()
                }
 
                audio->set_frames (this_time);
-               Audio (audio);
+               Audio (audio, double(done) / _audio_stream->sample_rate());
+               done += this_time;
                frames -= this_time;
        }
 
index 8046080dee7b984fb9b135e348f3d73478bea363..23fb5b7880731789fdb82976fa7cc35c40e0f3bb 100644 (file)
@@ -63,18 +63,9 @@ Transcoder::Transcoder (shared_ptr<Film> f, DecodeOptions o, Job* j, shared_ptr<
        _decoders.video->set_subtitle_stream (f->subtitle_stream ());
        _decoders.audio->set_audio_stream (f->audio_stream ());
 
-<<<<<<< HEAD
        _decoders.video->connect_video (_delay_line);
        _delay_line->connect_video (_matcher);
        _matcher->connect_video (_encoder);
-=======
-       if (_matcher) {
-               _decoders.video->connect_video (_matcher);
-               _matcher->connect_video (_encoder);
-       } else {
-               _decoders.video->connect_video (_encoder);
-       }
->>>>>>> master
        
        _decoders.audio->connect_audio (_delay_line);
        _delay_line->connect_audio (_matcher);
index f8612dff2b5140206fcef62c894768ca50b53bec..6e4fd48c0019710a2632e921d35645efa119c239 100644 (file)
@@ -24,7 +24,7 @@
 #include "stream.h"
 #include "decoder.h"
 
-class VideoDecoder : public VideoSource, public virtual Decoder
+class VideoDecoder : public TimedVideoSource, public virtual Decoder
 {
 public:
        VideoDecoder (boost::shared_ptr<Film>, DecodeOptions);
index 7c128cf73008d7ca8e71a5f4aa5c3aa52b3b4f8a..32c7f3b384f145cbb1bf83ba6de63294675fa253 100644 (file)
@@ -37,4 +37,16 @@ public:
        virtual void process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s) = 0;
 };
 
+class TimedVideoSink
+{
+public:
+       /** Call with a frame of video.
+        *  @param i Video frame image.
+        *  @param same true if i is the same as last time we were called.
+        *  @param s A subtitle that should be on this frame, or 0.
+        *  @param t Source timestamp.
+        */
+       virtual void process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s, double t) = 0;
+};
+
 #endif
index 56742e2b4729a988680ee50bf5536e8682fbba16..af6f941fd1f3f00a2b6ea2055e879bd75ddbf337 100644 (file)
@@ -28,3 +28,9 @@ VideoSource::connect_video (shared_ptr<VideoSink> s)
 {
        Video.connect (bind (&VideoSink::process_video, s, _1, _2, _3));
 }
+
+void
+TimedVideoSource::connect_video (shared_ptr<TimedVideoSink> s)
+{
+       Video.connect (bind (&TimedVideoSink::process_video, s, _1, _2, _3, _4));
+}
index 893629160eb4bc61a7327302e07923671bfd0b3e..705b0023aec3037877a60e5e7af16db1a854d97e 100644 (file)
 #include "util.h"
 
 class VideoSink;
+class TimedVideoSink;
 class Subtitle;
 class Image;
 
-/** @class VideoSink
- *  @param A class that emits video data.
+/** @class VideoSource
+ *  @param A class that emits video data without timestamps.
  */
 class VideoSource
 {
@@ -49,4 +50,22 @@ public:
        void connect_video (boost::shared_ptr<VideoSink>);
 };
 
+/** @class TimedVideoSource
+ *  @param A class that emits video data with timestamps.
+ */
+class TimedVideoSource
+{
+public:
+
+       /** Emitted when a video frame is ready.
+        *  First parameter is the video image.
+        *  Second parameter is true if the image is the same as the last one that was emitted.
+        *  Third parameter is either 0 or a subtitle that should be on this frame.
+        *  Fourth parameter is the source timestamp of this frame.
+        */
+       boost::signals2::signal<void (boost::shared_ptr<Image>, bool, boost::shared_ptr<Subtitle>, double)> Video;
+
+       void connect_video (boost::shared_ptr<TimedVideoSink>);
+};
+
 #endif