X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Faudio_decoder.cc;h=32453cc13c974d58218cf5dae9eb4eb6da5047d2;hb=a4c19a34244aeaf183c25878933b570fc5c0ee34;hp=8d3b0e1288ea5b53627a9cfb82619b0ccc125c7e;hpb=cc3900735839ff4b0da0c046b5c606c440ba917a;p=dcpomatic.git diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 8d3b0e128..32453cc13 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -23,7 +23,6 @@ #include "log.h" #include "resampler.h" #include "util.h" -#include "film.h" #include "i18n.h" @@ -34,9 +33,8 @@ using std::cout; using boost::optional; using boost::shared_ptr; -AudioDecoder::AudioDecoder (shared_ptr film, shared_ptr content) - : Decoder (film) - , _audio_content (content) +AudioDecoder::AudioDecoder (shared_ptr content) + : _audio_content (content) { if (content->output_audio_frame_rate() != content->content_audio_frame_rate() && content->audio_channels ()) { _resampler.reset (new Resampler (content->content_audio_frame_rate(), content->output_audio_frame_rate(), content->audio_channels ())); @@ -58,14 +56,11 @@ AudioDecoder::audio (shared_ptr data, ContentTime time) } if (!_audio_position) { - shared_ptr film = _film.lock (); - assert (film); - FrameRateChange frc = film->active_frame_rate_change (_audio_content->position ()); - _audio_position = (double (time) / frc.speed_up) * film->audio_frame_rate() / TIME_HZ; + _audio_position = time; } - _pending.push_back (shared_ptr (new DecodedAudio (data, _audio_position.get ()))); - _audio_position = _audio_position.get() + data->frames (); + _pending.push_back (shared_ptr (new DecodedAudio (_audio_position.get (), data))); + _audio_position = _audio_position.get() + ContentTime (data->frames (), _audio_content->output_audio_frame_rate ()); } void @@ -77,8 +72,8 @@ AudioDecoder::flush () shared_ptr b = _resampler->flush (); if (b) { - _pending.push_back (shared_ptr (new DecodedAudio (b, _audio_position.get ()))); - _audio_position = _audio_position.get() + b->frames (); + _pending.push_back (shared_ptr (new DecodedAudio (_audio_position.get (), b))); + _audio_position = _audio_position.get() + ContentTime (b->frames (), _audio_content->output_audio_frame_rate ()); } }