/* Keep stuffing data into _decoded until we have enough data, or the subclass does not want to give us any more */
while (
(_decoded.frame > frame || (_decoded.frame + _decoded.audio->frames()) < end) &&
- !_decoder->pass ()
+ !_decoder->pass (Decoder::PASS_REASON_AUDIO, accurate)
)
{}
} else {
while (
_decoded.audio->frames() < length &&
- !_decoder->pass ()
+ !_decoder->pass (Decoder::PASS_REASON_AUDIO, accurate)
)
{}
}
bool
-DCPDecoder::pass ()
+DCPDecoder::pass (PassReason reason, bool)
{
if (_reel == _reels.end () || !_dcp_content->can_be_played ()) {
return true;
double const vfr = _dcp_content->video_frame_rate ();
int64_t const frame = _next.frames_round (vfr);
- if ((*_reel)->main_picture ()) {
+ if ((*_reel)->main_picture () && reason != PASS_REASON_SUBTITLE) {
shared_ptr<dcp::PictureAsset> asset = (*_reel)->main_picture()->asset ();
shared_ptr<dcp::MonoPictureAsset> mono = dynamic_pointer_cast<dcp::MonoPictureAsset> (asset);
shared_ptr<dcp::StereoPictureAsset> stereo = dynamic_pointer_cast<dcp::StereoPictureAsset> (asset);
}
}
- if ((*_reel)->main_sound ()) {
+ if ((*_reel)->main_sound () && reason != PASS_REASON_SUBTITLE) {
int64_t const entry_point = (*_reel)->main_sound()->entry_point ();
shared_ptr<const dcp::SoundFrame> sf = (*_reel)->main_sound()->asset()->get_frame (entry_point + frame);
uint8_t const * from = sf->data ();
private:
friend struct dcp_subtitle_within_dcp_test;
- bool pass ();
+ bool pass (PassReason, bool accurate);
void seek (ContentTime t, bool accurate);
std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
}
bool
-DCPSubtitleDecoder::pass ()
+DCPSubtitleDecoder::pass (PassReason, bool)
{
if (_next == _subtitles.end ()) {
return true;
DCPSubtitleDecoder (boost::shared_ptr<const DCPSubtitleContent>);
protected:
- bool pass ();
+ bool pass (PassReason, bool accurate);
void seek (ContentTime time, bool accurate);
private:
*/
virtual void seek (ContentTime time, bool accurate) = 0;
- virtual bool pass () = 0;
+ enum PassReason {
+ PASS_REASON_VIDEO,
+ PASS_REASON_AUDIO,
+ PASS_REASON_SUBTITLE
+ };
+
+ virtual bool pass (PassReason, bool accurate) = 0;
};
#endif
}
bool
-FFmpegDecoder::pass ()
+FFmpegDecoder::pass (PassReason reason, bool accurate)
{
int r = av_read_frame (_format_context, &_packet);
int const si = _packet.stream_index;
shared_ptr<const FFmpegContent> fc = _ffmpeg_content;
- if (si == _video_stream && !_ignore_video) {
+ if (si == _video_stream && !_ignore_video && (accurate || reason != PASS_REASON_SUBTITLE)) {
decode_video_packet ();
} else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index (_format_context, si)) {
decode_subtitle_packet ();
- } else {
+ } else if (reason != PASS_REASON_SUBTITLE) {
decode_audio_packet ();
}
private:
friend struct ::ffmpeg_pts_offset_test;
- bool pass ();
+ bool pass (PassReason, bool accurate);
void seek (ContentTime time, bool);
void flush ();
}
bool
-ImageDecoder::pass ()
+ImageDecoder::pass (PassReason, bool)
{
if (_video_position >= _image_content->video_length()) {
return true;
}
private:
- bool pass ();
+ bool pass (PassReason, bool);
void seek (ContentTime, bool);
boost::shared_ptr<const ImageContent> _image_content;
boost::shared_ptr<ImageProxy> _image;
Frame _video_position;
};
-
/* Find subtitles for possible burn-in */
- PlayerSubtitles ps = get_subtitles (time, DCPTime::from_frames (1, _film->video_frame_rate ()), false, true);
+ PlayerSubtitles ps = get_subtitles (time, DCPTime::from_frames (1, _film->video_frame_rate ()), false, true, accurate);
list<PositionImage> sub_images;
* _always_burn_subtitles is true; in this case, all subtitles will be returned.
*/
PlayerSubtitles
-Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt)
+Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt, bool accurate)
{
list<shared_ptr<Piece> > subs = overlaps<SubtitleContent> (time, time + length);
/* XXX: this video_frame_rate() should be the rate that the subtitle content has been prepared for */
ContentTime const to = from + ContentTime::from_frames (1, _film->video_frame_rate ());
- list<ContentImageSubtitle> image = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to), starting);
+ list<ContentImageSubtitle> image = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to), starting, accurate);
for (list<ContentImageSubtitle>::iterator i = image.begin(); i != image.end(); ++i) {
/* Apply content's subtitle offsets */
ps.image.push_back (i->sub);
}
- list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting);
+ list<ContentTextSubtitle> text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting, accurate);
BOOST_FOREACH (ContentTextSubtitle& ts, text) {
BOOST_FOREACH (dcp::SubtitleString s, ts.subs) {
s.set_h_position (s.h_position() + subtitle_content->subtitle_x_offset ());
std::list<boost::shared_ptr<PlayerVideo> > get_video (DCPTime time, bool accurate);
boost::shared_ptr<AudioBuffers> get_audio (DCPTime time, DCPTime length, bool accurate);
- PlayerSubtitles get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt);
+ PlayerSubtitles get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt, bool accurate);
std::list<boost::shared_ptr<Font> > get_subtitle_fonts ();
std::list<ReferencedReelAsset> get_reel_assets ();
}
bool
-SndfileDecoder::pass ()
+SndfileDecoder::pass (PassReason, bool)
{
if (_remaining == 0) {
return true;
~SndfileDecoder ();
private:
- bool pass ();
+ bool pass (PassReason, bool);
void seek (ContentTime, bool);
int64_t _done;
}
bool
-SubRipDecoder::pass ()
+SubRipDecoder::pass (PassReason, bool)
{
if (_next >= _subtitles.size ()) {
return true;
protected:
void seek (ContentTime time, bool accurate);
- bool pass ();
+ bool pass (PassReason, bool accurate);
private:
std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
/** @param sp Full periods of subtitles that are showing or starting during the specified period */
template <class T>
list<T>
-SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting)
+SubtitleDecoder::get (list<T> const & subs, list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting, bool accurate)
{
if (sp.empty ()) {
/* Nothing in this period */
* (a) give us what we want, or
* (b) hit the end of the decoder.
*/
- while (!pass () && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
+ while (!pass(PASS_REASON_SUBTITLE, accurate) && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
/* Now look for what we wanted in the data we have collected */
/* XXX: inefficient */
}
list<ContentTextSubtitle>
-SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting)
+SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate)
{
- return get<ContentTextSubtitle> (_decoded_text_subtitles, text_subtitles_during (period, starting), period, starting);
+ return get<ContentTextSubtitle> (_decoded_text_subtitles, text_subtitles_during (period, starting), period, starting, accurate);
}
list<ContentImageSubtitle>
-SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting)
+SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate)
{
- return get<ContentImageSubtitle> (_decoded_image_subtitles, image_subtitles_during (period, starting), period, starting);
+ return get<ContentImageSubtitle> (_decoded_image_subtitles, image_subtitles_during (period, starting), period, starting, accurate);
}
void
public:
SubtitleDecoder (boost::shared_ptr<const SubtitleContent>);
- std::list<ContentImageSubtitle> get_image_subtitles (ContentTimePeriod period, bool starting);
- std::list<ContentTextSubtitle> get_text_subtitles (ContentTimePeriod period, bool starting);
+ std::list<ContentImageSubtitle> get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate);
+ std::list<ContentTextSubtitle> get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate);
protected:
void seek (ContentTime, bool);
private:
template <class T>
- std::list<T> get (std::list<T> const & subs, std::list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting);
+ std::list<T> get (std::list<T> const & subs, std::list<ContentTimePeriod> const & sp, ContentTimePeriod period, bool starting, bool accurate);
/** @param starting true if we want only subtitles that start during the period, otherwise
* we want subtitles that overlap the period.
_writer->write (_player->get_audio (t, frame, true));
if (non_burnt_subtitles) {
- _writer->write (_player->get_subtitles (t, frame, true, false));
+ _writer->write (_player->get_subtitles (t, frame, true, false, true));
}
}
break;
}
- if (pass ()) {
+ if (pass (PASS_REASON_VIDEO, accurate)) {
/* The decoder has nothing more for us */
break;
}
dec = decoded_video (frame);
} else {
/* Any frame will do: use the first one that comes out of pass() */
- while (_decoded_video.empty() && !pass ()) {}
+ while (_decoded_video.empty() && !pass (PASS_REASON_VIDEO, accurate)) {}
if (!_decoded_video.empty ()) {
dec.push_back (_decoded_video.front ());
}
sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
}
- list<ContentTextSubtitle> subs = decoder->get_text_subtitles (ContentTimePeriod (ContentTime(), ContentTime::max ()), true);
+ list<ContentTextSubtitle> subs = decoder->get_text_subtitles (ContentTimePeriod (ContentTime(), ContentTime::max ()), true, true);
FrameRateChange const frc = film->active_frame_rate_change (position);
int n = 0;
for (list<ContentTextSubtitle>::const_iterator i = subs.begin(); i != subs.end(); ++i) {
SetSizerAndFit (sizer);
}
-
, _position (0)
{}
- bool pass ()
+ bool pass (PassReason, bool)
{
Frame const N = min (
Frame (2000),
ContentTime::from_seconds (25),
ContentTime::from_seconds (26)
),
+ true,
true
);