Various more hacks.
[dcpomatic.git] / src / lib / black_decoder.cc
1 /*
2     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "black_decoder.h"
21
22 BlackDecoder::BlackDecoder (shared_ptr<Film> f, shared_ptr<NullContent> c)
23         : VideoDecoder (f, c)
24 {
25
26 }
27
28 void
29 BlackDecoder::pass ()
30 {
31         if (!_image) {
32                 _image.reset (new SimpleImage (AV_PIX_FMT_RGB24, video_size ()));
33                 _image->make_black ();
34                 video (_image, false, _next_video);
35         } else {
36                 video (_image, true, _next_video);
37         }
38 }
39
40 float
41 BlackDecoder::video_frame_rate () const
42 {
43         boost::shared_ptr<const Film> f = _film.lock ();
44         if (!f) {
45                 return 24;
46         }
47
48         return f->dcp_video_frame_rate ();
49 }
50
51 ContentVideoFrame
52 BlackDecoder::video_length () const
53 {
54         return _video_content->length() * video_frame_rate() / TIME_HZ;
55 }
56
57 Time
58 BlackDecoder::next () const
59 {
60         return _next_video;
61 }