Write still j2ks straight to a MXF.
Seem to be problems when waiting for (failing) server threads at the end of an encode;
their frames aren't reprocessed locally.
+md5_data to use openssl
Standardise j2c/j2k
Format name in ~/.dvdomatic screws up with spaces; use ID or something
_state.audio_sample_rate = d->audio_sample_rate ();
_state.audio_sample_format = d->audio_sample_format ();
+ _state.content_digest = md5_digest (c);
_state.content = c;
signal_changed (SIZE);
settings.
*/
s << _state.format->nickname()
- << "_" << _state.content
+ << "_" << _state.content_digest
<< "_" << left_crop() << "_" << right_crop() << "_" << top_crop() << "_" << bottom_crop()
<< "_" << f.first << "_" << f.second
<< "_" << _state.scaler->id();
f << "audio_channels " << audio_channels << "\n";
f << "audio_sample_rate " << audio_sample_rate << "\n";
f << "audio_sample_format " << audio_sample_format_to_string (audio_sample_format) << "\n";
+ f << "content_digest " << content_digest << "\n";
}
/** Read state from a key / value pair.
audio_sample_rate = atoi (v.c_str ());
} else if (k == "audio_sample_format") {
audio_sample_format = audio_sample_format_from_string (v);
+ } else if (k == "content_digest") {
+ content_digest = v;
+ }
+
+ /* Itsy bitsy hack: compute digest here if don't have one (for backwards compatibility) */
+ if (content_digest.empty() && !content.empty()) {
+ content_digest = md5_digest (file (content));
}
}
int audio_sample_rate;
/** Format of the audio samples */
AVSampleFormat audio_sample_format;
+ /** MD5 digest of our content file */
+ std::string content_digest;
private:
std::string thumb_file_for_frame (int) const;
#include <sstream>
#include <iomanip>
#include <iostream>
+#include <fstream>
#ifdef DVDOMATIC_POSIX
#include <execinfo.h>
#include <cxxabi.h>
#include <signal.h>
#include <boost/algorithm/string.hpp>
#include <openjpeg.h>
+#include <openssl/md5.h>
#include <magick/MagickCore.h>
#include <magick/version.h>
#include <libdcp/version.h>
}
#endif
+string
+md5_digest (string file)
+{
+ ifstream f (file.c_str(), ios::binary);
+ if (!f.good ()) {
+ throw OpenFileError (file);
+ }
+
+ f.seekg (0, ios::end);
+ int bytes = f.tellg ();
+ f.seekg (0, ios::beg);
+
+ int const buffer_size = 64 * 1024;
+ char buffer[buffer_size];
+
+ MD5_CTX md5_context;
+ MD5_Init (&md5_context);
+ while (bytes > 0) {
+ int const t = min (bytes, buffer_size);
+ f.read (buffer, t);
+ MD5_Update (&md5_context, buffer, t);
+ bytes -= t;
+ }
+
+ unsigned char digest[MD5_DIGEST_LENGTH];
+ MD5_Final (digest, &md5_context);
+
+ stringstream s;
+ for (int i = 0; i < MD5_DIGEST_LENGTH; ++i) {
+ s << hex << setfill('0') << setw(2) << ((int) digest[i]);
+ }
+
+ return s.str ();
+}
extern double seconds (struct timeval);
extern void dvdomatic_setup ();
extern std::vector<std::string> split_at_spaces_considering_quotes (std::string);
+extern std::string md5_digest (std::string);
enum ContentType {
STILL,
audio_channels 0
audio_sample_rate 0
audio_sample_format Unknown
+content_digest
do_negative_delay_line_test (-3, 512);
do_negative_delay_line_test (-512, 3);
}
+
+BOOST_AUTO_TEST_CASE (md5_digest_test)
+{
+ string const t = md5_digest ("test/md5.test");
+ BOOST_CHECK_EQUAL (t, "15058685ba99decdc4398c7634796eb0");
+
+ BOOST_CHECK_THROW (md5_digest ("foobar"), OpenFileError);
+}