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 "avfilter.h"
#include "bufferqueue.h"
#include "framesync.h"
#include "internal.h"

Go to the source code of this file.

Macros

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

Enumerations

enum  { STATE_BOF, STATE_RUN, STATE_EOF }
 

Functions

static const char * framesync_name (void *ptr)
 
void ff_framesync_init (FFFrameSync *fs, void *parent, unsigned nb_in)
 Initialize a frame sync structure.
 
static void framesync_sync_level_update (FFFrameSync *fs)
 
int ff_framesync_configure (FFFrameSync *fs)
 Configure a frame sync structure.
 
static void 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)
 
int ff_framesync_add_frame (FFFrameSync *fs, unsigned in, AVFrame *frame)
 Add a frame to an input.
 
void ff_framesync_next (FFFrameSync *fs)
 Prepare the next frame event.
 
void ff_framesync_drop (FFFrameSync *fs)
 Drop the current frame event.
 
int ff_framesync_get_frame (FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
 Get the current frame in an input.
 
void ff_framesync_uninit (FFFrameSync *fs)
 Free all memory currently allocated.
 
int ff_framesync_process_frame (FFFrameSync *fs, unsigned all)
 Process one or several frame using the on_event callback.
 
int ff_framesync_filter_frame (FFFrameSync *fs, AVFilterLink *inlink, AVFrame *in)
 Accept a frame on a filter input.
 
int ff_framesync_request_frame (FFFrameSync *fs, AVFilterLink *outlink)
 Request a frame on the filter output.
 

Variables

static const AVClass framesync_class
 

Macro Definition Documentation

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

Definition at line 27 of file framesync.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
STATE_BOF 
STATE_RUN 
STATE_EOF 

Definition at line 43 of file framesync.c.

Function Documentation

static const char* framesync_name ( void ptr)
static

Definition at line 29 of file framesync.c.

void ff_framesync_init ( FFFrameSync fs,
void parent,
unsigned  nb_in 
)

Initialize a frame sync structure.

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

Parameters
fsframe sync structure to initialize
parentparent object, used for logging
nb_innumber of inputs

Definition at line 49 of file framesync.c.

Referenced by config_output(), and ff_dualinput_init().

static void framesync_sync_level_update ( FFFrameSync fs)
static

Definition at line 56 of file framesync.c.

Referenced by ff_framesync_configure(), and framesync_inject_frame().

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 72 of file framesync.c.

Referenced by config_output(), and ff_dualinput_init().

static void framesync_advance ( FFFrameSync fs)
static

Definition at line 113 of file framesync.c.

Referenced by ff_framesync_next().

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

Definition at line 171 of file framesync.c.

Referenced by framesync_inject_frame().

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

Definition at line 178 of file framesync.c.

Referenced by ff_framesync_add_frame(), and ff_framesync_next().

int ff_framesync_add_frame ( FFFrameSync fs,
unsigned  in,
AVFrame frame 
)

Add a frame to an input.

Typically called from the filter_frame() method.

Parameters
fsframe sync structure
inindex of the input
frameinput frame, or NULL for EOF

Definition at line 197 of file framesync.c.

Referenced by ff_framesync_filter_frame(), and ff_framesync_request_frame().

void ff_framesync_next ( FFFrameSync fs)

Prepare the next frame event.

The status of the operation can be found in fs->frame_ready and fs->eof.

Definition at line 207 of file framesync.c.

Referenced by ff_framesync_process_frame().

void ff_framesync_drop ( FFFrameSync fs)

Drop the current frame event.

Definition at line 219 of file framesync.c.

Referenced by ff_framesync_process_frame().

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 224 of file framesync.c.

Referenced by process_frame().

void ff_framesync_uninit ( FFFrameSync fs)

Free all memory currently allocated.

Definition at line 261 of file framesync.c.

Referenced by ff_dualinput_uninit(), and uninit().

int ff_framesync_process_frame ( FFFrameSync fs,
unsigned  all 
)

Process one or several frame using the on_event callback.

Returns
number of frames processed or negative error code

Definition at line 272 of file framesync.c.

Referenced by ff_framesync_filter_frame(), and ff_framesync_request_frame().

int ff_framesync_filter_frame ( FFFrameSync fs,
AVFilterLink inlink,
AVFrame in 
)

Accept a frame on a filter input.

This function can be the complete implementation of all filter_frame methods of a filter using framesync.

Definition at line 293 of file framesync.c.

Referenced by ff_dualinput_filter_frame(), and filter_frame().

int ff_framesync_request_frame ( FFFrameSync fs,
AVFilterLink outlink 
)

Request a frame on the filter output.

This function can be the complete implementation of all filter_frame methods of a filter using framesync if it has only one output.

Definition at line 307 of file framesync.c.

Referenced by ff_dualinput_request_frame(), and request_frame().

Variable Documentation

const AVClass framesync_class
static
Initial value:
= {
.class_name = "framesync",
.item_name = framesync_name,
.option = NULL,
.parent_log_context_offset = OFFSET(parent),
}

Definition at line 34 of file framesync.c.

Referenced by ff_framesync_init().