X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg_image_proxy.cc;h=602185bb8b4ade76013935cd6a096a08c957d995;hb=6fa9748f382302fa88292b4219598bb81edc7bd0;hp=fa6cb288d28637ece3f55921cf69edb19fe1065e;hpb=fdc416faa317106d05be8fe5226ded84d8347d99;p=dcpomatic.git diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc index fa6cb288d..602185bb8 100644 --- a/src/lib/ffmpeg_image_proxy.cc +++ b/src/lib/ffmpeg_image_proxy.cc @@ -25,12 +25,15 @@ #include "image.h" #include "compose.hpp" #include "util.h" +#include "warnings.h" #include extern "C" { #include #include } +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_ENABLE_WARNINGS #include #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, shared_ptr 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(amount), static_cast(_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,13 +115,15 @@ FFmpegImageProxy::avio_seek (int64_t const pos, int whence) return _pos; } -pair, int> +DCPOMATIC_DISABLE_WARNINGS + +ImageProxy::Result FFmpegImageProxy::image (optional) const { boost::mutex::scoped_lock lm (_mutex); if (_image) { - return make_pair (_image, 0); + return Result (_image, 0); } uint8_t* avio_buffer = static_cast (wrapped_av_malloc(4096)); @@ -147,7 +152,7 @@ FFmpegImageProxy::image (optional) const } if (e < 0) { if (_path) { - throw OpenFileError (_path->string(), e, true); + throw OpenFileError (_path->string(), e, OpenFileError::READ); } else { boost::throw_exception(DecodeError(String::compose(_("Could not decode image (%1)"), e))); } @@ -192,9 +197,11 @@ FFmpegImageProxy::image (optional) const av_free (avio_context->buffer); av_free (avio_context); - return make_pair (_image, 0); + return Result (_image, 0); } +DCPOMATIC_ENABLE_WARNINGS + void FFmpegImageProxy::add_metadata (xmlpp::Node* node) const { @@ -202,10 +209,10 @@ FFmpegImageProxy::add_metadata (xmlpp::Node* node) const } void -FFmpegImageProxy::send_binary (shared_ptr socket) const +FFmpegImageProxy::write_to_socket (shared_ptr socket) const { socket->write (_data.size()); - socket->write (_data.data().get(), _data.size()); + socket->write (_data.data(), _data.size()); } bool @@ -216,11 +223,7 @@ FFmpegImageProxy::same (shared_ptr 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