summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-14 21:07:59 +0200
committerCarl Hetherington <cth@carlh.net>2025-10-14 21:07:59 +0200
commit535764f8c15a8b1b976f3e9edd7d7a8763f04e32 (patch)
tree8257fe489c1bb43e4b55cd268b8f0beaab7c11bb
parent45923ef4c7bbd0454c58887770c437e1f2232e31 (diff)
Add alignment parameter to PlayerVideo::image().
-rw-r--r--src/lib/dcp_video.cc6
-rw-r--r--src/lib/ffmpeg_file_encoder.cc2
-rw-r--r--src/lib/player_video.cc10
-rw-r--r--src/lib/player_video.h4
-rw-r--r--src/tools/dcpomatic_player.cc4
-rw-r--r--src/wx/gl_video_view.cc2
-rw-r--r--src/wx/simple_video_view.cc2
-rw-r--r--test/dcp_playback_test.cc2
-rw-r--r--test/player_test.cc10
-rw-r--r--test/video_level_test.cc2
-rw-r--r--test/video_trim_test.cc2
11 files changed, 23 insertions, 23 deletions
diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc
index 775298091..fa9daee09 100644
--- a/src/lib/dcp_video.cc
+++ b/src/lib/dcp_video.cc
@@ -108,7 +108,7 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame)
return fmt == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE;
};
- auto image = frame->image(conversion, VideoRange::FULL, false);
+ auto image = frame->image(conversion, VideoRange::FULL, Image::Alignment::COMPACT, false);
if (frame->colour_conversion()) {
xyz = dcp::rgb_to_xyz(
@@ -127,7 +127,7 @@ DCPVideo::convert_to_xyz(shared_ptr<const PlayerVideo> frame)
dcp::Size
DCPVideo::get_size() const
{
- auto image = _frame->image(force(AV_PIX_FMT_RGB48LE), VideoRange::FULL, false);
+ auto image = _frame->image(force(AV_PIX_FMT_RGB48LE), VideoRange::FULL, Image::Alignment::COMPACT, false);
return image->size();
}
@@ -137,7 +137,7 @@ DCPVideo::convert_to_xyz(uint16_t* dst) const
{
DCPOMATIC_ASSERT(_frame->colour_conversion());
- auto image = _frame->image(force(AV_PIX_FMT_RGB48LE), VideoRange::FULL, false);
+ auto image = _frame->image(force(AV_PIX_FMT_RGB48LE), VideoRange::FULL, Image::Alignment::COMPACT, 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 9f391df5d..07b54306b 100644
--- a/src/lib/ffmpeg_file_encoder.cc
+++ b/src/lib/ffmpeg_file_encoder.cc
@@ -417,7 +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(force(_pixel_format), VideoRange::VIDEO, false);
+ auto image = video->image(force(_pixel_format), VideoRange::VIDEO, Image::Alignment::COMPACT, false);
auto frame = av_frame_alloc();
DCPOMATIC_ASSERT(frame);
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index a3868856b..cd802636f 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -116,13 +116,13 @@ PlayerVideo::set_text(PositionImage image)
shared_ptr<Image>
-PlayerVideo::image(function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const
+PlayerVideo::image(function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, 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) */
boost::mutex::scoped_lock lm(_mutex);
if (!_image || _crop != _image_crop || _inter_size != _image_inter_size || _out_size != _image_out_size || _fade != _image_fade) {
- make_image(pixel_format, video_range, fast);
+ make_image(pixel_format, video_range, alignment, fast);
}
return _image;
}
@@ -140,7 +140,7 @@ PlayerVideo::raw_image() const
* @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(function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast) const
{
_image_crop = _crop;
_image_inter_size = _inter_size;
@@ -183,7 +183,7 @@ PlayerVideo::make_image(function<AVPixelFormat (AVPixelFormat)> pixel_format, Vi
}
_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(prox.image->pixel_format()), video_range, alignment, fast
);
if (_text) {
@@ -301,7 +301,7 @@ PlayerVideo::prepare(AVPixelFormat pixel_format, VideoRange video_range, Image::
_in->prepare(alignment, _inter_size);
boost::mutex::scoped_lock lm(_mutex);
if (!_image && !proxy_only) {
- make_image(force(pixel_format), video_range, fast);
+ make_image(force(pixel_format), video_range, Image::Alignment::COMPACT, fast);
}
}
diff --git a/src/lib/player_video.h b/src/lib/player_video.h
index 48c927f85..837f5737d 100644
--- a/src/lib/player_video.h
+++ b/src/lib/player_video.h
@@ -76,7 +76,7 @@ public:
}
void prepare(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;
+ std::shared_ptr<Image> image(std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast) const;
std::shared_ptr<const Image> raw_image() const;
void add_metadata(xmlpp::Element* element) const;
@@ -128,7 +128,7 @@ public:
}
private:
- void make_image(std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool fast) const;
+ void make_image(std::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, Image::Alignment alignment, bool fast) const;
std::shared_ptr<const ImageProxy> _in;
Crop _crop;
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index 31a2c2551..3581df13d 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -847,10 +847,10 @@ private:
player->Video.connect([path, &done, this](shared_ptr<PlayerVideo> video, DCPTime) {
auto ext = boost::algorithm::to_lower_copy(path.extension().string());
if (ext == ".png") {
- auto image = video->image(force(AV_PIX_FMT_RGBA), VideoRange::FULL, false);
+ auto image = video->image(force(AV_PIX_FMT_RGBA), VideoRange::FULL, Image::Alignment::COMPACT, false);
image_as_png(image).write(path);
} else if (ext == ".jpg" || ext == ".jpeg") {
- auto image = video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, false);
+ auto image = video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false);
image_as_jpeg(image, 80).write(path);
} else {
error_dialog(this, wxString::Format(_("Unrecognised file extension %s (use .jpg, .jpeg or .png)"), std_to_wx(ext)));
diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc
index 3df7a724c..64a2d71cb 100644
--- a/src/wx/gl_video_view.cc
+++ b/src/wx/gl_video_view.cc
@@ -622,7 +622,7 @@ GLVideoView::set_image(shared_ptr<const PlayerVideo> pv)
video = pv->raw_image();
break;
case Optimisation::NONE:
- video = pv->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, true);
+ video = pv->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true);
break;
}
diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc
index 3fbfe25cc..b16ea641a 100644
--- a/src/wx/simple_video_view.cc
+++ b/src/wx/simple_video_view.cc
@@ -252,7 +252,7 @@ SimpleVideoView::update ()
_state_timer.set ("get image");
auto const pv = player_video();
- _image = pv.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, true);
+ _image = pv.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true);
if (pv.first->colour_conversion() && pv.first->colour_conversion()->about_equal(dcp::ColourConversion::rec2020_to_xyz(), 1e-6)) {
_image = Image::ensure_alignment(_rec2020_filter_graph.get(_image->size(), _image->pixel_format())->process(_image).front(), Image::Alignment::COMPACT);
}
diff --git a/test/dcp_playback_test.cc b/test/dcp_playback_test.cc
index 752ae56a2..c9e32efc4 100644
--- a/test/dcp_playback_test.cc
+++ b/test/dcp_playback_test.cc
@@ -60,6 +60,6 @@ BOOST_AUTO_TEST_CASE (dcp_playback_test)
}
/* assuming DCP is 24fps/48kHz */
butler->get_audio (Butler::Behaviour::BLOCKING, audio_buffer.data(), 2000);
- p.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, true);
+ p.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true);
}
}
diff --git a/test/player_test.cc b/test/player_test.cc
index 7fc21ac36..82c84e150 100644
--- a/test/player_test.cc
+++ b/test/player_test.cc
@@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test)
butler->seek (t, true);
auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0);
BOOST_CHECK_EQUAL(video.second.get(), t.get());
- write_image(video.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, true), fmt::format("build/test/player_seek_test_{}.png", i));
+ write_image(video.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true), fmt::format("build/test/player_seek_test_{}.png", i));
/* This 14.08 is empirically chosen (hopefully) to accept changes in rendering between the reference and a test machine
(17.10 and 16.04 seem to anti-alias a little differently) but to reject gross errors e.g. missing fonts or missing
text altogether.
@@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE (player_seek_test2)
auto video = butler->get_video(Butler::Behaviour::BLOCKING, 0);
BOOST_CHECK_EQUAL(video.second.get(), t.get());
write_image(
- video.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, true), fmt::format("build/test/player_seek_test2_{}.png", i)
+ video.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true), fmt::format("build/test/player_seek_test2_{}.png", i)
);
check_image(TestPaths::private_data() / fmt::format("player_seek_test2_{}.png", i), fmt::format("build/test/player_seek_test2_{}.png", i), 14.08);
}
@@ -618,7 +618,7 @@ BOOST_AUTO_TEST_CASE(two_d_in_three_d_duplicates)
}
last_time = time;
- auto image = video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, false);
+ auto image = video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false);
auto const size = image->size();
for (int y = 0; y < size.height; ++y) {
uint8_t* line = image->data()[0] + y * image->stride()[0];
@@ -668,7 +668,7 @@ BOOST_AUTO_TEST_CASE(three_d_in_two_d_chooses_left)
BOOST_CHECK(!last_time || time == *last_time + DCPTime::from_frames(1, 24));
last_time = time;
- auto image = video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, false);
+ auto image = video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false);
auto const size = image->size();
for (int y = 0; y < size.height; ++y) {
uint8_t* line = image->data()[0] + y * image->stride()[0];
@@ -745,7 +745,7 @@ BOOST_AUTO_TEST_CASE(frames_are_copied_correctly_for_low_frame_rates)
/* Check that only red frames come out - previously there would be some black ones mixed in */
for (auto i = 0; i < 24; ++i) {
auto frame = butler.get_video(Butler::Behaviour::BLOCKING);
- auto image = frame.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, false);
+ auto image = frame.first->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false);
for (int y = 0; y < image->size().height; ++y) {
uint8_t const* p = image->data()[0] + image->stride()[0] * y;
for (int x = 0; x < image->size().width; ++x) {
diff --git a/test/video_level_test.cc b/test/video_level_test.cc
index 802c8c8fa..dd90e72f6 100644
--- a/test/video_level_test.cc
+++ b/test/video_level_test.cc
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_image_video_range_expanded)
BOOST_REQUIRE (!player->pass());
}
- auto image = player_video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, false);
+ auto image = player_video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, false);
for (int y = 0; y < size.height; ++y) {
uint8_t* p = image->data()[0] + y * image->stride()[0];
diff --git a/test/video_trim_test.cc b/test/video_trim_test.cc
index 8ec96dde5..8cae23ec7 100644
--- a/test/video_trim_test.cc
+++ b/test/video_trim_test.cc
@@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(video_trim_test)
BOOST_REQUIRE(!player->pass());
}
- image_as_png(first_video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, true)).write("build/test/video_trim_test.png");
+ image_as_png(first_video->image(force(AV_PIX_FMT_RGB24), VideoRange::FULL, Image::Alignment::COMPACT, true)).write("build/test/video_trim_test.png");
check_image("test/data/video_trim_test.png", "build/test/video_trim_test.png");
}