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/avfiltergraph.c (1 of 11 files). Show all

Unified · Split

libavfilter/avfiltergraph.c+53−9
@@ -20,6 +20,8 @@ · 19 unmodified lines
2020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2121 */
2222
23+#include "config.h"
24+
2325 #include <string.h>
2426
2527 #include "libavutil/avassert.h"
@@ -29,33 +31,63 @@ · 3 unmodified lines
2931 #include "libavutil/opt.h"
3032 #include "libavutil/pixdesc.h"
3133 #include "libavcodec/avcodec.h" // avcodec_find_best_pix_fmt_of_2()
34+
3235 #include "avfilter.h"
3336 #include "formats.h"
3437 #include "internal.h"
35−
36−#define OFFSET(x) offsetof(AVFilterGraph,x)
37−
38−static const AVOption options[]={
39−{"scale_sws_opts" , "default scale filter options" , OFFSET(scale_sws_opts) , AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, 0 },
40−{"aresample_swr_opts" , "default aresample filter options" , OFFSET(aresample_swr_opts) , AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, 0 },
41−{0}
38+#include "thread.h"
39+
40+#define OFFSET(x) offsetof(AVFilterGraph, x)
41+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
42+static const AVOption filtergraph_options[] = {
43+ { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
44+ { .i64 = AVFILTER_THREAD_SLICE }, 0, INT_MAX, FLAGS, "thread_type" },
45+ { "slice", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AVFILTER_THREAD_SLICE }, .flags = FLAGS, .unit = "thread_type" },
46+ { "threads", "Maximum number of threads", OFFSET(nb_threads),
47+ AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS },
48+ {"scale_sws_opts" , "default scale filter options" , OFFSET(scale_sws_opts) ,
49+ AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
50+ {"aresample_swr_opts" , "default aresample filter options" , OFFSET(aresample_swr_opts) ,
51+ AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
52+ { NULL },
4253 };
4354
44−
4555 static const AVClass filtergraph_class = {
4656 .class_name = "AVFilterGraph",
4757 .item_name = av_default_item_name,
48− .option = options,
4958 .version = LIBAVUTIL_VERSION_INT,
59+ .option = filtergraph_options,
5060 .category = AV_CLASS_CATEGORY_FILTER,
5161 };
5262
63+#if !HAVE_THREADS
64+void ff_graph_thread_free(AVFilterGraph *graph)
65+{
66+}
67+
68+int ff_graph_thread_init(AVFilterGraph *graph)
69+{
70+ graph->thread_type = 0;
71+ graph->nb_threads = 1;
72+ return 0;
73+}
74+#endif
75+
5376 AVFilterGraph *avfilter_graph_alloc(void)
5477 {
5578 AVFilterGraph *ret = av_mallocz(sizeof(*ret));
5679 if (!ret)
5780 return NULL;
81+
82+ ret->internal = av_mallocz(sizeof(*ret->internal));
83+ if (!ret->internal) {
84+ av_freep(&ret);
85+ return NULL;
86+ }
87+
5888 ret->av_class = &filtergraph_class;
89+ av_opt_set_defaults(ret);
90+
5991 return ret;
6092 }
6193
@@ -80,11 +112,15 @@ void avfilter_graph_free(AVFilterGraph **graph) · 18 unmodified lines
80112 while ((*graph)->nb_filters)
81113 avfilter_free((*graph)->filters[0]);
82114
115+ ff_graph_thread_free(*graph);
116+
83117 av_freep(&(*graph)->sink_links);
118+
84119 av_freep(&(*graph)->scale_sws_opts);
85120 av_freep(&(*graph)->aresample_swr_opts);
86121 av_freep(&(*graph)->resample_lavr_opts);
87122 av_freep(&(*graph)->filters);
123+ av_freep(&(*graph)->internal);
88124 av_freep(graph);
89125 }
90126
@@ -143,6 +179,14 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, · 52 unmodified lines
143179 {
144180 AVFilterContext **filters, *s;
145181
182+ if (graph->thread_type && !graph->internal->thread) {
183+ int ret = ff_graph_thread_init(graph);
184+ if (ret < 0) {
185+ av_log(graph, AV_LOG_ERROR, "Error initializing threading.\n");
186+ return NULL;
187+ }
188+ }
189+
146190 s = ff_filter_alloc(filter, name);
147191 if (!s)
148192 return NULL;

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