| @@ -71,6 +71,8 @@ enum XFadeTransitions { · 70 unmodified lines |
| 71 | 71 | WIPETR, |
| 72 | 72 | WIPEBL, |
| 73 | 73 | WIPEBR, |
| 74 | + SQUEEZEH, |
| 75 | + SQUEEZEV, |
| 74 | 76 | NB_TRANSITIONS, |
| 75 | 77 | }; |
| 76 | 78 | |
| @@ -195,6 +197,8 @@ static const AVOption xfade_options[] = { · 118 unmodified lines |
| 195 | 197 | { "wipetr", "wipe tr transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPETR}, 0, 0, FLAGS, "transition" }, |
| 196 | 198 | { "wipebl", "wipe bl transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEBL}, 0, 0, FLAGS, "transition" }, |
| 197 | 199 | { "wipebr", "wipe br transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEBR}, 0, 0, FLAGS, "transition" }, |
| 200 | + { "squeezeh", "squeeze h transition", 0, AV_OPT_TYPE_CONST, {.i64=SQUEEZEH}, 0, 0, FLAGS, "transition" }, |
| 201 | + { "squeezev", "squeeze v transition", 0, AV_OPT_TYPE_CONST, {.i64=SQUEEZEV}, 0, 0, FLAGS, "transition" }, |
| 198 | 202 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 199 | 203 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 200 | 204 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| @@ -1553,6 +1557,81 @@ static void wipebr##name##_transition(AVFilterContext *ctx, · 1352 unmodified lines |
| 1553 | 1557 | WIPEBR_TRANSITION(8, uint8_t, 1) |
| 1554 | 1558 | WIPEBR_TRANSITION(16, uint16_t, 2) |
| 1555 | 1559 | |
| 1560 | +#define SQUEEZEH_TRANSITION(name, type, div) \ |
| 1561 | +static void squeezeh##name##_transition(AVFilterContext *ctx, \ |
| 1562 | + const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| 1563 | + float progress, \ |
| 1564 | + int slice_start, int slice_end, int jobnr) \ |
| 1565 | +{ \ |
| 1566 | + XFadeContext *s = ctx->priv; \ |
| 1567 | + const float h = out->height; \ |
| 1568 | + const int height = slice_end - slice_start; \ |
| 1569 | + \ |
| 1570 | + for (int p = 0; p < s->nb_planes; p++) { \ |
| 1571 | + const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \ |
| 1572 | + type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \ |
| 1573 | + \ |
| 1574 | + for (int y = 0; y < height; y++) { \ |
| 1575 | + const float z = .5f + ((slice_start + y) / h - .5f) / progress; \ |
| 1576 | + \ |
| 1577 | + if (z < 0.f || z > 1.f) { \ |
| 1578 | + for (int x = 0; x < out->width; x++) \ |
| 1579 | + dst[x] = xf1[x]; \ |
| 1580 | + } else { \ |
| 1581 | + const int yy = lrintf(z * (h - 1.f)); \ |
| 1582 | + const type *xf0 = (const type *)(a->data[p] + yy * a->linesize[p]); \ |
| 1583 | + \ |
| 1584 | + for (int x = 0; x < out->width; x++) \ |
| 1585 | + dst[x] = xf0[x]; \ |
| 1586 | + } \ |
| 1587 | + \ |
| 1588 | + dst += out->linesize[p] / div; \ |
| 1589 | + xf1 += b->linesize[p] / div; \ |
| 1590 | + } \ |
| 1591 | + } \ |
| 1592 | +} |
| 1593 | + |
| 1594 | +SQUEEZEH_TRANSITION(8, uint8_t, 1) |
| 1595 | +SQUEEZEH_TRANSITION(16, uint16_t, 2) |
| 1596 | + |
| 1597 | +#define SQUEEZEV_TRANSITION(name, type, div) \ |
| 1598 | +static void squeezev##name##_transition(AVFilterContext *ctx, \ |
| 1599 | + const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| 1600 | + float progress, \ |
| 1601 | + int slice_start, int slice_end, int jobnr) \ |
| 1602 | +{ \ |
| 1603 | + XFadeContext *s = ctx->priv; \ |
| 1604 | + const float w = out->width; \ |
| 1605 | + const int height = slice_end - slice_start; \ |
| 1606 | + \ |
| 1607 | + for (int p = 0; p < s->nb_planes; p++) { \ |
| 1608 | + const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \ |
| 1609 | + const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \ |
| 1610 | + type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \ |
| 1611 | + \ |
| 1612 | + for (int y = 0; y < height; y++) { \ |
| 1613 | + for (int x = 0; x < out->width; x++) { \ |
| 1614 | + const float z = .5f + (x / w - .5f) / progress; \ |
| 1615 | + \ |
| 1616 | + if (z < 0.f || z > 1.f) { \ |
| 1617 | + dst[x] = xf1[x]; \ |
| 1618 | + } else { \ |
| 1619 | + const int xx = lrintf(z * (w - 1.f)); \ |
| 1620 | + \ |
| 1621 | + dst[x] = xf0[xx]; \ |
| 1622 | + } \ |
| 1623 | + } \ |
| 1624 | + \ |
| 1625 | + dst += out->linesize[p] / div; \ |
| 1626 | + xf0 += a->linesize[p] / div; \ |
| 1627 | + xf1 += b->linesize[p] / div; \ |
| 1628 | + } \ |
| 1629 | + } \ |
| 1630 | +} |
| 1631 | + |
| 1632 | +SQUEEZEV_TRANSITION(8, uint8_t, 1) |
| 1633 | +SQUEEZEV_TRANSITION(16, uint16_t, 2) |
| 1634 | + |
| 1556 | 1635 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 1557 | 1636 | { |
| 1558 | 1637 | XFadeContext *s = priv; |
| @@ -1700,6 +1779,8 @@ static int config_output(AVFilterLink *outlink) · 141 unmodified lines |
| 1700 | 1779 | case WIPETR: s->transitionf = s->depth <= 8 ? wipetr8_transition : wipetr16_transition; break; |
| 1701 | 1780 | case WIPEBL: s->transitionf = s->depth <= 8 ? wipebl8_transition : wipebl16_transition; break; |
| 1702 | 1781 | case WIPEBR: s->transitionf = s->depth <= 8 ? wipebr8_transition : wipebr16_transition; break; |
| 1782 | + case SQUEEZEH: s->transitionf = s->depth <= 8 ? squeezeh8_transition : squeezeh16_transition; break; |
| 1783 | + case SQUEEZEV: s->transitionf = s->depth <= 8 ? squeezev8_transition : squeezev16_transition; break; |
| 1703 | 1784 | } |
| 1704 | 1785 | |
| 1705 | 1786 | if (s->transition == CUSTOM) { |