From 0f8e8ae6dba273170a5f60a16a14fbe69627dc0e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 25 May 2017 00:07:49 +0100 Subject: Trim some code. --- src/lib/image.cc | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/lib/image.cc b/src/lib/image.cc index 228685442..b82cc6072 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -579,41 +579,17 @@ Image::alpha_blend (shared_ptr other, Position position) case AV_PIX_FMT_YUV420P: { shared_ptr yuv = other->scale (other->size(), dcp::YUV_TO_RGB_REC709, _pixel_format, false, false); - - for (int i = 0; i < 3; ++i) { - dcp::Size const tsize = sample_size(i); - dcp::Size const osize = yuv->sample_size(i); - int const tbpp = ceil (bytes_per_pixel(i) / horizontal_factor(i)); - int const obpp = ceil (yuv->bytes_per_pixel(i) / yuv->horizontal_factor(i)); - int const abpp = other->bytes_per_pixel(0); - start_tx /= horizontal_factor (i); - start_ty /= vertical_factor (i); - start_ox /= yuv->horizontal_factor (i); - start_oy /= yuv->vertical_factor (i); - for (int ty = start_ty, oy = start_oy; ty < tsize.height && oy < osize.height; ++ty, ++oy) { - /* this image */ - uint8_t* tp = data()[i] + ty * stride()[i] + start_tx * tbpp; - /* overlay image */ - uint8_t* op = yuv->data()[i] + oy * yuv->stride()[i]; - /* original RGBA for alpha channel */ - uint8_t* ap = other->data()[0] + oy * other->stride()[0]; - for (int tx = start_tx, ox = start_ox; tx < tsize.width && ox < osize.width; ++tx, ++ox) { - float const alpha = float (ap[3]) / 255; - *tp = *op * alpha + *tp * (1 - alpha); - tp += tbpp; - op += obpp; - ap += abpp; - } - } - } + component (0, this, yuv, other, start_tx, start_ty, start_ox, start_oy); + component (1, this, yuv, other, start_tx, start_ty, start_ox, start_oy); + component (2, this, yuv, other, start_tx, start_ty, start_ox, start_oy); break; } case AV_PIX_FMT_YUV420P10: { shared_ptr yuv = other->scale (other->size(), dcp::YUV_TO_RGB_REC709, _pixel_format, false, false); component (0, this, yuv, other, start_tx, start_ty, start_ox, start_oy); - component (1, this, yuv, other, start_tx, start_ty, start_ox, start_oy); - component (2, this, yuv, other, start_tx, start_ty, start_ox, start_oy); + component (1, this, yuv, other, start_tx, start_ty, start_ox, start_oy); + component (2, this, yuv, other, start_tx, start_ty, start_ox, start_oy); break; } default: -- cgit v1.2.3