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