FFmpeg
|
Multithreading support functions. More...
Go to the source code of this file.
Data Structures | |
struct | ThreadFrame |
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... | |
void | ff_thread_report_progress (ThreadFrame *f, int progress, int field) |
Notify later decoding threads when part of their reference picture is ready. More... | |
void | ff_thread_await_progress (ThreadFrame *f, int progress, int field) |
Wait for earlier decoding threads to finish reference pictures. 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, 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... | |
int | ff_thread_ref_frame (ThreadFrame *dst, ThreadFrame *src) |
int | ff_thread_init (AVCodecContext *s) |
void | ff_thread_free (AVCodecContext *s) |
int | ff_alloc_entries (AVCodecContext *avctx, int count) |
void | ff_reset_entries (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) |
Multithreading support functions.
Definition in file thread.h.
void ff_thread_flush | ( | AVCodecContext * | avctx | ) |
Wait for decoding threads to finish and reset internal state.
Called by avcodec_flush_buffers().
avctx | The context. |
Definition at line 841 of file pthread_frame.c.
Referenced by avcodec_flush_buffers().
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().
Definition at line 472 of file pthread_frame.c.
Referenced by avcodec_decode_audio4(), and 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. |
Definition at line 600 of file pthread_frame.c.
Referenced by decode_frame(), decode_idat_chunk(), decode_nal_units(), ff_h263_decode_frame(), ff_rv34_decode_frame(), frame_worker_thread(), hap_decode(), hevc_frame_start(), mimic_decode_frame(), mpeg_field_start(), tak_decode_frame(), thread_get_buffer_internal(), vp78_decode_frame(), and vp9_decode_frame().
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. |
Definition at line 558 of file pthread_frame.c.
Referenced by decode(), decode_finish_row(), decode_frame(), decode_frame_common(), decode_nal_units(), ff_h264_field_end(), ff_h264_queue_decode_slice(), ff_hevc_hls_filter(), ff_mpv_frame_end(), ff_mpv_frame_start(), ff_mpv_report_decode_progress(), ff_rv34_decode_frame(), finish_frame(), generate_missing_ref(), h264_field_start(), handle_p_frame_apng(), mimic_decode_frame(), rv34_decode_slice(), vp3_draw_horiz_band(), vp78_decode_frame(), vp78_decode_mb_row_sliced(), and vp9_decode_frame().
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. |
Definition at line 580 of file pthread_frame.c.
Referenced by await_reference_mb_row(), await_reference_row(), await_references(), decode(), decode_frame(), decode_mb_row_no_filter(), decode_mode(), decode_slice(), ff_er_frame_end(), find_ref_mvs(), guess_mv(), h264_field_start(), handle_p_frame_apng(), handle_p_frame_png(), hevc_await_progress(), is_intra_more_likely(), mc_chroma_scaled(), mc_chroma_unscaled(), mc_luma_scaled(), mc_luma_unscaled(), mpeg4_decode_mb(), mpv_decode_mb_internal(), rv34_decode_mv(), rv34_mc(), temporal_luma_motion_vector(), vp78_decode_frame(), vp8_mc_chroma(), and vp8_mc_luma().
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. |
Definition at line 939 of file pthread_frame.c.
Referenced by get_pixel_format(), mpeg_get_pixelformat(), set_sps(), and update_size().
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. |
Definition at line 965 of file pthread_frame.c.
Referenced by aic_decode_frame(), alloc_frame(), alloc_frame_buffer(), alloc_picture(), cfhd_decode(), decode_element(), decode_entropy_coded_image(), decode_frame(), decode_idat_chunk(), dnxhd_decode_frame(), dxv_decode(), flac_decode_frame(), hap_decode(), init_image(), jpeg2000_decode_frame(), lag_decode_frame(), libopenjpeg_decode_frame(), magy_decode_frame(), mimic_decode_frame(), pixlet_decode_frame(), tak_decode_frame(), tta_decode_frame(), vble_decode_frame(), vp8_alloc_frame(), vp9_frame_alloc(), and wavpack_decode_block().
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. |
Definition at line 973 of file pthread_frame.c.
Referenced by decode_frame(), decode_idat_chunk(), ff_ffv1_close(), ff_h264_unref_picture(), ff_hevc_unref_frame(), ff_mpeg_unref_picture(), ff_thread_ref_frame(), mimic_decode_end(), mimic_decode_frame(), png_dec_end(), ref_frame(), update_frames(), vp3_decode_flush(), vp8_alloc_frame(), vp8_release_frame(), vp9_decode_flush(), vp9_decode_frame(), vp9_decode_free(), and vp9_frame_unref().
int ff_thread_ref_frame | ( | ThreadFrame * | dst, |
ThreadFrame * | src | ||
) |
Definition at line 3970 of file utils.c.
Referenced by ff_h264_ref_picture(), ff_mpeg_ref_picture(), hevc_ref_frame(), ref_frame(), update_frames(), vp9_decode_frame(), and vp9_frame_ref().
int ff_thread_init | ( | AVCodecContext * | s | ) |
Definition at line 70 of file pthread.c.
Referenced by avcodec_open2().
void ff_thread_free | ( | AVCodecContext * | s | ) |
Definition at line 82 of file pthread.c.
Referenced by avcodec_close(), and ff_slice_thread_init().
int ff_alloc_entries | ( | AVCodecContext * | avctx, |
int | count | ||
) |
Definition at line 269 of file pthread_slice.c.
Referenced by hls_slice_data_wpp().
void ff_reset_entries | ( | AVCodecContext * | avctx | ) |
Definition at line 306 of file pthread_slice.c.
Referenced by hls_slice_data_wpp().
void ff_thread_report_progress2 | ( | AVCodecContext * | avctx, |
int | field, | ||
int | thread, | ||
int | n | ||
) |
Definition at line 242 of file pthread_slice.c.
Referenced by hls_decode_entry_wpp().
void ff_thread_await_progress2 | ( | AVCodecContext * | avctx, |
int | field, | ||
int | thread, | ||
int | shift | ||
) |
Definition at line 253 of file pthread_slice.c.
Referenced by hls_decode_entry_wpp().