X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fffmpeg_image_proxy.cc;h=e26f4b040f26177412a829fbb009f057ebc2b0c9;hb=refs%2Fheads%2Fcompose;hp=7b23221011474a246675977f9f7b260b29199484;hpb=1516214cdc7970797b79bca06b46a2eed16a1da3;p=dcpomatic.git diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc index 7b2322101..e26f4b040 100644 --- a/src/lib/ffmpeg_image_proxy.cc +++ b/src/lib/ffmpeg_image_proxy.cc @@ -19,7 +19,6 @@ */ -#include "compose.hpp" #include "cross.h" #include "dcpomatic_socket.h" #include "exceptions.h" @@ -27,13 +26,14 @@ #include "image.h" #include "util.h" #include "warnings.h" +#include #include +DCPOMATIC_DISABLE_WARNINGS extern "C" { #include #include #include } -DCPOMATIC_DISABLE_WARNINGS #include DCPOMATIC_ENABLE_WARNINGS #include @@ -53,26 +53,23 @@ using std::dynamic_pointer_cast; using dcp::raw_convert; -FFmpegImageProxy::FFmpegImageProxy (boost::filesystem::path path, VideoRange video_range) +FFmpegImageProxy::FFmpegImageProxy (boost::filesystem::path path) : _data (path) - , _video_range (video_range) , _pos (0) , _path (path) { } -FFmpegImageProxy::FFmpegImageProxy (dcp::ArrayData data, VideoRange video_range) +FFmpegImageProxy::FFmpegImageProxy (dcp::ArrayData data) : _data (data) - , _video_range (video_range) , _pos (0) { } -FFmpegImageProxy::FFmpegImageProxy (shared_ptr node, shared_ptr socket) - : _video_range (string_to_video_range(node->string_child("VideoRange"))) - , _pos (0) +FFmpegImageProxy::FFmpegImageProxy (shared_ptr socket) + : _pos (0) { uint32_t const size = socket->read_uint32 (); _data = dcp::ArrayData (size); @@ -163,13 +160,13 @@ FFmpegImageProxy::image (optional) const if (_path) { throw OpenFileError (_path->string(), e, OpenFileError::READ); } else { - boost::throw_exception(DecodeError(String::compose(_("Could not decode image (%1)"), e))); + boost::throw_exception(DecodeError(dcp::compose(_("Could not decode image (%1)"), e))); } } int r = avformat_find_stream_info(format_context, 0); if (r < 0) { - throw DecodeError (N_("avcodec_find_stream_info"), name_for_errors, r); + throw DecodeError (N_("avcodec_find_stream_info"), name_for_errors, r, *_path); } DCPOMATIC_ASSERT (format_context->nb_streams == 1); @@ -184,40 +181,31 @@ FFmpegImageProxy::image (optional) const auto context = avcodec_alloc_context3 (codec); if (!context) { - throw DecodeError (N_("avcodec_alloc_context3"), name_for_errors); + throw DecodeError (N_("avcodec_alloc_context3"), name_for_errors, *_path); } r = avcodec_open2 (context, codec, 0); if (r < 0) { - throw DecodeError (N_("avcodec_open2"), name_for_errors, r); + throw DecodeError (N_("avcodec_open2"), name_for_errors, r, *_path); } AVPacket packet; r = av_read_frame (format_context, &packet); if (r < 0) { - throw DecodeError (N_("av_read_frame"), name_for_errors, r); + throw DecodeError (N_("av_read_frame"), name_for_errors, r, *_path); } r = avcodec_send_packet (context, &packet); if (r < 0) { - throw DecodeError (N_("avcodec_send_packet"), name_for_errors, r); + throw DecodeError (N_("avcodec_send_packet"), name_for_errors, r, *_path); } r = avcodec_receive_frame (context, frame); if (r < 0) { - throw DecodeError (N_("avcodec_receive_frame"), name_for_errors, r); + throw DecodeError (N_("avcodec_receive_frame"), name_for_errors, r, *_path); } - auto const pix_fmt = static_cast(frame->format); - _image = make_shared(frame); - if (_video_range == VideoRange::VIDEO && av_pix_fmt_desc_get(pix_fmt)->flags & AV_PIX_FMT_FLAG_RGB) { - /* Asking for the video range to be converted by libswscale (in Image) will not work for - * RGB sources since that method only processes video range in YUV and greyscale. So we have - * to do it ourselves here. - */ - _image->video_range_to_full_range(); - } av_packet_unref (&packet); av_frame_free (&frame); @@ -234,7 +222,6 @@ void FFmpegImageProxy::add_metadata (xmlpp::Node* node) const { node->add_child("Type")->add_child_text (N_("FFmpeg")); - node->add_child("VideoRange")->add_child_text(video_range_to_string(_video_range)); } void @@ -247,7 +234,7 @@ FFmpegImageProxy::write_to_socket (shared_ptr socket) const bool FFmpegImageProxy::same (shared_ptr other) const { - shared_ptr mp = dynamic_pointer_cast (other); + auto mp = dynamic_pointer_cast(other); if (!mp) { return false; }