History

Merge commit '129bb238430ec45a3b5f8f1d384df590ddf7b62f'

* 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

Michael Niedermayer committed 13 years ago

Commit 8d4e9692 parents fe40a9f 129bb2311 files · +447 −14Browse files

Showing the changes to libavfilter/avfilter.c (1 of 11 files). Show all

Unified · Split

libavfilter/avfilter.c+42−3
@@ -538,9 +538,12 @@ static const AVClass *filter_child_class_next(const AVClass *prev) · 537 unmodified lines
538538
539539 #define OFFSET(x) offsetof(AVFilterContext, x)
540540 #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" },
542545 { "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
543− { NULL }
546+ { NULL },
544547 };
545548
546549 static const AVClass avfilter_class = {
@@ -549,10 +552,23 @@ static const AVClass avfilter_class = { · 2 unmodified lines
549552 .version = LIBAVUTIL_VERSION_INT,
550553 .category = AV_CLASS_CATEGORY_FILTER,
551554 .child_next = filter_child_next,
552− .option = filters_common_options,
553555 .child_class_next = filter_child_class_next,
556+ .option = options,
554557 };
555558
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+
556572 AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
557573 {
558574 AVFilterContext *ret;
@@ -573,11 +589,17 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) · 14 unmodified lines
573589 goto err;
574590 }
575591
592+ av_opt_set_defaults(ret);
576593 if (filter->priv_class) {
577594 *(const AVClass**)ret->priv = filter->priv_class;
578595 av_opt_set_defaults(ret->priv);
579596 }
580597
598+ ret->internal = av_mallocz(sizeof(*ret->internal));
599+ if (!ret->internal)
600+ goto err;
601+ ret->internal->execute = default_execute;
602+
581603 ret->nb_inputs = avfilter_pad_count(filter->inputs);
582604 if (ret->nb_inputs ) {
583605 ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs);
@@ -614,6 +636,7 @@ err: · 30 unmodified lines
614636 av_freep(&ret->output_pads);
615637 ret->nb_outputs = 0;
616638 av_freep(&ret->priv);
639+ av_freep(&ret->internal);
617640 av_free(ret);
618641 return NULL;
619642 }
@@ -681,6 +704,7 @@ void avfilter_free(AVFilterContext *filter) · 61 unmodified lines
681704 av_expr_free(filter->enable);
682705 filter->enable = NULL;
683706 av_freep(&filter->var_values);
707+ av_freep(&filter->internal);
684708 av_free(filter);
685709 }
686710
@@ -772,6 +796,21 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) · 85 unmodified lines
772796 {
773797 int ret = 0;
774798
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+
775814 if (ctx->filter->priv_class) {
776815 ret = av_opt_set_dict(ctx->priv, options);
777816 if (ret < 0) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t