Use dcp::ArrayData instead of custom struct.
[dcpomatic.git] / src / lib / grok_context.cc
index 14df64c15555ac3ecc5d159e8d8edba563727fa1..31363f01204d4874d9c079e223ddf40eec4839f9 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "grok_context.h"
+#include <dcp/array_data.h>
 
 
 using namespace grk_plugin;
@@ -114,38 +115,6 @@ GrokContext::GrokContext(const DcpomaticContext& dcpomaticContext)
        , _messenger(nullptr)
        , _launched(false)
 {
-       struct CompressedData : public dcp::Data
-       {
-               explicit CompressedData(int dataLen)
-                       : data_(new uint8_t[dataLen])
-                       , dataLen_(dataLen)
-               {
-               }
-
-               ~CompressedData()
-               {
-                       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()) {
                DCPOMATIC_ASSERT(_dcpomatic_context.location);
                boost::filesystem::path folder(*_dcpomatic_context.location);
@@ -165,9 +134,9 @@ GrokContext::GrokContext(const DcpomaticContext& dcpomaticContext)
                                        auto compressedFrameLength = msg.next_uint();
                                        auto processor =
                                            [this](FrameProxy srcFrame, uint8_t* compressed, uint32_t compressedFrameLength) {
-                                                   auto compressedData = std::make_shared<CompressedData>(compressedFrameLength);
-                                                   memcpy(compressedData->data_, compressed, compressedFrameLength);
-                                                   _dcpomatic_context.writer.write(compressedData, srcFrame.index(), srcFrame.eyes());
+                                                   auto compressed_data = std::make_shared<dcp::ArrayData>(compressedFrameLength);
+                                                   memcpy(compressed_data->data(), compressed, compressedFrameLength);
+                                                   _dcpomatic_context.writer.write(compressed_data, srcFrame.index(), srcFrame.eyes());
                                                    frame_done();
                                            };
                                        int const minimum_size = 16384;