summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-11-28 13:22:04 +0000
committerCarl Hetherington <cth@carlh.net>2015-11-28 13:22:04 +0000
commitae6860a1e10c0dc62db16fd47aacd8c19a79c754 (patch)
tree073d80ead8ecc9d44235b3793b7230ee973887f5
parent8ccf9e982971a8eca1027ad5c04d837b6ad068dc (diff)
Add nice decompress_j2k wrapper; small fixes to bench.
-rw-r--r--src/util.cc6
-rw-r--r--src/util.h1
-rw-r--r--test/bench.cc10
3 files changed, 14 insertions, 3 deletions
diff --git a/src/util.cc b/src/util.cc
index 0b8cf663..b37e99c8 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -193,6 +193,12 @@ dcp::content_kind_from_string (string kind)
DCP_ASSERT (false);
}
+shared_ptr<dcp::OpenJPEGImage>
+dcp::decompress_j2k (Data data, int reduce)
+{
+ return dcp::decompress_j2k (data.data.get(), data.size, reduce);
+}
+
/** Decompress a JPEG2000 image to a bitmap.
* @param data JPEG2000 data.
* @param size Size of data in bytes.
diff --git a/src/util.h b/src/util.h
index da1844cb..8802c81d 100644
--- a/src/util.h
+++ b/src/util.h
@@ -55,6 +55,7 @@ extern std::string content_kind_to_string (ContentKind kind);
extern ContentKind content_kind_from_string (std::string kind);
extern bool empty_or_white_space (std::string s);
extern boost::shared_ptr<OpenJPEGImage> decompress_j2k (uint8_t* data, int64_t size, int reduce);
+extern boost::shared_ptr<OpenJPEGImage> decompress_j2k (Data data, int reduce);
extern Data compress_j2k (boost::shared_ptr<OpenJPEGImage>, int bandwith, int frames_per_second, bool threed, bool fourk);
extern bool ids_equal (std::string a, std::string b);
diff --git a/test/bench.cc b/test/bench.cc
index c3f7dd1e..0559b5a9 100644
--- a/test/bench.cc
+++ b/test/bench.cc
@@ -48,14 +48,16 @@ main (int argc, char* argv[])
shared_ptr<dcp::OpenJPEGImage> xyz;
for (int i = 0; i < decompress_count; ++i) {
- xyz = dcp::decompress_j2k (j2k.data.get(), j2k.size, 0);
+ xyz = dcp::decompress_j2k (j2k, 0);
+ cout << (i + 1) << " ";
}
+ cout << "\n";
struct timeval stop;
gettimeofday (&stop, 0);
double start_seconds = start.tv_sec + double(start.tv_usec) / 1000000;
- double stop_seconds = stop.tv_sec + double(start.tv_usec) / 1000000;
+ double stop_seconds = stop.tv_sec + double(stop.tv_usec) / 1000000;
if (dcp::built_with_debug) {
cout << "Decompress (debug build): ";
} else {
@@ -67,12 +69,14 @@ main (int argc, char* argv[])
for (int i = 0; i < compress_count; ++i) {
dcp::compress_j2k (xyz, j2k_bandwidth, 24, false, false);
+ cout << (i + 1) << " ";
}
+ cout << "\n";
gettimeofday (&stop, 0);
start_seconds = start.tv_sec + double(start.tv_usec) / 1000000;
- stop_seconds = stop.tv_sec + double(start.tv_usec) / 1000000;
+ stop_seconds = stop.tv_sec + double(stop.tv_usec) / 1000000;
if (dcp::built_with_debug) {
cout << "Compress (debug build) ";
} else {