| @@ -80,6 +80,10 @@ enum XFadeTransitions { · 79 unmodified lines |
| 80 | 80 | HRWIND, |
| 81 | 81 | VUWIND, |
| 82 | 82 | VDWIND, |
| 83 | + COVERLEFT, |
| 84 | + COVERRIGHT, |
| 85 | + COVERUP, |
| 86 | + COVERDOWN, |
| 83 | 87 | NB_TRANSITIONS, |
| 84 | 88 | }; |
| 85 | 89 | |
| @@ -214,6 +218,10 @@ static const AVOption xfade_options[] = { · 128 unmodified lines |
| 214 | 218 | { "hrwind", "hr wind transition", 0, AV_OPT_TYPE_CONST, {.i64=HRWIND}, 0, 0, FLAGS, "transition" }, |
| 215 | 219 | { "vuwind", "vu wind transition", 0, AV_OPT_TYPE_CONST, {.i64=VUWIND}, 0, 0, FLAGS, "transition" }, |
| 216 | 220 | { "vdwind", "vd wind transition", 0, AV_OPT_TYPE_CONST, {.i64=VDWIND}, 0, 0, FLAGS, "transition" }, |
| 221 | + { "coverleft", "cover left transition", 0, AV_OPT_TYPE_CONST, {.i64=COVERLEFT}, 0, 0, FLAGS, "transition" }, |
| 222 | + { "coverright", "cover right transition", 0, AV_OPT_TYPE_CONST, {.i64=COVERRIGHT}, 0, 0, FLAGS, "transition" }, |
| 223 | + { "coverup", "cover up transition", 0, AV_OPT_TYPE_CONST, {.i64=COVERUP}, 0, 0, FLAGS, "transition" }, |
| 224 | + { "coverdown", "cover down transition", 0, AV_OPT_TYPE_CONST, {.i64=COVERDOWN}, 0, 0, FLAGS, "transition" }, |
| 217 | 225 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 218 | 226 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 219 | 227 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| @@ -1851,6 +1859,74 @@ VWIND_TRANSITION(16, u, uint16_t, 2, 1.f - ) · 1631 unmodified lines |
| 1851 | 1859 | VWIND_TRANSITION(8, d, uint8_t, 1, ) |
| 1852 | 1860 | VWIND_TRANSITION(16, d, uint16_t, 2, ) |
| 1853 | 1861 | |
| 1862 | +#define COVERH_TRANSITION(dir, name, type, div, expr) \ |
| 1863 | +static void cover##dir##name##_transition(AVFilterContext *ctx, \ |
| 1864 | + const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| 1865 | + float progress, \ |
| 1866 | + int slice_start, int slice_end, int jobnr) \ |
| 1867 | +{ \ |
| 1868 | + XFadeContext *s = ctx->priv; \ |
| 1869 | + const int height = slice_end - slice_start; \ |
| 1870 | + const int width = out->width; \ |
| 1871 | + const int z = (expr progress) * width; \ |
| 1872 | + \ |
| 1873 | + for (int p = 0; p < s->nb_planes; p++) { \ |
| 1874 | + const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \ |
| 1875 | + const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \ |
| 1876 | + type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \ |
| 1877 | + \ |
| 1878 | + for (int y = 0; y < height; y++) { \ |
| 1879 | + for (int x = 0; x < width; x++) { \ |
| 1880 | + const int zx = z + x; \ |
| 1881 | + const int zz = zx % width + width * (zx < 0); \ |
| 1882 | + dst[x] = (zx >= 0) && (zx < width) ? xf1[zz] : xf0[x]; \ |
| 1883 | + } \ |
| 1884 | + \ |
| 1885 | + dst += out->linesize[p] / div; \ |
| 1886 | + xf0 += a->linesize[p] / div; \ |
| 1887 | + xf1 += b->linesize[p] / div; \ |
| 1888 | + } \ |
| 1889 | + } \ |
| 1890 | +} |
| 1891 | + |
| 1892 | +COVERH_TRANSITION(left, 8, uint8_t, 1, -) |
| 1893 | +COVERH_TRANSITION(left, 16, uint16_t, 2, -) |
| 1894 | +COVERH_TRANSITION(right, 8, uint8_t, 1, ) |
| 1895 | +COVERH_TRANSITION(right, 16, uint16_t, 2, ) |
| 1896 | + |
| 1897 | +#define COVERV_TRANSITION(dir, name, type, div, expr) \ |
| 1898 | +static void cover##dir##name##_transition(AVFilterContext *ctx, \ |
| 1899 | + const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| 1900 | + float progress, \ |
| 1901 | + int slice_start, int slice_end, int jobnr) \ |
| 1902 | +{ \ |
| 1903 | + XFadeContext *s = ctx->priv; \ |
| 1904 | + const int height = out->height; \ |
| 1905 | + const int width = out->width; \ |
| 1906 | + const int z = (expr progress) * height; \ |
| 1907 | + \ |
| 1908 | + for (int p = 0; p < s->nb_planes; p++) { \ |
| 1909 | + type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \ |
| 1910 | + \ |
| 1911 | + for (int y = slice_start; y < slice_end; y++) { \ |
| 1912 | + const int zy = z + y; \ |
| 1913 | + const int zz = zy % height + height * (zy < 0); \ |
| 1914 | + const type *xf0 = (const type *)(a->data[p] + y * a->linesize[p]); \ |
| 1915 | + const type *xf1 = (const type *)(b->data[p] + zz * b->linesize[p]); \ |
| 1916 | + \ |
| 1917 | + for (int x = 0; x < width; x++) \ |
| 1918 | + dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; \ |
| 1919 | + \ |
| 1920 | + dst += out->linesize[p] / div; \ |
| 1921 | + } \ |
| 1922 | + } \ |
| 1923 | +} |
| 1924 | + |
| 1925 | +COVERV_TRANSITION(up, 8, uint8_t, 1, -) |
| 1926 | +COVERV_TRANSITION(up, 16, uint16_t, 2, -) |
| 1927 | +COVERV_TRANSITION(down, 8, uint8_t, 1, ) |
| 1928 | +COVERV_TRANSITION(down, 16, uint16_t, 2, ) |
| 1929 | + |
| 1854 | 1930 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 1855 | 1931 | { |
| 1856 | 1932 | XFadeContext *s = priv; |
| @@ -2001,6 +2077,10 @@ static int config_output(AVFilterLink *outlink) · 144 unmodified lines |
| 2001 | 2077 | case HRWIND: s->transitionf = s->depth <= 8 ? hrwind8_transition : hrwind16_transition; break; |
| 2002 | 2078 | case VUWIND: s->transitionf = s->depth <= 8 ? vuwind8_transition : vuwind16_transition; break; |
| 2003 | 2079 | case VDWIND: s->transitionf = s->depth <= 8 ? vdwind8_transition : vdwind16_transition; break; |
| 2080 | + case COVERLEFT: s->transitionf = s->depth <= 8 ? coverleft8_transition : coverleft16_transition; break; |
| 2081 | + case COVERRIGHT: s->transitionf = s->depth <= 8 ? coverright8_transition : coverright16_transition; break; |
| 2082 | + case COVERUP: s->transitionf = s->depth <= 8 ? coverup8_transition : coverup16_transition; break; |
| 2083 | + case COVERDOWN: s->transitionf = s->depth <= 8 ? coverdown8_transition : coverdown16_transition; break; |
| 2004 | 2084 | default: return AVERROR_BUG; |
| 2005 | 2085 | } |
| 2006 | 2086 | |