1 /* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
4 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "video_decoder.h"
30 using boost::shared_ptr;
32 VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<const VideoContent> c)
36 , _frame_rate_conversion (c->video_frame_rate(), f->dcp_frame_rate())
42 /** Called by subclasses when some video is ready.
43 * @param image frame to emit.
44 * @param same true if this frame is the same as the last one passed to this call.
45 * @param t Time of the frame within the source.
48 VideoDecoder::video (shared_ptr<Image> image, bool same, Time t)
50 if (_frame_rate_conversion.skip && _odd) {
55 shared_ptr<Subtitle> sub;
56 if (_timed_subtitle && _timed_subtitle->displayed_at (t)) {
57 sub = _timed_subtitle->subtitle ();
60 Video (image, same, sub, t);
62 if (_frame_rate_conversion.repeat) {
63 Video (image, true, sub, t + _film->video_frames_to_time (1));
64 _next_video = t + _film->video_frames_to_time (2);
66 _next_video = t + _film->video_frames_to_time (1);
72 /** Called by subclasses when a subtitle is ready.
73 * s may be 0 to say that there is no current subtitle.
74 * @param s New current subtitle, or 0.
77 VideoDecoder::subtitle (shared_ptr<TimedSubtitle> s)
81 if (_timed_subtitle) {
82 Position const p = _timed_subtitle->subtitle()->position ();
83 _timed_subtitle->subtitle()->set_position (Position (p.x - _video_content->crop().left, p.y - _video_content->crop().top));