summaryrefslogtreecommitdiff
path: root/src/lib/image_examiner.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-11-23 01:48:55 +0000
committerCarl Hetherington <cth@carlh.net>2014-11-23 12:47:36 +0000
commit80fafad9c11e0cd8cf9d6ce17deb83be6f680f2d (patch)
treead1b5f69d9863a86ecbf2c46ae0b7916ce60be09 /src/lib/image_examiner.cc
parent2f51e117cbaf36b9e0ccb02c338b316fc8e26b9a (diff)
First cut at J2K import.
Diffstat (limited to 'src/lib/image_examiner.cc')
-rw-r--r--src/lib/image_examiner.cc28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc
index 75ccb6a3e..ef9c13c5a 100644
--- a/src/lib/image_examiner.cc
+++ b/src/lib/image_examiner.cc
@@ -17,14 +17,16 @@
*/
-#include <iostream>
-#include <Magick++.h>
#include "image_content.h"
#include "image_examiner.h"
#include "film.h"
#include "job.h"
#include "exceptions.h"
#include "config.h"
+#include "cross.h"
+#include <dcp/xyz_frame.h>
+#include <Magick++.h>
+#include <iostream>
#include "i18n.h"
@@ -39,10 +41,24 @@ ImageExaminer::ImageExaminer (shared_ptr<const Film> film, shared_ptr<const Imag
{
#ifdef DCPOMATIC_IMAGE_MAGICK
using namespace MagickCore;
-#endif
- Magick::Image* image = new Magick::Image (content->path(0).string());
- _video_size = dcp::Size (image->columns(), image->rows());
- delete image;
+#endif
+ boost::filesystem::path path = content->path(0).string ();
+ if (valid_j2k_file (path)) {
+ boost::uintmax_t size = boost::filesystem::file_size (path);
+ uint8_t* buffer = new uint8_t[size];
+ FILE* f = fopen_boost (path, "r");
+ if (!f) {
+ throw FileError ("Could not open file for reading", path);
+ }
+ fread (buffer, 1, size, f);
+ fclose (f);
+ _video_size = dcp::decompress_j2k (buffer, size, 0)->size ();
+ delete[] buffer;
+ } else {
+ Magick::Image* image = new Magick::Image (content->path(0).string());
+ _video_size = dcp::Size (image->columns(), image->rows());
+ delete image;
+ }
if (content->still ()) {
_video_length = ContentTime::from_seconds (Config::instance()->default_still_length());