1 #include "video_decoder.h"
9 using boost::shared_ptr;
10 using boost::optional;
12 VideoDecoder::VideoDecoder (shared_ptr<Film> f, shared_ptr<const Options> o, Job* j)
19 /** Called by subclasses to tell the world that some video data is ready.
20 * We find a subtitle then emit it for listeners.
21 * @param frame to decode; caller manages memory.
24 VideoDecoder::emit_video (shared_ptr<Image> image)
26 shared_ptr<Subtitle> sub;
27 if (_timed_subtitle && _timed_subtitle->displayed_at (double (video_frame()) / _film->frames_per_second())) {
28 sub = _timed_subtitle->subtitle ();
31 signal_video (image, sub);
35 VideoDecoder::repeat_last_video ()
38 _last_image.reset (new CompactImage (pixel_format(), native_size()));
39 _last_image->make_black ();
42 signal_video (_last_image, _last_subtitle);
46 VideoDecoder::signal_video (shared_ptr<Image> image, shared_ptr<Subtitle> sub)
48 TIMING ("Decoder emits %1", _video_frame);
57 VideoDecoder::emit_subtitle (shared_ptr<TimedSubtitle> s)
61 if (_timed_subtitle && _opt->apply_crop) {
62 Position const p = _timed_subtitle->subtitle()->position ();
63 _timed_subtitle->subtitle()->set_position (Position (p.x - _film->crop().left, p.y - _film->crop().top));
68 VideoDecoder::set_subtitle_stream (optional<SubtitleStream> s)
74 VideoDecoder::set_progress () const
76 if (_job && _film->dcp_length()) {
77 _job->set_progress (float (_video_frame) / _film->length().get());