FFmpeg
Loading...
Searching...
No Matches
threadframe.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Andreas Rheinhardt <andreas.rheinhardt@outlook.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#ifndef AVCODEC_THREADFRAME_H
22#define AVCODEC_THREADFRAME_H
23
24#include "libavutil/frame.h"
25#include "avcodec.h"
26
32
33/**
34 * Notify later decoding threads when part of their reference picture is ready.
35 * Call this when some part of the picture is finished decoding.
36 * Later calls with lower values of progress have no effect.
37 *
38 * @param f The picture being decoded.
39 * @param progress Value, in arbitrary units, of how much of the picture has decoded.
40 * @param field The field being decoded, for field-picture codecs.
41 * 0 for top field or frame pictures, 1 for bottom field.
42 */
43void ff_thread_report_progress(ThreadFrame *f, int progress, int field);
44
45/**
46 * Wait for earlier decoding threads to finish reference pictures.
47 * Call this before accessing some part of a picture, with a given
48 * value for progress, and it will return after the responsible decoding
49 * thread calls ff_thread_report_progress() with the same or
50 * higher value for progress.
51 *
52 * @param f The picture being referenced.
53 * @param progress Value, in arbitrary units, to wait for.
54 * @param field The field being referenced, for field-picture codecs.
55 * 0 for top field or frame pictures, 1 for bottom field.
56 */
57void ff_thread_await_progress(const ThreadFrame *f, int progress, int field);
58
59/**
60 * Wrapper around ff_get_buffer() for frame-multithreaded codecs.
61 * Call this function instead of ff_get_buffer() if you might need
62 * to wait for progress on this frame.
63 * Cannot be called after the codec has called ff_thread_finish_setup().
64 *
65 * @param avctx The current context.
66 * @param f The frame to write into.
67 * @note: It is fine to call this with codecs that do not support
68 * frame threading.
69 */
71
72/**
73 * Unref a ThreadFrame.
74 *
75 * This is basically a wrapper around av_frame_unref() and should
76 * be called instead of it.
77 *
78 * @param avctx The current context.
79 * @param f The picture being released.
80 */
82
84
86
87#endif
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
Libavcodec external API header.
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define f(width, name)
Definition cbs_vp8.c:236
reference-counted frame API
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
atomic_int progress[2]
struct ThreadFrameProgress * progress
Definition threadframe.h:30
AVCodecContext * owner[2]
Definition threadframe.h:29
AVFrame * f
Definition threadframe.h:28
#define src
Definition vp8dsp.c:248
int ff_thread_replace_frame(ThreadFrame *dst, const ThreadFrame *src)
Definition utils.c:888
void ff_thread_release_ext_buffer(ThreadFrame *f)
Unref a ThreadFrame.
int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around ff_get_buffer() for frame-multithreaded codecs.
void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
Notify later decoding threads when part of their reference picture is ready.
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
Definition utils.c:869
void ff_thread_await_progress(const ThreadFrame *f, int progress, int field)
Wait for earlier decoding threads to finish reference pictures.