annotate ffmpeg/libavcodec/thread.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.com>
yading@10 3 *
yading@10 4 * This file is part of FFmpeg.
yading@10 5 *
yading@10 6 * FFmpeg is free software; you can redistribute it and/or
yading@10 7 * modify it under the terms of the GNU Lesser General Public
yading@10 8 * License as published by the Free Software Foundation; either
yading@10 9 * version 2.1 of the License, or (at your option) any later version.
yading@10 10 *
yading@10 11 * FFmpeg is distributed in the hope that it will be useful,
yading@10 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 14 * Lesser General Public License for more details.
yading@10 15 *
yading@10 16 * You should have received a copy of the GNU Lesser General Public
yading@10 17 * License along with FFmpeg; if not, write to the Free Software
yading@10 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 19 */
yading@10 20
yading@10 21 /**
yading@10 22 * @file
yading@10 23 * Multithreading support functions
yading@10 24 * @author Alexander Strange <astrange@ithinksw.com>
yading@10 25 */
yading@10 26
yading@10 27 #ifndef AVCODEC_THREAD_H
yading@10 28 #define AVCODEC_THREAD_H
yading@10 29
yading@10 30 #include "libavutil/buffer.h"
yading@10 31
yading@10 32 #include "config.h"
yading@10 33 #include "avcodec.h"
yading@10 34
yading@10 35 typedef struct ThreadFrame {
yading@10 36 AVFrame *f;
yading@10 37 AVCodecContext *owner;
yading@10 38 // progress->data is an array of 2 ints holding progress for top/bottom
yading@10 39 // fields
yading@10 40 AVBufferRef *progress;
yading@10 41 } ThreadFrame;
yading@10 42
yading@10 43 /**
yading@10 44 * Wait for decoding threads to finish and reset internal state.
yading@10 45 * Called by avcodec_flush_buffers().
yading@10 46 *
yading@10 47 * @param avctx The context.
yading@10 48 */
yading@10 49 void ff_thread_flush(AVCodecContext *avctx);
yading@10 50
yading@10 51 /**
yading@10 52 * Submit a new frame to a decoding thread.
yading@10 53 * Returns the next available frame in picture. *got_picture_ptr
yading@10 54 * will be 0 if none is available.
yading@10 55 * The return value on success is the size of the consumed packet for
yading@10 56 * compatibility with avcodec_decode_video2(). This means the decoder
yading@10 57 * has to consume the full packet.
yading@10 58 *
yading@10 59 * Parameters are the same as avcodec_decode_video2().
yading@10 60 */
yading@10 61 int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
yading@10 62 int *got_picture_ptr, AVPacket *avpkt);
yading@10 63
yading@10 64 /**
yading@10 65 * If the codec defines update_thread_context(), call this
yading@10 66 * when they are ready for the next thread to start decoding
yading@10 67 * the next frame. After calling it, do not change any variables
yading@10 68 * read by the update_thread_context() method, or call ff_thread_get_buffer().
yading@10 69 *
yading@10 70 * @param avctx The context.
yading@10 71 */
yading@10 72 void ff_thread_finish_setup(AVCodecContext *avctx);
yading@10 73
yading@10 74 /**
yading@10 75 * Notify later decoding threads when part of their reference picture is ready.
yading@10 76 * Call this when some part of the picture is finished decoding.
yading@10 77 * Later calls with lower values of progress have no effect.
yading@10 78 *
yading@10 79 * @param f The picture being decoded.
yading@10 80 * @param progress Value, in arbitrary units, of how much of the picture has decoded.
yading@10 81 * @param field The field being decoded, for field-picture codecs.
yading@10 82 * 0 for top field or frame pictures, 1 for bottom field.
yading@10 83 */
yading@10 84 void ff_thread_report_progress(ThreadFrame *f, int progress, int field);
yading@10 85
yading@10 86 /**
yading@10 87 * Wait for earlier decoding threads to finish reference pictures.
yading@10 88 * Call this before accessing some part of a picture, with a given
yading@10 89 * value for progress, and it will return after the responsible decoding
yading@10 90 * thread calls ff_thread_report_progress() with the same or
yading@10 91 * higher value for progress.
yading@10 92 *
yading@10 93 * @param f The picture being referenced.
yading@10 94 * @param progress Value, in arbitrary units, to wait for.
yading@10 95 * @param field The field being referenced, for field-picture codecs.
yading@10 96 * 0 for top field or frame pictures, 1 for bottom field.
yading@10 97 */
yading@10 98 void ff_thread_await_progress(ThreadFrame *f, int progress, int field);
yading@10 99
yading@10 100 /**
yading@10 101 * Wrapper around get_format() for frame-multithreaded codecs.
yading@10 102 * Call this function instead of avctx->get_format().
yading@10 103 * Cannot be called after the codec has called ff_thread_finish_setup().
yading@10 104 *
yading@10 105 * @param avctx The current context.
yading@10 106 * @param fmt The list of available formats.
yading@10 107 */
yading@10 108 enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
yading@10 109
yading@10 110 /**
yading@10 111 * Wrapper around get_buffer() for frame-multithreaded codecs.
yading@10 112 * Call this function instead of ff_get_buffer(f).
yading@10 113 * Cannot be called after the codec has called ff_thread_finish_setup().
yading@10 114 *
yading@10 115 * @param avctx The current context.
yading@10 116 * @param f The frame to write into.
yading@10 117 */
yading@10 118 int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags);
yading@10 119
yading@10 120 /**
yading@10 121 * Wrapper around release_buffer() frame-for multithreaded codecs.
yading@10 122 * Call this function instead of avctx->release_buffer(f).
yading@10 123 * The AVFrame will be copied and the actual release_buffer() call
yading@10 124 * will be performed later. The contents of data pointed to by the
yading@10 125 * AVFrame should not be changed until ff_thread_get_buffer() is called
yading@10 126 * on it.
yading@10 127 *
yading@10 128 * @param avctx The current context.
yading@10 129 * @param f The picture being released.
yading@10 130 */
yading@10 131 void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f);
yading@10 132
yading@10 133 int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src);
yading@10 134
yading@10 135 int ff_thread_init(AVCodecContext *s);
yading@10 136 void ff_thread_free(AVCodecContext *s);
yading@10 137
yading@10 138 #endif /* AVCODEC_THREAD_H */