summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-05-11 23:14:42 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-11 23:14:42 +0100
commit12eb3f36b30087c136a9855706450cbb01ffd7c2 (patch)
tree20c547f9dc199d59bdb43330aae92877671442b5
parent2a36773467d408607b04a7a57c65b87bf2ced83a (diff)
Fix typo (* for +) and use libdcp's sRGB to XYZ matrix (to help with #752).
-rw-r--r--ChangeLog5
-rw-r--r--src/lib/image.cc7
2 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 19aaf2dfd..3a08bd069 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-11 Carl Hetherington <cth@carlh.net>
+
+ * Hopefully improve strange colour fringing on
+ subtitles burnt into existing DCP sources (#752).
+
2016-04-29 Carl Hetherington <cth@carlh.net>
* Version 2.8.1 released.
diff --git a/src/lib/image.cc b/src/lib/image.cc
index 49cb20a61..9ddccb75f 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -498,6 +498,7 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position)
}
case AV_PIX_FMT_XYZ12LE:
{
+ boost::numeric::ublas::matrix<double> matrix = dcp::ColourConversion::srgb_to_xyz().rgb_to_xyz();
int const this_bpp = 6;
for (int ty = start_ty, oy = start_oy; ty < size().height && oy < other->size().height; ++ty, ++oy) {
uint8_t* tp = data()[0] + ty * stride()[0] + start_tx * this_bpp;
@@ -506,9 +507,9 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position)
float const alpha = float (op[3]) / 255;
/* Convert sRGB to XYZ; op is BGRA */
- int const x = 0.4124564 + op[2] + 0.3575761 * op[1] + 0.1804375 * op[0];
- int const y = 0.2126729 + op[2] + 0.7151522 * op[1] + 0.0721750 * op[0];
- int const z = 0.0193339 + op[2] + 0.1191920 * op[1] + 0.9503041 * op[0];
+ int const x = matrix(0, 0) * op[2] + matrix(0, 1) * op[1] + matrix(0, 2) * op[0];
+ int const y = matrix(1, 0) * op[2] + matrix(1, 1) * op[1] + matrix(1, 2) * op[0];
+ int const z = matrix(2, 0) * op[2] + matrix(2, 1) * op[1] + matrix(2, 2) * op[0];
/* Blend high bytes */
tp[1] = min (x, 255) * alpha + tp[1] * (1 - alpha);