2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
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.
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.
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.
22 #include "picture_frame.h"
23 #include "argb_frame.h"
25 using boost::dynamic_pointer_cast;
27 BOOST_AUTO_TEST_CASE (decryption_test)
29 boost::filesystem::path plaintext_path = test_corpus;
30 plaintext_path /= "TONEPLATES-SMPTE-PLAINTEXT_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
31 libdcp::DCP plaintext (plaintext_path.string ());
33 BOOST_CHECK_EQUAL (plaintext.encrypted (), false);
35 boost::filesystem::path encrypted_path = test_corpus;
36 encrypted_path /= "TONEPLATES-SMPTE-ENCRYPTED_TST_F_XX-XX_ITL-TD_51-XX_2K_WOE_20111001_WOE_OV";
37 libdcp::DCP encrypted (encrypted_path.string ());
39 BOOST_CHECK_EQUAL (encrypted.encrypted (), true);
42 "test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml",
43 "test/data/private.key"
46 encrypted.add_kdm (kdm);
48 shared_ptr<const libdcp::Reel> encrypted_reel = encrypted.cpls().front()->reels().front ();
49 shared_ptr<const libdcp::PictureAsset> encrypted_picture = encrypted_reel->main_picture ();
50 BOOST_CHECK (encrypted_picture);
52 shared_ptr<const libdcp::MonoPictureAsset> encrypted_mono_picture = dynamic_pointer_cast<const libdcp::MonoPictureAsset> (encrypted_picture);
53 shared_ptr<const libdcp::MonoPictureFrame> j2k_frame = encrypted_mono_picture->get_frame (0);
55 shared_ptr<const libdcp::ARGBFrame> argb_frame = j2k_frame->argb_frame ();
59 uint8_t* tiff_frame = new uint8_t[1998 * 3 * 1080];
61 uint8_t* t = tiff_frame;
62 uint8_t* r = argb_frame->data ();
63 for (int y = 0; y < 1080; ++y) {
64 for (int x = 0; x < 1998; ++x) {
65 /* Our data is first-byte blue, second-byte green, third-byte red, fourth-byte alpha,
66 so we need to twiddle here.
77 TIFF* output = TIFFOpen ("foo.tiff", "w");
80 TIFFSetField (output, TIFFTAG_IMAGEWIDTH, 1998);
81 TIFFSetField (output, TIFFTAG_IMAGELENGTH, 1080);
82 TIFFSetField (output, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
83 TIFFSetField (output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
84 TIFFSetField (output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
85 TIFFSetField (output, TIFFTAG_BITSPERSAMPLE, 8);
86 TIFFSetField (output, TIFFTAG_SAMPLESPERPIXEL, 3);
88 BOOST_CHECK (TIFFWriteEncodedStrip (output, 0, tiff_frame, 1998 * 1080 * 3));