28 #define OFFSET(member) offsetof(FFFrameSync, member)
29 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
37 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
43 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(opt_shortest),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
FLAGS },
44 {
"repeatlast",
"extend last frame of secondary streams beyond EOF",
OFFSET(opt_repeatlast),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
FLAGS },
49 .class_name =
"framesync",
53 .parent_log_context_offset =
OFFSET(parent),
103 unsigned i,
level = 0;
105 for (i = 0; i < fs->
nb_in; i++)
109 if (level < fs->sync_level)
131 for (i = 0; i < fs->
nb_in; i++)
135 for (i = 1; i < fs->
nb_in; i++) {
142 for (i = 0; i < fs->
nb_in; i++) {
169 for (i = 0; i < fs->
nb_in; i++)
189 for (i = 0; i < fs->
nb_in; i++)
192 if (pts == INT64_MAX) {
196 for (i = 0; i < fs->
nb_in; i++) {
215 for (i = 0; i < fs->
nb_in; i++)
260 unsigned need_copy = 0, i;
273 for (i = 0; i < fs->
nb_in && !need_copy; i++)
274 if (i != in && fs->
in[i].
sync &&
297 for (i = 0; i < fs->
nb_in; i++) {
310 unsigned i, nb_active, nb_miss;
313 nb_active = nb_miss = 0;
314 for (i = 0; i < fs->
nb_in; i++) {
336 for (i = 0; i < fs->
nb_in; i++)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
This structure describes decoded (raw) audio or video data.
static void framesync_sync_level_update(FFFrameSync *fs)
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
void ff_framesync_preinit(FFFrameSync *fs)
Pre-initialize a frame sync structure.
static const AVOption framesync_options[]
#define FFERROR_NOT_READY
Filters implementation helper functions.
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
static const char * framesync_name(void *ptr)
static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts)
int is_disabled
the enabled state from the last expression evaluation
int64_t pts
Timestamp of the current event.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
static void framesync_eof(FFFrameSync *fs)
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
AVFilterContext * parent
Parent filter context.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint8_t have_next
Boolean flagging the next frame, for internal use.
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
unsigned sync_level
Synchronization level: only inputs with the same sync level are sync sources.
FFFrameSyncIn * in
Pointer to array of inputs.
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
AVFrame * frame_next
Next frame, for internal use.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
unsigned nb_outputs
number of output pads
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
simple assert() macros that are a bit more flexible than ISO C assert().
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
AVRational time_base
Time base for the incoming frames.
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
uint8_t eof
Flag indicating that output has reached EOF.
#define AV_TIME_BASE
Internal time base represented as integer.
AVRational time_base
Time base for the output events.
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in, int64_t pts)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
static const AVClass framesync_class
Extend the frame to infinity.
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
const AVClass * framesync_get_class(void)
Get the class for the framesync object.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
uint8_t state
State: before first, in stream or after EOF, for internal use.
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events...
Describe the class of an AVClass context structure.
Ignore this stream and continue processing the other ones.
unsigned nb_in
Number of input streams.
AVFrame * frame
Current frame, may be NULL before the first one or after EOF.
AVFilterLink ** outputs
array of pointers to output links
static int consume_from_fifos(FFFrameSync *fs)
static int64_t pts
Global timestamp for the audio frames.
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
uint8_t frame_ready
Flag indicating that a frame event is ready.
int version
LIBAVUTIL_VERSION with which this structure was created.
int64_t pts
PTS of the current frame.
Completely stop all streams with this one.
static int framesync_advance(FFFrameSync *fs)
static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame)
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int64_t pts_next
PTS of the next frame, for internal use.