diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-11-03 22:23:12 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-11-03 22:23:12 +0000 |
| commit | 6a28bb6f533b22fcb77f74355e35980bd75b97d6 (patch) | |
| tree | 8d501e0133d636cc3030e7640bb052f9d68a2bf1 /src | |
| parent | ccbe9126407eb31abaf991c39bcac6d3aec1b852 (diff) | |
Add missing alpha_blend() for XYZ content so that subtitle overlay works on DCP content again.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/image.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index 48a4e16cd..ed029ca2d 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -475,6 +475,31 @@ Image::alpha_blend (shared_ptr<const Image> other, Position<int> position) } break; } + case AV_PIX_FMT_XYZ12LE: + { + 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; + uint8_t* op = other->data()[0] + oy * other->stride()[0]; + for (int tx = start_tx, ox = start_ox; tx < size().width && ox < other->size().width; ++tx, ++ox) { + 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]; + + /* Blend high bytes */ + tp[1] = min (x, 255) * alpha + tp[1] * (1 - alpha); + tp[3] = min (y, 255) * alpha + tp[3] * (1 - alpha); + tp[5] = min (z, 255) * alpha + tp[5] * (1 - alpha); + + tp += this_bpp; + op += other_bpp; + } + } + break; + } default: DCPOMATIC_ASSERT (false); } |
