fe18667d10c2f89400c35b6223e4ad69f31e110e
[dcpomatic.git] / test / poznan.cc
1 #include "lib/poznan_encoder.h"
2 #include "lib/jpeg2000_encoder.h"
3 #include "lib/image.h"
4 #include "lib/colour_conversion.h"
5 #include "lib/config.h"
6 #include <dcp/rgb_xyz.h>
7
8 using std::vector;
9 using boost::shared_ptr;
10
11 int main ()
12 {
13         JPEG2000Encoder::setup_encoders ();
14
15         shared_ptr<JPEG2000Encoder> encoder = JPEG2000Encoder::from_id ("poznan");
16
17         shared_ptr<Image> rgb (new Image (PIX_FMT_RGB24, dcp::Size (1998, 1080), false));
18
19         int const line_size = 1998 * 3;
20
21         for (int x = 0; x < 666; ++x) {
22                 for (int y = 0; y < 1080; ++y) {
23                         rgb->data()[0][y * line_size + x * 3] = 255;
24                         rgb->data()[0][y * line_size + x * 3 + 1] = 0;
25                         rgb->data()[0][y * line_size + x * 3 + 2] = 0;
26                 }
27         }
28
29         for (int x = 666; x < 1332; ++x) {
30                 for (int y = 0; y < 1080; ++y) {
31                         rgb->data()[0][y * line_size + x * 3] = 0;
32                         rgb->data()[0][y * line_size + x * 3 + 1] = 255;
33                         rgb->data()[0][y * line_size + x * 3 + 2] = 0;
34                 }
35         }
36
37         for (int x = 1332; x < 1998; ++x) {
38                 for (int y = 0; y < 1080; ++y) {
39                         rgb->data()[0][y * line_size + x * 3] = 0;
40                         rgb->data()[0][y * line_size + x * 3 + 1] = 0;
41                         rgb->data()[0][y * line_size + x * 3 + 2] = 255;
42                 }
43         }
44
45         shared_ptr<const dcp::OpenJPEGImage> xyz = dcp::rgb_to_xyz (rgb->data()[0], rgb->size(), rgb->stride()[0], ColourConversion::rec709_to_xyz ());
46         Data j2k = encoder->encode (xyz, 100000000, 24, RESOLUTION_2K, false);
47         j2k.write ("poznan.j2k");
48 }