summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-07-25 12:29:01 +0100
committerCarl Hetherington <cth@carlh.net>2019-07-25 12:29:01 +0100
commitd481e3b4df6eeac962250b15ee0a036a07e385d9 (patch)
treeb7ace652f0cadc561f5185785cbbf8e61f7321c7 /src
parent57f112a2bd073123a686141be6c16ba997349056 (diff)
Setup fast state of decoder after creation.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_decoder.cc17
-rw-r--r--src/lib/audio_decoder.h4
-rw-r--r--src/lib/dcp_content.cc4
-rw-r--r--src/lib/dcp_decoder.cc4
-rw-r--r--src/lib/dcp_decoder.h1
-rw-r--r--src/lib/decoder.cc8
-rw-r--r--src/lib/decoder.h1
-rw-r--r--src/lib/decoder_factory.cc6
-rw-r--r--src/lib/decoder_factory.h1
-rw-r--r--src/lib/ffmpeg_decoder.cc4
-rw-r--r--src/lib/ffmpeg_decoder.h2
-rw-r--r--src/lib/player.cc6
-rw-r--r--src/lib/resampler.cc11
-rw-r--r--src/lib/resampler.h3
-rw-r--r--src/wx/text_panel.cc2
15 files changed, 50 insertions, 24 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index e0fb20b7e..d0ff5efec 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -37,10 +37,10 @@ using boost::shared_ptr;
using boost::optional;
using namespace dcpomatic;
-AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr<const AudioContent> content, bool fast)
+AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr<const AudioContent> content)
: DecoderPart (parent)
, _content (content)
- , _fast (fast)
+ , _fast (false)
{
/* Set up _positions so that we have one for each stream */
BOOST_FOREACH (AudioStreamPtr i, content->streams ()) {
@@ -83,9 +83,7 @@ AudioDecoder::emit (shared_ptr<const Film> film, AudioStreamPtr stream, shared_p
);
resampler.reset (new Resampler (stream->frame_rate(), _content->resampled_frame_rate(film), stream->channels()));
- if (_fast) {
- resampler->set_fast ();
- }
+ resampler->set_fast (_fast);
_resamplers[stream] = resampler;
}
}
@@ -165,3 +163,12 @@ AudioDecoder::silence (int milliseconds)
Data (i, ContentAudio (silence, _positions[i]));
}
}
+
+void
+AudioDecoder::set_fast (bool fast)
+{
+ _fast = fast;
+ for (ResamplerMap::iterator i = _resamplers.begin(); i != _resamplers.end(); ++i) {
+ i->second->set_fast (_fast);
+ }
+}
diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h
index 32d71c067..0c9b29217 100644
--- a/src/lib/audio_decoder.h
+++ b/src/lib/audio_decoder.h
@@ -45,13 +45,15 @@ class Resampler;
class AudioDecoder : public boost::enable_shared_from_this<AudioDecoder>, public DecoderPart
{
public:
- AudioDecoder (Decoder* parent, boost::shared_ptr<const AudioContent> content, bool fast);
+ AudioDecoder (Decoder* parent, boost::shared_ptr<const AudioContent> content);
dcpomatic::ContentTime position (boost::shared_ptr<const Film> film) const;
void emit (boost::shared_ptr<const Film> film, AudioStreamPtr stream, boost::shared_ptr<const AudioBuffers>, dcpomatic::ContentTime);
void seek ();
void flush ();
+ void set_fast (bool fast);
+
dcpomatic::ContentTime stream_position (boost::shared_ptr<const Film> film, AudioStreamPtr stream) const;
/** @return Number of frames of data that were accepted */
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index dc1a463c5..68e94df79 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -625,7 +625,7 @@ DCPContent::can_reference_audio (shared_ptr<const Film> film, string& why_not) c
{
shared_ptr<DCPDecoder> decoder;
try {
- decoder.reset (new DCPDecoder (film, shared_from_this(), false));
+ decoder.reset (new DCPDecoder (film, shared_from_this()));
} catch (dcp::DCPReadError &) {
/* We couldn't read the DCP, so it's probably missing */
return false;
@@ -660,7 +660,7 @@ DCPContent::can_reference_text (shared_ptr<const Film> film, TextType type, stri
{
shared_ptr<DCPDecoder> decoder;
try {
- decoder.reset (new DCPDecoder (film, shared_from_this(), false));
+ decoder.reset (new DCPDecoder (film, shared_from_this()));
} catch (dcp::DCPReadError &) {
/* We couldn't read the DCP, so it's probably missing */
return false;
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index b6947211c..1e5be8800 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -56,7 +56,7 @@ using boost::dynamic_pointer_cast;
using boost::optional;
using namespace dcpomatic;
-DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent> c, bool fast, shared_ptr<DCPDecoder> old)
+DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent> c, shared_ptr<DCPDecoder> old)
: DCP (c)
, Decoder (film)
, _decode_referenced (false)
@@ -66,7 +66,7 @@ DCPDecoder::DCPDecoder (shared_ptr<const Film> film, shared_ptr<const DCPContent
video.reset (new VideoDecoder (this, c));
}
if (c->audio) {
- audio.reset (new AudioDecoder (this, c->audio, fast));
+ audio.reset (new AudioDecoder (this, c->audio));
}
BOOST_FOREACH (shared_ptr<TextContent> i, c->text) {
/* XXX: this time here should be the time of the first subtitle, not 0 */
diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h
index f31d28053..37a95a314 100644
--- a/src/lib/dcp_decoder.h
+++ b/src/lib/dcp_decoder.h
@@ -43,7 +43,6 @@ public:
DCPDecoder (
boost::shared_ptr<const Film> film,
boost::shared_ptr<const DCPContent>,
- bool fast,
boost::shared_ptr<DCPDecoder> old = boost::shared_ptr<DCPDecoder>()
);
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index 3cadcca47..976f97fa9 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -101,3 +101,11 @@ Decoder::film () const
DCPOMATIC_ASSERT (f);
return f;
}
+
+void
+Decoder::set_fast (bool fast)
+{
+ if (audio) {
+ audio->set_fast (fast);
+ }
+}
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index 92082ca18..b731fe32c 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -50,6 +50,7 @@ public:
std::list<boost::shared_ptr<TextDecoder> > text;
boost::shared_ptr<TextDecoder> only_text () const;
+ void set_fast (bool fast);
/** Do some decoding and perhaps emit video, audio or subtitle data.
* @return true if this decoder will emit no more data unless a seek() happens.
diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc
index 5d758956d..917c1747b 100644
--- a/src/lib/decoder_factory.cc
+++ b/src/lib/decoder_factory.cc
@@ -49,17 +49,17 @@ maybe_cast (shared_ptr<Decoder> d)
/** @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0 */
shared_ptr<Decoder>
-decoder_factory (shared_ptr<const Film> film, shared_ptr<const Content> content, bool fast, shared_ptr<Decoder> old_decoder)
+decoder_factory (shared_ptr<const Film> film, shared_ptr<const Content> content, shared_ptr<Decoder> old_decoder)
{
shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (content);
if (fc) {
- return shared_ptr<Decoder> (new FFmpegDecoder(film, fc, fast));
+ return shared_ptr<Decoder> (new FFmpegDecoder(film, fc));
}
shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (content);
if (dc) {
try {
- return shared_ptr<Decoder> (new DCPDecoder(film, dc, fast, maybe_cast<DCPDecoder>(old_decoder)));
+ return shared_ptr<Decoder> (new DCPDecoder(film, dc, maybe_cast<DCPDecoder>(old_decoder)));
} catch (KDMError& e) {
/* This will be found and reported to the user when the content is examined */
return shared_ptr<Decoder>();
diff --git a/src/lib/decoder_factory.h b/src/lib/decoder_factory.h
index cb145c8a9..e6c8f749e 100644
--- a/src/lib/decoder_factory.h
+++ b/src/lib/decoder_factory.h
@@ -23,6 +23,5 @@ class ImageDecoder;
extern boost::shared_ptr<Decoder> decoder_factory (
boost::shared_ptr<const Film> film,
boost::shared_ptr<const Content> content,
- bool fast,
boost::shared_ptr<Decoder> old_decoder
);
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index 62d4d2655..d703f776d 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -75,7 +75,7 @@ using boost::dynamic_pointer_cast;
using dcp::Size;
using namespace dcpomatic;
-FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmpegContent> c, bool fast)
+FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmpegContent> c)
: FFmpeg (c)
, Decoder (film)
, _have_current_subtitle (false)
@@ -91,7 +91,7 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> film, shared_ptr<const FFmp
}
if (c->audio) {
- audio.reset (new AudioDecoder (this, c->audio, fast));
+ audio.reset (new AudioDecoder (this, c->audio));
}
if (c->only_text()) {
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h
index 65f36a004..e9d401953 100644
--- a/src/lib/ffmpeg_decoder.h
+++ b/src/lib/ffmpeg_decoder.h
@@ -45,7 +45,7 @@ struct ffmpeg_pts_offset_test;
class FFmpegDecoder : public FFmpeg, public Decoder
{
public:
- FFmpegDecoder (boost::shared_ptr<const Film> film, boost::shared_ptr<const FFmpegContent>, bool fast);
+ FFmpegDecoder (boost::shared_ptr<const Film> film, boost::shared_ptr<const FFmpegContent>);
bool pass ();
void seek (dcpomatic::ContentTime time, bool);
diff --git a/src/lib/player.cc b/src/lib/player.cc
index acde910be..16d17138f 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -164,7 +164,7 @@ Player::setup_pieces_unlocked ()
}
}
- shared_ptr<Decoder> decoder = decoder_factory (_film, i, _fast, old_decoder);
+ shared_ptr<Decoder> decoder = decoder_factory (_film, i, old_decoder);
FrameRateChange frc (_film, i);
if (!decoder) {
@@ -172,6 +172,8 @@ Player::setup_pieces_unlocked ()
continue;
}
+ decoder->set_fast (_fast);
+
if (decoder->video && _ignore_video) {
decoder->video->set_ignore (true);
}
@@ -503,7 +505,7 @@ Player::get_reel_assets ()
scoped_ptr<DCPDecoder> decoder;
try {
- decoder.reset (new DCPDecoder (_film, j, false));
+ decoder.reset (new DCPDecoder (_film, j));
} catch (...) {
return a;
}
diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc
index 322c00c13..b27d7c966 100644
--- a/src/lib/resampler.cc
+++ b/src/lib/resampler.cc
@@ -43,6 +43,7 @@ Resampler::Resampler (int in, int out, int channels)
: _in_rate (in)
, _out_rate (out)
, _channels (channels)
+ , _fast (false)
{
int error;
_src = src_new (SRC_SINC_BEST_QUALITY, _channels, &error);
@@ -59,13 +60,19 @@ Resampler::~Resampler ()
}
void
-Resampler::set_fast ()
+Resampler::set_fast (bool fast)
{
+ if (fast == _fast) {
+ return;
+ }
+
+ _fast = fast;
+
src_delete (_src);
_src = 0;
int error;
- _src = src_new (SRC_LINEAR, _channels, &error);
+ _src = src_new (_fast ? SRC_LINEAR : SRC_SINC_BEST_QUALITY, _channels, &error);
if (!_src) {
throw runtime_error (String::compose (N_("could not create sample-rate converter (%1)"), error));
}
diff --git a/src/lib/resampler.h b/src/lib/resampler.h
index 4b19dc511..dfd3ffd08 100644
--- a/src/lib/resampler.h
+++ b/src/lib/resampler.h
@@ -34,11 +34,12 @@ public:
boost::shared_ptr<const AudioBuffers> run (boost::shared_ptr<const AudioBuffers>);
boost::shared_ptr<const AudioBuffers> flush ();
void reset ();
- void set_fast ();
+ void set_fast (bool fast);
private:
SRC_STATE* _src;
int _in_rate;
int _out_rate;
int _channels;
+ bool _fast;
};
diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc
index 98398aaa6..63500f7c6 100644
--- a/src/wx/text_panel.cc
+++ b/src/wx/text_panel.cc
@@ -667,7 +667,7 @@ TextPanel::text_view_clicked ()
ContentList c = _parent->selected_text ();
DCPOMATIC_ASSERT (c.size() == 1);
- shared_ptr<Decoder> decoder = decoder_factory (_parent->film(), c.front(), false, shared_ptr<Decoder>());
+ shared_ptr<Decoder> decoder = decoder_factory (_parent->film(), c.front(), shared_ptr<Decoder>());
if (decoder) {
_text_view = new TextView (this, _parent->film(), c.front(), c.front()->text_of_original_type(_original_type), decoder, _parent->film_viewer());