From: Carl Hetherington Date: Wed, 6 Mar 2013 00:51:44 +0000 (+0000) Subject: Revert "Split timed from untimed sinks / sources. Should produce same output, in... X-Git-Tag: v2.0.48~1337^2~582 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=422341d1cb6bc8cbb6be76eac239c40cb4061c79;p=dcpomatic.git Revert "Split timed from untimed sinks / sources. Should produce same output, in theory." This reverts commit 18614dda0d53b713ace5ad1df57298d049dba87f. --- diff --git a/src/lib/ab_transcoder.cc b/src/lib/ab_transcoder.cc index 373549b57..4ed5d02ca 100644 --- a/src/lib/ab_transcoder.cc +++ b/src/lib/ab_transcoder.cc @@ -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) { diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index cfe94b528..9bef8e0e7 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -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, DecodeOptions); diff --git a/src/lib/audio_sink.h b/src/lib/audio_sink.h index a222bd6a0..11d578a60 100644 --- a/src/lib/audio_sink.h +++ b/src/lib/audio_sink.h @@ -27,11 +27,4 @@ public: virtual void process_audio (boost::shared_ptr) = 0; }; -class TimedAudioSink -{ -public: - /** Call with some audio data */ - virtual void process_audio (boost::shared_ptr, double t) = 0; -}; - #endif diff --git a/src/lib/audio_source.cc b/src/lib/audio_source.cc index bca3562cf..53b0dda15 100644 --- a/src/lib/audio_source.cc +++ b/src/lib/audio_source.cc @@ -28,9 +28,3 @@ AudioSource::connect_audio (shared_ptr s) { Audio.connect (bind (&AudioSink::process_audio, s, _1)); } - -void -TimedAudioSource::connect_audio (shared_ptr s) -{ - Audio.connect (bind (&TimedAudioSink::process_audio, s, _1, _2)); -} diff --git a/src/lib/audio_source.h b/src/lib/audio_source.h index 3dc998cca..5a1510d3c 100644 --- a/src/lib/audio_source.h +++ b/src/lib/audio_source.h @@ -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); }; - -/** A class that emits audio data with timestamps */ -class TimedAudioSource -{ -public: - /** Emitted when some audio data is ready */ - boost::signals2::signal, double)> Audio; - - void connect_audio (boost::shared_ptr); -}; - #endif diff --git a/src/lib/combiner.cc b/src/lib/combiner.cc index e628f3a84..68aafd2a2 100644 --- a/src/lib/combiner.cc +++ b/src/lib/combiner.cc @@ -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, bool, shared_ptr, double) +Combiner::process_video (shared_ptr image, bool, shared_ptr) { _image = image; } @@ -43,7 +43,7 @@ Combiner::process_video (shared_ptr image, bool, shared_ptr, do * @param sub Subtitle (which will be put onto the whole frame) */ void -Combiner::process_video_b (shared_ptr image, bool, shared_ptr sub, double t) +Combiner::process_video_b (shared_ptr image, bool, shared_ptr 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, bool, shared_ptr s } } - Video (_image, false, sub, t); + Video (_image, false, sub); _image.reset (); } diff --git a/src/lib/combiner.h b/src/lib/combiner.h index c52c53ed9..7fad1aeae 100644 --- a/src/lib/combiner.h +++ b/src/lib/combiner.h @@ -28,13 +28,13 @@ * 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 i, bool, boost::shared_ptr s, double t); - void process_video_b (boost::shared_ptr i, bool, boost::shared_ptr s, double t); + void process_video (boost::shared_ptr i, bool, boost::shared_ptr s); + void process_video_b (boost::shared_ptr i, bool, boost::shared_ptr s); private: /** The image that we are currently working on */ diff --git a/src/lib/delay_line.cc b/src/lib/delay_line.cc index 84785cfc6..4ad172781 100644 --- a/src/lib/delay_line.cc +++ b/src/lib/delay_line.cc @@ -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 data, double t) +DelayLine::process_audio (shared_ptr data) { if (_buffers) { /* We have some buffers, so we are moving the audio later */ @@ -90,5 +89,5 @@ DelayLine::process_audio (shared_ptr data, double t) } } - Audio (data, t); + Audio (data); } diff --git a/src/lib/delay_line.h b/src/lib/delay_line.h index 8c4a3953c..4d6f1313b 100644 --- a/src/lib/delay_line.h +++ b/src/lib/delay_line.h @@ -23,12 +23,12 @@ 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, double); + void process_audio (boost::shared_ptr); private: boost::shared_ptr _buffers; diff --git a/src/lib/external_audio_decoder.cc b/src/lib/external_audio_decoder.cc index 50e5852c5..1248b5a3b 100644 --- a/src/lib/external_audio_decoder.cc +++ b/src/lib/external_audio_decoder.cc @@ -115,7 +115,6 @@ ExternalAudioDecoder::pass () sf_count_t const block = _audio_stream->sample_rate() / 2; shared_ptr 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; } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 32c8e224a..ac25844e3 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -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 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)); } } diff --git a/src/lib/gain.cc b/src/lib/gain.cc index 35ce27cea..cec3b3c62 100644 --- a/src/lib/gain.cc +++ b/src/lib/gain.cc @@ -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) { diff --git a/src/lib/gain.h b/src/lib/gain.h index 449473582..716ee9b51 100644 --- a/src/lib/gain.h +++ b/src/lib/gain.h @@ -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); diff --git a/src/lib/imagemagick_decoder.cc b/src/lib/imagemagick_decoder.cc index 38dace6de..5dc0b7b06 100644 --- a/src/lib/imagemagick_decoder.cc +++ b/src/lib/imagemagick_decoder.cc @@ -77,8 +77,7 @@ ImageMagickDecoder::pass () return true; } - /* XXX: timestamp is wrong */ - repeat_last_video (0); + repeat_last_video (); return false; } diff --git a/src/lib/matcher.cc b/src/lib/matcher.cc index 3a513b24e..4cd264338 100644 --- a/src/lib/matcher.cc +++ b/src/lib/matcher.cc @@ -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 i, bool same, boost::shared_ptr s, double) +Matcher::process_video (boost::shared_ptr i, bool same, boost::shared_ptr s) { Video (i, same, s); _video_frames++; @@ -47,7 +47,7 @@ Matcher::process_video (boost::shared_ptr i, bool same, boost::shared_ptr } void -Matcher::process_audio (boost::shared_ptr b, double) +Matcher::process_audio (boost::shared_ptr b) { Audio (b); _audio_frames += b->frames (); diff --git a/src/lib/matcher.h b/src/lib/matcher.h index 4a66f4e70..60bb87432 100644 --- a/src/lib/matcher.h +++ b/src/lib/matcher.h @@ -21,12 +21,12 @@ #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 i, bool, boost::shared_ptr s, double t); - void process_audio (boost::shared_ptr, double t); + void process_video (boost::shared_ptr i, bool, boost::shared_ptr s); + void process_audio (boost::shared_ptr); void process_end (); private: diff --git a/src/lib/processor.h b/src/lib/processor.h index 863bfdbb5..19d7c4b0c 100644 --- a/src/lib/processor.h +++ b/src/lib/processor.h @@ -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 diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc index 3beda2b8b..9720ca56a 100644 --- a/src/lib/transcoder.cc +++ b/src/lib/transcoder.cc @@ -72,8 +72,7 @@ Transcoder::Transcoder (shared_ptr 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) { diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 773688b34..891720f6b 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -51,7 +51,7 @@ VideoDecoder::emit_video (shared_ptr 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, 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, bool same, shared_ptr sub, double t) +VideoDecoder::signal_video (shared_ptr image, bool same, shared_ptr sub) { TIMING (N_("Decoder emits %1"), _video_frame); - Video (image, same, sub, t); + Video (image, same, sub); ++_video_frame; _last_image = image; diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index 5e9c60d08..283ab5d88 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -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, DecodeOptions); @@ -67,7 +67,7 @@ protected: void emit_video (boost::shared_ptr, double); void emit_subtitle (boost::shared_ptr); - void repeat_last_video (double t); + void repeat_last_video (); /** Subtitle stream to use when decoding */ boost::shared_ptr _subtitle_stream; @@ -75,7 +75,7 @@ protected: std::vector > _subtitle_streams; private: - void signal_video (boost::shared_ptr, bool, boost::shared_ptr, double); + void signal_video (boost::shared_ptr, bool, boost::shared_ptr); int _video_frame; double _last_source_time; diff --git a/src/lib/video_sink.h b/src/lib/video_sink.h index 32c7f3b38..7c128cf73 100644 --- a/src/lib/video_sink.h +++ b/src/lib/video_sink.h @@ -37,16 +37,4 @@ public: virtual void process_video (boost::shared_ptr i, bool same, boost::shared_ptr 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 i, bool same, boost::shared_ptr s, double t) = 0; -}; - #endif diff --git a/src/lib/video_source.cc b/src/lib/video_source.cc index af6f941fd..56742e2b4 100644 --- a/src/lib/video_source.cc +++ b/src/lib/video_source.cc @@ -28,9 +28,3 @@ VideoSource::connect_video (shared_ptr s) { Video.connect (bind (&VideoSink::process_video, s, _1, _2, _3)); } - -void -TimedVideoSource::connect_video (shared_ptr s) -{ - Video.connect (bind (&TimedVideoSink::process_video, s, _1, _2, _3, _4)); -} diff --git a/src/lib/video_source.h b/src/lib/video_source.h index 705b0023a..893629160 100644 --- a/src/lib/video_source.h +++ b/src/lib/video_source.h @@ -29,12 +29,11 @@ #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); }; -/** @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, bool, boost::shared_ptr, double)> Video; - - void connect_video (boost::shared_ptr); -}; - #endif diff --git a/test/test.cc b/test/test.cc index b2af8ab22..15c34ca78 100644 --- a/test/test.cc +++ b/test/test.cc @@ -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) {