h264: simplify calls to ff_er_add_slice().
[FFMpeg-mirror/mplayer-patches.git] / libavcodec / thread.h
blob99b0ce146a4761901da35151e09149e00fba7b84
1 /*
2 * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.com>
4 * This file is part of Libav.
6 * Libav 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 * Libav 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 Libav; 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 support functions
24 * @author Alexander Strange <astrange@ithinksw.com>
27 #ifndef AVCODEC_THREAD_H
28 #define AVCODEC_THREAD_H
30 #include "config.h"
31 #include "avcodec.h"
33 /**
34 * Wait for decoding threads to finish and reset internal state.
35 * Called by avcodec_flush_buffers().
37 * @param avctx The context.
39 void ff_thread_flush(AVCodecContext *avctx);
41 /**
42 * Submit a new frame to a decoding thread.
43 * Returns the next available frame in picture. *got_picture_ptr
44 * will be 0 if none is available.
45 * The return value on success is the size of the consumed packet for
46 * compatibility with avcodec_decode_video2(). This means the decoder
47 * has to consume the full packet.
49 * Parameters are the same as avcodec_decode_video2().
51 int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
52 int *got_picture_ptr, AVPacket *avpkt);
54 /**
55 * If the codec defines update_thread_context(), call this
56 * when they are ready for the next thread to start decoding
57 * the next frame. After calling it, do not change any variables
58 * read by the update_thread_context() method, or call ff_thread_get_buffer().
60 * @param avctx The context.
62 void ff_thread_finish_setup(AVCodecContext *avctx);
64 /**
65 * Notify later decoding threads when part of their reference picture is ready.
66 * Call this when some part of the picture is finished decoding.
67 * Later calls with lower values of progress have no effect.
69 * @param f The picture being decoded.
70 * @param progress Value, in arbitrary units, of how much of the picture has decoded.
71 * @param field The field being decoded, for field-picture codecs.
72 * 0 for top field or frame pictures, 1 for bottom field.
74 void ff_thread_report_progress(AVFrame *f, int progress, int field);
76 /**
77 * Wait for earlier decoding threads to finish reference pictures.
78 * Call this before accessing some part of a picture, with a given
79 * value for progress, and it will return after the responsible decoding
80 * thread calls ff_thread_report_progress() with the same or
81 * higher value for progress.
83 * @param f The picture being referenced.
84 * @param progress Value, in arbitrary units, to wait for.
85 * @param field The field being referenced, for field-picture codecs.
86 * 0 for top field or frame pictures, 1 for bottom field.
88 void ff_thread_await_progress(AVFrame *f, int progress, int field);
90 /**
91 * Wrapper around get_buffer() for frame-multithreaded codecs.
92 * Call this function instead of ff_get_buffer(f).
93 * Cannot be called after the codec has called ff_thread_finish_setup().
95 * @param avctx The current context.
96 * @param f The frame to write into.
98 int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f);
101 * Wrapper around release_buffer() frame-for multithreaded codecs.
102 * Call this function instead of avctx->release_buffer(f).
103 * The AVFrame will be copied and the actual release_buffer() call
104 * will be performed later. The contents of data pointed to by the
105 * AVFrame should not be changed until ff_thread_get_buffer() is called
106 * on it.
108 * @param avctx The current context.
109 * @param f The picture being released.
111 void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
113 int ff_thread_init(AVCodecContext *s);
114 void ff_thread_free(AVCodecContext *s);
116 #endif /* AVCODEC_THREAD_H */