unsigned int band, int show, int direct)
{
int x, y;
- uint64_t interp, weightl, weightr, weightt, weightb;
+ uint64_t interp, weightl, weightr, weightt, weightb, weight;
uint8_t *xdst, *xsrc;
uint8_t *topleft, *botleft, *topright;
yclipb = FFMAX(logo_y+logo_h-h, 0);
logo_x1 = logo_x + xclipl;
- logo_x2 = logo_x + logo_w - xclipr;
+ logo_x2 = logo_x + logo_w - xclipr - 1;
logo_y1 = logo_y + yclipt;
- logo_y2 = logo_y + logo_h - yclipb;
+ logo_y2 = logo_y + logo_h - yclipb - 1;
- topleft = src+logo_y1 * src_linesize+logo_x1;
- topright = src+logo_y1 * src_linesize+logo_x2-1;
- botleft = src+(logo_y2-1) * src_linesize+logo_x1;
+ topleft = src+logo_y1 * src_linesize+logo_x1;
+ topright = src+logo_y1 * src_linesize+logo_x2;
+ botleft = src+logo_y2 * src_linesize+logo_x1;
if (!direct)
av_image_copy_plane(dst, dst_linesize, src, src_linesize, w, h);
dst += (logo_y1 + 1) * dst_linesize;
src += (logo_y1 + 1) * src_linesize;
- for (y = logo_y1+1; y < logo_y2-1; y++) {
+ for (y = logo_y1+1; y < logo_y2; y++) {
left_sample = topleft[src_linesize*(y-logo_y1)] +
topleft[src_linesize*(y-logo_y1-1)] +
topleft[src_linesize*(y-logo_y1+1)];
for (x = logo_x1+1,
xdst = dst+logo_x1+1,
- xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
+ xsrc = src+logo_x1+1; x < logo_x2; x++, xdst++, xsrc++) {
- if (show && (y == logo_y+1 || y == logo_y+logo_h-2 ||
- x == logo_x+1 || x == logo_x+logo_w-2)) {
+ if (show && (y == logo_y1+1 || y == logo_y2-1 ||
+ x == logo_x1+1 || x == logo_x2-1)) {
*xdst = 0;
continue;
}
/* Weighted interpolation based on relative distances, taking SAR into account */
- weightl = (uint64_t) (logo_x2-1-x) * (y-logo_y1) * (logo_y2-1-y) * sar.den;
- weightr = (uint64_t)(x-logo_x1) * (y-logo_y1) * (logo_y2-1-y) * sar.den;
- weightt = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (logo_y2-1-y) * sar.num;
- weightb = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (y-logo_y1) * sar.num;
+ weightl = (uint64_t) (logo_x2-x) * (y-logo_y1) * (logo_y2-y) * sar.den;
+ weightr = (uint64_t)(x-logo_x1) * (y-logo_y1) * (logo_y2-y) * sar.den;
+ weightt = (uint64_t)(x-logo_x1) * (logo_x2-x) * (logo_y2-y) * sar.num;
+ weightb = (uint64_t)(x-logo_x1) * (logo_x2-x) * (y-logo_y1) * sar.num;
interp =
left_sample * weightl
(botleft[x-logo_x1] +
botleft[x-logo_x1-1] +
botleft[x-logo_x1+1]) * weightb;
- interp /= (weightl + weightr + weightt + weightb) * 3U;
+ weight = (weightl + weightr + weightt + weightb) * 3U;
+ interp = ROUNDED_DIV(interp, weight);
if (y >= logo_y+band && y < logo_y+logo_h-band &&
x >= logo_x+band && x < logo_x+logo_w-band) {
if (!sar.num)
sar.num = sar.den = 1;
- for (plane = 0; plane < 4 && in->data[plane] && in->linesize[plane]; plane++) {
+ for (plane = 0; plane < desc->nb_components; plane++) {
int hsub = plane == 1 || plane == 2 ? hsub0 : 0;
int vsub = plane == 1 || plane == 2 ? vsub0 : 0;
apply_delogo(out->data[plane], out->linesize[plane],
in ->data[plane], in ->linesize[plane],
- FF_CEIL_RSHIFT(inlink->w, hsub),
- FF_CEIL_RSHIFT(inlink->h, vsub),
+ AV_CEIL_RSHIFT(inlink->w, hsub),
+ AV_CEIL_RSHIFT(inlink->h, vsub),
sar, s->x>>hsub, s->y>>vsub,
/* Up and left borders were rounded down, inject lost bits
* into width and height to avoid error accumulation */
- FF_CEIL_RSHIFT(s->w + (s->x & ((1<<hsub)-1)), hsub),
- FF_CEIL_RSHIFT(s->h + (s->y & ((1<<vsub)-1)), vsub),
+ AV_CEIL_RSHIFT(s->w + (s->x & ((1<<hsub)-1)), hsub),
+ AV_CEIL_RSHIFT(s->h + (s->y & ((1<<vsub)-1)), vsub),
s->band>>FFMIN(hsub, vsub),
s->show, direct);
}