mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
swscale/alphablend: Fix slice handling
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 06d6726588
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
c59e2d2f03
commit
ff48f4aad7
@ -26,7 +26,7 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
|
|||||||
{
|
{
|
||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
|
||||||
int nb_components = desc->nb_components;
|
int nb_components = desc->nb_components;
|
||||||
int plane, x, y;
|
int plane, x, ysrc;
|
||||||
int plane_count = isGray(c->srcFormat) ? 1 : 3;
|
int plane_count = isGray(c->srcFormat) ? 1 : 3;
|
||||||
int sixteen_bits = desc->comp[0].depth >= 9;
|
int sixteen_bits = desc->comp[0].depth >= 9;
|
||||||
unsigned off = 1<<(desc->comp[0].depth - 1);
|
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 w = plane ? c->chrSrcW : c->srcW;
|
||||||
int x_subsample = plane ? desc->log2_chroma_w: 0;
|
int x_subsample = plane ? desc->log2_chroma_w: 0;
|
||||||
int y_subsample = plane ? desc->log2_chroma_h: 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) {
|
if (x_subsample || y_subsample) {
|
||||||
int alpha;
|
int alpha;
|
||||||
unsigned u;
|
unsigned u;
|
||||||
if (sixteen_bits) {
|
if (sixteen_bits) {
|
||||||
ptrdiff_t alpha_step = srcStride[plane_count] >> 1;
|
ptrdiff_t alpha_step = srcStride[plane_count] >> 1;
|
||||||
const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * 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] * y << y_subsample));
|
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);
|
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
|
||||||
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
|
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
@ -82,8 +83,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ptrdiff_t alpha_step = srcStride[plane_count];
|
ptrdiff_t alpha_step = srcStride[plane_count];
|
||||||
const uint8_t *s = src[plane ] + srcStride[plane] * y;
|
const uint8_t *s = src[plane ] + srcStride[plane] * ysrc;
|
||||||
const uint8_t *a = src[plane_count] + (srcStride[plane_count] * y << y_subsample);
|
const uint8_t *a = src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample);
|
||||||
uint8_t *d = dst[plane ] + dstStride[plane] * y;
|
uint8_t *d = dst[plane ] + dstStride[plane] * y;
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
if (y_subsample) {
|
if (y_subsample) {
|
||||||
@ -97,8 +98,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sixteen_bits) {
|
if (sixteen_bits) {
|
||||||
const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * 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] * y);
|
const uint16_t *a = (const uint16_t *)(src[plane_count] + srcStride[plane_count] * ysrc);
|
||||||
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
|
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
|
||||||
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
|
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
@ -113,8 +114,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const uint8_t *s = src[plane ] + srcStride[plane] * y;
|
const uint8_t *s = src[plane ] + srcStride[plane] * ysrc;
|
||||||
const uint8_t *a = src[plane_count] + srcStride[plane_count] * y;
|
const uint8_t *a = src[plane_count] + srcStride[plane_count] * ysrc;
|
||||||
uint8_t *d = dst[plane ] + dstStride[plane] * y;
|
uint8_t *d = dst[plane ] + dstStride[plane] * y;
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
unsigned u = s[x]*a[x] + target_table[((x^y)>>5)&1][plane]*(255-a[x]) + 128;
|
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 {
|
} else {
|
||||||
int alpha_pos = desc->comp[plane_count].offset;
|
int alpha_pos = desc->comp[plane_count].offset;
|
||||||
int w = c->srcW;
|
int w = c->srcW;
|
||||||
for (y = srcSliceY; y < srcSliceH; y++) {
|
for (ysrc = 0; ysrc < srcSliceH; ysrc++) {
|
||||||
|
int y = ysrc + srcSliceY;
|
||||||
if (sixteen_bits) {
|
if (sixteen_bits) {
|
||||||
const uint16_t *s = (const uint16_t *)(src[0] + srcStride[0] * y + 2*!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] * y + 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);
|
uint16_t *d = ( uint16_t *)(dst[0] + dstStride[0] * y);
|
||||||
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
|
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
@ -151,8 +153,8 @@ int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const uint8_t *s = 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] * y + alpha_pos;
|
const uint8_t *a = src[0] + srcStride[0] * ysrc + alpha_pos;
|
||||||
uint8_t *d = dst[0] + dstStride[0] * y;
|
uint8_t *d = dst[0] + dstStride[0] * y;
|
||||||
for (x = 0; x < w; x++) {
|
for (x = 0; x < w; x++) {
|
||||||
for (plane = 0; plane < plane_count; plane++) {
|
for (plane = 0; plane < plane_count; plane++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user