FFmpeg
libavcodec
pthread_internal.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 AVCODEC_PTHREAD_INTERNAL_H
20
#define AVCODEC_PTHREAD_INTERNAL_H
21
22
#include "
avcodec.h
"
23
24
/* H.264 slice threading seems to be buggy with more than 16 threads,
25
* limit the number of threads to 16 for automatic detection */
26
#define MAX_AUTO_THREADS 16
27
28
int
ff_slice_thread_init
(
AVCodecContext
*avctx);
29
void
ff_slice_thread_free
(
AVCodecContext
*avctx);
30
31
int
ff_frame_thread_init
(
AVCodecContext
*avctx);
32
void
ff_frame_thread_free
(
AVCodecContext
*avctx,
int
thread_count);
33
34
#define THREAD_SENTINEL 0 // This forbids putting a mutex/condition variable at the front.
35
/**
36
* Initialize/destroy a list of mutexes/conditions contained in a structure.
37
* The positions of these mutexes/conditions in the structure are given by
38
* their offsets. Because it is undefined behaviour to destroy
39
* an uninitialized mutex/condition, ff_pthread_init() stores the number
40
* of successfully initialized mutexes and conditions in the object itself
41
* and ff_pthread_free() uses this number to destroy exactly the mutexes and
42
* condition variables that have been successfully initialized.
43
*
44
* @param obj The object containing the mutexes/conditions.
45
* @param[in] offsets An array of offsets. Its first member gives the offset
46
* of the variable that contains the count of successfully
47
* initialized mutexes/condition variables; said variable
48
* must be an unsigned int. Two arrays of offsets, each
49
* delimited by a THREAD_SENTINEL follow. The first
50
* contains the offsets of all the mutexes, the second
51
* contains the offsets of all the condition variables.
52
*/
53
int
ff_pthread_init
(
void
*obj,
const
unsigned
offsets
[]);
54
void
ff_pthread_free
(
void
*obj,
const
unsigned
offsets
[]);
55
56
/**
57
* Macros to help creating the above lists. mutexes and conds need
58
* to be parentheses-enclosed lists of offsets in the containing structure.
59
*/
60
#define OFFSET_ARRAY(...) __VA_ARGS__, THREAD_SENTINEL
61
#define DEFINE_OFFSET_ARRAY(type, name, cnt_variable, mutexes, conds) \
62
static const unsigned name ## _offsets[] = { offsetof(type, cnt_variable), \
63
OFFSET_ARRAY mutexes, \
64
OFFSET_ARRAY conds }
65
66
#endif // AVCODEC_PTHREAD_INTERNAL_H
ff_slice_thread_init
int ff_slice_thread_init(AVCodecContext *avctx)
Definition:
pthread_slice.c:134
ff_pthread_free
void ff_pthread_free(void *obj, const unsigned offsets[])
Definition:
pthread.c:92
offsets
static const int offsets[]
Definition:
hevc_pel.c:34
ff_frame_thread_free
void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
Definition:
pthread_frame.c:749
ff_pthread_init
int ff_pthread_init(void *obj, const unsigned offsets[])
Initialize/destroy a list of mutexes/conditions contained in a structure.
Definition:
pthread.c:105
avcodec.h
ff_frame_thread_init
int ff_frame_thread_init(AVCodecContext *avctx)
Definition:
pthread_frame.c:921
AVCodecContext
main external API structure.
Definition:
avcodec.h:451
ff_slice_thread_free
void ff_slice_thread_free(AVCodecContext *avctx)
Definition:
pthread_slice.c:82
Generated on Sat Oct 12 2024 19:22:04 for FFmpeg by
1.8.17