FFmpeg
Loading...
Searching...
No Matches
slicethread.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVUTIL_SLICETHREAD_H
20#define AVUTIL_SLICETHREAD_H
21
22#include "attributes.h"
23#include "version.h"
24
26
27/**
28 * Create slice threading context.
29 * @param pctx slice threading context returned here
30 * @param priv private pointer to be passed to callback function
31 * @param worker_func callback function to be executed
32 * @param main_func special callback function, called from main thread, may be NULL
33 * @param nb_threads number of threads, 0 for automatic, must be >= 0
34 * @return return number of threads or negative AVERROR on failure
35 */
36int avpriv_slicethread_create2(AVSliceThread **pctx, void *priv,
37 int (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads),
38 int (*main_func)(void *priv),
39 int nb_threads);
40
41/**
42 * Execute slice threading. If any job returns a nonzero value,
43 * all remaining jobs will be aborted and that value returned.
44 *
45 * If `main_func` itself returns a nonzero value, that value is guaranteed
46 * to be returned, even if a worker thread returns a nonzero value first.
47 *
48 * @param ctx slice threading context
49 * @param nb_jobs number of jobs, must be > 0
50 * @param execute_main also execute main_func
51 * @return 0 on success, else first seen return value
52 */
53int avpriv_slicethread_execute2(AVSliceThread *ctx, int nb_jobs, int execute_main);
54
55/**
56 * Destroy slice threading context.
57 * @param pctx pointer to context
58 */
60
61#if LIBAVUTIL_VERSION_MAJOR < 62
62/**
63 * @deprecated
64 * Wrapper around avpriv_slicethread_create2() for ABI backwards compatibility.
65 */
67int avpriv_slicethread_create(AVSliceThread **pctx, void *priv,
68 void (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads),
69 void (*main_func)(void *priv),
70 int nb_threads);
71
72/**
73 * @deprecated
74 * Wrapper around avpriv_slicethread_execute2() for ABI backwards compatibility.
75 */
77void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main);
78#endif /* LIBAVUTIL_VERSION_MAJOR < 62 */
79
80#endif
static AVFormatContext * ctx
Macro definitions for various function/variable attributes.
#define attribute_deprecated
Definition attributes.h:131
Libavutil version macros.
static int worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads)
int main_func(AVCodecContext *c)
attribute_deprecated void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main)
attribute_deprecated int avpriv_slicethread_create(AVSliceThread **pctx, void *priv, void(*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), void(*main_func)(void *priv), int nb_threads)
void avpriv_slicethread_free(AVSliceThread **pctx)
Destroy slice threading context.
struct AVSliceThread AVSliceThread
Definition slicethread.h:25
int avpriv_slicethread_execute2(AVSliceThread *ctx, int nb_jobs, int execute_main)
Execute slice threading.
int avpriv_slicethread_create2(AVSliceThread **pctx, void *priv, int(*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads), int(*main_func)(void *priv), int nb_threads)
Create slice threading context.