Various build fixes.
[dcpomatic.git] / src / lib / jpeg2000_encoder.h
1 /*
2     Copyright (C) 2015-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 #ifndef DCPOMATIC_JPEG2000_ENCODER_H
21 #define DCPOMATIC_JPEG2000_ENCODER_H
22
23 #include "types.h"
24 #include <dcp/types.h>
25 #include <dcp/data.h>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/optional.hpp>
28 #include <list>
29
30 namespace dcp {
31         class OpenJPEGImage;
32 }
33
34 class JPEG2000Encoder
35 {
36 public:
37         virtual ~JPEG2000Encoder () {}
38
39         /** @return Internationalised descriptive name for this encoder */
40         virtual std::string name () const = 0;
41         /** @return Non-internationalised ID for this encoder */
42         virtual std::string id () const = 0;
43
44         /** @param input XYZ input frame.
45          *  @param note_handler Handler for notes about the encode.
46
47          *  @return Encoded JPEG2000 data.
48          */
49         dcp::Data encode (
50                 boost::shared_ptr<const dcp::OpenJPEGImage> input,
51                 int bandwidth,
52                 int frame_rate,
53                 Resolution resolution,
54                 bool threed
55                 );
56
57         static void setup_encoders ();
58         /** @return Return all available JPEG2000 encoders in order of preference (best first) */
59         static std::vector<boost::shared_ptr<JPEG2000Encoder> > all ();
60         static boost::shared_ptr<JPEG2000Encoder> from_id (std::string id);
61
62 protected:
63
64         virtual dcp::Data do_encode (
65                 boost::shared_ptr<const dcp::OpenJPEGImage> input
66                 ) = 0;
67
68         virtual void parameters_changed () {}
69
70         boost::optional<int> _bandwidth;
71         boost::optional<int> _frame_rate;
72         boost::optional<Resolution> _resolution;
73         boost::optional<bool> _threed;
74
75         static std::vector<boost::shared_ptr<JPEG2000Encoder> > _encoders;
76 };
77
78 #endif