| @@ -84,6 +84,10 @@ enum XFadeTransitions { · 83 unmodified lines |
| 84 | COVERRIGHT, | 84 | COVERRIGHT, |
| 85 | COVERUP, | 85 | COVERUP, |
| 86 | COVERDOWN, | 86 | COVERDOWN, |
| | 87 | REVEALLEFT, |
| | 88 | REVEALRIGHT, |
| | 89 | REVEALUP, |
| | 90 | REVEALDOWN, |
| 87 | NB_TRANSITIONS, | 91 | NB_TRANSITIONS, |
| 88 | }; | 92 | }; |
| 89 | | 93 | |
| @@ -222,6 +226,10 @@ static const AVOption xfade_options[] = { · 132 unmodified lines |
| 222 | { "coverright", "cover right transition", 0, AV_OPT_TYPE_CONST, {.i64=COVERRIGHT}, 0, 0, FLAGS, "transition" }, | 226 | { "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" }, | 227 | { "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" }, | 228 | { "coverdown", "cover down transition", 0, AV_OPT_TYPE_CONST, {.i64=COVERDOWN}, 0, 0, FLAGS, "transition" }, |
| | 229 | { "revealleft", "reveal left transition", 0, AV_OPT_TYPE_CONST, {.i64=REVEALLEFT}, 0, 0, FLAGS, "transition" }, |
| | 230 | { "revealright","reveal right transition",0, AV_OPT_TYPE_CONST, {.i64=REVEALRIGHT},0, 0, FLAGS, "transition" }, |
| | 231 | { "revealup", "reveal up transition", 0, AV_OPT_TYPE_CONST, {.i64=REVEALUP}, 0, 0, FLAGS, "transition" }, |
| | 232 | { "revealdown", "reveal down transition", 0, AV_OPT_TYPE_CONST, {.i64=REVEALDOWN}, 0, 0, FLAGS, "transition" }, |
| 225 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, | 233 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 226 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, | 234 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 227 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, | 235 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| @@ -1927,6 +1935,74 @@ COVERV_TRANSITION(up, 16, uint16_t, 2, -) · 1699 unmodified lines |
| 1927 | COVERV_TRANSITION(down, 8, uint8_t, 1, ) | 1935 | COVERV_TRANSITION(down, 8, uint8_t, 1, ) |
| 1928 | COVERV_TRANSITION(down, 16, uint16_t, 2, ) | 1936 | COVERV_TRANSITION(down, 16, uint16_t, 2, ) |
| 1929 | | 1937 | |
| | 1938 | #define REVEALH_TRANSITION(dir, name, type, div, expr) \ |
| | 1939 | static void reveal##dir##name##_transition(AVFilterContext *ctx, \ |
| | 1940 | const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| | 1941 | float progress, \ |
| | 1942 | int slice_start, int slice_end, int jobnr) \ |
| | 1943 | { \ |
| | 1944 | XFadeContext *s = ctx->priv; \ |
| | 1945 | const int height = slice_end - slice_start; \ |
| | 1946 | const int width = out->width; \ |
| | 1947 | const int z = (expr progress) * width; \ |
| | 1948 | \ |
| | 1949 | for (int p = 0; p < s->nb_planes; p++) { \ |
| | 1950 | const type *xf0 = (const type *)(a->data[p] + slice_start * a->linesize[p]); \ |
| | 1951 | const type *xf1 = (const type *)(b->data[p] + slice_start * b->linesize[p]); \ |
| | 1952 | type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \ |
| | 1953 | \ |
| | 1954 | for (int y = 0; y < height; y++) { \ |
| | 1955 | for (int x = 0; x < width; x++) { \ |
| | 1956 | const int zx = z + x; \ |
| | 1957 | const int zz = zx % width + width * (zx < 0); \ |
| | 1958 | dst[x] = (zx >= 0) && (zx < width) ? xf1[x] : xf0[zz]; \ |
| | 1959 | } \ |
| | 1960 | \ |
| | 1961 | dst += out->linesize[p] / div; \ |
| | 1962 | xf0 += a->linesize[p] / div; \ |
| | 1963 | xf1 += b->linesize[p] / div; \ |
| | 1964 | } \ |
| | 1965 | } \ |
| | 1966 | } |
| | 1967 | |
| | 1968 | REVEALH_TRANSITION(left, 8, uint8_t, 1, -) |
| | 1969 | REVEALH_TRANSITION(left, 16, uint16_t, 2, -) |
| | 1970 | REVEALH_TRANSITION(right, 8, uint8_t, 1, ) |
| | 1971 | REVEALH_TRANSITION(right, 16, uint16_t, 2, ) |
| | 1972 | |
| | 1973 | #define REVEALV_TRANSITION(dir, name, type, div, expr) \ |
| | 1974 | static void reveal##dir##name##_transition(AVFilterContext *ctx, \ |
| | 1975 | const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| | 1976 | float progress, \ |
| | 1977 | int slice_start, int slice_end, int jobnr) \ |
| | 1978 | { \ |
| | 1979 | XFadeContext *s = ctx->priv; \ |
| | 1980 | const int height = out->height; \ |
| | 1981 | const int width = out->width; \ |
| | 1982 | const int z = (expr progress) * height; \ |
| | 1983 | \ |
| | 1984 | for (int p = 0; p < s->nb_planes; p++) { \ |
| | 1985 | type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \ |
| | 1986 | \ |
| | 1987 | for (int y = slice_start; y < slice_end; y++) { \ |
| | 1988 | const int zy = z + y; \ |
| | 1989 | const int zz = zy % height + height * (zy < 0); \ |
| | 1990 | const type *xf0 = (const type *)(a->data[p] + zz * a->linesize[p]); \ |
| | 1991 | const type *xf1 = (const type *)(b->data[p] + y * b->linesize[p]); \ |
| | 1992 | \ |
| | 1993 | for (int x = 0; x < width; x++) \ |
| | 1994 | dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; \ |
| | 1995 | \ |
| | 1996 | dst += out->linesize[p] / div; \ |
| | 1997 | } \ |
| | 1998 | } \ |
| | 1999 | } |
| | 2000 | |
| | 2001 | REVEALV_TRANSITION(up, 8, uint8_t, 1, -) |
| | 2002 | REVEALV_TRANSITION(up, 16, uint16_t, 2, -) |
| | 2003 | REVEALV_TRANSITION(down, 8, uint8_t, 1, ) |
| | 2004 | REVEALV_TRANSITION(down, 16, uint16_t, 2, ) |
| | 2005 | |
| 1930 | static inline double getpix(void *priv, double x, double y, int plane, int nb) | 2006 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 1931 | { | 2007 | { |
| 1932 | XFadeContext *s = priv; | 2008 | XFadeContext *s = priv; |
| @@ -2081,6 +2157,10 @@ static int config_output(AVFilterLink *outlink) · 148 unmodified lines |
| 2081 | case COVERRIGHT: s->transitionf = s->depth <= 8 ? coverright8_transition : coverright16_transition; break; | 2157 | 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; | 2158 | 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; | 2159 | case COVERDOWN: s->transitionf = s->depth <= 8 ? coverdown8_transition : coverdown16_transition; break; |
| | 2160 | case REVEALLEFT: s->transitionf = s->depth <= 8 ? revealleft8_transition : revealleft16_transition; break; |
| | 2161 | case REVEALRIGHT:s->transitionf = s->depth <= 8 ? revealright8_transition: revealright16_transition;break; |
| | 2162 | case REVEALUP: s->transitionf = s->depth <= 8 ? revealup8_transition : revealup16_transition; break; |
| | 2163 | case REVEALDOWN: s->transitionf = s->depth <= 8 ? revealdown8_transition : revealdown16_transition; break; |
| 2084 | default: return AVERROR_BUG; | 2164 | default: return AVERROR_BUG; |
| 2085 | } | 2165 | } |
| 2086 | | 2166 | |