65 static void worker_func(
void *priv,
int jobnr,
int threadnr,
int nb_jobs,
int nb_threads)
72 : c->
func2(avctx, c->
args, jobnr, threadnr);
152 if (thread_count <= 1) {
190 if (!entries || !field)
return;
195 while ((entries[field - 1] - entries[field]) < shift){
const struct AVCodec * codec
int ff_slice_thread_init(AVCodecContext *avctx)
static int shift(int a, int b)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
#define pthread_mutex_lock(a)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
int av_codec_is_encoder(const AVCodec *codec)
Memory handling functions.
static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
struct AVSliceThread AVSliceThread
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Multithreading support functions.
pthread_mutex_t * progress_mutex
static void main_function(void *priv)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
int( action_func)(AVCodecContext *c, void *arg)
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 field
int active_thread_type
Which multithreading methods are in use by the codec.
simple assert() macros that are a bit more flexible than ISO C assert().
int ff_alloc_entries(AVCodecContext *avctx, int count)
static int thread_execute2(AVCodecContext *avctx, action_func2 *func2, void *arg, int *ret, int job_count)
void avpriv_slicethread_free(AVSliceThread **pctx)
Destroy slice threading context.
void ff_slice_thread_free(AVCodecContext *avctx)
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
int( main_func)(AVCodecContext *c)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
pthread_cond_t * progress_cond
#define pthread_mutex_unlock(a)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
void ff_reset_entries(AVCodecContext *avctx)
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Libavcodec external API header.
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n)
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)
Create slice threading context.
main external API structure.
void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main)
Execute slice threading.
int( action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr)
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF
Codec initializes slice-based threading with a main function.
common internal api header.
common internal and external API header
int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, action_func2 *func2, main_func *mainfunc, void *arg, int *ret, int job_count)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
int caps_internal
Internal codec capabilities.
struct AVCodecInternal * internal
Private context used for internal data.
#define av_malloc_array(a, b)
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 int thread_execute(AVCodecContext *avctx, action_func *func, void *arg, int *ret, int job_count, int job_size)
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
int avcodec_default_execute(AVCodecContext *c, int(*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
void * av_mallocz_array(size_t nmemb, size_t size)