FFmpeg
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * Multithreading API for decoders
24 * @author Alexander Strange <astrange@ithinksw.com>
25 */
26
27#ifndef AVCODEC_THREAD_H
28#define AVCODEC_THREAD_H
29
30#include "libavutil/buffer.h"
31
32#include "avcodec.h"
33
35
36/**
37 * If the codec defines update_thread_context(), call this
38 * when they are ready for the next thread to start decoding
39 * the next frame. After calling it, do not change any variables
40 * read by the update_thread_context() method, or call ff_thread_get_buffer().
41 *
42 * @param avctx The context.
43 */
45
46/**
47 * Wrapper around get_buffer() for frame-multithreaded codecs.
48 * Call this function instead of ff_get_buffer(f).
49 * Cannot be called after the codec has called ff_thread_finish_setup().
50 *
51 * @param avctx The current context.
52 * @param f The frame to write into.
53 */
55
57 int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr),
58 int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count);
59
65
66/**
67 * Allows to synchronize objects whose lifetime is the whole decoding
68 * process among all frame threads.
69 *
70 * When called from a non-copy thread, do nothing.
71 * When called from another thread, place a new RefStruct reference
72 * at the given offset in the calling thread's private data from
73 * the RefStruct reference in the private data of the first decoding thread.
74 * The first thread must have a valid RefStruct reference at the given
75 * offset in its private data; the calling thread must not have
76 * a reference at this offset in its private data (must be NULL).
77 *
78 * @param avctx an AVCodecContext
79 * @param offset offset of the RefStruct reference in avctx's private data
80 *
81 * @retval FF_THREAD_IS_COPY if frame-threading is in use and the
82 * calling thread is a copy; in this case, the RefStruct reference
83 * will be set.
84 * @retval FF_THREAD_IS_MAIN_THREAD if frame-threading is in use
85 * and the calling thread is the main thread.
86 * @retval FF_THREAD_NO_FRAME_THREADING if frame-threading is not in use.
87 */
89
90#endif /* AVCODEC_THREAD_H */
Libavcodec external API header.
refcounted data buffer API
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define f(width, name)
Definition cbs_vp8.c:236
unsigned offset
Definition libaomenc.c:763
const char * arg
Definition jacosubdec.c:65
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset)
Allows to synchronize objects whose lifetime is the whole decoding process among all frame threads.
Definition decode.c:1990
ThreadingStatus
Definition thread.h:60
@ FF_THREAD_IS_COPY
Definition thread.h:61
@ FF_THREAD_IS_FIRST_THREAD
Definition thread.h:62
@ FF_THREAD_NO_FRAME_THREADING
Definition thread.h:63
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
int ff_thread_can_start_frame(AVCodecContext *avctx)
int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, int(*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr), int(*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count)
int main_func(AVCodecContext *c)
int action_func2(AVCodecContext *c, void *arg, int jobnr, int threadnr)
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
static double c[64]