avformat/mpeg: demux ivtv captions
[ffmpeg.git] / libavcodec / thread.h
blob7df5839ed0976d842bb75e14f317452f922ce61a
1 /*
2 * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.com>
4 * This file is part of FFmpeg.
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.
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.
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
21 /**
22 * @file
23 * Multithreading API for decoders
24 * @author Alexander Strange <astrange@ithinksw.com>
27 #ifndef AVCODEC_THREAD_H
28 #define AVCODEC_THREAD_H
30 #include "libavutil/buffer.h"
32 #include "avcodec.h"
34 int ff_thread_can_start_frame(AVCodecContext *avctx);
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().
42 * @param avctx The context.
44 void ff_thread_finish_setup(AVCodecContext *avctx);
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().
51 * @param avctx The current context.
52 * @param f The frame to write into.
54 int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags);
56 int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
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);
60 enum ThreadingStatus {
61 FF_THREAD_IS_COPY,
62 FF_THREAD_IS_FIRST_THREAD,
63 FF_THREAD_NO_FRAME_THREADING,
66 /**
67 * Allows to synchronize objects whose lifetime is the whole decoding
68 * process among all frame threads.
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).
78 * @param avctx an AVCodecContext
79 * @param offset offset of the RefStruct reference in avctx's private data
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.
88 enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset);
90 #endif /* AVCODEC_THREAD_H */