* commit '129bb238430ec45a3b5f8f1d384df590ddf7b62f': lavfi: add a slice threading infrastructure Conflicts: Changelog cmdutils.c doc/APIchanges libavfilter/Makefile libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/internal.h libavfilter/version.h
Showing the changes to libavfilter/avfilter.c (1 of 11 files). Show all
Unified · Split
| @@ -538,9 +538,12 @@ static const AVClass *filter_child_class_next(const AVClass *prev) · 537 unmodified lines | |||
| 538 | 538 | ||
| 539 | #define OFFSET(x) offsetof(AVFilterContext, x) | 539 | #define OFFSET(x) offsetof(AVFilterContext, x) |
| 540 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | 540 | #define FLAGS AV_OPT_FLAG_FILTERING_PARAM |
| 541 | static const AVOption filters_common_options[] = { | 541 | static const AVOption options[] = { |
| 542 | { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, | ||
| 543 | { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" }, | ||
| 544 | { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .unit = "thread_type" }, | ||
| 542 | { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, | 545 | { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS }, |
| 543 | { NULL } | 546 | { NULL }, |
| 544 | }; | 547 | }; |
| 545 | 548 | ||
| 546 | static const AVClass avfilter_class = { | 549 | static const AVClass avfilter_class = { |
| @@ -549,10 +552,23 @@ static const AVClass avfilter_class = { · 2 unmodified lines | |||
| 549 | .version = LIBAVUTIL_VERSION_INT, | 552 | .version = LIBAVUTIL_VERSION_INT, |
| 550 | .category = AV_CLASS_CATEGORY_FILTER, | 553 | .category = AV_CLASS_CATEGORY_FILTER, |
| 551 | .child_next = filter_child_next, | 554 | .child_next = filter_child_next, |
| 552 | .option = filters_common_options, | ||
| 553 | .child_class_next = filter_child_class_next, | 555 | .child_class_next = filter_child_class_next, |
| 556 | .option = options, | ||
| 554 | }; | 557 | }; |
| 555 | 558 | ||
| 559 | static int default_execute(AVFilterContext *ctx, action_func *func, void *arg, | ||
| 560 | int *ret, int nb_jobs) | ||
| 561 | { | ||
| 562 | int i; | ||
| 563 | |||
| 564 | for (i = 0; i < nb_jobs; i++) { | ||
| 565 | int r = func(ctx, arg, i, nb_jobs); | ||
| 566 | if (ret) | ||
| 567 | ret[i] = r; | ||
| 568 | } | ||
| 569 | return 0; | ||
| 570 | } | ||
| 571 | |||
| 556 | AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) | 572 | AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) |
| 557 | { | 573 | { |
| 558 | AVFilterContext *ret; | 574 | AVFilterContext *ret; |
| @@ -573,11 +589,17 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) · 14 unmodified lines | |||
| 573 | goto err; | 589 | goto err; |
| 574 | } | 590 | } |
| 575 | 591 | ||
| 592 | av_opt_set_defaults(ret); | ||
| 576 | if (filter->priv_class) { | 593 | if (filter->priv_class) { |
| 577 | *(const AVClass**)ret->priv = filter->priv_class; | 594 | *(const AVClass**)ret->priv = filter->priv_class; |
| 578 | av_opt_set_defaults(ret->priv); | 595 | av_opt_set_defaults(ret->priv); |
| 579 | } | 596 | } |
| 580 | 597 | ||
| 598 | ret->internal = av_mallocz(sizeof(*ret->internal)); | ||
| 599 | if (!ret->internal) | ||
| 600 | goto err; | ||
| 601 | ret->internal->execute = default_execute; | ||
| 602 | |||
| 581 | ret->nb_inputs = avfilter_pad_count(filter->inputs); | 603 | ret->nb_inputs = avfilter_pad_count(filter->inputs); |
| 582 | if (ret->nb_inputs ) { | 604 | if (ret->nb_inputs ) { |
| 583 | ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs); | 605 | ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs); |
| @@ -614,6 +636,7 @@ err: · 30 unmodified lines | |||
| 614 | av_freep(&ret->output_pads); | 636 | av_freep(&ret->output_pads); |
| 615 | ret->nb_outputs = 0; | 637 | ret->nb_outputs = 0; |
| 616 | av_freep(&ret->priv); | 638 | av_freep(&ret->priv); |
| 639 | av_freep(&ret->internal); | ||
| 617 | av_free(ret); | 640 | av_free(ret); |
| 618 | return NULL; | 641 | return NULL; |
| 619 | } | 642 | } |
| @@ -681,6 +704,7 @@ void avfilter_free(AVFilterContext *filter) · 61 unmodified lines | |||
| 681 | av_expr_free(filter->enable); | 704 | av_expr_free(filter->enable); |
| 682 | filter->enable = NULL; | 705 | filter->enable = NULL; |
| 683 | av_freep(&filter->var_values); | 706 | av_freep(&filter->var_values); |
| 707 | av_freep(&filter->internal); | ||
| 684 | av_free(filter); | 708 | av_free(filter); |
| 685 | } | 709 | } |
| 686 | 710 | ||
| @@ -772,6 +796,21 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) · 85 unmodified lines | |||
| 772 | { | 796 | { |
| 773 | int ret = 0; | 797 | int ret = 0; |
| 774 | 798 | ||
| 799 | ret = av_opt_set_dict(ctx, options); | ||
| 800 | if (ret < 0) { | ||
| 801 | av_log(ctx, AV_LOG_ERROR, "Error applying generic filter options.\n"); | ||
| 802 | return ret; | ||
| 803 | } | ||
| 804 | |||
| 805 | if (ctx->filter->flags & AVFILTER_FLAG_SLICE_THREADS && | ||
| 806 | ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE && | ||
| 807 | ctx->graph->internal->thread_execute) { | ||
| 808 | ctx->thread_type = AVFILTER_THREAD_SLICE; | ||
| 809 | ctx->internal->execute = ctx->graph->internal->thread_execute; | ||
| 810 | } else { | ||
| 811 | ctx->thread_type = 0; | ||
| 812 | } | ||
| 813 | |||
| 775 | if (ctx->filter->priv_class) { | 814 | if (ctx->filter->priv_class) { |
| 776 | ret = av_opt_set_dict(ctx->priv, options); | 815 | ret = av_opt_set_dict(ctx->priv, options); |
| 777 | if (ret < 0) { | 816 | if (ret < 0) { |