2014-06-03 Carl Hetherington <cth@carlh.net>
+ * Re-calculate audio plots when the mapping is changed.
+
* Version 1.69.19 released.
2014-06-02 Carl Hetherington <cth@carlh.net>
}
boost::filesystem::path p = film->audio_analysis_dir ();
- p /= digest ();
+ p /= digest() + "_" + audio_mapping().digest();
return p;
}
#include <libdcp/raw_convert.h>
#include "audio_mapping.h"
#include "util.h"
+#include "md5_digester.h"
using std::list;
using std::cout;
}
}
}
+
+/** @return a string which is unique for a given AudioMapping configuration, for
+ * differentiation between different AudioMappings.
+ */
+string
+AudioMapping::digest () const
+{
+ MD5Digester digester;
+ digester.add (_content_channels);
+ for (int i = 0; i < _content_channels; ++i) {
+ for (int j = 0; j < MAX_DCP_AUDIO_CHANNELS; ++j) {
+ digester.add (_gain[i][j]);
+ }
+ }
+
+ return digester.get ();
+}
int content_channels () const {
return _content_channels;
}
+
+ std::string digest () const;
private:
void setup (int);
#include "config.h"
#include "colour_conversion.h"
#include "util.h"
+#include "md5_digester.h"
#include "i18n.h"
string
ColourConversion::identifier () const
{
- double numbers[12];
-
- int n = 0;
- numbers[n++] = input_gamma;
- numbers[n++] = input_gamma_linearised;
+ MD5Digester digester;
+
+ digester.add (input_gamma);
+ digester.add (input_gamma_linearised);
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
- numbers[n++] = matrix (i, j);
+ digester.add (matrix (i, j));
}
}
- numbers[n++] = output_gamma;
-
- assert (n == 12);
-
- return md5_digest (numbers, 12 * sizeof (double));
+ digester.add (output_gamma);
+
+ return digester.get ();
}
PresetColourConversion::PresetColourConversion ()
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/filesystem.hpp>
-#include <openssl/md5.h>
#include <libdcp/rec709_linearised_gamma_lut.h>
#include <libdcp/srgb_linearised_gamma_lut.h>
#include <libdcp/gamma_lut.h>
matrix
);
- {
- MD5_CTX md5_context;
- MD5_Init (&md5_context);
- MD5_Update (&md5_context, xyz->data(0), 1998 * 1080 * 4);
- MD5_Update (&md5_context, xyz->data(1), 1998 * 1080 * 4);
- MD5_Update (&md5_context, xyz->data(2), 1998 * 1080 * 4);
- 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]);
- }
- }
-
/* Set the max image and component sizes based on frame_rate */
int max_cs_len = ((float) _j2k_bandwidth) / 8 / _frames_per_second;
if (_frame->eyes() == EYES_LEFT || _frame->eyes() == EYES_RIGHT) {
*/
#include <iostream>
-#include <openssl/md5.h>
extern "C" {
#include <libswscale/swscale.h>
#include <libavutil/pixfmt.h>
#include "image.h"
#include "exceptions.h"
#include "scaler.h"
+#include "md5_digester.h"
#include "i18n.h"
string
Image::digest () const
{
- MD5_CTX md5_context;
- MD5_Init (&md5_context);
+ MD5Digester digester;
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]);
+ digester.add (data()[i], line_size()[i]);
}
- return s.str ();
+ return digester.get ();
}
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <iomanip>
+#include <sstream>
+#include <openssl/md5.h>
+#include "md5_digester.h"
+
+using std::string;
+using std::stringstream;
+using std::hex;
+using std::setfill;
+using std::setw;
+
+MD5Digester::MD5Digester ()
+{
+ MD5_Init (&_context);
+}
+
+MD5Digester::~MD5Digester ()
+{
+ get ();
+}
+
+void
+MD5Digester::add (void const * data, size_t size)
+{
+ MD5_Update (&_context, data, size);
+}
+
+string
+MD5Digester::get () const
+{
+ if (!_digest) {
+ unsigned char digest[MD5_DIGEST_LENGTH];
+ MD5_Final (digest, &_context);
+
+ stringstream s;
+ for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) {
+ s << hex << setfill('0') << setw(2) << ((int) digest[i]);
+ }
+
+ _digest = s.str ();
+ }
+
+ return _digest.get ();
+}
--- /dev/null
+/*
+ Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <string>
+#include <boost/noncopyable.hpp>
+#include <boost/optional.hpp>
+#include <openssl/md5.h>
+
+class MD5Digester : public boost::noncopyable
+{
+public:
+ MD5Digester ();
+ ~MD5Digester ();
+
+ void add (void const * data, size_t size);
+
+ template <class T>
+ void add (T data) {
+ add (&data, sizeof (T));
+ }
+
+ std::string get () const;
+
+private:
+ mutable MD5_CTX _context;
+ mutable boost::optional<std::string> _digest;
+};
#include "job.h"
#include "config.h"
#include "util.h"
+#include "md5_digester.h"
#include "i18n.h"
}
}
- return md5_digest (t.c_str(), t.length());
+ MD5Digester digester;
+ digester.add (t.c_str(), t.length());
+ return digester.get ();
}
/** @param node <Playlist> node */
#endif
#include <glib.h>
#include <openjpeg.h>
-#include <openssl/md5.h>
#include <magick/MagickCore.h>
#include <magick/version.h>
#include <libdcp/version.h>
#include "job.h"
#include "cross.h"
#include "video_content.h"
+#include "md5_digester.h"
#ifdef DCPOMATIC_WINDOWS
#include "stack.hpp"
#endif
return out;
}
-string
-md5_digest (void const * data, int size)
-{
- MD5_CTX md5_context;
- MD5_Init (&md5_context);
- MD5_Update (&md5_context, data, size);
- 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 ();
-}
-
/** @param job Optional job for which to report progress */
string
md5_digest (vector<boost::filesystem::path> files, shared_ptr<Job> job)
boost::uintmax_t const buffer_size = 64 * 1024;
char buffer[buffer_size];
- MD5_CTX md5_context;
- MD5_Init (&md5_context);
+ MD5Digester digester;
vector<int64_t> sizes;
for (size_t i = 0; i < files.size(); ++i) {
while (remaining > 0) {
int const t = min (remaining, buffer_size);
fread (buffer, 1, t, f);
- MD5_Update (&md5_context, buffer, t);
+ digester.add (buffer, t);
remaining -= t;
if (job) {
fclose (f);
}
- 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 ();
+ return digester.get ();
}
static bool
extern void dcpomatic_setup_gettext_i18n (std::string);
extern std::vector<std::string> split_at_spaces_considering_quotes (std::string);
extern std::string md5_digest (std::vector<boost::filesystem::path>, boost::shared_ptr<Job>);
-extern std::string md5_digest (void const *, int);
extern void ensure_ui_thread ();
extern std::string audio_channel_name (int);
extern bool valid_image_file (boost::filesystem::path);
#include "config.h"
#include "job.h"
#include "cross.h"
+#include "md5_digester.h"
#include "i18n.h"
LOG_GENERAL ("Existing frame %1 is incomplete", f);
return false;
}
-
- string const existing_hash = md5_digest (data.data(), data.size());
- if (existing_hash != info.hash) {
+
+ MD5Digester digester;
+ digester.add (data.data(), data.size());
+ if (digester.get() != info.hash) {
LOG_GENERAL ("Existing frame %1 failed hash check", f);
return false;
}
kdm.cc
json_server.cc
log.cc
+ md5_digester.cc
piece.cc
player.cc
player_video_frame.cc