diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-19 11:05:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-19 11:05:10 +0100 |
| commit | 9e758fddfb8bbadb1fc84e393daa815445d5e9d5 (patch) | |
| tree | 291005ebf01a66f07ab05b09e72f634ddd1ac45a /src/lib/image.cc | |
| parent | 362ed9ee4f73bee21b3ef8d3b449bb8e8877f501 (diff) | |
| parent | 69c08e8bbd5028a65cbddd2aa5f10632bd059191 (diff) | |
Merge delay-decode-take2 branch into master.
Diffstat (limited to 'src/lib/image.cc')
| -rw-r--r-- | src/lib/image.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index d083cf3f6..1fa55e242 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -22,6 +22,7 @@ */ #include <iostream> +#include <openssl/md5.h> extern "C" { #include <libswscale/swscale.h> #include <libavutil/pixfmt.h> @@ -37,6 +38,7 @@ using std::string; using std::min; using std::cout; using std::cerr; +using std::stringstream; using boost::shared_ptr; using libdcp::Size; @@ -619,3 +621,24 @@ Image::aligned () const return _aligned; } +string +Image::digest () const +{ + MD5_CTX md5_context; + MD5_Init (&md5_context); + + for (int i = 0; i < components(); ++i) { + MD5_Update (&md5_context, data()[i], line_size()[i]); + } + + unsigned char digest[MD5_DIGEST_LENGTH]; + MD5_Final (digest, &md5_context); + + stringstream s; + for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) { + s << std::hex << std::setfill('0') << std::setw(2) << ((int) digest[i]); + } + + return s.str (); +} + |
