FFmpeg
Loading...
Searching...
No Matches
pthread.c File Reference

Multithreading support functions. More...

#include "libavutil/attributes.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "avcodec_internal.h"
#include "codec_internal.h"
#include "pthread_internal.h"

Go to the source code of this file.

Macros

#define PTHREAD_INIT_LOOP(type)
 

Functions

static av_cold void validate_thread_parameters (AVCodecContext *avctx)
 Set the threading algorithms used.
 
av_cold int ff_thread_init (AVCodecContext *avctx)
 
av_cold 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.
 

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; \
} \
}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
#define NULL
Definition coverity.c:32
#define fail
Definition test.h:479
#define AVERROR(e)
Definition error.h:45
cl_device_type type
#define THREAD_SENTINEL

Referenced by ff_pthread_init().

Function Documentation

◆ validate_thread_parameters()

static av_cold 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 49 of file pthread.c.

Referenced by ff_thread_init().

◆ ff_thread_init()

av_cold int ff_thread_init ( AVCodecContext * avctx)

Definition at line 72 of file pthread.c.

Referenced by avcodec_open2().

◆ ff_thread_free()

av_cold void ff_thread_free ( AVCodecContext * avctx)

Definition at line 84 of file pthread.c.

Referenced by ff_codec_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 105 of file pthread.c.

Referenced by ff_frame_thread_encoder_init(), ff_frame_thread_init(), ff_thread_progress_init(), init_thread(), oh_decode_init(), and vp9_decode_init().