diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2015-08-08 11:24:26 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-08-09 15:58:43 +0200 |
commit | b7faa9d314f26855f8555a265a6231b291773482 (patch) | |
tree | 3cffaf2033e983babb9dde8344ed1754d159af0f /libswscale/alphablend.c | |
parent | 16df02fd2e5b43013d19eed4891a576f91ceb52e (diff) | |
download | ffmpeg-b7faa9d314f26855f8555a265a6231b291773482.tar.gz |
swscale/alphablend: support packed pixel formats
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libswscale/alphablend.c')
-rw-r--r-- | libswscale/alphablend.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libswscale/alphablend.c b/libswscale/alphablend.c index 5833653b83..8e04d6c4e1 100644 --- a/libswscale/alphablend.c +++ b/libswscale/alphablend.c @@ -68,6 +68,48 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], } } } + } else { + int alpha_pos = desc->comp[plane_count].offset_plus1 - 1; + int w = c->srcW; + for (y = srcSliceY; y < srcSliceH; y++) { + if (sixteen_bits) { + const uint16_t *s = src[0] + srcStride[0] * y + 2*!alpha_pos; + const uint16_t *a = src[0] + srcStride[0] * y + alpha_pos; + uint16_t *d = dst[0] + dstStride[0] * y; + if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { + for (x = 0; x < w; x++) { + for (plane = 0; plane < plane_count; plane++) { + unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; + int x_index = (plane_count + 1) * x; + unsigned u = s[x_index + plane]*a[x_index] + target*(max-a[x_index]) + off; + d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); + } + } + } else { + for (x = 0; x < w; x++) { + for (plane = 0; plane < plane_count; plane++) { + unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; + int x_index = (plane_count + 1) * x; + unsigned aswap =av_bswap16(a[x_index]); + unsigned u = av_bswap16(s[x_index + plane])*aswap + target*(max-aswap) + off; + d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); + } + } + } + } else { + const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos; + const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos; + uint8_t *d = dst[0] + dstStride[0] * y; + for (x = 0; x < w; x++) { + for (plane = 0; plane < plane_count; plane++) { + unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; + int x_index = (plane_count + 1) * x; + unsigned u = s[x_index + plane]*a[x_index] + target*(255-a[x_index]) + 128; + d[plane_count*x + plane] = (257*u) >> 16; + } + } + } + } } return 0; |