Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2012-10-22 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2013-08-xx - xxxxxxx - lavfi 3.11.0 - avfilter.h | |
| 17 | + Add AVFilterGraph.execute and AVFilterGraph.opaque for custom slice threading | |
| 18 | + implementations. | |
| 19 | + | |
| 16 | 20 | 2013-09-21 - xxxxxxx - lavu 52.16.0 - pixfmt.h |
| 17 | 21 | Add interleaved 4:2:2 8/10-bit formats AV_PIX_FMT_NV16 and |
| 18 | 22 | AV_PIX_FMT_NV20. |
| @@ -371,7 +371,7 @@ static const AVClass avfilter_class = { · 370 unmodified lines | ||
| 371 | 371 | .option = avfilter_options, |
| 372 | 372 | }; |
| 373 | 373 | |
| 374 | −static int default_execute(AVFilterContext *ctx, action_func *func, void *arg, | |
| 374 | +static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, | |
| 375 | 375 | int *ret, int nb_jobs) |
| 376 | 376 | { |
| 377 | 377 | int i; |
| @@ -899,6 +899,35 @@ const AVClass *avfilter_get_class(void); · 898 unmodified lines | ||
| 899 | 899 | |
| 900 | 900 | typedef struct AVFilterGraphInternal AVFilterGraphInternal; |
| 901 | 901 | |
| 902 | +/** | |
| 903 | + * A function pointer passed to the @ref AVFilterGraph.execute callback to be | |
| 904 | + * executed multiple times, possibly in parallel. | |
| 905 | + * | |
| 906 | + * @param ctx the filter context the job belongs to | |
| 907 | + * @param arg an opaque parameter passed through from @ref | |
| 908 | + * AVFilterGraph.execute | |
| 909 | + * @param jobnr the index of the job being executed | |
| 910 | + * @param nb_jobs the total number of jobs | |
| 911 | + * | |
| 912 | + * @return 0 on success, a negative AVERROR on error | |
| 913 | + */ | |
| 914 | +typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); | |
| 915 | + | |
| 916 | +/** | |
| 917 | + * A function executing multiple jobs, possibly in parallel. | |
| 918 | + * | |
| 919 | + * @param ctx the filter context to which the jobs belong | |
| 920 | + * @param func the function to be called multiple times | |
| 921 | + * @param arg the argument to be passed to func | |
| 922 | + * @param ret a nb_jobs-sized array to be filled with return values from each | |
| 923 | + * invocation of func | |
| 924 | + * @param nb_jobs the number of jobs to execute | |
| 925 | + * | |
| 926 | + * @return 0 on success, a negative AVERROR on error | |
| 927 | + */ | |
| 928 | +typedef int (avfilter_execute_func)(AVFilterContext *ctx, avfilter_action_func *func, | |
| 929 | + void *arg, int *ret, int nb_jobs); | |
| 930 | + | |
| 902 | 931 | typedef struct AVFilterGraph { |
| 903 | 932 | const AVClass *av_class; |
| 904 | 933 | #if FF_API_FOO_COUNT |
| @@ -941,6 +970,27 @@ typedef struct AVFilterGraph { · 36 unmodified lines | ||
| 941 | 970 | * Opaque object for libavfilter internal use. |
| 942 | 971 | */ |
| 943 | 972 | AVFilterGraphInternal *internal; |
| 973 | + | |
| 974 | + /** | |
| 975 | + * Opaque user data. May be set by the caller to an arbitrary value, e.g. to | |
| 976 | + * be used from callbacks like @ref AVFilterGraph.execute. | |
| 977 | + * Libavfilter will not touch this field in any way. | |
| 978 | + */ | |
| 979 | + void *opaque; | |
| 980 | + | |
| 981 | + /** | |
| 982 | + * This callback may be set by the caller immediately after allocating the | |
| 983 | + * graph and before adding any filters to it, to provide a custom | |
| 984 | + * multithreading implementation. | |
| 985 | + * | |
| 986 | + * If set, filters with slice threading capability will call this callback | |
| 987 | + * to execute multiple jobs in parallel. | |
| 988 | + * | |
| 989 | + * If this field is left unset, libavfilter will use its internal | |
| 990 | + * implementation, which may or may not be multithreaded depending on the | |
| 991 | + * platform and build options. | |
| 992 | + */ | |
| 993 | + avfilter_execute_func *execute; | |
| 944 | 994 | } AVFilterGraph; |
| 945 | 995 | |
| 946 | 996 | /** |
| @@ -168,11 +168,15 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, · 167 unmodified lines | ||
| 168 | 168 | { |
| 169 | 169 | AVFilterContext **filters, *s; |
| 170 | 170 | |
| 171 | − if (graph->thread_type && !graph->internal->thread) { | |
| 172 | − int ret = ff_graph_thread_init(graph); | |
| 173 | − if (ret < 0) { | |
| 174 | − av_log(graph, AV_LOG_ERROR, "Error initializing threading.\n"); | |
| 175 | − return NULL; | |
| 171 | + if (graph->thread_type && !graph->internal->thread_execute) { | |
| 172 | + if (graph->execute) { | |
| 173 | + graph->internal->thread_execute = graph->execute; | |
| 174 | + } else { | |
| 175 | + int ret = ff_graph_thread_init(graph); | |
| 176 | + if (ret < 0) { | |
| 177 | + av_log(graph, AV_LOG_ERROR, "Error initializing threading.\n"); | |
| 178 | + return NULL; | |
| 179 | + } | |
| 176 | 180 | } |
| 177 | 181 | } |
| 178 | 182 | |
| @@ -122,13 +122,11 @@ struct AVFilterPad { · 121 unmodified lines | ||
| 122 | 122 | |
| 123 | 123 | struct AVFilterGraphInternal { |
| 124 | 124 | void *thread; |
| 125 | − int (*thread_execute)(AVFilterContext *ctx, action_func *func, void *arg, | |
| 126 | − int *ret, int nb_jobs); | |
| 125 | + avfilter_execute_func *thread_execute; | |
| 127 | 126 | }; |
| 128 | 127 | |
| 129 | 128 | struct AVFilterInternal { |
| 130 | − int (*execute)(AVFilterContext *ctx, action_func *func, void *arg, | |
| 131 | − int *ret, int nb_jobs); | |
| 129 | + avfilter_execute_func *execute; | |
| 132 | 130 | }; |
| 133 | 131 | |
| 134 | 132 | #if FF_API_AVFILTERBUFFER |
| @@ -43,7 +43,7 @@ typedef struct ThreadContext { · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | int nb_threads; |
| 45 | 45 | pthread_t *workers; |
| 46 | − action_func *func; | |
| 46 | + avfilter_action_func *func; | |
| 47 | 47 | |
| 48 | 48 | /* per-execute perameters */ |
| 49 | 49 | AVFilterContext *ctx; |
| @@ -114,7 +114,7 @@ static void slice_thread_park_workers(ThreadContext *c) · 64 unmodified lines | ||
| 114 | 114 | pthread_mutex_unlock(&c->current_job_lock); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | −static int thread_execute(AVFilterContext *ctx, action_func *func, | |
| 117 | +static int thread_execute(AVFilterContext *ctx, avfilter_action_func *func, | |
| 118 | 118 | void *arg, int *ret, int nb_jobs) |
| 119 | 119 | { |
| 120 | 120 | ThreadContext *c = ctx->graph->internal->thread; |
| @@ -22,8 +22,6 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "avfilter.h" |
| 24 | 24 | |
| 25 | −typedef int (action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); | |
| 26 | − | |
| 27 | 25 | int ff_graph_thread_init(AVFilterGraph *graph); |
| 28 | 26 | |
| 29 | 27 | void ff_graph_thread_free(AVFilterGraph *graph); |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/avutil.h" |
| 31 | 31 | |
| 32 | 32 | #define LIBAVFILTER_VERSION_MAJOR 3 |
| 33 | −#define LIBAVFILTER_VERSION_MINOR 10 | |
| 33 | +#define LIBAVFILTER_VERSION_MINOR 11 | |
| 34 | 34 | #define LIBAVFILTER_VERSION_MICRO 0 |
| 35 | 35 | |
| 36 | 36 | #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |