| @@ -67,6 +67,10 @@ enum XFadeTransitions { · 66 unmodified lines |
| 67 | 67 | VDSLICE, |
| 68 | 68 | HBLUR, |
| 69 | 69 | FADEGRAYS, |
| 70 | + WIPETL, |
| 71 | + WIPETR, |
| 72 | + WIPEBL, |
| 73 | + WIPEBR, |
| 70 | 74 | NB_TRANSITIONS, |
| 71 | 75 | }; |
| 72 | 76 | |
| @@ -187,6 +191,10 @@ static const AVOption xfade_options[] = { · 114 unmodified lines |
| 187 | 191 | { "vdslice", "vd slice transition", 0, AV_OPT_TYPE_CONST, {.i64=VDSLICE}, 0, 0, FLAGS, "transition" }, |
| 188 | 192 | { "hblur", "hblur transition", 0, AV_OPT_TYPE_CONST, {.i64=HBLUR}, 0, 0, FLAGS, "transition" }, |
| 189 | 193 | { "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" }, |
| 190 | 198 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 191 | 199 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 192 | 200 | { "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 |
| 1416 | 1424 | FADEGRAYS_TRANSITION(8, uint8_t, 1) |
| 1417 | 1425 | FADEGRAYS_TRANSITION(16, uint16_t, 2) |
| 1418 | 1426 | |
| 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 | + |
| 1419 | 1555 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 1420 | 1556 | { |
| 1421 | 1557 | XFadeContext *s = priv; |
| @@ -1559,6 +1695,10 @@ static int config_output(AVFilterLink *outlink) · 137 unmodified lines |
| 1559 | 1695 | case VDSLICE: s->transitionf = s->depth <= 8 ? vdslice8_transition : vdslice16_transition; break; |
| 1560 | 1696 | case HBLUR: s->transitionf = s->depth <= 8 ? hblur8_transition : hblur16_transition; break; |
| 1561 | 1697 | 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; |
| 1562 | 1702 | } |
| 1563 | 1703 | |
| 1564 | 1704 | if (s->transition == CUSTOM) { |