Revert "Split timed from untimed sinks / sources. Should produce same output, in...
authorCarl Hetherington <cth@carlh.net>
Wed, 6 Mar 2013 00:51:44 +0000 (00:51 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 6 Mar 2013 00:51:44 +0000 (00:51 +0000)
This reverts commit 18614dda0d53b713ace5ad1df57298d049dba87f.

24 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/external_audio_decoder.cc
src/lib/ffmpeg_decoder.cc
src/lib/gain.cc
src/lib/gain.h
src/lib/imagemagick_decoder.cc
src/lib/matcher.cc
src/lib/matcher.h
src/lib/processor.h
src/lib/transcoder.cc
src/lib/video_decoder.cc
src/lib/video_decoder.h
src/lib/video_sink.h
src/lib/video_source.cc
src/lib/video_source.h
test/test.cc

index 373549b574f29dd83426cb2d391db5c02457d070..4ed5d02ca7018e3f90048448c49114dd2106253c 100644 (file)
@@ -70,15 +70,14 @@ 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, _4));
-       _db.video->Video.connect (bind (&Combiner::process_video_b, _combiner, _1, _2, _3, _4));
+       _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));
 
        if (_matcher) {
                _combiner->connect_video (_matcher);
                _matcher->connect_video (_encoder);
        } else {
-               /* Remove timestamp from the output of the combiner */
-               _combiner->Video.connect (bind (&Encoder::process_video, _encoder, _1, _2, _3));
+               _combiner->connect_video (_encoder);
        }
        
        if (_matcher && _delay_line) {
index cfe94b5283dc48c06a83e516b526c789dae46861..9bef8e0e7cf579f9903a3abed1dd7b684d739860 100644 (file)
@@ -31,7 +31,7 @@
 /** @class AudioDecoder.
  *  @brief Parent class for audio decoders.
  */
-class AudioDecoder : public TimedAudioSource, public virtual Decoder
+class AudioDecoder : public AudioSource, public virtual Decoder
 {
 public:
        AudioDecoder (boost::shared_ptr<Film>, DecodeOptions);
index a222bd6a0403523449f9077ffe910cd343dc2dd7..11d578a6035b449c55c95c8301dda82418dee226 100644 (file)
@@ -27,11 +27,4 @@ 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 bca3562cf974f36ea45077b1a08ed01142ea79a2..53b0dda1500a705ac314d9a5c5bd314c896140ba 100644 (file)
@@ -28,9 +28,3 @@ 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 3dc998ccacd7156cf2f766b7f40dff009791fcb2..5a1510d3ce5fd242980d88ead686d249a5efed42 100644 (file)
@@ -28,7 +28,6 @@
 
 class AudioBuffers;
 class AudioSink;
-class TimedAudioSink;
 
 /** A class that emits audio data */
 class AudioSource
@@ -40,15 +39,4 @@ 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 e628f3a8425a8eeb3754106e06f1dd4211d6b958..68aafd2a24d97d65b183dfcf97f0edd97a5fb48c 100644 (file)
@@ -23,7 +23,7 @@
 using boost::shared_ptr;
 
 Combiner::Combiner (Log* log)
-       : Processor (log)
+       : VideoProcessor (log)
 {
 
 }
@@ -33,7 +33,7 @@ Combiner::Combiner (Log* log)
  *  @param image Frame image.
  */
 void
-Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>, double)
+Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>)
 {
        _image = image;
 }
@@ -43,7 +43,7 @@ Combiner::process_video (shared_ptr<Image> image, bool, shared_ptr<Subtitle>, do
  *  @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, double t)
+Combiner::process_video_b (shared_ptr<Image> image, bool, shared_ptr<Subtitle> sub)
 {
        /* 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, t);
+       Video (_image, false, sub);
        _image.reset ();
 }
index c52c53ed95b2d37a1450915118144677694fc26d..7fad1aeae84d44a486bb1d2b09b680274669e5c0 100644 (file)
  *  one image used for the left half of the screen and the other for
  *  the right.
  */
-class Combiner : public Processor, public TimedVideoSink, public TimedVideoSource
+class Combiner : public VideoProcessor
 {
 public:
        Combiner (Log* log);
 
-       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double t);
-       void process_video_b (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double t);
+       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);
 
 private:
        /** The image that we are currently working on */
index 84785cfc69780f33e13bad00992f61cf563f891b..4ad17278169574f6a9af75bd233d7509a80473f3 100644 (file)
@@ -31,7 +31,7 @@ using boost::shared_ptr;
  *  @param frames Delay in frames, +ve to move audio later.
  */
 DelayLine::DelayLine (Log* log, int channels, int frames)
-       : Processor (log)
+       : AudioProcessor (log)
        , _negative_delay_remaining (0)
        , _frames (frames)
 {
@@ -47,9 +47,8 @@ DelayLine::DelayLine (Log* log, int channels, int frames)
        }
 }
 
-/* XXX: can we just get rid of all this and fiddle with the timestamp? */
 void
-DelayLine::process_audio (shared_ptr<AudioBuffers> data, double t)
+DelayLine::process_audio (shared_ptr<AudioBuffers> data)
 {
        if (_buffers) {
                /* We have some buffers, so we are moving the audio later */
@@ -90,5 +89,5 @@ DelayLine::process_audio (shared_ptr<AudioBuffers> data, double t)
                }
        }
 
-       Audio (data, t);
+       Audio (data);
 }
index 8c4a3953c7fcf78ae7a15d15d4cfdac956e49aeb..4d6f1313bd1e5af24fbaf3ed8b61a13312e754cd 100644 (file)
 class AudioBuffers;
 
 /** A delay line for audio */
-class DelayLine : public Processor, public TimedAudioSink, public TimedAudioSource
+class DelayLine : public AudioProcessor
 {
 public:
        DelayLine (Log* log, int channels, int frames);
        
-       void process_audio (boost::shared_ptr<AudioBuffers>, double);
+       void process_audio (boost::shared_ptr<AudioBuffers>);
 
 private:
        boost::shared_ptr<AudioBuffers> _buffers;
index 50e5852c5fb86bee5c6729133503ed568cde66bb..1248b5a3b1a5a0b18b7ff076f9ae14cfd5acb5d0 100644 (file)
@@ -115,7 +115,6 @@ ExternalAudioDecoder::pass ()
        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) {
@@ -127,8 +126,7 @@ ExternalAudioDecoder::pass ()
                }
 
                audio->set_frames (this_time);
-               Audio (audio, double(done) / _audio_stream->sample_rate());
-               done += this_time;
+               Audio (audio);
                frames -= this_time;
        }
 
index 32c8e224ade1b11ca65561ece3bc4ab2e3f2b9c3..ac25844e34687032ea6c47c1808a0672704b9f44 100644 (file)
@@ -640,8 +640,7 @@ FFmpegDecoder::out_with_sync ()
        if (delta > one_frame) {
                int const extra = rint (delta / one_frame);
                for (int i = 0; i < extra; ++i) {
-                       /* XXX: timestamp is wrong */
-                       repeat_last_video (source_pts_seconds);
+                       repeat_last_video ();
                        _film->log()->log (
                                String::compose (
                                        N_("Extra video frame inserted at %1s; source frame %2, source PTS %3 (at %4 fps)"),
@@ -740,8 +739,7 @@ FFmpegDecoder::decode_audio_packet ()
                                        if (s) {
                                                shared_ptr<AudioBuffers> audio (new AudioBuffers (ffa->channels(), s));
                                                audio->make_silent ();
-                                               /* XXX: this time stamp is wrong */
-                                               Audio (audio, source_pts_seconds);
+                                               Audio (audio);
                                        }
                                }
                                
@@ -750,7 +748,7 @@ FFmpegDecoder::decode_audio_packet ()
                                        );
                                
                                assert (_audio_codec_context->channels == _film->audio_channels());
-                               Audio (deinterleave_audio (_frame->data, data_size), source_pts_seconds );
+                               Audio (deinterleave_audio (_frame->data, data_size));
                        }
                }
 
index 35ce27cea623fd9c969ae8dfbc614213315a90e0..cec3b3c62c4d3acf64238600c3f62d19119c3c26 100644 (file)
@@ -23,7 +23,7 @@ using boost::shared_ptr;
 
 /** @param gain gain in dB */
 Gain::Gain (Log* log, float gain)
-       : Processor (log)
+       : AudioProcessor (log)
        , _gain (gain)
 {
 
index 44947358228801306a397f38766b50e69765a0d6..716ee9b51abd38b4e578ec86726ae6d601ce0884 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "processor.h"
 
-class Gain : public Processor, public AudioSink, public AudioSource
+class Gain : public AudioProcessor
 {
 public:
        Gain (Log* log, float gain);
index 38dace6deb54b5669986a04868daa611b917c134..5dc0b7b06d6ff9cfad6116ff12c7f7b6c1a4c7e0 100644 (file)
@@ -77,8 +77,7 @@ ImageMagickDecoder::pass ()
                        return true;
                }
 
-               /* XXX: timestamp is wrong */
-               repeat_last_video (0);
+               repeat_last_video ();
                return false;
        }
        
index 3a513b24ea7c8224e6fe04ae51dd6d7f5019069b..4cd2643381ab8138ebf6862b931cf3eff3f0f0ac 100644 (file)
@@ -27,7 +27,7 @@ using std::min;
 using boost::shared_ptr;
 
 Matcher::Matcher (Log* log, int sample_rate, float frames_per_second)
-       : Processor (log)
+       : AudioVideoProcessor (log)
        , _sample_rate (sample_rate)
        , _frames_per_second (frames_per_second)
        , _video_frames (0)
@@ -37,7 +37,7 @@ Matcher::Matcher (Log* log, int sample_rate, float frames_per_second)
 }
 
 void
-Matcher::process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s, double)
+Matcher::process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr<Subtitle> s)
 {
        Video (i, same, s);
        _video_frames++;
@@ -47,7 +47,7 @@ Matcher::process_video (boost::shared_ptr<Image> i, bool same, boost::shared_ptr
 }
 
 void
-Matcher::process_audio (boost::shared_ptr<AudioBuffers> b, double)
+Matcher::process_audio (boost::shared_ptr<AudioBuffers> b)
 {
        Audio (b);
        _audio_frames += b->frames ();
index 4a66f4e703ad4ad3473bb6fab310fc6998892ed0..60bb8743226078628adfb7246fe2a3922c83a7b3 100644 (file)
 #include "processor.h"
 #include "ffmpeg_compatibility.h"
 
-class Matcher : public Processor, public TimedVideoSink, public TimedAudioSink, public VideoSource, public AudioSource
+class Matcher : public AudioVideoProcessor
 {
 public:
        Matcher (Log* log, int sample_rate, float frames_per_second);
-       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s, double t);
-       void process_audio (boost::shared_ptr<AudioBuffers>, double t);
+       void process_video (boost::shared_ptr<Image> i, bool, boost::shared_ptr<Subtitle> s);
+       void process_audio (boost::shared_ptr<AudioBuffers>);
        void process_end ();
 
 private:
index 863bfdbb539e5b17095c9f190227988c4ef2337e..19d7c4b0c82e80e0ec22ee6a259a3f7d69efb0f0 100644 (file)
@@ -53,4 +53,46 @@ protected:
        Log* _log; ///< log to write to
 };
 
+/** @class AudioVideoProcessor
+ *  @brief A processor which handles both video and audio data.
+ */
+class AudioVideoProcessor : public Processor, public VideoSource, public VideoSink, public AudioSource, public AudioSink
+{
+public:
+       /** Construct an AudioVideoProcessor.
+        *  @param log Log to write to.
+        */
+       AudioVideoProcessor (Log* log)
+               : Processor (log)
+       {}
+};
+
+/** @class AudioProcessor
+ *  @brief A processor which handles just audio data.
+ */
+class AudioProcessor : public Processor, public AudioSource, public AudioSink
+{
+public:
+       /** Construct an AudioProcessor.
+        *  @param log Log to write to.
+        */
+       AudioProcessor (Log* log)
+               : Processor (log)
+       {}
+};
+
+/** @class VideoProcessor
+ *  @brief A processor which handles just video data.
+ */
+class VideoProcessor : public Processor, public VideoSource, public VideoSink
+{
+public:
+       /** Construct an VideoProcessor.
+        *  @param log Log to write to.
+        */
+       VideoProcessor (Log* log)
+               : Processor (log)
+       {}
+};
+
 #endif
index 3beda2b8b31a7625d6e45efdf614c789bb0ff250..9720ca56ad3654849a31fa258292a60d75f139b3 100644 (file)
@@ -72,8 +72,7 @@ Transcoder::Transcoder (shared_ptr<Film> f, DecodeOptions o, Job* j, shared_ptr<
                _decoders.video->connect_video (_matcher);
                _matcher->connect_video (_encoder);
        } else {
-               /* Discard timestamps here */
-               _decoders.video->Video.connect (boost::bind (&Encoder::process_video, _encoder, _1, _2, _3));
+               _decoders.video->connect_video (_encoder);
        }
        
        if (_matcher && _delay_line && _decoders.audio) {
index 773688b34e668571bb5891e3f198e0b47eab478d..891720f6b85ecb04a4185e92ac49821fd228bf12 100644 (file)
@@ -51,7 +51,7 @@ VideoDecoder::emit_video (shared_ptr<Image> image, double t)
                sub = _timed_subtitle->subtitle ();
        }
 
-       signal_video (image, false, sub, t);
+       signal_video (image, false, sub);
        _last_source_time = t;
 }
 
@@ -60,14 +60,14 @@ VideoDecoder::emit_video (shared_ptr<Image> image, double t)
  *  we will generate a black frame.
  */
 void
-VideoDecoder::repeat_last_video (double t)
+VideoDecoder::repeat_last_video ()
 {
        if (!_last_image) {
                _last_image.reset (new SimpleImage (pixel_format(), native_size(), true));
                _last_image->make_black ();
        }
 
-       signal_video (_last_image, true, _last_subtitle, t);
+       signal_video (_last_image, true, _last_subtitle);
 }
 
 /** Emit our signal to say that some video data is ready.
@@ -76,10 +76,10 @@ VideoDecoder::repeat_last_video (double t)
  *  @param sub Subtitle for this frame, or 0.
  */
 void
-VideoDecoder::signal_video (shared_ptr<Image> image, bool same, shared_ptr<Subtitle> sub, double t)
+VideoDecoder::signal_video (shared_ptr<Image> image, bool same, shared_ptr<Subtitle> sub)
 {
        TIMING (N_("Decoder emits %1"), _video_frame);
-       Video (image, same, sub, t);
+       Video (image, same, sub);
        ++_video_frame;
 
        _last_image = image;
index 5e9c60d08ca16f9ee7ce7e83c7ea57470f348b65..283ab5d884c0f3d4d379e15033dd549032ec29b2 100644 (file)
@@ -24,7 +24,7 @@
 #include "stream.h"
 #include "decoder.h"
 
-class VideoDecoder : public TimedVideoSource, public virtual Decoder
+class VideoDecoder : public VideoSource, public virtual Decoder
 {
 public:
        VideoDecoder (boost::shared_ptr<Film>, DecodeOptions);
@@ -67,7 +67,7 @@ protected:
 
        void emit_video (boost::shared_ptr<Image>, double);
        void emit_subtitle (boost::shared_ptr<TimedSubtitle>);
-       void repeat_last_video (double t);
+       void repeat_last_video ();
 
        /** Subtitle stream to use when decoding */
        boost::shared_ptr<SubtitleStream> _subtitle_stream;
@@ -75,7 +75,7 @@ protected:
        std::vector<boost::shared_ptr<SubtitleStream> > _subtitle_streams;
 
 private:
-       void signal_video (boost::shared_ptr<Image>, bool, boost::shared_ptr<Subtitle>, double);
+       void signal_video (boost::shared_ptr<Image>, bool, boost::shared_ptr<Subtitle>);
 
        int _video_frame;
        double _last_source_time;
index 32c7f3b384f145cbb1bf83ba6de63294675fa253..7c128cf73008d7ca8e71a5f4aa5c3aa52b3b4f8a 100644 (file)
@@ -37,16 +37,4 @@ 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 af6f941fd1f3f00a2b6ea2055e879bd75ddbf337..56742e2b4729a988680ee50bf5536e8682fbba16 100644 (file)
@@ -28,9 +28,3 @@ 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 705b0023aec3037877a60e5e7af16db1a854d97e..893629160eb4bc61a7327302e07923671bfd0b3e 100644 (file)
 #include "util.h"
 
 class VideoSink;
-class TimedVideoSink;
 class Subtitle;
 class Image;
 
-/** @class VideoSource
- *  @param A class that emits video data without timestamps.
+/** @class VideoSink
+ *  @param A class that emits video data.
  */
 class VideoSource
 {
@@ -50,22 +49,4 @@ 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
index b2af8ab22d25b6e4004bbc9abbb0f8a93af0d965..15c34ca78dc23206f0efaa9f83e512701db202de 100644 (file)
@@ -273,8 +273,7 @@ do_positive_delay_line_test (int delay_length, int data_length)
                }
 
                /* This only works because the delay line modifies the parameter */
-               /* XXX: timestamp is wrong */
-               d.process_audio (data, 0);
+               d.process_audio (data);
                returned += data->frames ();
 
                for (int j = 0; j < data->frames(); ++j) {
@@ -317,8 +316,7 @@ do_negative_delay_line_test (int delay_length, int data_length)
                }
 
                /* This only works because the delay line modifies the parameter */
-               /* XXX: timestamp is wrong */
-               d.process_audio (data, 0);
+               d.process_audio (data);
                returned += data->frames ();
 
                for (int j = 0; j < data->frames(); ++j) {