Go to the documentation of this file.
21 #include "config_components.h"
57 #define AFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
58 #define VFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
59 #define OFFSET(x) offsetof(LoopContext, x)
74 if (
s->time != INT64_MAX) {
77 s->time_pts = time_pts;
81 #if CONFIG_ALOOP_FILTER
92 if (!
s->fifo || !
s->left)
115 while (
s->loop != 0 &&
i < nb_samples) {
127 i +=
out->nb_samples;
128 s->current_sample +=
out->nb_samples;
132 if (
s->current_sample >=
s->nb_samples) {
133 s->current_sample = 0;
153 if (((
s->start >= 0 &&
s->ignored_samples +
frame->nb_samples >
s->start) ||
155 frame->pts >=
s->time_pts)) &&
156 s->size > 0 &&
s->loop != 0) {
157 if (
s->nb_samples <
s->size) {
158 int written =
FFMIN(
frame->nb_samples,
s->size -
s->nb_samples);
167 if (!
s->nb_samples) {
168 drain =
FFMAX(0,
s->start -
s->ignored_samples);
173 s->nb_samples +=
ret - drain;
174 if (
s->nb_samples ==
s->size &&
frame->nb_samples > written) {
189 s->ignored_samples +=
frame->nb_samples;
205 (
s->nb_samples <
s->size) ||
206 (
s->nb_samples >=
s->size &&
s->loop == 0)) {
209 if (
s->loop == 0 && nb_samples > 0) {
241 ret = arequest_frame(outlink, &
frame);
256 s->size =
s->nb_samples;
269 static const AVOption aloop_options[] = {
283 .config_props = aconfig_input,
291 .priv_class = &aloop_class,
299 #if CONFIG_LOOP_FILTER
320 for (
int i = 0;
i <
s->nb_frames;
i++)
343 out->pts +=
s->pts_offset;
347 if (
s->current_frame >=
s->nb_frames) {
348 s->current_frame = 0;
350 s->pts_offset +=
s->duration;
372 frame->pts >=
s->time_pts)) &&
373 s->size > 0 &&
s->loop != 0) {
374 if (
s->nb_frames <
s->size) {
376 if (!
s->frames[
s->nb_frames]) {
386 s->pts_offset =
s->duration;
393 frame->pts +=
s->pts_offset -
s->duration;
417 if (!
s->eof && (
s->nb_frames <
s->size || !
s->loop || !
s->size)) {
427 s->size =
s->nb_frames;
432 if (
s->eof && (!
s->loop || !
s->size)) {
438 if (!
s->eof && (!
s->size ||
439 (
s->nb_frames <
s->size) ||
440 (
s->nb_frames >=
s->size &&
s->loop == 0))) {
442 }
else if (
s->loop &&
s->nb_frames ==
s->size) {
449 static const AVOption loop_options[] = {
463 .priv_class = &loop_class,
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int push_samples(ATempoContext *atempo, AVFilterLink *outlink, int n_out)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
static void check_size(AVFilterContext *ctx)
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Link properties exposed to filter code, but not external callers.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Context for an Audio FIFO Buffer.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
A filter pad used for either input or output.
static int push_frame(AVFilterLink *outlink)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define FILTER_OUTPUTS(array)
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
filter_frame For filters that do not use the activate() callback
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
#define AVFILTER_DEFINE_CLASS(fname)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
static FilterLink * ff_filter_link(AVFilterLink *link)
int(* init)(AVBSFContext *ctx)
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVFilterContext * src
source filter
FF_FILTER_FORWARD_WANTED(outlink, inlink)
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
const AVFilter ff_af_aloop
int sample_rate
samples per second
static void uninit(AVBSFContext *ctx)
#define i(width, name, range_min, range_max)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
void * av_calloc(size_t nmemb, size_t size)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static void free_frames(int nb_inputs, AVFrame **input_frames)
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static void update_time(AVFilterContext *ctx, AVRational tb)
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
const AVFilter ff_vf_loop
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
int av_audio_fifo_peek_at(const AVAudioFifo *af, void *const *data, int nb_samples, int offset)
Peek data from an AVAudioFifo.