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

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2013-05-24 13:47:45 +02:00
11 changed files with 446 additions and 13 deletions

View File

@@ -538,9 +538,12 @@ static const AVClass *filter_child_class_next(const AVClass *prev)
#define OFFSET(x) offsetof(AVFilterContext, x)
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM
static const AVOption filters_common_options[] = {
static const AVOption options[] = {
{ "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
{ .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" },
{ "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .unit = "thread_type" },
{ "enable", "set enable expression", OFFSET(enable_str), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ NULL }
{ NULL },
};
static const AVClass avfilter_class = {
@@ -549,10 +552,23 @@ static const AVClass avfilter_class = {
.version = LIBAVUTIL_VERSION_INT,
.category = AV_CLASS_CATEGORY_FILTER,
.child_next = filter_child_next,
.option = filters_common_options,
.child_class_next = filter_child_class_next,
.option = options,
};
static int default_execute(AVFilterContext *ctx, action_func *func, void *arg,
int *ret, int nb_jobs)
{
int i;
for (i = 0; i < nb_jobs; i++) {
int r = func(ctx, arg, i, nb_jobs);
if (ret)
ret[i] = r;
}
return 0;
}
AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
{
AVFilterContext *ret;
@@ -573,11 +589,17 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
goto err;
}
av_opt_set_defaults(ret);
if (filter->priv_class) {
*(const AVClass**)ret->priv = filter->priv_class;
av_opt_set_defaults(ret->priv);
}
ret->internal = av_mallocz(sizeof(*ret->internal));
if (!ret->internal)
goto err;
ret->internal->execute = default_execute;
ret->nb_inputs = avfilter_pad_count(filter->inputs);
if (ret->nb_inputs ) {
ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->nb_inputs);
@@ -614,6 +636,7 @@ err:
av_freep(&ret->output_pads);
ret->nb_outputs = 0;
av_freep(&ret->priv);
av_freep(&ret->internal);
av_free(ret);
return NULL;
}
@@ -681,6 +704,7 @@ void avfilter_free(AVFilterContext *filter)
av_expr_free(filter->enable);
filter->enable = NULL;
av_freep(&filter->var_values);
av_freep(&filter->internal);
av_free(filter);
}
@@ -772,6 +796,21 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
{
int ret = 0;
ret = av_opt_set_dict(ctx, options);
if (ret < 0) {
av_log(ctx, AV_LOG_ERROR, "Error applying generic filter options.\n");
return ret;
}
if (ctx->filter->flags & AVFILTER_FLAG_SLICE_THREADS &&
ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE &&
ctx->graph->internal->thread_execute) {
ctx->thread_type = AVFILTER_THREAD_SLICE;
ctx->internal->execute = ctx->graph->internal->thread_execute;
} else {
ctx->thread_type = 0;
}
if (ctx->filter->priv_class) {
ret = av_opt_set_dict(ctx->priv, options);
if (ret < 0) {