/* 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)
)
{}
} else {
while (
_decoded.audio->frames() < length &&
- !_decoder->pass ()
+ !_decoder->pass (Decoder::PASS_REASON_AUDIO)
)
{}
}
bool
-DCPDecoder::pass ()
+DCPDecoder::pass (PassReason reason)
{
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);
void seek (ContentTime t, bool accurate);
std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
}
bool
-DCPSubtitleDecoder::pass ()
+DCPSubtitleDecoder::pass (PassReason)
{
if (_next == _subtitles.end ()) {
return true;
DCPSubtitleDecoder (boost::shared_ptr<const DCPSubtitleContent>);
protected:
- bool pass ();
+ bool pass (PassReason);
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) = 0;
};
#endif
}
bool
-FFmpegDecoder::pass ()
+FFmpegDecoder::pass (PassReason reason)
{
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 && 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);
void seek (ContentTime time, bool);
void flush ();
}
bool
-ImageDecoder::pass ()
+ImageDecoder::pass (PassReason)
{
if (_video_position >= _image_content->video_length()) {
return true;
}
private:
- bool pass ();
+ bool pass (PassReason);
void seek (ContentTime, bool);
boost::shared_ptr<const ImageContent> _image_content;
}
bool
-SndfileDecoder::pass ()
+SndfileDecoder::pass (PassReason)
{
if (_remaining == 0) {
return true;
~SndfileDecoder ();
private:
- bool pass ();
+ bool pass (PassReason);
void seek (ContentTime, bool);
int64_t _done;
}
bool
-SubRipDecoder::pass ()
+SubRipDecoder::pass (PassReason)
{
if (_next >= _subtitles.size ()) {
return true;
protected:
void seek (ContentTime time, bool accurate);
- bool pass ();
+ bool pass (PassReason);
private:
std::list<ContentTimePeriod> image_subtitles_during (ContentTimePeriod, bool starting) const;
* (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) && (subs.empty() || (subs.back().period().to < sp.back().to))) {}
/* Now look for what we wanted in the data we have collected */
/* XXX: inefficient */
break;
}
- if (pass ()) {
+ if (pass (PASS_REASON_VIDEO)) {
/* 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)) {}
if (!_decoded_video.empty ()) {
dec.push_back (_decoded_video.front ());
}
, _position (0)
{}
- bool pass ()
+ bool pass (PassReason)
{
Frame const N = min (
Frame (2000),