X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fdcp_decoder.cc;h=86152c817f6642eb0d931ca4a342ad00299e2ee2;hp=9893cf7fc7318740aef7a8347b89219839e54d28;hb=df17bbd25da69fc38eb2dcd8b4a2531cf0bab0bc;hpb=64a6a87dd4a3fd43665242b8a8b2b35a675a7839 diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 9893cf7fc..86152c817 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -24,7 +24,7 @@ #include "video_decoder.h" #include "audio_decoder.h" #include "j2k_image_proxy.h" -#include "subtitle_decoder.h" +#include "text_decoder.h" #include "image.h" #include "config.h" #include @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -62,9 +63,9 @@ DCPDecoder::DCPDecoder (shared_ptr c, shared_ptr log, boo if (c->audio) { audio.reset (new AudioDecoder (this, c->audio, log, fast)); } - if (c->subtitle) { + BOOST_FOREACH (shared_ptr i, c->caption) { /* XXX: this time here should be the time of the first subtitle, not 0 */ - subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime())); + caption.push_back (shared_ptr (new TextDecoder (this, i, log, ContentTime()))); } list > cpl_list = cpls (); @@ -109,10 +110,10 @@ DCPDecoder::pass () /* Frame within the (played part of the) reel that is coming up next */ int64_t const frame = _next.frames_round (vfr); - /* We must emit subtitles first as when we emit the video for this frame - it will expect already to have the subs. + /* We must emit captions first as when we emit the video for this frame + it will expect already to have the captions. */ - pass_subtitles (_next); + pass_captions (_next); if ((_mono_reader || _stereo_reader) && (_decode_referenced || !_dcp_content->reference_video())) { shared_ptr asset = (*_reel)->main_picture()->asset (); @@ -190,15 +191,32 @@ DCPDecoder::pass () } void -DCPDecoder::pass_subtitles (ContentTime next) +DCPDecoder::pass_captions (ContentTime next) +{ + list >::const_iterator decoder = caption.begin (); + if ((*_reel)->main_subtitle()) { + pass_captions ( + next, (*_reel)->main_subtitle()->asset(), _dcp_content->reference_caption(CAPTION_OPEN), (*_reel)->main_subtitle()->entry_point(), *decoder + ); + ++decoder; + } + if ((*_reel)->closed_caption()) { + pass_captions ( + next, (*_reel)->closed_caption()->asset(), _dcp_content->reference_caption(CAPTION_CLOSED), (*_reel)->closed_caption()->entry_point(), *decoder + ); + ++decoder; + } +} + +void +DCPDecoder::pass_captions (ContentTime next, shared_ptr asset, bool reference, int64_t entry_point, shared_ptr decoder) { double const vfr = _dcp_content->active_video_frame_rate (); /* Frame within the (played part of the) reel that is coming up next */ int64_t const frame = next.frames_round (vfr); - if ((*_reel)->main_subtitle() && (_decode_referenced || !_dcp_content->reference_subtitle())) { - int64_t const entry_point = (*_reel)->main_subtitle()->entry_point (); - list > subs = (*_reel)->main_subtitle()->asset()->subtitles_during ( + if (_decode_referenced || !reference) { + list > subs = asset->subtitles_during ( dcp::Time (entry_point + frame, vfr, vfr), dcp::Time (entry_point + frame + 1, vfr, vfr), true @@ -209,7 +227,7 @@ DCPDecoder::pass_subtitles (ContentTime next) if (is) { list s; s.push_back (*is); - subtitle->emit_text ( + decoder->emit_plain ( ContentTimePeriod ( ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i->in().as_seconds ()), ContentTime::from_frames (_offset - entry_point, vfr) + ContentTime::from_seconds (i->out().as_seconds ()) @@ -296,11 +314,11 @@ DCPDecoder::seek (ContentTime t, bool accurate) next_reel (); } - /* Pass subtitles in the pre-roll */ + /* Pass captions in the pre-roll */ double const vfr = _dcp_content->active_video_frame_rate (); for (int i = 0; i < pre_roll_seconds * vfr; ++i) { - pass_subtitles (pre); + pass_captions (pre); pre += ContentTime::from_frames (1, vfr); }