|
FFmpeg
|
Frame multithreading support functions. More...
#include "config.h"#include <stdatomic.h>#include <stdint.h>#include "avcodec.h"#include "hwaccel.h"#include "internal.h"#include "pthread_internal.h"#include "thread.h"#include "version.h"#include "libavutil/avassert.h"#include "libavutil/buffer.h"#include "libavutil/common.h"#include "libavutil/cpu.h"#include "libavutil/frame.h"#include "libavutil/internal.h"#include "libavutil/log.h"#include "libavutil/mem.h"#include "libavutil/opt.h"#include "libavutil/thread.h"Classes | |
| struct | PerThreadContext |
| Context used by codec threads and stored in their AVCodecInternal thread_ctx. More... | |
| struct | FrameThreadContext |
| Context stored in the client AVCodecInternal thread_ctx. More... | |
Macros | |
| #define | THREAD_SAFE_CALLBACKS(avctx) ((avctx)->thread_safe_callbacks || (avctx)->get_buffer2 == avcodec_default_get_buffer2) |
| #define | copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s); |
Typedefs | |
| typedef struct PerThreadContext | PerThreadContext |
| Context used by codec threads and stored in their AVCodecInternal thread_ctx. | |
| typedef struct FrameThreadContext | FrameThreadContext |
| Context stored in the client AVCodecInternal thread_ctx. | |
Enumerations | |
| enum | { STATE_INPUT_READY, STATE_SETTING_UP, STATE_GET_BUFFER, STATE_GET_FORMAT, STATE_SETUP_FINISHED } |
Functions | |
| int | ff_thread_decode_frame (AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) |
| Submit a new frame to a decoding thread. More... | |
| void | ff_thread_report_progress (ThreadFrame *f, int n, int field) |
| Notify later decoding threads when part of their reference picture is ready. More... | |
| void | ff_thread_await_progress (ThreadFrame *f, int n, int field) |
| Wait for earlier decoding threads to finish reference pictures. More... | |
| 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 start decoding the next frame. More... | |
| void | ff_frame_thread_free (AVCodecContext *avctx, int thread_count) |
| int | ff_frame_thread_init (AVCodecContext *avctx) |
| void | ff_thread_flush (AVCodecContext *avctx) |
| Wait for decoding threads to finish and reset internal state. More... | |
| int | ff_thread_can_start_frame (AVCodecContext *avctx) |
| enum AVPixelFormat | ff_thread_get_format (AVCodecContext *avctx, const enum AVPixelFormat *fmt) |
| Wrapper around get_format() for frame-multithreaded codecs. More... | |
| int | ff_thread_get_buffer (AVCodecContext *avctx, ThreadFrame *f, int flags) |
| Wrapper around get_buffer() for frame-multithreaded codecs. More... | |
| void | ff_thread_release_buffer (AVCodecContext *avctx, ThreadFrame *f) |
| Wrapper around release_buffer() frame-for multithreaded codecs. More... | |
Frame multithreading support functions.
| anonymous enum |
| Enumerator | |
|---|---|
| STATE_INPUT_READY | Set when the thread is awaiting a packet. Set before the codec has called ff_thread_finish_setup(). |
| STATE_GET_BUFFER | Set when the codec calls get_buffer(). State is returned to STATE_SETTING_UP afterwards. |
| STATE_GET_FORMAT | Set when the codec calls get_format(). State is returned to STATE_SETTING_UP afterwards.Set after the codec has called ff_thread_finish_setup(). |
| void ff_thread_await_progress | ( | ThreadFrame * | f, |
| int | progress, | ||
| int | field | ||
| ) |
Wait for earlier decoding threads to finish reference pictures.
Call this before accessing some part of a picture, with a given value for progress, and it will return after the responsible decoding thread calls ff_thread_report_progress() with the same or higher value for progress.
| f | The picture being referenced. |
| progress | Value, in arbitrary units, to wait for. |
| field | The field being referenced, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field. |
| int ff_thread_decode_frame | ( | AVCodecContext * | avctx, |
| AVFrame * | picture, | ||
| int * | got_picture_ptr, | ||
| AVPacket * | avpkt | ||
| ) |
Submit a new frame to a decoding thread.
Returns the next available frame in picture. *got_picture_ptr will be 0 if none is available. The return value on success is the size of the consumed packet for compatibility with avcodec_decode_video2(). This means the decoder has to consume the full packet.
Parameters are the same as avcodec_decode_video2().
| 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 start decoding the next frame.
After calling it, do not change any variables read by the update_thread_context() method, or call ff_thread_get_buffer().
| avctx | The context. |
| void ff_thread_flush | ( | AVCodecContext * | avctx | ) |
Wait for decoding threads to finish and reset internal state.
Called by avcodec_flush_buffers().
| avctx | The context. |
| int ff_thread_get_buffer | ( | AVCodecContext * | avctx, |
| ThreadFrame * | f, | ||
| int | flags | ||
| ) |
Wrapper around get_buffer() for frame-multithreaded codecs.
Call this function instead of ff_get_buffer(f). Cannot be called after the codec has called ff_thread_finish_setup().
| avctx | The current context. |
| f | The frame to write into. |
| enum AVPixelFormat ff_thread_get_format | ( | AVCodecContext * | avctx, |
| const enum AVPixelFormat * | fmt | ||
| ) |
Wrapper around get_format() for frame-multithreaded codecs.
Call this function instead of avctx->get_format(). Cannot be called after the codec has called ff_thread_finish_setup().
| avctx | The current context. |
| fmt | The list of available formats. |
| void ff_thread_release_buffer | ( | AVCodecContext * | avctx, |
| ThreadFrame * | f | ||
| ) |
Wrapper around release_buffer() frame-for multithreaded codecs.
Call this function instead of avctx->release_buffer(f). The AVFrame will be copied and the actual release_buffer() call will be performed later. The contents of data pointed to by the AVFrame should not be changed until ff_thread_get_buffer() is called on it.
| avctx | The current context. |
| f | The picture being released. |
| void ff_thread_report_progress | ( | ThreadFrame * | f, |
| int | progress, | ||
| int | field | ||
| ) |
Notify later decoding threads when part of their reference picture is ready.
Call this when some part of the picture is finished decoding. Later calls with lower values of progress have no effect.
| f | The picture being decoded. |
| progress | Value, in arbitrary units, of how much of the picture has decoded. |
| field | The field being decoded, for field-picture codecs. 0 for top field or frame pictures, 1 for bottom field. |
1.8.12