[FFmpeg-cvslog] swscale/alphablend: Fix slice handling
Michael Niedermayer
git at videolan.org
Wed Oct 6 19:08:02 EEST 2021
ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Thu Sep 30 19:00:56 2021 +0200| [667d62c60339a13cb4f057b787da7db510db3f2d] | committer: Michael Niedermayer
swscale/alphablend: Fix slice handling
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 06d67265881249566f385309e2fb5a9449720b6e)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=667d62c60339a13cb4f057b787da7db510db3f2d
---
libswscale/alphablend.c | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/libswscale/alphablend.c b/libswscale/alphablend.c
index b5686599c0..b5967c889b 100644
--- a/libswscale/alphablend.c
+++ b/libswscale/alphablend.c
@@ -26,7 +26,7 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
int nb_components = desc->nb_components;
- int plane, x, y;
+ int plane, x, ysrc;
int plane_count = isGray(c->srcFormat) ? 1 : 3;
int sixteen_bits = desc->comp[0].depth >= 9;
unsigned off = 1<<(desc->comp[0].depth - 1);
@@ -50,14 +50,15 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
int w = plane ? c->chrSrcW : c->srcW;
int x_subsample = plane ? desc->log2_chroma_w: 0;
int y_subsample = plane ? desc->log2_chroma_h: 0;
- for (y = srcSliceY >> y_subsample; y < AV_CEIL_RSHIFT(srcSliceH, y_subsample); y++) {
+ for (ysrc = 0; ysrc < AV_CEIL_RSHIFT(srcSliceH, y_subsample); ysrc++) {
+ int y = ysrc + (srcSliceY >> y_subsample);
if (x_subsample || y_subsample) {
int alpha;
unsigned u;
if (sixteen_bits) {
ptrdiff_t alpha_step = srcStride[plane_count] >> 1;
- const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * y);
- const uint16_t *a = (const uint16_t *)(src[plane_count] + (srcStride[plane_count] * y << y_subsample));
+ const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * ysrc);
+ const uint16_t *a = (const uint16_t *)(src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample));
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
for (x = 0; x < w; x++) {
@@ -82,8 +83,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
}
} else {
ptrdiff_t alpha_step = srcStride[plane_count];
- const uint8_t *s = src[plane ] + srcStride[plane] * y;
- const uint8_t *a = src[plane_count] + (srcStride[plane_count] * y << y_subsample);
+ const uint8_t *s = src[plane ] + srcStride[plane] * ysrc;
+ const uint8_t *a = src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample);
uint8_t *d = dst[plane ] + dstStride[plane] * y;
for (x = 0; x < w; x++) {
if (y_subsample) {
@@ -97,8 +98,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
}
} else {
if (sixteen_bits) {
- const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * y);
- const uint16_t *a = (const uint16_t *)(src[plane_count] + srcStride[plane_count] * y);
+ const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * ysrc);
+ const uint16_t *a = (const uint16_t *)(src[plane_count] + srcStride[plane_count] * ysrc);
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
for (x = 0; x < w; x++) {
@@ -113,8 +114,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
}
}
} else {
- const uint8_t *s = src[plane ] + srcStride[plane] * y;
- const uint8_t *a = src[plane_count] + srcStride[plane_count] * y;
+ const uint8_t *s = src[plane ] + srcStride[plane] * ysrc;
+ const uint8_t *a = src[plane_count] + srcStride[plane_count] * ysrc;
uint8_t *d = dst[plane ] + dstStride[plane] * y;
for (x = 0; x < w; x++) {
unsigned u = s[x]*a[x] + target_table[((x^y)>>5)&1][plane]*(255-a[x]) + 128;
@@ -127,10 +128,11 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
} else {
int alpha_pos = desc->comp[plane_count].offset;
int w = c->srcW;
- for (y = srcSliceY; y < srcSliceH; y++) {
+ for (ysrc = 0; ysrc < srcSliceH; ysrc++) {
+ int y = ysrc + srcSliceY;
if (sixteen_bits) {
- const uint16_t *s = (const uint16_t *)(src[0] + srcStride[0] * y + 2*!alpha_pos);
- const uint16_t *a = (const uint16_t *)(src[0] + srcStride[0] * y + alpha_pos);
+ const uint16_t *s = (const uint16_t *)(src[0] + srcStride[0] * ysrc + 2*!alpha_pos);
+ const uint16_t *a = (const uint16_t *)(src[0] + srcStride[0] * ysrc + alpha_pos);
uint16_t *d = ( uint16_t *)(dst[0] + dstStride[0] * y);
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
for (x = 0; x < w; x++) {
@@ -151,8 +153,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
}
}
} else {
- const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos;
- const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos;
+ const uint8_t *s = src[0] + srcStride[0] * ysrc + !alpha_pos;
+ const uint8_t *a = src[0] + srcStride[0] * ysrc + alpha_pos;
uint8_t *d = dst[0] + dstStride[0] * y;
for (x = 0; x < w; x++) {
for (plane = 0; plane < plane_count; plane++) {
More information about the ffmpeg-cvslog
mailing list