X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fimage.cc;h=8e7a51fd8d39371c278b65c125e710396565be21;hb=8102046b2f29e0c7b234c29bf204b056cb30e64f;hp=432cfbd54b9279e0b2631cc417b511066dc2ab2f;hpb=cfdd68eb5fb0ef8423e860103ad4e5510994f1da;p=dcpomatic.git diff --git a/src/lib/image.cc b/src/lib/image.cc index 432cfbd54..8e7a51fd8 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -32,6 +32,7 @@ extern "C" { #include "scaler.h" #include "timer.h" #include "rect.h" +#include "md5_digester.h" #include "i18n.h" @@ -40,6 +41,7 @@ using std::min; using std::cout; using std::cerr; using std::list; +using std::stringstream; using boost::shared_ptr; using dcp::Size; @@ -511,8 +513,13 @@ Image::allocate () OS X crashes on this illegal read, though other operating systems don't seem to mind. The nasty + 1 in this malloc makes sure there is always a byte for that instruction to read safely. + + Further to the above, valgrind is now telling me that ff_rgb24ToY_ssse3 + over-reads by more then _avx. I can't follow the code to work out how much, + so I'll just over-allocate by 32 bytes and have done with it. Empirical + testing suggests that it works. */ - _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * lines (i) + 1); + _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * lines (i) + 32); } } @@ -662,3 +669,15 @@ merge (list images) return PositionImage (merged, all.position ()); } + +string +Image::digest () const +{ + MD5Digester digester; + + for (int i = 0; i < components(); ++i) { + digester.add (data()[i], line_size()[i]); + } + + return digester.get (); +}