/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2015 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
#include "util.h"
#include "exceptions.h"
-#include "scaler.h"
#include "dcp_content_type.h"
#include "filter.h"
#include "cinema_sound_processor.h"
#include "safe_stringstream.h"
#include <dcp/util.h>
#include <dcp/signer.h>
-#include <dcp/raw_convert.h>
#include <glib.h>
#include <pangomm/init.h>
#include <boost/algorithm/string.hpp>
using std::vector;
using std::min;
using std::max;
+using std::map;
using std::list;
using std::multimap;
using std::istream;
using boost::thread;
using boost::optional;
using dcp::Size;
-using dcp::raw_convert;
/** Path to our executable, required by the stacktrace stuff and filled
* in during App::onInit().
Ratio::setup_ratios ();
VideoContentScale::setup_scales ();
DCPContentType::setup_dcp_content_types ();
- Scaler::setup_scalers ();
Filter::setup_filters ();
CinemaSoundProcessor::setup_cinema_sound_processors ();
AudioProcessor::setup_audio_processors ();
}
boost::uintmax_t this_time = min (to_do, boost::filesystem::file_size (files[i]));
- fseek (f, -this_time, SEEK_END);
+ dcpomatic_fseek (f, -this_time, SEEK_END);
fread (p, 1, this_time, f);
p += this_time;
to_do -= this_time;
return period;
}
+
+map<string, string>
+split_get_request (string url)
+{
+ enum {
+ AWAITING_QUESTION_MARK,
+ KEY,
+ VALUE
+ } state = AWAITING_QUESTION_MARK;
+
+ map<string, string> r;
+ string k;
+ string v;
+ for (size_t i = 0; i < url.length(); ++i) {
+ switch (state) {
+ case AWAITING_QUESTION_MARK:
+ if (url[i] == '?') {
+ state = KEY;
+ }
+ break;
+ case KEY:
+ if (url[i] == '=') {
+ v.clear ();
+ state = VALUE;
+ } else {
+ k += url[i];
+ }
+ break;
+ case VALUE:
+ if (url[i] == '&') {
+ r.insert (make_pair (k, v));
+ k.clear ();
+ state = KEY;
+ } else {
+ v += url[i];
+ }
+ break;
+ }
+ }
+
+ if (state == VALUE) {
+ r.insert (make_pair (k, v));
+ }
+
+ return r;
+}
+
+long
+frame_info_position (int frame, Eyes eyes)
+{
+ static int const info_size = 48;
+
+ switch (eyes) {
+ case EYES_BOTH:
+ return frame * info_size;
+ case EYES_LEFT:
+ return frame * info_size * 2;
+ case EYES_RIGHT:
+ return frame * info_size * 2 + info_size;
+ default:
+ DCPOMATIC_ASSERT (false);
+ }
+
+ DCPOMATIC_ASSERT (false);
+}
+
+dcp::FrameInfo
+read_frame_info (FILE* file, int frame, Eyes eyes)
+{
+ dcp::FrameInfo info;
+ dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
+ fread (&info.offset, sizeof (info.offset), 1, file);
+ fread (&info.size, sizeof (info.size), 1, file);
+
+ char hash_buffer[33];
+ fread (hash_buffer, 1, 32, file);
+ hash_buffer[32] = '\0';
+ info.hash = hash_buffer;
+
+ return info;
+}
+
+void
+write_frame_info (FILE* file, int frame, Eyes eyes, dcp::FrameInfo info)
+{
+ dcpomatic_fseek (file, frame_info_position (frame, eyes), SEEK_SET);
+ fwrite (&info.offset, sizeof (info.offset), 1, file);
+ fwrite (&info.size, sizeof (info.size), 1, file);
+ fwrite (info.hash.c_str(), 1, info.hash.size(), file);
+}