diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-05-25 22:16:19 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-05-26 21:51:18 +0200 |
| commit | df9b4676aba8b941f124b174393988cad21677e1 (patch) | |
| tree | 21658068cf5b2a74e23339e013398b20b327f886 /src/lib | |
| parent | e444fbd0d7c8a32e9f50adc19d0d49ae7c489a11 (diff) | |
Remove functors for choosing pixel format output from make_image().
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/butler.cc | 3 | ||||
| -rw-r--r-- | src/lib/butler.h | 4 | ||||
| -rw-r--r-- | src/lib/dcp_video.cc | 8 | ||||
| -rw-r--r-- | src/lib/ffmpeg_file_encoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/ffmpeg_film_encoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/mpeg2_encoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/player_video.cc | 25 | ||||
| -rw-r--r-- | src/lib/player_video.h | 9 |
8 files changed, 18 insertions, 45 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 14f342045..5edd84115 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -31,7 +31,6 @@ using std::cout; -using std::function; using std::make_pair; using std::pair; using std::shared_ptr; @@ -65,7 +64,7 @@ Butler::Butler( Player& player, AudioMapping audio_mapping, int audio_channels, - function<AVPixelFormat (AVPixelFormat)> pixel_format, + AVPixelFormat pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, diff --git a/src/lib/butler.h b/src/lib/butler.h index 011f0d28e..d85ec90f4 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -55,7 +55,7 @@ public: Player& player, AudioMapping map, int audio_channels, - std::function<AVPixelFormat(AVPixelFormat)> pixel_format, + AVPixelFormat pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, @@ -135,7 +135,7 @@ private: bool _disable_audio; - std::function<AVPixelFormat (AVPixelFormat)> _pixel_format; + AVPixelFormat _pixel_format; VideoRange _video_range; Image::Alignment _alignment; bool _fast; diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 66c09daca..988a92ac5 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -102,7 +102,7 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame) shared_ptr<dcp::OpenJPEGImage> xyz; if (frame->colour_conversion()) { - auto image = frame->image([](AVPixelFormat) { return AV_PIX_FMT_RGB48LE; }, VideoRange::FULL, false); + auto image = frame->image(AV_PIX_FMT_RGB48LE, VideoRange::FULL, false); xyz = dcp::rgb_to_xyz( image->data()[0], image->size(), @@ -110,7 +110,7 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame) frame->colour_conversion().get() ); } else { - auto image = frame->image([](AVPixelFormat) { return AV_PIX_FMT_XYZ12LE; }, VideoRange::FULL, false); + auto image = frame->image(AV_PIX_FMT_XYZ12LE, VideoRange::FULL, false); xyz = make_shared<dcp::OpenJPEGImage>(image->data()[0], image->size(), image->stride()[0]); } @@ -120,7 +120,7 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame) dcp::Size DCPVideo::get_size() const { - auto image = _frame->image([](AVPixelFormat) { return AV_PIX_FMT_RGB48LE; }, VideoRange::FULL, false); + auto image = _frame->image(AV_PIX_FMT_RGB48LE, VideoRange::FULL, false); return image->size(); } @@ -130,7 +130,7 @@ DCPVideo::convert_to_xyz(uint16_t* dst) const { DCPOMATIC_ASSERT(_frame->colour_conversion()); - auto image = _frame->image([](AVPixelFormat) { return AV_PIX_FMT_RGB48LE; }, VideoRange::FULL, false); + auto image = _frame->image(AV_PIX_FMT_RGB48LE, VideoRange::FULL, false); dcp::rgb_to_xyz( image->data()[0], dst, diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index 7f74ae4f6..8f5a75061 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -417,11 +417,7 @@ void FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time) { /* All our output formats are video range at the moment */ - auto image = video->image ( - bind (&PlayerVideo::force, _pixel_format), - VideoRange::VIDEO, - false - ); + auto image = video->image(_pixel_format, VideoRange::VIDEO, false); auto frame = av_frame_alloc (); DCPOMATIC_ASSERT (frame); diff --git a/src/lib/ffmpeg_film_encoder.cc b/src/lib/ffmpeg_film_encoder.cc index a2d26fd66..f07d6be66 100644 --- a/src/lib/ffmpeg_film_encoder.cc +++ b/src/lib/ffmpeg_film_encoder.cc @@ -71,7 +71,7 @@ FFmpegFilmEncoder::FFmpegFilmEncoder( _player, mixdown_to_stereo ? stereo_map() : many_channel_map(), _output_audio_channels, - boost::bind(&PlayerVideo::force, FFmpegFileEncoder::pixel_format(format)), + FFmpegFileEncoder::pixel_format(format), VideoRange::VIDEO, Image::Alignment::PADDED, false, diff --git a/src/lib/mpeg2_encoder.cc b/src/lib/mpeg2_encoder.cc index 9b9cdfd09..73f3d57e7 100644 --- a/src/lib/mpeg2_encoder.cc +++ b/src/lib/mpeg2_encoder.cc @@ -43,11 +43,7 @@ MPEG2Encoder::encode(shared_ptr<PlayerVideo> pv, dcpomatic::DCPTime time) { VideoEncoder::encode(pv, time); - auto image = pv->image( - [](AVPixelFormat) { return AV_PIX_FMT_YUV420P; }, - VideoRange::VIDEO, - false - ); + auto image = pv->image(AV_PIX_FMT_YUV420P, VideoRange::VIDEO, false); dcp::FFmpegImage ffmpeg_image(time.get() * _film->video_frame_rate() / dcpomatic::DCPTime::HZ); diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index b2da6c33b..05538b845 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -116,7 +116,7 @@ PlayerVideo::set_text (PositionImage image) shared_ptr<Image> -PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const +PlayerVideo::image(AVPixelFormat pixel_format, VideoRange video_range, bool fast) const { /* XXX: this assumes that image() and prepare() are only ever called with the same parameters (except crop, inter size, out size, fade) */ @@ -136,13 +136,11 @@ PlayerVideo::raw_image () const /** 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 - * output pixel format. Two functions force and keep_xyz_or_rgb are provided for use here. + * @param pixel_format Output image pixel format. * @param fast true to be fast at the expense of quality. */ void -PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const +PlayerVideo::make_image(AVPixelFormat pixel_format, VideoRange video_range, bool fast) const { _image_crop = _crop; _image_inter_size = _inter_size; @@ -185,7 +183,7 @@ PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, V } _image = prox.image->crop_scale_window ( - total_crop, _inter_size, _out_size, yuv_to_rgb, _video_range, pixel_format (prox.image->pixel_format()), video_range, Image::Alignment::COMPACT, fast + total_crop, _inter_size, _out_size, yuv_to_rgb, _video_range, pixel_format, video_range, Image::Alignment::COMPACT, fast ); if (_text) { @@ -297,21 +295,8 @@ PlayerVideo::same (shared_ptr<const PlayerVideo> other) const } -AVPixelFormat -PlayerVideo::force (AVPixelFormat force_to) -{ - return force_to; -} - -AVPixelFormat -PlayerVideo::keep_xyz_or_rgb (AVPixelFormat p) -{ - return p == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE; -} - - void -PlayerVideo::prepare (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, bool proxy_only) +PlayerVideo::prepare(AVPixelFormat pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, bool proxy_only) { _in->prepare (alignment, _inter_size); boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/player_video.h b/src/lib/player_video.h index e2968749c..32e462c5f 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -75,13 +75,10 @@ public: return _text; } - void prepare (std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, bool proxy_only); - std::shared_ptr<Image> image (std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const; + void prepare(AVPixelFormat pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast, bool proxy_only); + std::shared_ptr<Image> image(AVPixelFormat pixel_format, VideoRange video_range, bool fast) const; std::shared_ptr<const Image> raw_image () const; - static AVPixelFormat force (AVPixelFormat); - static AVPixelFormat keep_xyz_or_rgb (AVPixelFormat); - void add_metadata(xmlpp::Element* element) const; void write_to_socket (std::shared_ptr<Socket> socket) const; @@ -127,7 +124,7 @@ public: } private: - void make_image (std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const; + void make_image(AVPixelFormat pixel_format, VideoRange video_range, bool fast) const; std::shared_ptr<const ImageProxy> _in; Crop _crop; |
