diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-07-21 23:42:00 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-07-21 23:42:00 +0200 |
| commit | aeaf8995c5eaff87720b3c7d5bc014183abdddd8 (patch) | |
| tree | 30f3e997f23bb8dc650a3ba7d137acc271ce0126 /src/lib/ffmpeg_image_proxy.cc | |
| parent | 7511fa9bb8d8b39d11f687dd55193d3e554a0874 (diff) | |
White space: ffmpeg_image_proxy.{cc,h}
Diffstat (limited to 'src/lib/ffmpeg_image_proxy.cc')
| -rw-r--r-- | src/lib/ffmpeg_image_proxy.cc | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src/lib/ffmpeg_image_proxy.cc b/src/lib/ffmpeg_image_proxy.cc index 9ba8f8bf5..c476bfc25 100644 --- a/src/lib/ffmpeg_image_proxy.cc +++ b/src/lib/ffmpeg_image_proxy.cc @@ -53,55 +53,55 @@ using boost::optional; using std::dynamic_pointer_cast; -FFmpegImageProxy::FFmpegImageProxy (boost::filesystem::path path) - : _data (path) - , _pos (0) - , _path (path) +FFmpegImageProxy::FFmpegImageProxy(boost::filesystem::path path) + : _data(path) + , _pos(0) + , _path(path) { } -FFmpegImageProxy::FFmpegImageProxy (dcp::ArrayData data) - : _data (data) - , _pos (0) +FFmpegImageProxy::FFmpegImageProxy(dcp::ArrayData data) + : _data(data) + , _pos(0) { } -FFmpegImageProxy::FFmpegImageProxy (shared_ptr<Socket> socket) - : _pos (0) +FFmpegImageProxy::FFmpegImageProxy(shared_ptr<Socket> socket) + : _pos(0) { - uint32_t const size = socket->read_uint32 (); - _data = dcp::ArrayData (size); - socket->read (_data.data(), size); + uint32_t const size = socket->read_uint32(); + _data = dcp::ArrayData(size); + socket->read(_data.data(), size); } static int -avio_read_wrapper (void* data, uint8_t* buffer, int amount) +avio_read_wrapper(void* data, uint8_t* buffer, int amount) { - return reinterpret_cast<FFmpegImageProxy*>(data)->avio_read (buffer, amount); + return reinterpret_cast<FFmpegImageProxy*>(data)->avio_read(buffer, amount); } static int64_t -avio_seek_wrapper (void* data, int64_t offset, int whence) +avio_seek_wrapper(void* data, int64_t offset, int whence) { - return reinterpret_cast<FFmpegImageProxy*>(data)->avio_seek (offset, whence); + return reinterpret_cast<FFmpegImageProxy*>(data)->avio_seek(offset, whence); } int -FFmpegImageProxy::avio_read (uint8_t* buffer, int const amount) +FFmpegImageProxy::avio_read(uint8_t* buffer, int const amount) { 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() + _pos, to_do); + memcpy(buffer, _data.data() + _pos, to_do); _pos += to_do; return to_do; } int64_t -FFmpegImageProxy::avio_seek (int64_t const pos, int whence) +FFmpegImageProxy::avio_seek(int64_t const pos, int whence) { switch (whence) { case AVSEEK_SIZE: @@ -122,19 +122,19 @@ FFmpegImageProxy::avio_seek (int64_t const pos, int whence) ImageProxy::Result -FFmpegImageProxy::image (Image::Alignment alignment, optional<dcp::Size>) const +FFmpegImageProxy::image(Image::Alignment alignment, optional<dcp::Size>) const { auto constexpr name_for_errors = "FFmpegImageProxy::image"; - boost::mutex::scoped_lock lm (_mutex); + boost::mutex::scoped_lock lm(_mutex); if (_image) { - return Result (_image, 0); + return Result(_image, 0); } - uint8_t* avio_buffer = static_cast<uint8_t*> (wrapped_av_malloc(4096)); - auto avio_context = avio_alloc_context (avio_buffer, 4096, 0, const_cast<FFmpegImageProxy*>(this), avio_read_wrapper, 0, avio_seek_wrapper); - AVFormatContext* format_context = avformat_alloc_context (); + uint8_t* avio_buffer = static_cast<uint8_t*>(wrapped_av_malloc(4096)); + auto avio_context = avio_alloc_context(avio_buffer, 4096, 0, const_cast<FFmpegImageProxy*>(this), avio_read_wrapper, 0, avio_seek_wrapper); + AVFormatContext* format_context = avformat_alloc_context(); format_context->pb = avio_context; AVDictionary* options = nullptr; @@ -144,21 +144,21 @@ FFmpegImageProxy::image (Image::Alignment alignment, optional<dcp::Size>) const av_dict_set(&options, "analyzeduration", fmt::to_string(5 * 60 * 1000000).c_str(), 0); av_dict_set(&options, "probesize", fmt::to_string(5 * 60 * 1000000).c_str(), 0); - int e = avformat_open_input (&format_context, 0, 0, &options); + int e = avformat_open_input(&format_context, 0, 0, &options); if ((e < 0 && e == AVERROR_INVALIDDATA) || (e >= 0 && format_context->probe_score <= 25)) { /* Hack to fix loading of .tga files through AVIOContexts (rather then directly from the file). This code just does enough to allow the probe code to take a hint from "foo.tga" and so try targa format. */ - auto f = av_find_input_format ("image2"); - format_context = avformat_alloc_context (); + auto f = av_find_input_format("image2"); + format_context = avformat_alloc_context(); format_context->pb = avio_context; format_context->iformat = f; - e = avformat_open_input (&format_context, "foo.tga", f, &options); + e = avformat_open_input(&format_context, "foo.tga", f, &options); } if (e < 0) { if (_path) { - throw OpenFileError (_path->string(), e, OpenFileError::READ); + throw OpenFileError(_path->string(), e, OpenFileError::READ); } else { boost::throw_exception(DecodeError(fmt::format(_("Could not decode image ({})"), e))); } @@ -166,43 +166,43 @@ FFmpegImageProxy::image (Image::Alignment alignment, optional<dcp::Size>) const int r = avformat_find_stream_info(format_context, 0); if (r < 0) { - throw DecodeError (N_("avcodec_find_stream_info"), name_for_errors, r, *_path); + throw DecodeError(N_("avcodec_find_stream_info"), name_for_errors, r, *_path); } - DCPOMATIC_ASSERT (format_context->nb_streams == 1); + DCPOMATIC_ASSERT(format_context->nb_streams == 1); - auto frame = av_frame_alloc (); + auto frame = av_frame_alloc(); if (!frame) { - std::bad_alloc (); + std::bad_alloc(); } - auto codec = avcodec_find_decoder (format_context->streams[0]->codecpar->codec_id); - DCPOMATIC_ASSERT (codec); + auto codec = avcodec_find_decoder(format_context->streams[0]->codecpar->codec_id); + DCPOMATIC_ASSERT(codec); - auto context = avcodec_alloc_context3 (codec); + auto context = avcodec_alloc_context3(codec); if (!context) { - throw DecodeError (N_("avcodec_alloc_context3"), name_for_errors, *_path); + throw DecodeError(N_("avcodec_alloc_context3"), name_for_errors, *_path); } - r = avcodec_open2 (context, codec, 0); + r = avcodec_open2(context, codec, 0); if (r < 0) { - throw DecodeError (N_("avcodec_open2"), name_for_errors, r, *_path); + throw DecodeError(N_("avcodec_open2"), name_for_errors, r, *_path); } AVPacket packet; - r = av_read_frame (format_context, &packet); + r = av_read_frame(format_context, &packet); if (r < 0) { - throw DecodeError (N_("av_read_frame"), name_for_errors, r, *_path); + throw DecodeError(N_("av_read_frame"), name_for_errors, r, *_path); } - r = avcodec_send_packet (context, &packet); + r = avcodec_send_packet(context, &packet); if (r < 0) { - throw DecodeError (N_("avcodec_send_packet"), name_for_errors, r, *_path); + throw DecodeError(N_("avcodec_send_packet"), name_for_errors, r, *_path); } - r = avcodec_receive_frame (context, frame); + r = avcodec_receive_frame(context, frame); if (r < 0) { - throw DecodeError (N_("avcodec_receive_frame"), name_for_errors, r, *_path); + throw DecodeError(N_("avcodec_receive_frame"), name_for_errors, r, *_path); } if (av_pix_fmt_desc_get(context->pix_fmt)->flags & AV_PIX_FMT_FLAG_ALPHA) { @@ -220,14 +220,14 @@ FFmpegImageProxy::image (Image::Alignment alignment, optional<dcp::Size>) const _image = make_shared<Image>(frame, alignment); } - av_packet_unref (&packet); - av_frame_free (&frame); - avcodec_free_context (&context); - avformat_close_input (&format_context); - av_free (avio_context->buffer); - av_free (avio_context); + av_packet_unref(&packet); + av_frame_free(&frame); + avcodec_free_context(&context); + avformat_close_input(&format_context); + av_free(avio_context->buffer); + av_free(avio_context); - return Result (_image, 0); + return Result(_image, 0); } @@ -238,14 +238,14 @@ FFmpegImageProxy::add_metadata(xmlpp::Element* element) const } void -FFmpegImageProxy::write_to_socket (shared_ptr<Socket> socket) const +FFmpegImageProxy::write_to_socket(shared_ptr<Socket> socket) const { - socket->write (_data.size()); - socket->write (_data.data(), _data.size()); + socket->write(_data.size()); + socket->write(_data.data(), _data.size()); } bool -FFmpegImageProxy::same (shared_ptr<const ImageProxy> other) const +FFmpegImageProxy::same(shared_ptr<const ImageProxy> other) const { auto mp = dynamic_pointer_cast<const FFmpegImageProxy>(other); if (!mp) { @@ -256,7 +256,7 @@ FFmpegImageProxy::same (shared_ptr<const ImageProxy> other) const } size_t -FFmpegImageProxy::memory_used () const +FFmpegImageProxy::memory_used() const { size_t m = _data.size(); if (_image) { |
