From: Carl Hetherington Date: Mon, 1 Feb 2021 09:02:56 +0000 (+0100) Subject: Fix hang when trying to assure minimum bitrate. X-Git-Tag: v2.15.124~9 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=c150d49754daa77f70ba0d47ab5948747e10a7d4 Fix hang when trying to assure minimum bitrate. --- diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index cb1517727..7b529c45a 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -128,6 +128,7 @@ DCPVideo::encode_locally () int constexpr minimum_size = 65536; auto xyz = convert_to_xyz (_frame, boost::bind(&Log::dcp_log, dcpomatic_log.get(), _1, _2)); + int noise_amount = 2; while (true) { enc = dcp::compress_j2k ( xyz, @@ -153,10 +154,14 @@ DCPVideo::encode_locally () for (auto c = 0; c < 3; ++c) { auto p = xyz->data(c); for (auto i = 0; i < pixels; ++i) { - *p = std::min(4095, std::max(0, *p + rand() % 2)); + *p = std::min(4095, std::max(0, *p + rand() % noise_amount)); ++p; } } + + ++noise_amount; + /* Something's gone badly wrong if this much noise doesn't help */ + DCP_ASSERT (noise_amount < 16); } switch (_frame->eyes()) {