FFmpeg
Functions
thread.h File Reference
#include "libavutil/buffer.h"
#include "avcodec.h"

Go to the source code of this file.

Functions

void ff_thread_flush (AVCodecContext *avctx)
 Wait for decoding threads to finish and reset internal state. More...
 
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_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...
 
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, AVFrame *f, int flags)
 Wrapper around get_buffer() for frame-multithreaded codecs. More...
 
void ff_thread_release_buffer (AVCodecContext *avctx, AVFrame *f)
 Wrapper around release_buffer() frame-for multithreaded codecs. More...
 
int ff_thread_init (AVCodecContext *s)
 
int ff_slice_thread_execute_with_mainfunc (AVCodecContext *avctx, int(*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr), int(*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count)
 
void ff_thread_free (AVCodecContext *s)
 
int ff_alloc_entries (AVCodecContext *avctx, int count)
 
void ff_reset_entries (AVCodecContext *avctx)
 
int ff_slice_thread_init_progress (AVCodecContext *avctx)
 
void ff_thread_report_progress2 (AVCodecContext *avctx, int field, int thread, int n)
 
void ff_thread_await_progress2 (AVCodecContext *avctx, int field, int thread, int shift)
 

Detailed Description

Multithreading support functions

Author
Alexander Strange astra.nosp@m.nge@.nosp@m.ithin.nosp@m.ksw..nosp@m.com

Definition in file thread.h.

Function Documentation

◆ ff_thread_flush()

void ff_thread_flush ( AVCodecContext avctx)

Wait for decoding threads to finish and reset internal state.

Called by avcodec_flush_buffers().

Parameters
avctxThe context.

Definition at line 902 of file pthread_frame.c.

Referenced by avcodec_flush_buffers().

◆ ff_thread_decode_frame()

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 FFCodec.decode. This means the decoder has to consume the full packet.

Parameters are the same as FFCodec.decode.

Definition at line 510 of file pthread_frame.c.

Referenced by decode_simple_internal().

◆ ff_thread_finish_setup()

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().

Parameters
avctxThe context.

Definition at line 639 of file pthread_frame.c.

Referenced by frame_worker_thread(), and thread_get_buffer_internal().

◆ ff_thread_get_format()

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().

Parameters
avctxThe current context.
fmtThe list of available formats.

Definition at line 1005 of file pthread_frame.c.

Referenced by decode_frame_header(), get_format(), get_pixel_format(), mpeg_get_pixelformat(), and update_size().

◆ ff_thread_get_buffer()

int ff_thread_get_buffer ( AVCodecContext avctx,
AVFrame 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().

Parameters
avctxThe current context.
fThe frame to write into.

Definition at line 1035 of file pthread_frame.c.

Referenced by ff_thread_get_ext_buffer().

◆ ff_thread_release_buffer()

void ff_thread_release_buffer ( AVCodecContext avctx,
AVFrame 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.

Parameters
avctxThe current context.
fThe picture being released.

Definition at line 1074 of file pthread_frame.c.

Referenced by av1_frame_unref(), ff_h264_replace_picture(), ff_h264_unref_picture(), ff_hevc_unref_frame(), ff_thread_release_ext_buffer(), frame_worker_thread(), vaapi_av1_decode_uninit(), and vaapi_av1_end_frame().

◆ ff_thread_init()

int ff_thread_init ( AVCodecContext s)

Definition at line 74 of file pthread.c.

Referenced by avcodec_open2().

◆ ff_slice_thread_execute_with_mainfunc()

int ff_slice_thread_execute_with_mainfunc ( AVCodecContext avctx,
int(*)(AVCodecContext *c, void *arg, int jobnr, int threadnr)  action_func2,
int(*)(AVCodecContext *c main_func,
void *  arg,
int ret,
int  job_count 
)

◆ ff_thread_free()

void ff_thread_free ( AVCodecContext s)

Definition at line 86 of file pthread.c.

Referenced by avcodec_close().

◆ ff_alloc_entries()

int ff_alloc_entries ( AVCodecContext avctx,
int  count 
)

Definition at line 240 of file pthread_slice.c.

Referenced by hls_slice_data_wpp().

◆ ff_reset_entries()

void ff_reset_entries ( AVCodecContext avctx)

Definition at line 260 of file pthread_slice.c.

Referenced by hls_slice_data_wpp().

◆ ff_slice_thread_init_progress()

int ff_slice_thread_init_progress ( AVCodecContext avctx)

Definition at line 179 of file pthread_slice.c.

Referenced by hevc_decode_init().

◆ ff_thread_report_progress2()

void ff_thread_report_progress2 ( AVCodecContext avctx,
int  field,
int  thread,
int  n 
)

Definition at line 210 of file pthread_slice.c.

Referenced by hls_decode_entry_wpp().

◆ ff_thread_await_progress2()

void ff_thread_await_progress2 ( AVCodecContext avctx,
int  field,
int  thread,
int  shift 
)

Definition at line 222 of file pthread_slice.c.

Referenced by hls_decode_entry_wpp().