FFmpeg
thread.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Alexander Strange <astrange@ithinksw.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 
27 #ifndef AVCODEC_THREAD_H
28 #define AVCODEC_THREAD_H
29 
30 #include "libavutil/buffer.h"
31 
32 #include "avcodec.h"
33 
34 typedef struct ThreadFrame {
35  AVFrame *f;
36  AVCodecContext *owner[2];
37  // progress->data is an array of 2 ints holding progress for top/bottom
38  // fields
39  AVBufferRef *progress;
40 } ThreadFrame;
41 
48 void ff_thread_flush(AVCodecContext *avctx);
49 
60 int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
61  int *got_picture_ptr, AVPacket *avpkt);
62 
72 
83 void ff_thread_report_progress(ThreadFrame *f, int progress, int field);
84 
97 void ff_thread_await_progress(ThreadFrame *f, int progress, int field);
98 
107 enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
108 
117 int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags);
118 
131 
132 int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src);
133 
134 int ff_thread_init(AVCodecContext *s);
135 int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
136  int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr),
137  int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count);
138 void ff_thread_free(AVCodecContext *s);
139 int ff_alloc_entries(AVCodecContext *avctx, int count);
140 void ff_reset_entries(AVCodecContext *avctx);
141 void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n);
142 void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift);
143 
144 #endif /* AVCODEC_THREAD_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
void ff_thread_flush(AVCodecContext *avctx)
Wait for decoding threads to finish and reset internal state.
Definition: pthread_frame.c:842
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
Definition: pthread_frame.c:973
void ff_thread_report_progress(ThreadFrame *f, int progress, int field)
Notify later decoding threads when part of their reference picture is ready.
Definition: pthread_frame.c:557
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Wrapper around get_format() for frame-multithreaded codecs.
Definition: pthread_frame.c:939
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
Definition: pthread_frame.c:965
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 st...
Definition: pthread_frame.c:601
void ff_thread_await_progress(ThreadFrame *f, int progress, int field)
Wait for earlier decoding threads to finish reference pictures.
Definition: pthread_frame.c:580
Definition: thread.h:34
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1518
refcounted data buffer API
A reference to a data buffer.
Definition: buffer.h:81
int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
Submit a new frame to a decoding thread.
Definition: pthread_frame.c:472
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
This structure stores compressed data.
Definition: avcodec.h:1407