2da97701c5f04bf1494b323a23c95f15d10a3c8f
[dcpomatic.git] / src / lib / poznan_encoder.cc
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 #include "poznan_encoder.h"
21 #include "exceptions.h"
22 #include "poznan/config/parameters.h"
23 #include <dlfcn.h>
24
25 #include "i18n.h"
26
27 using std::string;
28 using boost::shared_ptr;
29
30 PoznanEncoder::PoznanEncoder ()
31 {
32         /* XXX: need cross-platform implementation of dlopen etc. */
33         
34         void* config = dlopen ("libdcpomatic-config.so", RTLD_LAZY | RTLD_GLOBAL);
35         if (!config) {
36                 throw JPEG2000EncoderUnavailableException (name(), "could not find libdcpomatic-config.so");
37         }
38
39         void* misc = dlopen ("libdcpomatic-misc.so", RTLD_LAZY | RTLD_GLOBAL);
40         if (!misc) {
41                 throw JPEG2000EncoderUnavailableException (name(), "could not find libdcpomatic-misc.so");
42         }
43         
44         void (*init_device) (type_parameters *);
45         init_device = (void (*)(type_parameters *)) dlsym (config, "init_device");
46         if (!init_device) {
47                 throw JPEG2000EncoderUnavailableException (name(), "missing symbol");
48         }
49                 
50         type_parameters param;
51
52         /* One tile which covers entire image */
53         param.param_tile_w = -1;
54         param.param_tile_h = -1;
55
56         /* XXX */
57         /*
58         uint8_t param_tile_comp_dlvls;
59         uint8_t param_cblk_exp_w; ///Maximum codeblock size is 2^6 x 2^6 ( 64 x 64 ).
60         uint8_t param_cblk_exp_h; ///Maximum codeblock size is 2^6 x 2^6 ( 64 x 64 ).
61         uint8_t param_wavelet_type; ///Lossy encoding
62         uint8_t param_use_mct;//Multi-component transform
63         */
64         param.param_device = 0;
65         /*
66         uint32_t param_target_size;//Target size of output file
67         float param_bp;//Bits per pixel per component
68         uint8_t param_use_part2_mct; // Multiple component transform as in 15444-2
69         uint8_t param_mct_compression_method; // 0 klt 2 wavelet
70         uint32_t param_mct_klt_iterations; // max number of iterations of Gram-Schmidt algorithm
71         float param_mct_klt_border_eigenvalue; // cut-off for dumping components 
72         float param_mct_klt_err; // error sufficient for Gram-Schmit algorithm to end iteration
73         */
74         
75         init_device (&param);
76 }
77
78 string
79 PoznanEncoder::name () const
80 {
81         return _("CUDA (GPU) encoder (Poznan Supercomputing and Networking Center)");
82 }
83
84 void
85 PoznanEncoder::set_bandwidth (int bandwidth)
86 {
87         /* XXX */
88 }
89
90 void
91 PoznanEncoder::set_frame_rate (int frame_rate)
92 {
93         /* XXX */
94 }
95
96 void
97 PoznanEncoder::set_resolution (Resolution resolution)
98 {
99         /* XXX */
100 }
101
102 void
103 PoznanEncoder::set_threed (bool threed)
104 {
105         /* XXX */
106 }
107
108 shared_ptr<EncodedData>
109 PoznanEncoder::do_encode (shared_ptr<const dcp::XYZImage> input, dcp::NoteHandler note_handler)
110 {
111         return shared_ptr<EncodedData> ();
112 }