FFmpeg
Data Structures | Functions
threadprogress.h File Reference
#include <limits.h>
#include <stdatomic.h>
#include "libavutil/thread.h"

Go to the source code of this file.

Data Structures

struct  ThreadProgress
 ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can be packaged into an int and is consistent with the natural ordering of integers. More...
 

Functions

int ff_thread_progress_init (ThreadProgress *pro, int init_mode)
 Initialize a ThreadProgress. More...
 
void ff_thread_progress_destroy (ThreadProgress *pro)
 Destroy a ThreadProgress. More...
 
static void ff_thread_progress_reset (ThreadProgress *pro)
 Reset the ThreadProgress.progress counter; must only be called if the ThreadProgress is not in use in any way (e.g. More...
 
void ff_thread_progress_report (ThreadProgress *pro, int progress)
 This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of progress has been reached. More...
 
void ff_thread_progress_await (const ThreadProgress *pro, int progress)
 This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain level of progress: This function will return after another thread has called ff_thread_progress_report() with the same or higher value for progress. More...
 

Function Documentation

◆ ff_thread_progress_init()

int ff_thread_progress_init ( ThreadProgress pro,
int  init_mode 
)

Initialize a ThreadProgress.

Parameters
init_modeIf zero, the ThreadProgress will be initialized to be in no-op mode as described above. Otherwise it is initialized to be in ordinary mode.

Definition at line 33 of file threadprogress.c.

Referenced by mpv_pic_init(), progress_frame_pool_init_cb(), progress_init(), and wpp_progress_init().

◆ ff_thread_progress_destroy()

void ff_thread_progress_destroy ( ThreadProgress pro)

Destroy a ThreadProgress.

Can be called on a ThreadProgress that has never been initialized provided that the ThreadProgress struct has been initially zeroed. Must be called even if ff_thread_progress_init() failed.

Definition at line 44 of file threadprogress.c.

Referenced by hevc_decode_free(), mpv_pic_free(), progress_frame_pool_free_entry_cb(), and rv60_decode_end().

◆ ff_thread_progress_reset()

static void ff_thread_progress_reset ( ThreadProgress pro)
inlinestatic

Reset the ThreadProgress.progress counter; must only be called if the ThreadProgress is not in use in any way (e.g.

no thread may wait on it via ff_thread_progress_await()).

Definition at line 72 of file threadprogress.h.

Referenced by mpv_pic_reset(), progress_frame_pool_reset_cb(), progress_init(), and wpp_progress_init().

◆ ff_thread_progress_report()

void ff_thread_progress_report ( ThreadProgress pro,
int  progress 
)

This function is a no-op in no-op mode; otherwise it notifies other threads that a certain level of progress has been reached.

Later calls with lower values of progress have no effect.

Definition at line 53 of file threadprogress.c.

Referenced by alloc_dummy_frame(), decode_slice(), ff_mpv_frame_end(), ff_mpv_report_decode_progress(), ff_progress_frame_report(), ff_rv34_decode_frame(), finish_frame(), hls_decode_entry_wpp(), rv34_decode_slice(), and wavpack_decode_frame().

◆ ff_thread_progress_await()

void ff_thread_progress_await ( const ThreadProgress pro,
int  progress 
)

This function is a no-op in no-op mode; otherwise it waits until other threads have reached a certain level of progress: This function will return after another thread has called ff_thread_progress_report() with the same or higher value for progress.

Definition at line 65 of file threadprogress.c.

Referenced by decode_slice(), ff_er_frame_end(), ff_progress_frame_await(), guess_mv(), hls_decode_entry_wpp(), is_intra_more_likely(), mpeg4_decode_mb(), mpv_reconstruct_mb_internal(), rv34_decode_mv(), rv34_mc(), and wavpack_decode_frame().