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
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */21 */
22 22
23#include "config.h"
24
23#include <string.h>25#include <string.h>
24 26
25#include "libavutil/avassert.h"27#include "libavutil/avassert.h"
@@ -29,33 +31,63 @@ · 3 unmodified lines
29#include "libavutil/opt.h"31#include "libavutil/opt.h"
30#include "libavutil/pixdesc.h"32#include "libavutil/pixdesc.h"
31#include "libavcodec/avcodec.h" // avcodec_find_best_pix_fmt_of_2()33#include "libavcodec/avcodec.h" // avcodec_find_best_pix_fmt_of_2()
34
32#include "avfilter.h"35#include "avfilter.h"
33#include "formats.h"36#include "formats.h"
34#include "internal.h"37#include "internal.h"
35 38#include "thread.h"
36#define OFFSET(x) offsetof(AVFilterGraph,x)39
37 40#define OFFSET(x) offsetof(AVFilterGraph, x)
38static const AVOption options[]={41#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
39{"scale_sws_opts" , "default scale filter options" , OFFSET(scale_sws_opts) , AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, 0 },42static const AVOption filtergraph_options[] = {
40{"aresample_swr_opts" , "default aresample filter options" , OFFSET(aresample_swr_opts) , AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, 0 },43 { "thread_type", "Allowed thread types", OFFSET(thread_type), AV_OPT_TYPE_FLAGS,
41{0}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 },
42};53};
43 54
44
45static const AVClass filtergraph_class = {55static const AVClass filtergraph_class = {
46 .class_name = "AVFilterGraph",56 .class_name = "AVFilterGraph",
47 .item_name = av_default_item_name,57 .item_name = av_default_item_name,
48 .option = options,
49 .version = LIBAVUTIL_VERSION_INT,58 .version = LIBAVUTIL_VERSION_INT,
59 .option = filtergraph_options,
50 .category = AV_CLASS_CATEGORY_FILTER,60 .category = AV_CLASS_CATEGORY_FILTER,
51};61};
52 62
63#if !HAVE_THREADS
64void ff_graph_thread_free(AVFilterGraph *graph)
65{
66}
67
68int ff_graph_thread_init(AVFilterGraph *graph)
69{
70 graph->thread_type = 0;
71 graph->nb_threads = 1;
72 return 0;
73}
74#endif
75
53AVFilterGraph *avfilter_graph_alloc(void)76AVFilterGraph *avfilter_graph_alloc(void)
54{77{
55 AVFilterGraph *ret = av_mallocz(sizeof(*ret));78 AVFilterGraph *ret = av_mallocz(sizeof(*ret));
56 if (!ret)79 if (!ret)
57 return NULL;80 return NULL;
81
82 ret->internal = av_mallocz(sizeof(*ret->internal));
83 if (!ret->internal) {
84 av_freep(&ret);
85 return NULL;
86 }
87
58 ret->av_class = &filtergraph_class;88 ret->av_class = &filtergraph_class;
89 av_opt_set_defaults(ret);
90
59 return ret;91 return ret;
60}92}
61 93
@@ -80,11 +112,15 @@ void avfilter_graph_free(AVFilterGraph **graph) · 18 unmodified lines
80 while ((*graph)->nb_filters)112 while ((*graph)->nb_filters)
81 avfilter_free((*graph)->filters[0]);113 avfilter_free((*graph)->filters[0]);
82 114
115 ff_graph_thread_free(*graph);
116
83 av_freep(&(*graph)->sink_links);117 av_freep(&(*graph)->sink_links);
118
84 av_freep(&(*graph)->scale_sws_opts);119 av_freep(&(*graph)->scale_sws_opts);
85 av_freep(&(*graph)->aresample_swr_opts);120 av_freep(&(*graph)->aresample_swr_opts);
86 av_freep(&(*graph)->resample_lavr_opts);121 av_freep(&(*graph)->resample_lavr_opts);
87 av_freep(&(*graph)->filters);122 av_freep(&(*graph)->filters);
123 av_freep(&(*graph)->internal);
88 av_freep(graph);124 av_freep(graph);
89}125}
90 126
@@ -143,6 +179,14 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, · 52 unmodified lines
143{179{
144 AVFilterContext **filters, *s;180 AVFilterContext **filters, *s;
145 181
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
146 s = ff_filter_alloc(filter, name);190 s = ff_filter_alloc(filter, name);
147 if (!s)191 if (!s)
148 return NULL;192 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