summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-02-01 10:02:56 +0100
committerCarl Hetherington <cth@carlh.net>2021-02-01 10:02:56 +0100
commitc150d49754daa77f70ba0d47ab5948747e10a7d4 (patch)
treed78a19b53276734312a3a14fa836f1d70956a3d0
parentacfbd1c01020ea95d9e7eb3d63ddb14b9407732a (diff)
Fix hang when trying to assure minimum bitrate.
-rw-r--r--src/lib/dcp_video.cc7
1 files changed, 6 insertions, 1 deletions
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()) {