Go to the documentation of this file.
22 #ifndef AVUTIL_THREAD_H
23 #define AVUTIL_THREAD_H
28 #include <sys/prctl.h>
33 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
38 #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
45 #define ASSERT_PTHREAD_ABORT(func, ret) do { \
46 char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \
47 av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \
48 " failed with error: %s\n", \
49 av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, \
54 #define ASSERT_PTHREAD_NORET(func, ...) do { \
55 int ret = func(__VA_ARGS__); \
57 ASSERT_PTHREAD_ABORT(func, ret); \
60 #define ASSERT_PTHREAD(func, ...) do { \
61 ASSERT_PTHREAD_NORET(func, __VA_ARGS__); \
65 static inline int strict_pthread_join(
pthread_t thread,
void **value_ptr)
76 ASSERT_PTHREAD_NORET(pthread_mutexattr_init, &local_attr);
77 ASSERT_PTHREAD_NORET(pthread_mutexattr_settype, &local_attr, PTHREAD_MUTEX_ERRORCHECK);
79 ASSERT_PTHREAD_NORET(pthread_mutexattr_destroy, &local_attr);
125 const struct timespec *abstime)
128 if (
ret &&
ret != ETIMEDOUT)
133 static inline int strict_pthread_once(
pthread_once_t *once_control,
void (*init_routine)(
void))
135 ASSERT_PTHREAD(
pthread_once, once_control, init_routine);
138 #define pthread_join strict_pthread_join
139 #define pthread_mutex_init strict_pthread_mutex_init
140 #define pthread_mutex_destroy strict_pthread_mutex_destroy
141 #define pthread_mutex_lock strict_pthread_mutex_lock
142 #define pthread_mutex_unlock strict_pthread_mutex_unlock
143 #define pthread_cond_init strict_pthread_cond_init
144 #define pthread_cond_destroy strict_pthread_cond_destroy
145 #define pthread_cond_signal strict_pthread_cond_signal
146 #define pthread_cond_broadcast strict_pthread_cond_broadcast
147 #define pthread_cond_wait strict_pthread_cond_wait
148 #define pthread_cond_timedwait strict_pthread_cond_timedwait
149 #define pthread_once strict_pthread_once
152 #elif HAVE_OS2THREADS
158 #define AVMutex pthread_mutex_t
159 #define AV_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
161 #define ff_mutex_init pthread_mutex_init
162 #define ff_mutex_lock pthread_mutex_lock
163 #define ff_mutex_unlock pthread_mutex_unlock
164 #define ff_mutex_destroy pthread_mutex_destroy
166 #define AVCond pthread_cond_t
168 #define ff_cond_init pthread_cond_init
169 #define ff_cond_destroy pthread_cond_destroy
170 #define ff_cond_signal pthread_cond_signal
171 #define ff_cond_broadcast pthread_cond_broadcast
172 #define ff_cond_wait pthread_cond_wait
173 #define ff_cond_timedwait pthread_cond_timedwait
175 #define AVOnce pthread_once_t
176 #define AV_ONCE_INIT PTHREAD_ONCE_INIT
178 #define ff_thread_once(control, routine) pthread_once(control, routine)
183 #define AV_MUTEX_INITIALIZER 0
198 const void *abstime){
return 0; }
201 #define AV_ONCE_INIT 0
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
static int ff_mutex_init(AVMutex *mutex, const void *attr)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static int ff_cond_timedwait(AVCond *cond, AVMutex *mutex, const void *abstime)
static int ff_cond_broadcast(AVCond *cond)
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_thread_once(char *control, void(*routine)(void))
static int ff_cond_wait(AVCond *cond, AVMutex *mutex)
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
static av_always_inline int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
#define pthread_mutex_unlock(a)
static int ff_mutex_destroy(AVMutex *mutex)
static int ff_mutex_lock(AVMutex *mutex)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static int ff_cond_signal(AVCond *cond)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static int ff_cond_destroy(AVCond *cond)
static av_always_inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
static int ff_cond_init(AVCond *cond, const void *attr)
int(* cond)(enum AVPixelFormat pix_fmt)
#define pthread_mutex_lock(a)
static int ff_thread_setname(const char *name)