From 7245e46453a82886739a45bd78fcdf9e8401367c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 11 Sep 2021 18:52:05 +0200 Subject: When the player is used in OpenGL mode, pass unscaled XYZ data through to the shader and do colourspace conversion there. --- src/lib/butler.cc | 2 +- src/lib/butler.h | 11 +++++++++++ src/lib/j2k_image_proxy.cc | 2 +- src/lib/player_video.cc | 12 ++++++++++-- src/lib/player_video.h | 3 ++- 5 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src/lib') diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 5a8e646aa..cbd5ba15d 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -323,7 +323,7 @@ try /* If the weak_ptr cannot be locked the video obviously no longer requires any work */ if (video) { LOG_TIMING("start-prepare in %1", thread_id()); - video->prepare (_pixel_format, _video_range, _aligned, _fast); + video->prepare (_pixel_format, _video_range, _aligned, _fast, _prepare_only_proxy); LOG_TIMING("finish-prepare in %1", thread_id()); } } diff --git a/src/lib/butler.h b/src/lib/butler.h index a231fd099..d31442f6c 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -80,6 +80,9 @@ public: boost::optional get_closed_caption (); void disable_audio (); + void set_prepare_only_proxy (bool p) { + _prepare_only_proxy = p; + } std::pair memory_used () const; @@ -127,6 +130,14 @@ private: bool _aligned; bool _fast; + /** true to ask PlayerVideo::prepare to only prepare the ImageProxy and not also + * the final image. We want to do this when the viewer is intending to call + * PlayerVideo::raw_image() and do the things in PlayerVideo::make_imgae() itself: + * this is the case for the GLVideoView which can do scale, pixfmt conversion etc. + * in the shader. + */ + bool _prepare_only_proxy = false; + /** If we are waiting to be refilled following a seek, this is the time we were seeking to. */ diff --git a/src/lib/j2k_image_proxy.cc b/src/lib/j2k_image_proxy.cc index 144da396d..c98273ad2 100644 --- a/src/lib/j2k_image_proxy.cc +++ b/src/lib/j2k_image_proxy.cc @@ -145,7 +145,7 @@ J2KImageProxy::prepare (optional target_size) const try { /* XXX: should check that potentially trashing _data here doesn't matter */ auto decompressed = dcp::decompress_j2k (const_cast(_data->data()), _data->size(), reduce); - _image.reset (new Image (_pixel_format, decompressed->size(), true)); + _image.reset (new Image (_pixel_format, decompressed->size(), false)); int const shift = 16 - decompressed->precision (0); diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index b0e75972c..0a6ce0d99 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -121,6 +121,14 @@ PlayerVideo::image (function pixel_format, VideoR return _image; } + +shared_ptr +PlayerVideo::raw_image () const +{ + return _in->image(_inter_size).image; +} + + /** Create an image for this frame. A lock must be held on _mutex. * @param pixel_format Function which is called to decide what pixel format the output image should be; * it is passed the pixel format of the input image from the ImageProxy, and should return the desired @@ -290,11 +298,11 @@ PlayerVideo::keep_xyz_or_rgb (AVPixelFormat p) } void -PlayerVideo::prepare (function pixel_format, VideoRange video_range, bool aligned, bool fast) +PlayerVideo::prepare (function pixel_format, VideoRange video_range, bool aligned, bool fast, bool proxy_only) { _in->prepare (_inter_size); boost::mutex::scoped_lock lm (_mutex); - if (!_image) { + if (!_image && !proxy_only) { make_image (pixel_format, video_range, aligned, fast); } } diff --git a/src/lib/player_video.h b/src/lib/player_video.h index f29684832..8134c8d4e 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -71,8 +71,9 @@ public: void set_text (PositionImage); - void prepare (std::function pixel_format, VideoRange video_range, bool aligned, bool fast); + void prepare (std::function pixel_format, VideoRange video_range, bool aligned, bool fast, bool proxy_only); std::shared_ptr image (std::function pixel_format, VideoRange video_range, bool aligned, bool fast) const; + std::shared_ptr raw_image () const; static AVPixelFormat force (AVPixelFormat, AVPixelFormat); static AVPixelFormat keep_xyz_or_rgb (AVPixelFormat); -- cgit v1.2.3