From ae4471c0aa06e40532778791f10f780b312ac88d Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Wed, 21 Oct 2026 20:34:34 +0200 Subject: [PATCH 1/7] Add tests for the 5.1, 7.1 and monitor downmix maps Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- test/downmix_test.cc | 170 +++++++++++++++++++++++++++++++++++++++++++ test/wscript | 1 + 2 files changed, 171 insertions(+) create mode 100644 test/downmix_test.cc diff --git a/test/downmix_test.cc b/test/downmix_test.cc new file mode 100644 index 000000000..459e8c888 --- /dev/null +++ b/test/downmix_test.cc @@ -0,0 +1,170 @@ +/* + Copyright (C) 2026 Jaume Puig + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +/** @file test/downmix_test.cc + * @brief Test the 5.1 to stereo, 7.1 to stereo and 7.1 to 5.1 downmix maps (doc/design/downmix_7_1_to_5_1.md). + * @ingroup selfcontained + */ + + +#include "lib/audio_mapping.h" +#include "lib/config.h" +#include "lib/constants.h" +#include +#include +#include + + +static int +ch(dcp::Channel channel) +{ + return static_cast(channel); +} + + +static void +check_gain(AudioMapping const& map, dcp::Channel input, int output, float expected) +{ + BOOST_TEST_INFO("input " << ch(input) << " output " << output); + if (expected == 0) { + BOOST_CHECK_SMALL(map.get(ch(input), output), 1e-6F); + } else { + BOOST_CHECK_CLOSE(map.get(ch(input), output), expected, 0.01); + } +} + + +/** 5.1 to stereo: the rule the stereo mixdown export has always used, L = g * (L + 0.707 C + Ls) with g = 2 / (4 + sqrt(2)) */ +BOOST_AUTO_TEST_CASE(downmix_5_1_to_stereo_test) +{ + float const g = 2 / (4 + std::sqrt(2.0F)); + float const c = g / std::sqrt(2.0F); + + auto const map = stereo_downmix_map(6, MAX_DCP_AUDIO_CHANNELS); + + check_gain(map, dcp::Channel::LEFT, 0, g); + check_gain(map, dcp::Channel::LEFT, 1, 0); + check_gain(map, dcp::Channel::RIGHT, 0, 0); + check_gain(map, dcp::Channel::RIGHT, 1, g); + check_gain(map, dcp::Channel::CENTRE, 0, c); + check_gain(map, dcp::Channel::CENTRE, 1, c); + check_gain(map, dcp::Channel::LS, 0, g); + check_gain(map, dcp::Channel::LS, 1, 0); + check_gain(map, dcp::Channel::RS, 0, 0); + check_gain(map, dcp::Channel::RS, 1, g); + check_gain(map, dcp::Channel::LFE, 0, 0); + check_gain(map, dcp::Channel::LFE, 1, 0); + check_gain(map, dcp::Channel::BSL, 0, 0); + check_gain(map, dcp::Channel::BSR, 1, 0); + + /* Full-level coherent content cannot overflow: the gains into each output add up to 1 */ + BOOST_CHECK_CLOSE(map.get(ch(dcp::Channel::LEFT), 0) + map.get(ch(dcp::Channel::CENTRE), 0) + map.get(ch(dcp::Channel::LS), 0), 1.0F, 0.01); + BOOST_CHECK_CLOSE(map.get(ch(dcp::Channel::RIGHT), 1) + map.get(ch(dcp::Channel::CENTRE), 1) + map.get(ch(dcp::Channel::RS), 1), 1.0F, 0.01); +} + + +/** 7.1 goes through 5.1 first: L, R and C keep the 5.1 gains and each of the four surrounds enters at -3 dB of the 5.1 surround gain */ +BOOST_AUTO_TEST_CASE(downmix_7_1_to_stereo_test) +{ + float const g = 2 / (4 + std::sqrt(2.0F)); + float const c = g / std::sqrt(2.0F); + + auto const map = stereo_downmix_map(MAX_DCP_AUDIO_CHANNELS, MAX_DCP_AUDIO_CHANNELS); + + check_gain(map, dcp::Channel::LEFT, 0, g); + check_gain(map, dcp::Channel::RIGHT, 1, g); + check_gain(map, dcp::Channel::CENTRE, 0, c); + check_gain(map, dcp::Channel::CENTRE, 1, c); + check_gain(map, dcp::Channel::LS, 0, c); + check_gain(map, dcp::Channel::LS, 1, 0); + check_gain(map, dcp::Channel::BSL, 0, c); + check_gain(map, dcp::Channel::BSL, 1, 0); + check_gain(map, dcp::Channel::RS, 1, c); + check_gain(map, dcp::Channel::RS, 0, 0); + check_gain(map, dcp::Channel::BSR, 1, c); + check_gain(map, dcp::Channel::BSR, 0, 0); + check_gain(map, dcp::Channel::LFE, 0, 0); + check_gain(map, dcp::Channel::LFE, 1, 0); + + /* A 7.1 film is not louder than a 5.1 one in L, R and C */ + auto const five_one = stereo_downmix_map(6, MAX_DCP_AUDIO_CHANNELS); + for (auto channel: { dcp::Channel::LEFT, dcp::Channel::RIGHT, dcp::Channel::CENTRE }) { + for (int output = 0; output < 2; ++output) { + BOOST_TEST_INFO("input " << ch(channel) << " output " << output); + BOOST_CHECK_EQUAL(map.get(ch(channel), output), five_one.get(ch(channel), output)); + } + } +} + + +/** 2-channel films are passed through unchanged */ +BOOST_AUTO_TEST_CASE(downmix_stereo_film_test) +{ + auto const map = stereo_downmix_map(2, MAX_DCP_AUDIO_CHANNELS); + check_gain(map, dcp::Channel::LEFT, 0, 1); + check_gain(map, dcp::Channel::LEFT, 1, 0); + check_gain(map, dcp::Channel::RIGHT, 0, 0); + check_gain(map, dcp::Channel::RIGHT, 1, 1); + check_gain(map, dcp::Channel::CENTRE, 0, 0); +} + + +/** Monitor with 6 outputs and a 7.1 film: Ls = 0.707 Lss + 0.707 Lrs, Rs = 0.707 Rss + 0.707 Rrs, everything else 1:1 */ +BOOST_AUTO_TEST_CASE(downmix_7_1_to_5_1_monitor_test) +{ + float const minus_3dB = 1 / std::sqrt(2.0F); + + auto const map = Config::instance()->audio_mapping(6, MAX_DCP_AUDIO_CHANNELS); + BOOST_CHECK_EQUAL(map.input_channels(), MAX_DCP_AUDIO_CHANNELS); + BOOST_CHECK_EQUAL(map.output_channels(), 6); + + for (auto channel: { dcp::Channel::LEFT, dcp::Channel::RIGHT, dcp::Channel::CENTRE, dcp::Channel::LFE }) { + check_gain(map, channel, ch(channel), 1); + } + check_gain(map, dcp::Channel::LS, ch(dcp::Channel::LS), minus_3dB); + check_gain(map, dcp::Channel::RS, ch(dcp::Channel::RS), minus_3dB); + check_gain(map, dcp::Channel::BSL, ch(dcp::Channel::LS), minus_3dB); + check_gain(map, dcp::Channel::BSR, ch(dcp::Channel::RS), minus_3dB); + + /* No cross-feed between sides */ + check_gain(map, dcp::Channel::LS, ch(dcp::Channel::RS), 0); + check_gain(map, dcp::Channel::RS, ch(dcp::Channel::LS), 0); + check_gain(map, dcp::Channel::BSL, ch(dcp::Channel::RS), 0); + check_gain(map, dcp::Channel::BSR, ch(dcp::Channel::LS), 0); +} + + +/** Monitor with 6 outputs and a 5.1 film passes unchanged: the rear channels are not folded */ +BOOST_AUTO_TEST_CASE(downmix_5_1_monitor_passthrough_test) +{ + auto const map = Config::instance()->audio_mapping(6, 6); + BOOST_CHECK_EQUAL(map.output_channels(), 6); + + for (int i = 0; i < 6; ++i) { + BOOST_TEST_INFO("channel " << i); + BOOST_CHECK_CLOSE(map.get(i, i), 1.0F, 0.01); + } + check_gain(map, dcp::Channel::BSL, ch(dcp::Channel::LS), 0); + check_gain(map, dcp::Channel::BSR, ch(dcp::Channel::RS), 0); + + /* Leave the cached default for a full-size film, as the Player would regenerate it */ + Config::instance()->audio_mapping(6, MAX_DCP_AUDIO_CHANNELS); +} diff --git a/test/wscript b/test/wscript index d616ffe0c..cd0bd389d 100644 --- a/test/wscript +++ b/test/wscript @@ -76,6 +76,7 @@ def build(bld): cover_sheet_test.cc cpl_hash_test.cc cpl_metadata_test.cc + downmix_test.cc create_cli_test.cc dcpomatic_time_test.cc dcp_decoder_test.cc From d14708954144db5076a6d84b5fb6422d0441ae55 Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Thu, 22 Oct 2026 05:55:08 +0200 Subject: [PATCH 2/7] Keep tests on their own config after ConfigRestorer ConfigRestorer's destructor cleared the override path shared by Config and State, so every test after the first ConfigRestorer read the user's real configuration from $HOME. A default facility code there leaked into the ISDCF name tests. Restore build/test/state instead. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- test/test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test.cc b/test/test.cc index 27b00b9d3..c0d04ce2d 100644 --- a/test/test.cc +++ b/test/test.cc @@ -1095,7 +1095,8 @@ ConfigRestorer::ConfigRestorer(boost::filesystem::path override_path) ConfigRestorer::~ConfigRestorer() { - Config::override_path = boost::none; + /* Back to the tests' own state directory, as set up by TestConfig, rather than $HOME */ + Config::override_path = "build/test/state"; setup_test_config(); } From cf4e4d5d6ed41a60a8172c0b62fdc150a2b23fea Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Thu, 22 Oct 2026 15:02:29 +0200 Subject: [PATCH 3/7] Add tests for the stereo monitor map, default mapping, Butler limiter and 7.1 export Cover what the downmix changes left untested: the 4-channel stereo map, Config::audio_mapping(2, ...) giving the same map as the export, a default mapping following the film's channel count and not being saved while a user's mapping is, the limiter gain carrying over between buffers, the Butler limiting a mapping that would clip, and the stereo mixdown export of a 7.1 film taking the rear surrounds. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- test/butler_test.cc | 43 +++++++++++++++++ test/downmix_test.cc | 92 +++++++++++++++++++++++++++++++++++++ test/ffmpeg_encoder_test.cc | 51 ++++++++++++++++++++ test/limiter_test.cc | 20 ++++++++ 4 files changed, 206 insertions(+) diff --git a/test/butler_test.cc b/test/butler_test.cc index 21e33b1a3..5aa804545 100644 --- a/test/butler_test.cc +++ b/test/butler_test.cc @@ -85,6 +85,49 @@ BOOST_AUTO_TEST_CASE (butler_test1) } +/** The Butler limits the peaks of its mapped audio, so a mapping that adds up to more than full scale cannot clip */ +BOOST_AUTO_TEST_CASE(butler_limits_peaks_test) +{ + auto video = content_factory("test/data/flat_red.png")[0]; + auto audio = content_factory("test/data/staircase.wav")[0]; + auto film = new_test_film("butler_limits_peaks_test", { video, audio }); + film->set_audio_channels(6); + + /* The staircase is on the centre channel; send it to both outputs far too loud */ + auto map = AudioMapping(6, 2); + map.set(dcp::Channel::CENTRE, 0, 1000); + map.set(dcp::Channel::CENTRE, 1, 1000); + + Player player(film, Image::Alignment::COMPACT, false); + + Butler butler( + film, + player, + map, + 2, + AV_PIX_FMT_RGB24, + VideoRange::FULL, + Image::Alignment::COMPACT, + false, + false, + Butler::Video::ENABLED, + Butler::Audio::ENABLED + ); + + butler.get_video(Butler::Behaviour::BLOCKING, 0); + + float buffer[2048 * 2]; + BOOST_REQUIRE(butler.get_audio(Butler::Behaviour::BLOCKING, buffer, 2048) == DCPTime()); + float peak = 0; + for (auto sample: buffer) { + peak = std::max(peak, std::fabs(sample)); + } + /* Without the limiter the staircase would reach 1000 * 2047 / 32768, about 62 */ + BOOST_CHECK(peak <= 1.0f + 1e-6f); + BOOST_CHECK(peak > 0.5f); +} + + BOOST_AUTO_TEST_CASE (butler_test2) { auto content = content_factory(TestPaths::private_data() / "arrietty_JP-EN.mkv"); diff --git a/test/downmix_test.cc b/test/downmix_test.cc index 459e8c888..43684d668 100644 --- a/test/downmix_test.cc +++ b/test/downmix_test.cc @@ -28,7 +28,9 @@ #include "lib/audio_mapping.h" #include "lib/config.h" #include "lib/constants.h" +#include "test.h" #include +#include #include #include @@ -168,3 +170,93 @@ BOOST_AUTO_TEST_CASE(downmix_5_1_monitor_passthrough_test) /* Leave the cached default for a full-size film, as the Player would regenerate it */ Config::instance()->audio_mapping(6, MAX_DCP_AUDIO_CHANNELS); } + + +/** 4-channel films keep the rule the stereo mixdown export has always used */ +BOOST_AUTO_TEST_CASE(downmix_4_channel_film_test) +{ + float const g = 2 / (4 + std::sqrt(2.0F)); + float const c = g / std::sqrt(2.0F); + + auto const map = stereo_downmix_map(4, MAX_DCP_AUDIO_CHANNELS); + + check_gain(map, dcp::Channel::LEFT, 0, g); + check_gain(map, dcp::Channel::LEFT, 1, 0); + check_gain(map, dcp::Channel::RIGHT, 0, 0); + check_gain(map, dcp::Channel::RIGHT, 1, g); + check_gain(map, dcp::Channel::CENTRE, 0, c); + check_gain(map, dcp::Channel::CENTRE, 1, c); + check_gain(map, dcp::Channel::LS, 0, g); + check_gain(map, dcp::Channel::LS, 1, 0); + check_gain(map, dcp::Channel::RS, 0, 0); + check_gain(map, dcp::Channel::RS, 1, 0); +} + + +/** Monitor with 2 outputs: the same downmix as the stereo mixdown export, with no LFE */ +BOOST_AUTO_TEST_CASE(downmix_stereo_monitor_test) +{ + for (auto film_channels: { 6, MAX_DCP_AUDIO_CHANNELS }) { + auto const map = Config::instance()->audio_mapping(2, film_channels); + auto const expected = stereo_downmix_map(film_channels, MAX_DCP_AUDIO_CHANNELS); + BOOST_REQUIRE_EQUAL(map.input_channels(), MAX_DCP_AUDIO_CHANNELS); + BOOST_REQUIRE_EQUAL(map.output_channels(), 2); + for (int input = 0; input < MAX_DCP_AUDIO_CHANNELS; ++input) { + for (int output = 0; output < 2; ++output) { + BOOST_TEST_INFO("film channels " << film_channels << " input " << input << " output " << output); + BOOST_CHECK_EQUAL(map.get(input, output), expected.get(input, output)); + } + } + check_gain(map, dcp::Channel::LFE, 0, 0); + check_gain(map, dcp::Channel::LFE, 1, 0); + } +} + + +/** A default mapping follows the film's channel count; a mapping the user set does not, and is kept */ +BOOST_AUTO_TEST_CASE(downmix_default_follows_film_test) +{ + boost::filesystem::path const dir = "build/test/downmix_default_follows_film_test"; + boost::filesystem::remove_all(dir); + boost::filesystem::create_directories(dir); + ConfigRestorer cr(dir); + + float const minus_3dB = 1 / std::sqrt(2.0F); + + check_gain(Config::instance()->audio_mapping(6, 6), dcp::Channel::BSL, ch(dcp::Channel::LS), 0); + check_gain(Config::instance()->audio_mapping(6, MAX_DCP_AUDIO_CHANNELS), dcp::Channel::BSL, ch(dcp::Channel::LS), minus_3dB); + check_gain(Config::instance()->audio_mapping(6, 6), dcp::Channel::BSL, ch(dcp::Channel::LS), 0); + + auto user = AudioMapping(MAX_DCP_AUDIO_CHANNELS, 6); + user.set(dcp::Channel::BSL, ch(dcp::Channel::LS), 0.25); + Config::instance()->set_audio_mapping(user); + + check_gain(Config::instance()->audio_mapping(6, 6), dcp::Channel::BSL, ch(dcp::Channel::LS), 0.25); + check_gain(Config::instance()->audio_mapping(6, MAX_DCP_AUDIO_CHANNELS), dcp::Channel::BSL, ch(dcp::Channel::LS), 0.25); +} + + +/** A default mapping is not written to config.xml; one the user set is, and going back to the default removes it */ +BOOST_AUTO_TEST_CASE(downmix_default_mapping_not_saved_test) +{ + boost::filesystem::path const dir = "build/test/downmix_default_mapping_not_saved_test"; + boost::filesystem::remove_all(dir); + boost::filesystem::create_directories(dir); + ConfigRestorer cr(dir); + + auto saved = []() { + Config::instance()->write_config(); + return dcp::file_to_string(Config::config_write_file()).find("") != std::string::npos; + }; + + Config::instance()->audio_mapping(2, 6); + BOOST_CHECK(!saved()); + + auto user = AudioMapping(MAX_DCP_AUDIO_CHANNELS, 2); + user.set(dcp::Channel::LEFT, 0, 0.5); + Config::instance()->set_audio_mapping(user); + BOOST_CHECK(saved()); + + Config::instance()->set_audio_mapping_to_default(); + BOOST_CHECK(!saved()); +} diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index da2a78bf1..e29f4dd78 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -39,7 +39,9 @@ #include "test.h" #include #include +#include #include +#include using std::make_shared; @@ -594,3 +596,52 @@ BOOST_AUTO_TEST_CASE(ffmpeg_encoder_vob_to_wav_test) } +/** The stereo mixdown export of a 7.1 film takes the rear surrounds too (see stereo_downmix_map) */ +BOOST_AUTO_TEST_CASE(ffmpeg_encoder_mixdown_7_1_rear_surround_test) +{ + Cleanup cl; + + /* One second of a constant 0.25 on a mono WAV, which goes to the film's left rear surround (Lrs) */ + boost::filesystem::path const input = "build/test/ffmpeg_encoder_mixdown_7_1_rear_surround_test_in.wav"; + cl.add(input); + SF_INFO in_info = {}; + in_info.samplerate = 48000; + in_info.channels = 1; + in_info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; + auto in_file = sf_open(input.string().c_str(), SFM_WRITE, &in_info); + BOOST_REQUIRE(in_file); + vector constant(48000, 8192); + sf_write_short(in_file, constant.data(), constant.size()); + sf_close(in_file); + + auto content = content_factory(input)[0]; + auto film = new_test_film("ffmpeg_encoder_mixdown_7_1_rear_surround_test", { content }, &cl); + film->set_audio_channels(12); + AudioMapping map(1, MAX_DCP_AUDIO_CHANNELS); + map.set(0, static_cast(dcp::Channel::BSL), 1); + content->audio->set_mapping(map); + + boost::filesystem::path const output = "build/test/ffmpeg_encoder_mixdown_7_1_rear_surround_test.wav"; + cl.add(output); + auto job = make_shared(film, TranscodeJob::ChangedBehaviour::IGNORE); + FFmpegFilmEncoder encoder(film, job, output, ExportFormat::WAV_16, true, false, false, 23); + encoder.go(); + + SF_INFO out_info = {}; + auto out_file = sf_open(output.string().c_str(), SFM_READ, &out_info); + BOOST_REQUIRE(out_file); + BOOST_REQUIRE_EQUAL(out_info.channels, 2); + BOOST_REQUIRE(out_info.frames > 24000); + vector samples(out_info.frames * 2); + sf_readf_short(out_file, samples.data(), out_info.frames); + sf_close(out_file); + + /* Lrs enters the left output at -3 dB of the 5.1 surround gain 2 / (4 + sqrt(2)) and the right output not at all */ + float const expected = 8192 * (2 / (4 + std::sqrt(2.0F))) / std::sqrt(2.0F); + BOOST_CHECK_CLOSE(static_cast(samples[24000 * 2]), expected, 1); + BOOST_CHECK(std::abs(samples[24000 * 2 + 1]) <= 1); + + cl.run(); +} + + diff --git a/test/limiter_test.cc b/test/limiter_test.cc index 1c13016e6..ce6dfcf76 100644 --- a/test/limiter_test.cc +++ b/test/limiter_test.cc @@ -60,3 +60,23 @@ BOOST_AUTO_TEST_CASE(limiter_test) /* The gain comes back to 1 within a second */ BOOST_CHECK(gain > 0.99f); } + + +/** The gain carries over from one buffer to the next: after a peak at the end of one buffer the next starts quieter and recovers */ +BOOST_AUTO_TEST_CASE(limiter_gain_carries_over_test) +{ + auto first = make_shared(1, 100); + first->make_silent(); + first->data(0)[99] = 2.0f; + float gain = 1; + limit_peaks(first, gain, 48000); + BOOST_CHECK_CLOSE(gain, 0.5f, 0.01); + + auto second = make_shared(1, 100); + for (int i = 0; i < 100; ++i) { + second->data(0)[i] = 0.5f; + } + limit_peaks(second, gain, 48000); + BOOST_CHECK_CLOSE(second->data(0)[0], 0.25f, 0.1); + BOOST_CHECK(second->data(0)[99] > second->data(0)[0]); +} From c35c0645454b24321b965e1a04edd9f8653b84c1 Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Thu, 22 Oct 2026 16:32:40 +0200 Subject: [PATCH 4/7] Fix the colourspace property with FFmpeg 7.1. FFmpeg 7.1 added AVCOL_SPC_IPT_C2, AVCOL_SPC_YCGCO_RE and AVCOL_SPC_YCGCO_RO (AVCOL_SPC_NB = 18) but still has libpostproc, so it is built without DCPOMATIC_FFMPEG_8 and the assertion that AVCOL_SPC_NB is 15 fails when the properties of an FFmpeg content are listed. Always list the three names and check AVCOL_SPC_NB <= 18, as is done for the primaries and transfer characteristics. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- src/lib/ffmpeg_content.cc | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 3ab9bfb0c..73a996d25 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -655,21 +655,14 @@ FFmpegContent::add_properties(shared_ptr film, list& p _("SMPTE 2085, Y'D'zD'x"), _("Chroma-derived non-constant luminance"), _("Chroma-derived constant luminance"), -#ifdef DCPOMATIC_FFMPEG_8 - _("BT2100"), - _("SMPTE ST 2128, IPT-C2"), - _("YCgCo-R, even addition"), - _("YCgCo-R, odd addition") -#else - _("BT2100") -#endif + _("BT2100"), + /* These three are in FFmpeg 7.1 and later */ + _("SMPTE ST 2128, IPT-C2"), + _("YCgCo-R, even addition"), + _("YCgCo-R, odd addition") }; -#ifdef DCPOMATIC_FFMPEG_8 - DCPOMATIC_ASSERT(AVCOL_SPC_NB == 18); -#else - DCPOMATIC_ASSERT(AVCOL_SPC_NB == 15); -#endif + DCPOMATIC_ASSERT(AVCOL_SPC_NB <= 18); p.push_back(UserProperty(UserProperty::VIDEO, _("Colourspace"), spaces[_colorspace.get_value_or(AVCOL_SPC_UNSPECIFIED)])); From fd244aeca921974dc698869825d2fbca886743ce Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Thu, 22 Oct 2026 16:32:42 +0200 Subject: [PATCH 5/7] Find the server in real_encode_with_server without a broadcast. The test relied on EncodeServerFinder's UDP broadcast to 255.255.255.255 reaching the server on the same machine. Where a broadcast is not allowed (a sandbox, a machine without a network) no server was found, every frame was encoded locally and the test failed. Ask 127.0.0.1 directly instead, and put the configuration back afterwards (before dropping the finder, which stays connected to Config::Changed). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- test/client_server_test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/client_server_test.cc b/test/client_server_test.cc index 43084bf31..2536478fb 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -325,6 +325,14 @@ BOOST_AUTO_TEST_CASE(real_encode_with_server) auto film = new_test_film("real_encode_with_server", content, &cl); film->set_interop(false); + /* Ask the server on this machine directly rather than broadcasting, as a broadcast may not + * be allowed (e.g. in a sandbox or on a machine without a network). + */ + auto const use_any_servers = Config::instance()->use_any_servers(); + auto const servers = Config::instance()->servers(); + Config::instance()->set_use_any_servers(false); + Config::instance()->set_servers({"127.0.0.1"}); + EncodeServerFinder::instance(); EncodeServer server(true, 4); @@ -336,6 +344,10 @@ BOOST_AUTO_TEST_CASE(real_encode_with_server) server_thread.join(); BOOST_CHECK(server.frames_encoded() > 0); + + Config::instance()->set_use_any_servers(use_any_servers); + Config::instance()->set_servers(servers); + EncodeServerFinder::drop(); cl.run(); From 478359f0ddd39f951c25c6837553d2e581568c57 Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Thu, 22 Oct 2026 16:39:16 +0200 Subject: [PATCH 6/7] Build with --warnings-are-errors on Xcode 26. clang 20 (Xcode 26) warns about two things that break a -Werror build: - -Wunnecessary-virtual-specifier in ICU 74's headers (virtual methods in final classes); turn it off when the compiler has it. - -Wimplicit-const-int-float-conversion where tests divide by RAND_MAX, which is not exactly representable as a float; make the conversion explicit. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- test/audio_analysis_test.cc | 2 +- test/audio_buffers_test.cc | 2 +- wscript | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc index 578250b2c..5fc53fe23 100644 --- a/test/audio_analysis_test.cc +++ b/test/audio_analysis_test.cc @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(audio_analysis_serialisation_test) int const points = 4096; auto random_float = []() { - return (float(rand()) / RAND_MAX) * 2 - 1; + return (float(rand()) / static_cast(RAND_MAX)) * 2 - 1; }; AudioAnalysis a(3); diff --git a/test/audio_buffers_test.cc b/test/audio_buffers_test.cc index 49df09646..77a300138 100644 --- a/test/audio_buffers_test.cc +++ b/test/audio_buffers_test.cc @@ -34,7 +34,7 @@ static float tolerance = 1e-3; static float random_float () { - return float (rand ()) / RAND_MAX; + return float (rand ()) / static_cast(RAND_MAX); } static void diff --git a/wscript b/wscript index 97ce05e2f..aae5d9012 100644 --- a/wscript +++ b/wscript @@ -137,6 +137,10 @@ def configure(conf): '-D_FILE_OFFSET_BITS=64', '-std=c++' + cpp_std]) + # ICU 74's headers have virtual methods in final classes, which clang 20 (Xcode 26) warns about + if conf.check_cxx(cxxflags=['-Wunnecessary-virtual-specifier', '-Werror'], msg='Checking for -Wunnecessary-virtual-specifier', mandatory=False): + conf.env.append_value('CXXFLAGS', ['-Wno-unnecessary-virtual-specifier']) + if conf.options.warnings_are_errors: conf.env.append_value('CXXFLAGS', '-Werror') From f4b42c43119e0961612103ef7d58ef4464cfce02 Mon Sep 17 00:00:00 2001 From: Jaume Puig Date: Thu, 22 Oct 2026 16:42:37 +0200 Subject: [PATCH 7/7] Disconnect EncodeServerFinder from Config::Changed when it is destroyed. EncodeServerFinder connected to Config::Changed with a raw this and never disconnected, so a configuration change after EncodeServerFinder::drop() called config_changed() on the deleted finder (seen as boost::lock_error, "mutex lock failed ... Invalid argument"). Keep the connection in a scoped_connection, declared last so that it goes first. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017CHMGrzt5n5oKGFSjhKnrp --- src/lib/encode_server_finder.cc | 2 +- src/lib/encode_server_finder.h | 3 +++ test/client_server_test.cc | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index a873b258a..df1b65408 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -57,7 +57,7 @@ EncodeServerFinder* EncodeServerFinder::_instance = 0; EncodeServerFinder::EncodeServerFinder() : _stop(false) { - Config::instance()->Changed.connect(boost::bind(&EncodeServerFinder::config_changed, this, _1)); + _config_changed_connection = Config::instance()->Changed.connect(boost::bind(&EncodeServerFinder::config_changed, this, _1)); } diff --git a/src/lib/encode_server_finder.h b/src/lib/encode_server_finder.h index ae83b9609..77a8f73b4 100644 --- a/src/lib/encode_server_finder.h +++ b/src/lib/encode_server_finder.h @@ -89,5 +89,8 @@ class EncodeServerFinder : public Signaller, public ExceptionStore std::shared_ptr _accept_socket; + /** Last, so that it is disconnected before anything else is destroyed */ + boost::signals2::scoped_connection _config_changed_connection; + static EncodeServerFinder* _instance; }; diff --git a/test/client_server_test.cc b/test/client_server_test.cc index 2536478fb..6105bd5de 100644 --- a/test/client_server_test.cc +++ b/test/client_server_test.cc @@ -353,3 +353,16 @@ BOOST_AUTO_TEST_CASE(real_encode_with_server) cl.run(); } + +/** A configuration change after the finder has been dropped must not reach the deleted finder */ +BOOST_AUTO_TEST_CASE(encode_server_finder_dropped_before_config_change) +{ + auto const servers = Config::instance()->servers(); + + EncodeServerFinder::instance(); + EncodeServerFinder::drop(); + + Config::instance()->set_servers({"127.0.0.1"}); + Config::instance()->set_servers(servers); +} +