History

avfilter/vf_xfade: add corner wipe transforms

Paul B Mahol committed 6 years ago

Commit 9ebde671 parent 71ec3e42 files · +144 −0Browse files

Unified · Split

2 files
  1. doc/filters.texi +4 −0
  2. libavfilter/vf_xfade.c +140 −0
doc/filters.texi+4−0
@@ -20521,6 +20521,10 @@ Set one of available transition effects: · 20520 unmodified lines
2052120521 @item vdslice
2052220522 @item hblur
2052320523 @item fadegrays
20524+@item wipetl
20525+@item wipetr
20526+@item wipebl
20527+@item wipebr
2052420528 @end table
2052520529 Default transition effect is fade.
2052620530
libavfilter/vf_xfade.c+140−0
@@ -67,6 +67,10 @@ enum XFadeTransitions { · 66 unmodified lines
6767 VDSLICE,
6868 HBLUR,
6969 FADEGRAYS,
70+ WIPETL,
71+ WIPETR,
72+ WIPEBL,
73+ WIPEBR,
7074 NB_TRANSITIONS,
7175 };
7276
@@ -187,6 +191,10 @@ static const AVOption xfade_options[] = { · 114 unmodified lines
187191 { "vdslice", "vd slice transition", 0, AV_OPT_TYPE_CONST, {.i64=VDSLICE}, 0, 0, FLAGS, "transition" },
188192 { "hblur", "hblur transition", 0, AV_OPT_TYPE_CONST, {.i64=HBLUR}, 0, 0, FLAGS, "transition" },
189193 { "fadegrays", "fadegrays transition", 0, AV_OPT_TYPE_CONST, {.i64=FADEGRAYS}, 0, 0, FLAGS, "transition" },
194+ { "wipetl", "wipe tl transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPETL}, 0, 0, FLAGS, "transition" },
195+ { "wipetr", "wipe tr transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPETR}, 0, 0, FLAGS, "transition" },
196+ { "wipebl", "wipe bl transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEBL}, 0, 0, FLAGS, "transition" },
197+ { "wipebr", "wipe br transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEBR}, 0, 0, FLAGS, "transition" },
190198 { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS },
191199 { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
192200 { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
@@ -1416,6 +1424,134 @@ static void fadegrays##name##_transition(AVFilterContext *ctx, · 1223 unmodified lines
14161424 FADEGRAYS_TRANSITION(8, uint8_t, 1)
14171425 FADEGRAYS_TRANSITION(16, uint16_t, 2)
14181426
1427+#define WIPETL_TRANSITION(name, type, div) \
1428+static void wipetl##name##_transition(AVFilterContext *ctx, \
1429+ const AVFrame *a, const AVFrame *b, AVFrame *out, \
1430+ float progress, \
1431+ int slice_start, int slice_end, int jobnr) \
1432+{ \
1433+ XFadeContext *s = ctx->priv; \
1434+ const int height = slice_end - slice_start; \
1435+ const int zw = out->width * progress; \
1436+ const int zh = out->height * progress; \
1437+ \
1438+ for (int p = 0; p < s->nb_planes; p++) { \
1439+ const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
1440+ const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
1441+ type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
1442+ \
1443+ for (int y = 0; y < height; y++) { \
1444+ for (int x = 0; x < out->width; x++) { \
1445+ dst[x] = slice_start + y <= zh && \
1446+ x <= zw ? xf0[x] : xf1[x]; \
1447+ } \
1448+ \
1449+ dst += out->linesize[p] / div; \
1450+ xf0 += a->linesize[p] / div; \
1451+ xf1 += b->linesize[p] / div; \
1452+ } \
1453+ } \
1454+}
1455+
1456+WIPETL_TRANSITION(8, uint8_t, 1)
1457+WIPETL_TRANSITION(16, uint16_t, 2)
1458+
1459+#define WIPETR_TRANSITION(name, type, div) \
1460+static void wipetr##name##_transition(AVFilterContext *ctx, \
1461+ const AVFrame *a, const AVFrame *b, AVFrame *out, \
1462+ float progress, \
1463+ int slice_start, int slice_end, int jobnr) \
1464+{ \
1465+ XFadeContext *s = ctx->priv; \
1466+ const int height = slice_end - slice_start; \
1467+ const int zw = out->width * (1.f - progress); \
1468+ const int zh = out->height * progress; \
1469+ \
1470+ for (int p = 0; p < s->nb_planes; p++) { \
1471+ const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
1472+ const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
1473+ type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
1474+ \
1475+ for (int y = 0; y < height; y++) { \
1476+ for (int x = 0; x < out->width; x++) { \
1477+ dst[x] = slice_start + y <= zh && \
1478+ x > zw ? xf0[x] : xf1[x]; \
1479+ } \
1480+ \
1481+ dst += out->linesize[p] / div; \
1482+ xf0 += a->linesize[p] / div; \
1483+ xf1 += b->linesize[p] / div; \
1484+ } \
1485+ } \
1486+}
1487+
1488+WIPETR_TRANSITION(8, uint8_t, 1)
1489+WIPETR_TRANSITION(16, uint16_t, 2)
1490+
1491+#define WIPEBL_TRANSITION(name, type, div) \
1492+static void wipebl##name##_transition(AVFilterContext *ctx, \
1493+ const AVFrame *a, const AVFrame *b, AVFrame *out, \
1494+ float progress, \
1495+ int slice_start, int slice_end, int jobnr) \
1496+{ \
1497+ XFadeContext *s = ctx->priv; \
1498+ const int height = slice_end - slice_start; \
1499+ const int zw = out->width * progress; \
1500+ const int zh = out->height * (1.f - progress); \
1501+ \
1502+ for (int p = 0; p < s->nb_planes; p++) { \
1503+ const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
1504+ const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
1505+ type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
1506+ \
1507+ for (int y = 0; y < height; y++) { \
1508+ for (int x = 0; x < out->width; x++) { \
1509+ dst[x] = slice_start + y > zh && \
1510+ x <= zw ? xf0[x] : xf1[x]; \
1511+ } \
1512+ \
1513+ dst += out->linesize[p] / div; \
1514+ xf0 += a->linesize[p] / div; \
1515+ xf1 += b->linesize[p] / div; \
1516+ } \
1517+ } \
1518+}
1519+
1520+WIPEBL_TRANSITION(8, uint8_t, 1)
1521+WIPEBL_TRANSITION(16, uint16_t, 2)
1522+
1523+#define WIPEBR_TRANSITION(name, type, div) \
1524+static void wipebr##name##_transition(AVFilterContext *ctx, \
1525+ const AVFrame *a, const AVFrame *b, AVFrame *out, \
1526+ float progress, \
1527+ int slice_start, int slice_end, int jobnr) \
1528+{ \
1529+ XFadeContext *s = ctx->priv; \
1530+ const int height = slice_end - slice_start; \
1531+ const int zh = out->height * (1.f - progress); \
1532+ const int zw = out->width * (1.f - progress); \
1533+ \
1534+ for (int p = 0; p < s->nb_planes; p++) { \
1535+ const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \
1536+ const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \
1537+ type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
1538+ \
1539+ for (int y = 0; y < height; y++) { \
1540+ for (int x = 0; x < out->width; x++) { \
1541+ dst[x] = slice_start + y > zh && \
1542+ x > zw ? xf0[x] : xf1[x]; \
1543+ } \
1544+ \
1545+ dst += out->linesize[p] / div; \
1546+ xf0 += a->linesize[p] / div; \
1547+ xf1 += b->linesize[p] / div; \
1548+ } \
1549+ } \
1550+}
1551+
1552+WIPEBR_TRANSITION(8, uint8_t, 1)
1553+WIPEBR_TRANSITION(16, uint16_t, 2)
1554+
14191555 static inline double getpix(void *priv, double x, double y, int plane, int nb)
14201556 {
14211557 XFadeContext *s = priv;
@@ -1559,6 +1695,10 @@ static int config_output(AVFilterLink *outlink) · 137 unmodified lines
15591695 case VDSLICE: s->transitionf = s->depth <= 8 ? vdslice8_transition : vdslice16_transition; break;
15601696 case HBLUR: s->transitionf = s->depth <= 8 ? hblur8_transition : hblur16_transition; break;
15611697 case FADEGRAYS: s->transitionf = s->depth <= 8 ? fadegrays8_transition : fadegrays16_transition; break;
1698+ case WIPETL: s->transitionf = s->depth <= 8 ? wipetl8_transition : wipetl16_transition; break;
1699+ case WIPETR: s->transitionf = s->depth <= 8 ? wipetr8_transition : wipetr16_transition; break;
1700+ case WIPEBL: s->transitionf = s->depth <= 8 ? wipebl8_transition : wipebl16_transition; break;
1701+ case WIPEBR: s->transitionf = s->depth <= 8 ? wipebr8_transition : wipebr16_transition; break;
15621702 }
15631703
15641704 if (s->transition == CUSTOM) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t