#include <sstream>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
+#include <openjpeg.h>
#include "AS_DCP.h"
#include "KM_fileio.h"
#include "picture_asset.h"
throw DCPReadError ("could not read video frame");
}
+ bool j2k_same = true;
+
if (buffer_A.Size() != buffer_B.Size()) {
notes.push_back ("sizes of video data for frame " + lexical_cast<string>(i) + " differ");
+ j2k_same = false;
continue;
}
if (memcmp (buffer_A.RoData(), buffer_B.RoData(), buffer_A.Size()) != 0) {
notes.push_back ("J2K data for frame " + lexical_cast<string>(i) + " differ");
+ j2k_same = false;
continue;
}
+
+ if (!j2k_same) {
+ /* Decompress the images to bitmaps */
+ opj_image_t* image_A = decompress_j2k (const_cast<uint8_t*> (buffer_A.RoData()), buffer_A.Size ());
+ opj_image_t* image_B = decompress_j2k (const_cast<uint8_t*> (buffer_B.RoData()), buffer_B.Size ());
+
+ /* Compare them */
+
+ if (image_A->numcomps != image_B->numcomps) {
+ notes.push_back ("image component counts for frame " + lexical_cast<string>(i) + " differ");
+ }
+
+ for (int c = 0; c < image_A->numcomps; ++c) {
+ if (image_A->comps[c].w != image_B->comps[c].w || image_A->comps[c].h != image_B->comps[c].h) {
+ notes.push_back ("image sizes for frame " + lexical_cast<string>(i) + " differ");
+ }
+
+ cout << "comp " << c << " of " << image_A->numcomps << "\n";
+ cout << "bpp " << image_A->comps[c].bpp << "\n";
+
+ for (int x = 0; x < image_A->comps[c].w; ++x) {
+ for (int y = 0; y < image_A->comps[c].h; ++y) {
+
+ }
+ }
+ }
+
+
+ opj_image_destroy (image_A);
+ opj_image_destroy (image_B);
+ }
}
}
return notes;
}
+
+opj_image_t *
+PictureAsset::decompress_j2k (uint8_t* data, int64_t size) const
+{
+ opj_dinfo_t* decoder = opj_create_decompress (CODEC_J2K);
+ opj_dparameters_t parameters;
+ opj_set_default_decoder_parameters (¶meters);
+ opj_setup_decoder (decoder, ¶meters);
+ opj_cio_t* cio = opj_cio_open ((opj_common_ptr) decoder, data, size);
+ opj_image_t* image = opj_decode (decoder, cio);
+ if (!image) {
+ opj_destroy_decompress (decoder);
+ opj_cio_close (cio);
+ throw DCPReadError ("could not decode JPEG2000 codestream");
+ }
+
+ opj_cio_close (cio);
+ return image;
+}
* @brief An asset made up of JPEG2000 files
*/
+#include <openjpeg.h>
#include "asset.h"
namespace libdcp
private:
std::string path_from_list (int f, std::vector<std::string> const & files) const;
void construct (sigc::slot<std::string, int>);
+ opj_image_t* decompress_j2k (uint8_t* data, int64_t size) const;
/** picture width in pixels */
int _width;
conf.check_cfg(package = 'sigc++-2.0', args = '--cflags --libs', uselib_store = 'SIGC++', mandatory = True)
conf.check_cfg(package = 'libxml++-2.6', args = '--cflags --libs', uselib_store = 'LIBXML++', mandatory = True)
+ conf.check_cc(fragment = """
+ #include <stdio.h>\n
+ #include <openjpeg.h>\n
+ int main () {\n
+ void* p = (void *) opj_image_create;\n
+ return 0;\n
+ }
+ """, msg = 'Checking for library openjpeg', lib = 'openjpeg', uselib_store = 'OPENJPEG')
+
if conf.options.target_windows:
boost_lib_suffix = '-mt'
else: