| @@ -65,6 +65,7 @@ enum XFadeTransitions { · 64 unmodified lines |
| 65 | HRSLICE, | 65 | HRSLICE, |
| 66 | VUSLICE, | 66 | VUSLICE, |
| 67 | VDSLICE, | 67 | VDSLICE, |
| | 68 | HBLUR, |
| 68 | NB_TRANSITIONS, | 69 | NB_TRANSITIONS, |
| 69 | }; | 70 | }; |
| 70 | | 71 | |
| @@ -182,6 +183,7 @@ static const AVOption xfade_options[] = { · 111 unmodified lines |
| 182 | { "hrslice", "hr slice transition", 0, AV_OPT_TYPE_CONST, {.i64=HRSLICE}, 0, 0, FLAGS, "transition" }, | 183 | { "hrslice", "hr slice transition", 0, AV_OPT_TYPE_CONST, {.i64=HRSLICE}, 0, 0, FLAGS, "transition" }, |
| 183 | { "vuslice", "vu slice transition", 0, AV_OPT_TYPE_CONST, {.i64=VUSLICE}, 0, 0, FLAGS, "transition" }, | 184 | { "vuslice", "vu slice transition", 0, AV_OPT_TYPE_CONST, {.i64=VUSLICE}, 0, 0, FLAGS, "transition" }, |
| 184 | { "vdslice", "vd slice transition", 0, AV_OPT_TYPE_CONST, {.i64=VDSLICE}, 0, 0, FLAGS, "transition" }, | 185 | { "vdslice", "vd slice transition", 0, AV_OPT_TYPE_CONST, {.i64=VDSLICE}, 0, 0, FLAGS, "transition" }, |
| | 186 | { "hblur", "hblur transition", 0, AV_OPT_TYPE_CONST, {.i64=HBLUR}, 0, 0, FLAGS, "transition" }, |
| 185 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, | 187 | { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS }, |
| 186 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, | 188 | { "offset", "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS }, |
| 187 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, | 189 | { "expr", "set expression for custom transition", OFFSET(custom_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| @@ -1299,6 +1301,50 @@ static void vdslice##name##_transition(AVFilterContext *ctx, · 1111 unmodified lines |
| 1299 | VDSLICE_TRANSITION(8, uint8_t, 1) | 1301 | VDSLICE_TRANSITION(8, uint8_t, 1) |
| 1300 | VDSLICE_TRANSITION(16, uint16_t, 2) | 1302 | VDSLICE_TRANSITION(16, uint16_t, 2) |
| 1301 | | 1303 | |
| | 1304 | #define HBLUR_TRANSITION(name, type, div) \ |
| | 1305 | static void hblur##name##_transition(AVFilterContext *ctx, \ |
| | 1306 | const AVFrame *a, const AVFrame *b, AVFrame *out, \ |
| | 1307 | float progress, \ |
| | 1308 | int slice_start, int slice_end, int jobnr) \ |
| | 1309 | { \ |
| | 1310 | XFadeContext *s = ctx->priv; \ |
| | 1311 | const int width = out->width; \ |
| | 1312 | const float prog = progress <= 0.5f ? progress * 2.f : (1.f - progress) * 2.f; \ |
| | 1313 | const int size = 1 + (width / 2) * prog; \ |
| | 1314 | \ |
| | 1315 | for (int y = slice_start; y < slice_end; y++) { \ |
| | 1316 | for (int p = 0; p < s->nb_planes; p++) { \ |
| | 1317 | const type *xf0 = (const type *)(a->data[p] + y * a->linesize[p]); \ |
| | 1318 | const type *xf1 = (const type *)(b->data[p] + y * b->linesize[p]); \ |
| | 1319 | type *dst = (type *)(out->data[p] + y * out->linesize[p]); \ |
| | 1320 | float sum0 = 0.f; \ |
| | 1321 | float sum1 = 0.f; \ |
| | 1322 | float cnt = size; \ |
| | 1323 | \ |
| | 1324 | for (int x = 0; x < size; x++) { \ |
| | 1325 | sum0 += xf0[x]; \ |
| | 1326 | sum1 += xf1[x]; \ |
| | 1327 | } \ |
| | 1328 | \ |
| | 1329 | for (int x = 0; x < width; x++) { \ |
| | 1330 | dst[x] = mix(sum0 / cnt, sum1 / cnt, progress); \ |
| | 1331 | \ |
| | 1332 | if (x + size < width) { \ |
| | 1333 | sum0 += xf0[x + size] - xf0[x]; \ |
| | 1334 | sum1 += xf1[x + size] - xf1[x]; \ |
| | 1335 | } else { \ |
| | 1336 | sum0 -= xf0[x]; \ |
| | 1337 | sum1 -= xf1[x]; \ |
| | 1338 | cnt--; \ |
| | 1339 | } \ |
| | 1340 | } \ |
| | 1341 | } \ |
| | 1342 | } \ |
| | 1343 | } |
| | 1344 | |
| | 1345 | HBLUR_TRANSITION(8, uint8_t, 1) |
| | 1346 | HBLUR_TRANSITION(16, uint16_t, 2) |
| | 1347 | |
| 1302 | static inline double getpix(void *priv, double x, double y, int plane, int nb) | 1348 | static inline double getpix(void *priv, double x, double y, int plane, int nb) |
| 1303 | { | 1349 | { |
| 1304 | XFadeContext *s = priv; | 1350 | XFadeContext *s = priv; |
| @@ -1425,6 +1471,7 @@ static int config_output(AVFilterLink *outlink) · 120 unmodified lines |
| 1425 | case HRSLICE: s->transitionf = s->depth <= 8 ? hrslice8_transition : hrslice16_transition; break; | 1471 | case HRSLICE: s->transitionf = s->depth <= 8 ? hrslice8_transition : hrslice16_transition; break; |
| 1426 | case VUSLICE: s->transitionf = s->depth <= 8 ? vuslice8_transition : vuslice16_transition; break; | 1472 | case VUSLICE: s->transitionf = s->depth <= 8 ? vuslice8_transition : vuslice16_transition; break; |
| 1427 | case VDSLICE: s->transitionf = s->depth <= 8 ? vdslice8_transition : vdslice16_transition; break; | 1473 | case VDSLICE: s->transitionf = s->depth <= 8 ? vdslice8_transition : vdslice16_transition; break; |
| | 1474 | case HBLUR: s->transitionf = s->depth <= 8 ? hblur8_transition : hblur16_transition; break; |
| 1428 | } | 1475 | } |
| 1429 | | 1476 | |
| 1430 | if (s->transition == CUSTOM) { | 1477 | if (s->transition == CUSTOM) { |