FFmpeg
Data Structures | Functions
progressframe.h File Reference

Go to the source code of this file.

Data Structures

struct  ProgressFrame
 The ProgressFrame structure. More...
 

Functions

void ff_progress_frame_report (ProgressFrame *f, int progress)
 Notify later decoding threads when part of their reference frame is ready. More...
 
void ff_progress_frame_await (const ProgressFrame *f, int progress)
 Wait for earlier decoding threads to finish reference frames. More...
 
int ff_progress_frame_alloc (struct AVCodecContext *avctx, ProgressFrame *f)
 This function allocates ProgressFrame.f May be called before ff_progress_frame_get_buffer() in the cases where the AVFrame needs to be accessed before the ff_thread_get_buffer() call in ff_progress_frame_alloc(). More...
 
int ff_progress_frame_get_buffer (struct AVCodecContext *avctx, ProgressFrame *f, int flags)
 This function sets up the ProgressFrame, i.e. More...
 
void ff_progress_frame_unref (ProgressFrame *f)
 Give up a reference to the underlying frame contained in a ProgressFrame and reset the ProgressFrame, setting all pointers to NULL. More...
 
void ff_progress_frame_ref (ProgressFrame *dst, const ProgressFrame *src)
 Set dst->f to src->f and make dst a co-owner of src->f. More...
 
void ff_progress_frame_replace (ProgressFrame *dst, const ProgressFrame *src)
 Do nothing if dst and src already refer to the same AVFrame; otherwise unreference dst and if src is not blank, put a reference to src's AVFrame in its place (in case src is not blank). More...
 

Function Documentation

◆ ff_progress_frame_report()

void ff_progress_frame_report ( ProgressFrame f,
int  progress 
)

Notify later decoding threads when part of their reference frame is ready.

Call this when some part of the frame is finished decoding. Later calls with lower values of progress have no effect.

Parameters
fThe frame being decoded.
progressValue, in arbitrary units, of how much of the frame has decoded.
Warning
Calling this on a blank ProgressFrame causes undefined behaviour

Definition at line 1893 of file decode.c.

Referenced by decode(), decode_frame(), decode_frame_common(), decode_nal_units(), decode_slice(), decode_tiles(), ff_hevc_hls_filter(), generate_missing_ref(), mimic_decode_frame(), vp3_draw_horiz_band(), vp78_decode_frame(), vp78_decode_mb_row_sliced(), and vp9_decode_frame().

◆ ff_progress_frame_await()

void ff_progress_frame_await ( const ProgressFrame f,
int  progress 
)

Wait for earlier decoding threads to finish reference frames.

Call this before accessing some part of a frame, with a given value for progress, and it will return after the responsible decoding thread calls ff_thread_progress_report() with the same or higher value for progress.

Parameters
fThe frame being referenced.
progressValue, in arbitrary units, to wait for.
Warning
Calling this on a blank ProgressFrame causes undefined behaviour

Definition at line 1898 of file decode.c.

◆ ff_progress_frame_alloc()

int ff_progress_frame_alloc ( struct AVCodecContext avctx,
ProgressFrame f 
)

This function allocates ProgressFrame.f May be called before ff_progress_frame_get_buffer() in the cases where the AVFrame needs to be accessed before the ff_thread_get_buffer() call in ff_progress_frame_alloc().

Note
: This must only be called by codecs with the FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.

Definition at line 1834 of file decode.c.

Referenced by alloc_frame(), and ff_progress_frame_get_buffer().

◆ ff_progress_frame_get_buffer()

int ff_progress_frame_get_buffer ( struct AVCodecContext avctx,
ProgressFrame f,
int  flags 
)

This function sets up the ProgressFrame, i.e.

allocates ProgressFrame.f if needed, and also calls ff_thread_get_buffer() on the frame.

Note
: This must only be called by codecs with the FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap.
See also
ff_progress_frame_alloc

Definition at line 1848 of file decode.c.

Referenced by alloc_frame(), av1_frame_alloc(), decode_frame(), decode_idat_chunk(), mimic_decode_frame(), vp8_alloc_frame(), and vp9_frame_alloc().

◆ ff_progress_frame_unref()

void ff_progress_frame_unref ( ProgressFrame f)

Give up a reference to the underlying frame contained in a ProgressFrame and reset the ProgressFrame, setting all pointers to NULL.

Note
: This implies that when using this API the check for whether a frame exists is by checking ProgressFrame.f and not ProgressFrame.f->data[0] or ProgressFrame.f->buf[0].

Definition at line 1876 of file decode.c.

Referenced by av1_frame_unref(), decode_frame(), decode_idat_chunk(), ff_hevc_unref_frame(), ff_progress_frame_replace(), ffv1_decode_close(), mimic_decode_end(), mimic_decode_frame(), png_dec_end(), update_frames(), vp3_decode_flush(), vp8_alloc_frame(), vp8_release_frame(), vp9_decode_flush(), vp9_decode_free(), and vp9_frame_unref().

◆ ff_progress_frame_ref()

void ff_progress_frame_ref ( ProgressFrame dst,
const ProgressFrame src 
)

Set dst->f to src->f and make dst a co-owner of src->f.

dst can then be used to wait on progress of the underlying frame.

Note
: There is no underlying av_frame_ref() here. dst->f and src->f really point to the same AVFrame. Typically this means that the decoding thread is allowed to set all the properties of the AVFrame until it has indicated to have finished decoding. Afterwards later threads may read all of these fields. Access to the frame's data is governed by ff_thread_progress_report/await().

Definition at line 1868 of file decode.c.

Referenced by ff_progress_frame_replace(), and hevc_ref_frame().

◆ ff_progress_frame_replace()

void ff_progress_frame_replace ( ProgressFrame dst,
const ProgressFrame src 
)

Do nothing if dst and src already refer to the same AVFrame; otherwise unreference dst and if src is not blank, put a reference to src's AVFrame in its place (in case src is not blank).

Definition at line 1883 of file decode.c.

Referenced by av1_frame_replace(), update_frames(), vp9_decode_frame(), and vp9_frame_replace().