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 ()) {
);
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;
}
}
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);
+ }
+}
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 */
{
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;
{
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;
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)
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 */
DCPDecoder (
boost::shared_ptr<const Film> film,
boost::shared_ptr<const DCPContent>,
- bool fast,
boost::shared_ptr<DCPDecoder> old = boost::shared_ptr<DCPDecoder>()
);
DCPOMATIC_ASSERT (f);
return f;
}
+
+void
+Decoder::set_fast (bool fast)
+{
+ if (audio) {
+ audio->set_fast (fast);
+ }
+}
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.
/** @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>();
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
);
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)
}
if (c->audio) {
- audio.reset (new AudioDecoder (this, c->audio, fast));
+ audio.reset (new AudioDecoder (this, c->audio));
}
if (c->only_text()) {
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);
}
}
- 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) {
continue;
}
+ decoder->set_fast (_fast);
+
if (decoder->video && _ignore_video) {
decoder->video->set_ignore (true);
}
scoped_ptr<DCPDecoder> decoder;
try {
- decoder.reset (new DCPDecoder (_film, j, false));
+ decoder.reset (new DCPDecoder (_film, j));
} catch (...) {
return a;
}
: _in_rate (in)
, _out_rate (out)
, _channels (channels)
+ , _fast (false)
{
int error;
_src = src_new (SRC_SINC_BEST_QUALITY, _channels, &error);
}
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));
}
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;
};
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());