FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions | Variables
framesync.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "framesync.h"
#include "internal.h"

Go to the source code of this file.

Macros

#define OFFSET(member)   offsetof(FFFrameSync, member)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

enum  { STATE_BOF, STATE_RUN, STATE_EOF }
 

Functions

static const char * framesync_name (void *ptr)
 
static int consume_from_fifos (FFFrameSync *fs)
 
const AVClassff_framesync_get_class (void)
 Get the class for the framesync object. More...
 
void ff_framesync_preinit (FFFrameSync *fs)
 Pre-initialize a frame sync structure. More...
 
int ff_framesync_init (FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
 Initialize a frame sync structure. More...
 
static void framesync_eof (FFFrameSync *fs)
 
static void framesync_sync_level_update (FFFrameSync *fs)
 
int ff_framesync_configure (FFFrameSync *fs)
 Configure a frame sync structure. More...
 
static int framesync_advance (FFFrameSync *fs)
 
static int64_t framesync_pts_extrapolate (FFFrameSync *fs, unsigned in, int64_t pts)
 
static void framesync_inject_frame (FFFrameSync *fs, unsigned in, AVFrame *frame)
 
static void framesync_inject_status (FFFrameSync *fs, unsigned in, int status, int64_t pts)
 
int ff_framesync_get_frame (FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
 Get the current frame in an input. More...
 
void ff_framesync_uninit (FFFrameSync *fs)
 Free all memory currently allocated. More...
 
int ff_framesync_activate (FFFrameSync *fs)
 Examine the frames in the filter's input and try to produce output. More...
 
int ff_framesync_init_dualinput (FFFrameSync *fs, AVFilterContext *parent)
 Initialize a frame sync structure for dualinput. More...
 
int ff_framesync_dualinput_get (FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
 
int ff_framesync_dualinput_get_writable (FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
 Same as ff_framesync_dualinput_get(), but make sure that f0 is writable. More...
 

Variables

static const AVOption framesync_options []
 
static const AVClass framesync_class
 

Macro Definition Documentation

#define OFFSET (   member)    offsetof(FFFrameSync, member)

Definition at line 28 of file framesync.c.

Definition at line 29 of file framesync.c.

Enumeration Type Documentation

anonymous enum
Enumerator
STATE_BOF 
STATE_RUN 
STATE_EOF 

Definition at line 56 of file framesync.c.

Function Documentation

static const char* framesync_name ( void ptr)
static

Definition at line 31 of file framesync.c.

static int consume_from_fifos ( FFFrameSync fs)
static

Definition at line 305 of file framesync.c.

Referenced by framesync_advance().

const AVClass* ff_framesync_get_class ( void  )

Get the class for the framesync object.

Definition at line 64 of file framesync.c.

void ff_framesync_preinit ( FFFrameSync fs)

Pre-initialize a frame sync structure.

It sets the class pointer and inits the options to their default values. The entire structure is expected to be already set to 0. This step is optional, but necessary to use the options.

Definition at line 69 of file framesync.c.

Referenced by ff_framesync_init().

int ff_framesync_init ( FFFrameSync fs,
AVFilterContext parent,
unsigned  nb_in 
)

Initialize a frame sync structure.

The entire structure is expected to be already set to 0 or preinited.

Parameters
fsframe sync structure to initialize
parentparent AVFilterContext object
nb_innumber of inputs
Returns
>= 0 for success or a negative error code

Definition at line 77 of file framesync.c.

Referenced by config_output(), ff_framesync_init_dualinput(), init_framesync(), lut2_config_output(), and program_opencl_config_output().

static void framesync_eof ( FFFrameSync fs)
static

Definition at line 94 of file framesync.c.

Referenced by framesync_advance(), and framesync_sync_level_update().

static void framesync_sync_level_update ( FFFrameSync fs)
static

Definition at line 101 of file framesync.c.

Referenced by ff_framesync_configure(), and framesync_inject_status().

int ff_framesync_configure ( FFFrameSync fs)

Configure a frame sync structure.

Must be called after all options are set but before all use.

Returns
>= 0 for success or a negative error code

Definition at line 117 of file framesync.c.

Referenced by config_output(), init_framesync(), lut2_config_output(), overlay_opencl_config_output(), and program_opencl_config_output().

static int framesync_advance ( FFFrameSync fs)
static

Definition at line 177 of file framesync.c.

Referenced by ff_framesync_activate().

static int64_t framesync_pts_extrapolate ( FFFrameSync fs,
unsigned  in,
int64_t  pts 
)
static

Definition at line 224 of file framesync.c.

Referenced by framesync_inject_status().

static void framesync_inject_frame ( FFFrameSync fs,
unsigned  in,
AVFrame frame 
)
static

Definition at line 231 of file framesync.c.

Referenced by consume_from_fifos().

static void framesync_inject_status ( FFFrameSync fs,
unsigned  in,
int  status,
int64_t  pts 
)
static

Definition at line 244 of file framesync.c.

Referenced by consume_from_fifos().

int ff_framesync_get_frame ( FFFrameSync fs,
unsigned  in,
AVFrame **  rframe,
unsigned  get 
)

Get the current frame in an input.

Parameters
fsframe sync structure
inindex of the input
rframeused to return the current frame (or NULL)
getif not zero, the calling code needs to get ownership of the returned frame; the current frame will either be duplicated or removed from the framesync structure

Definition at line 256 of file framesync.c.

Referenced by ff_framesync_dualinput_get(), overlay_opencl_blend(), process_frame(), and program_opencl_filter().

void ff_framesync_uninit ( FFFrameSync fs)

Free all memory currently allocated.

Definition at line 293 of file framesync.c.

Referenced by overlay_opencl_uninit(), overlay_qsv_uninit(), program_opencl_uninit(), and uninit().

int ff_framesync_activate ( FFFrameSync fs)

Examine the frames in the filter's input and try to produce output.

This function can be the complete implementation of the activate method of a filter using framesync.

Definition at line 344 of file framesync.c.

Referenced by activate(), overlay_opencl_activate(), and program_opencl_activate().

int ff_framesync_init_dualinput ( FFFrameSync fs,
AVFilterContext parent 
)

Initialize a frame sync structure for dualinput.

Compared to generic framesync, dualinput assumes the first input is the main one and the filtering is performed on it. The first input will be the only one with sync set and generic timeline support will just pass it unchanged when disabled.

Equivalent to ff_framesync_init(fs, parent, 2) then setting the time base, sync and ext modes on the inputs.

Definition at line 361 of file framesync.c.

Referenced by config_output(), and overlay_opencl_config_output().

int ff_framesync_dualinput_get ( FFFrameSync fs,
AVFrame **  f0,
AVFrame **  f1 
)
Parameters
f0used to return the main frame
f1used to return the second frame, or NULL if disabled
Returns
>=0 for success or AVERROR code
Note
The frame returned in f0 belongs to the caller (get = 1 in ff_framesync_get_frame()) while the frame returned in f1 is still owned by the framesync structure.

Definition at line 379 of file framesync.c.

Referenced by blend_frame_for_dualinput(), do_convolve(), do_psnr(), do_ssim(), do_vmaf(), and ff_framesync_dualinput_get_writable().

int ff_framesync_dualinput_get_writable ( FFFrameSync fs,
AVFrame **  f0,
AVFrame **  f1 
)

Same as ff_framesync_dualinput_get(), but make sure that f0 is writable.

Definition at line 399 of file framesync.c.

Referenced by do_blend(), and load_apply_palette().

Variable Documentation

const AVOption framesync_options[]
static
Initial value:
= {
{ "eof_action", "Action to take when encountering EOF from secondary input ",
OFFSET(opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
{ "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
{ "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
{ "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" },
{ "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "repeatlast", "extend last frame of secondary streams beyond EOF", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(member)
Definition: framesync.c:28
#define FLAGS
Definition: framesync.c:29

Definition at line 36 of file framesync.c.

const AVClass framesync_class
static
Initial value:
= {
.class_name = "framesync",
.item_name = framesync_name,
.option = framesync_options,
.parent_log_context_offset = OFFSET(parent),
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
static const AVOption framesync_options[]
Definition: framesync.c:36
static const char * framesync_name(void *ptr)
Definition: framesync.c:31
#define OFFSET(member)
Definition: framesync.c:28

Definition at line 47 of file framesync.c.

Referenced by ff_framesync_get_class(), and ff_framesync_preinit().