Optimise image scaling for the preview.
[dcpomatic.git] / src / lib / dcp_video.h
1 /*
2     Copyright (C) 2012-2016 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 "types.h"
21 #include "encode_server_description.h"
22 #include <libcxml/cxml.h>
23 #include <dcp/data.h>
24
25 /** @file  src/dcp_video_frame.h
26  *  @brief A single frame of video destined for a DCP.
27  */
28
29 class Log;
30 class PlayerVideo;
31
32 /** @class DCPVideo
33  *  @brief A single frame of video destined for a DCP.
34  *
35  *  Given an Image and some settings, this class knows how to encode
36  *  the image to J2K either on the local host or on a remote server.
37  *
38  *  Objects of this class are used for the queue that we keep
39  *  of images that require encoding.
40  */
41 class DCPVideo : public boost::noncopyable
42 {
43 public:
44         DCPVideo (boost::shared_ptr<const PlayerVideo>, int, int, int, Resolution, boost::shared_ptr<Log>);
45         DCPVideo (boost::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr, boost::shared_ptr<Log>);
46
47         dcp::Data encode_locally (dcp::NoteHandler note);
48         dcp::Data encode_remotely (EncodeServerDescription, int timeout = 30);
49
50         int index () const {
51                 return _index;
52         }
53
54         Eyes eyes () const;
55
56         bool same (boost::shared_ptr<const DCPVideo> other) const;
57
58         static boost::shared_ptr<dcp::OpenJPEGImage> convert_to_xyz (boost::shared_ptr<const PlayerVideo> frame, dcp::NoteHandler note);
59
60 private:
61
62         void add_metadata (xmlpp::Element *) const;
63
64         boost::shared_ptr<const PlayerVideo> _frame;
65         int _index;                      ///< frame index within the DCP's intrinsic duration
66         int _frames_per_second;          ///< Frames per second that we will use for the DCP
67         int _j2k_bandwidth;              ///< J2K bandwidth to use
68         Resolution _resolution;          ///< Resolution (2K or 4K)
69
70         boost::shared_ptr<Log> _log; ///< log
71 };