FFmpeg
Macros | Functions
pthread.c File Reference
#include "libavutil/thread.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "pthread_internal.h"
#include "thread.h"

Go to the source code of this file.

Macros

#define PTHREAD_INIT_LOOP(type)
 

Functions

static void validate_thread_parameters (AVCodecContext *avctx)
 Set the threading algorithms used. More...
 
int ff_thread_init (AVCodecContext *avctx)
 
void ff_thread_free (AVCodecContext *avctx)
 
av_cold void ff_pthread_free (void *obj, const unsigned offsets[])
 
av_cold int ff_pthread_init (void *obj, const unsigned offsets[])
 Initialize/destroy a list of mutexes/conditions contained in a structure. More...
 

Detailed Description

Multithreading support functions

See also
doc/multithreading.txt

Definition in file pthread.c.

Macro Definition Documentation

◆ PTHREAD_INIT_LOOP

#define PTHREAD_INIT_LOOP (   type)
Value:
for (; *(++cur_offset) != THREAD_SENTINEL; cnt++) { \
pthread_ ## type ## _t *dst = (void*)((char*)obj + *cur_offset); \
err = pthread_ ## type ## _init(dst, NULL); \
if (err) { \
err = AVERROR(err); \
goto fail; \
} \
}

Function Documentation

◆ validate_thread_parameters()

static void validate_thread_parameters ( AVCodecContext avctx)
static

Set the threading algorithms used.

Threading requires more than one thread. Frame threading requires entire frames to be passed to the codec, and introduces extra decoding delay, so is incompatible with low_delay.

Parameters
avctxThe context.

Definition at line 48 of file pthread.c.

Referenced by ff_thread_init().

◆ ff_thread_init()

int ff_thread_init ( AVCodecContext avctx)

Definition at line 71 of file pthread.c.

Referenced by avcodec_open2().

◆ ff_thread_free()

void ff_thread_free ( AVCodecContext avctx)

Definition at line 83 of file pthread.c.

Referenced by avcodec_close().

◆ ff_pthread_free()

av_cold void ff_pthread_free ( void *  obj,
const unsigned  offsets[] 
)

◆ ff_pthread_init()

av_cold int ff_pthread_init ( void *  obj,
const unsigned  offsets[] 
)

Initialize/destroy a list of mutexes/conditions contained in a structure.

The positions of these mutexes/conditions in the structure are given by their offsets. Because it is undefined behaviour to destroy an uninitialized mutex/condition, ff_pthread_init() stores the number of successfully initialized mutexes and conditions in the object itself and ff_pthread_free() uses this number to destroy exactly the mutexes and condition variables that have been successfully initialized.

Parameters
objThe object containing the mutexes/conditions.
[in]offsetsAn array of offsets. Its first member gives the offset of the variable that contains the count of successfully initialized mutexes/condition variables; said variable must be an unsigned int. Two arrays of offsets, each delimited by a THREAD_SENTINEL follow. The first contains the offsets of all the mutexes, the second contains the offsets of all the condition variables.

Definition at line 104 of file pthread.c.

Referenced by ff_frame_thread_encoder_init(), ff_frame_thread_init(), init_thread(), omx_encode_init(), and vp9_decode_init().

AVERROR
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
fail
#define fail()
Definition: checkasm.h:134
type
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 type
Definition: writing_filters.txt:86
NULL
#define NULL
Definition: coverity.c:32
THREAD_SENTINEL
#define THREAD_SENTINEL
Definition: pthread_internal.h:34