Also use const where appropriate.
Unified · Split
| @@ -470,16 +470,13 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 469 unmodified lines | ||
| 470 | 470 | int dst_hp = AV_CEIL_RSHIFT(dst_h, vsub); \ |
| 471 | 471 | int yp = y>>vsub; \ |
| 472 | 472 | int xp = x>>hsub; \ |
| 473 | − int jmax, j, k, kmax; \ | |
| 474 | − int slice_start, slice_end; \ | |
| 475 | 473 | const T max = (1 << nbits) - 1; \ |
| 476 | 474 | const T mid = (1 << (nbits - 1)); \ |
| 477 | 475 | \ |
| 478 | − j = FFMAX(-yp, 0); \ | |
| 479 | − jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp); \ | |
| 480 | − \ | |
| 481 | − slice_start = j + (jmax * jobnr) / nb_jobs; \ | |
| 482 | − slice_end = j + (jmax * (jobnr+1)) / nb_jobs; \ | |
| 476 | + const int jmin = FFMAX(-yp, 0), jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp); \ | |
| 477 | + const int kmin = FFMAX(-xp, 0), kmax = FFMIN(-xp + dst_wp, src_wp); \ | |
| 478 | + const int slice_start = jmin + (jmax * jobnr) / nb_jobs; \ | |
| 479 | + const int slice_end = jmin + (jmax * (jobnr + 1)) / nb_jobs; \ | |
| 483 | 480 | \ |
| 484 | 481 | const uint8_t *sp = src->data[i] + (slice_start) * src->linesize[i]; \ |
| 485 | 482 | uint8_t *dp = dst->data[dst_plane] \ |
| @@ -488,13 +485,12 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext · 2 unmodified lines | ||
| 488 | 485 | const uint8_t *ap = src->data[3] + (slice_start << vsub) * src->linesize[3]; \ |
| 489 | 486 | const uint8_t *dap = main_has_alpha ? dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3] : NULL; \ |
| 490 | 487 | \ |
| 491 | − for (j = slice_start; j < slice_end; j++) { \ | |
| 492 | − k = FFMAX(-xp, 0); \ | |
| 488 | + for (int j = slice_start; j < slice_end; ++j) { \ | |
| 489 | + int k = kmin; \ | |
| 493 | 490 | const T *s = (const T *)sp + k; \ |
| 494 | 491 | const T *a = (const T *)ap + (k << hsub); \ |
| 495 | 492 | const T *da = main_has_alpha ? (T *)dap + ((xp + k) << hsub) : NULL; \ |
| 496 | 493 | T *d = (T *)(dp + (xp + k) * dst_step); \ |
| 497 | − kmax = FFMIN(-xp + dst_wp, src_wp); \ | |
| 498 | 494 | \ |
| 499 | 495 | if (nbits == 8 && ((vsub && j+1 < src_hp) || !vsub) && octx->blend_row[i]) { \ |
| 500 | 496 | int c = octx->blend_row[i]((uint8_t*)d, (uint8_t*)da, (uint8_t*)s, \ |
| @@ -585,25 +581,21 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c · 84 unmodified lines | ||
| 585 | 581 | int jobnr, int nb_jobs) \ |
| 586 | 582 | { \ |
| 587 | 583 | T alpha; /* the amount of overlay to blend on to main */ \ |
| 588 | − int i, imax, j, jmax; \ | |
| 589 | − int slice_start, slice_end; \ | |
| 590 | 584 | const T max = (1 << nbits) - 1; \ |
| 591 | 585 | \ |
| 592 | − imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h); \ | |
| 593 | − i = FFMAX(-y, 0); \ | |
| 594 | − \ | |
| 595 | − slice_start = i + (imax * jobnr) / nb_jobs; \ | |
| 596 | − slice_end = i + ((imax * (jobnr+1)) / nb_jobs); \ | |
| 586 | + const int imin = FFMAX(-y, 0), imax = FFMIN3(-y + dst_h, FFMIN(src_h, dst_h), y + src_h); \ | |
| 587 | + const int jmin = FFMAX(-x, 0), jmax = FFMIN(-x + dst_w, src_w); \ | |
| 588 | + const int slice_start = imin + ( imax * jobnr) / nb_jobs; \ | |
| 589 | + const int slice_end = imin + ((imax * (jobnr + 1)) / nb_jobs); \ | |
| 597 | 590 | \ |
| 598 | 591 | const uint8_t *sa = src->data[3] + (slice_start) * src->linesize[3]; \ |
| 599 | 592 | uint8_t *da = dst->data[3] + (y + slice_start) * dst->linesize[3]; \ |
| 600 | 593 | \ |
| 601 | − for (i = slice_start; i < slice_end; i++) { \ | |
| 602 | − j = FFMAX(-x, 0); \ | |
| 603 | − const T *s = (const T *)sa + j; \ | |
| 604 | − T *d = (T *)da + x + j; \ | |
| 594 | + for (int i = slice_start; i < slice_end; ++i) { \ | |
| 595 | + const T *s = (const T *)sa + jmin; \ | |
| 596 | + T *d = (T *)da + x + jmin; \ | |
| 605 | 597 | \ |
| 606 | − for (jmax = FFMIN(-x + dst_w, src_w); j < jmax; j++) { \ | |
| 598 | + for (int j = jmin; j < jmax; ++j) { \ | |
| 607 | 599 | alpha = *s; \ |
| 608 | 600 | if (alpha != 0 && alpha != max) { \ |
| 609 | 601 | uint8_t alpha_d = *d; \ |