Replace dcp::Data with dcp::ArrayData
[dcpomatic.git] / src / lib / ffmpeg_image_proxy.cc
index db6059266dc472e13b8908a67f5baf0b2a800618..602185bb8b4ade76013935cd6a096a08c957d995 100644 (file)
 #include "image.h"
 #include "compose.hpp"
 #include "util.h"
+#include "warnings.h"
 #include <dcp/raw_convert.h>
 extern "C" {
 #include <libavcodec/avcodec.h>
 #include <libavformat/avformat.h>
 }
+DCPOMATIC_DISABLE_WARNINGS
 #include <libxml++/libxml++.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <iostream>
 
 #include "i18n.h"
@@ -53,7 +56,7 @@ FFmpegImageProxy::FFmpegImageProxy (boost::filesystem::path path)
 
 }
 
-FFmpegImageProxy::FFmpegImageProxy (dcp::Data data)
+FFmpegImageProxy::FFmpegImageProxy (dcp::ArrayData data)
        : _data (data)
        , _pos (0)
 {
@@ -64,8 +67,8 @@ FFmpegImageProxy::FFmpegImageProxy (shared_ptr<cxml::Node>, shared_ptr<Socket> s
        : _pos (0)
 {
        uint32_t const size = socket->read_uint32 ();
-       _data = dcp::Data (size);
-       socket->read (_data.data().get(), size);
+       _data = dcp::ArrayData (size);
+       socket->read (_data.data(), size);
 }
 
 static int
@@ -83,11 +86,11 @@ avio_seek_wrapper (void* data, int64_t offset, int whence)
 int
 FFmpegImageProxy::avio_read (uint8_t* buffer, int const amount)
 {
-       int const to_do = min(int64_t(amount), _data.size() - _pos);
+       int const to_do = min(static_cast<int64_t>(amount), static_cast<int64_t>(_data.size()) - _pos);
        if (to_do == 0) {
                return AVERROR_EOF;
        }
-       memcpy (buffer, _data.data().get() + _pos, to_do);
+       memcpy (buffer, _data.data() + _pos, to_do);
        _pos += to_do;
        return to_do;
 }
@@ -112,6 +115,7 @@ FFmpegImageProxy::avio_seek (int64_t const pos, int whence)
        return _pos;
 }
 
+DCPOMATIC_DISABLE_WARNINGS
 
 ImageProxy::Result
 FFmpegImageProxy::image (optional<dcp::Size>) const
@@ -196,6 +200,8 @@ FFmpegImageProxy::image (optional<dcp::Size>) const
        return Result (_image, 0);
 }
 
+DCPOMATIC_ENABLE_WARNINGS
+
 void
 FFmpegImageProxy::add_metadata (xmlpp::Node* node) const
 {
@@ -206,7 +212,7 @@ void
 FFmpegImageProxy::write_to_socket (shared_ptr<Socket> socket) const
 {
        socket->write (_data.size());
-       socket->write (_data.data().get(), _data.size());
+       socket->write (_data.data(), _data.size());
 }
 
 bool
@@ -217,11 +223,7 @@ FFmpegImageProxy::same (shared_ptr<const ImageProxy> other) const
                return false;
        }
 
-       if (_data.size() != mp->_data.size()) {
-               return false;
-       }
-
-       return memcmp (_data.data().get(), mp->_data.data().get(), _data.size()) == 0;
+       return _data == mp->_data;
 }
 
 size_t