#include "../dcpomatic_log.h"
#include "../writer.h"
#include "messenger.h"
+#include <dcp/array_data.h>
-class Film;
static std::mutex launchMutex;
}
};
-struct GrokInitializer {
- GrokInitializer(void) {
- setMessengerLogger(new GrokLogger("[GROK] "));
- }
- ~GrokInitializer() = default;
-};
-
struct FrameProxy {
FrameProxy(int index, Eyes eyes, DCPVideo dcpv) : index_(index), eyes_(eyes), vf(dcpv)
{}
};
struct DcpomaticContext {
- DcpomaticContext(std::shared_ptr<const Film> film, Writer& writer,
- EventHistory &history, const std::string &location) :
- film_(film), writer_(writer),
- history_(history), location_(location),
- width_(0), height_(0)
- {}
+ DcpomaticContext(
+ std::shared_ptr<const Film> film,
+ Writer& writer,
+ EventHistory& history,
+ boost::filesystem::path const& location
+ )
+ : film_(film)
+ , writer_(writer)
+ , history_(history)
+ , _location(location)
+ , width_(0)
+ , height_(0)
+ {
+
+ }
+
void setDimensions(uint32_t w, uint32_t h) {
width_ = w;
height_ = h;
std::shared_ptr<const Film> film_;
Writer& writer_;
EventHistory &history_;
- std::string location_;
+ boost::filesystem::path _location;
uint32_t width_;
uint32_t height_;
};
-class GrokContext {
+
+class GrokContext
+{
public:
- explicit GrokContext(const DcpomaticContext &dcpomaticContext) :
- dcpomaticContext_(dcpomaticContext),
- messenger_(nullptr),
- launched_(false)
+ explicit GrokContext(DcpomaticContext const& dcpomatic_context)
+ : _dcpomatic_context(dcpomatic_context)
+ , messenger_(nullptr)
+ , launched_(false)
{
- struct CompressedData : public dcp::Data {
- explicit CompressedData(int dataLen) : data_(new uint8_t[dataLen]), dataLen_(dataLen)
- {}
- ~CompressedData(void){
- delete[] data_;
- }
- uint8_t const * data () const override {
- return data_;
- }
- uint8_t * data () override {
- return data_;
- }
- int size () const override {
- return dataLen_;
- }
- uint8_t *data_;
- int dataLen_;
- };
if (Config::instance()->enable_gpu ()) {
- boost::filesystem::path folder(dcpomaticContext_.location_);
+ boost::filesystem::path folder(_dcpomatic_context._location);
boost::filesystem::path binaryPath = folder / "grk_compress";
if (!boost::filesystem::exists(binaryPath)) {
- getMessengerLogger()->error("Invalid binary location %s",
- dcpomaticContext_.location_.c_str());
- return;
+ getMessengerLogger()->error(
+ "Invalid binary location %s", _dcpomatic_context._location.c_str()
+ );
+ return;
}
auto proc = [this](const std::string& str) {
try {
auto processor =
[this](FrameProxy srcFrame, uint8_t* compressed, uint32_t compressedFrameLength)
{
- auto compressedData = std::make_shared<CompressedData>(compressedFrameLength);
- memcpy(compressedData->data_,compressed,compressedFrameLength );
- dcpomaticContext_.writer_.write(compressedData, srcFrame.index(), srcFrame.eyes());
+ auto compressed_data = std::make_shared<dcp::ArrayData>(compressed, compressedFrameLength);
+ _dcpomatic_context.writer_.write(compressed_data, srcFrame.index(), srcFrame.eyes());
frame_done ();
};
int const minimum_size = 16384;
}
auto encoded = std::make_shared<dcp::ArrayData>(fp->vf.encode_locally());
- dcpomaticContext_.writer_.write(encoded, fp->vf.index(), fp->vf.eyes());
+ _dcpomatic_context.writer_.write(encoded, fp->vf.index(), fp->vf.eyes());
frame_done ();
}
}
return true;
if (MessengerInit::firstLaunch(true)) {
auto s = dcpv.get_size();
- dcpomaticContext_.setDimensions(s.width, s.height);
+ _dcpomatic_context.setDimensions(s.width, s.height);
auto config = Config::instance();
- messenger_->launchGrok(dcpomaticContext_.location_,
- dcpomaticContext_.width_,dcpomaticContext_.width_,
- dcpomaticContext_.height_,
- 3, 12, device,
- dcpomaticContext_.film_->resolution() == Resolution::FOUR_K,
- dcpomaticContext_.film_->video_frame_rate(),
- dcpomaticContext_.film_->j2k_bandwidth(),
- config->gpu_license_server(),
- config->gpu_license_port(),
- config->gpu_license());
+ messenger_->launchGrok(
+ _dcpomatic_context._location,
+ _dcpomatic_context.width_,_dcpomatic_context.width_,
+ _dcpomatic_context.height_,
+ 3, 12, device,
+ _dcpomatic_context.film_->resolution() == Resolution::FOUR_K,
+ _dcpomatic_context.film_->video_frame_rate(),
+ _dcpomatic_context.film_->j2k_bandwidth(),
+ config->gpu_license_server(),
+ config->gpu_license_port(),
+ config->gpu_license()
+ );
}
launched_ = messenger_->waitForClientInit();
messenger_ = nullptr;
}
void frame_done () {
- dcpomaticContext_.history_.event ();
+ _dcpomatic_context.history_.event();
}
private:
- DcpomaticContext dcpomaticContext_;
+ DcpomaticContext _dcpomatic_context;
ScheduledMessenger<FrameProxy> *messenger_;
bool launched_;
};