Go to the documentation of this file.
21 #include "config_components.h"
56 #define AFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
57 #define VFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
58 #define OFFSET(x) offsetof(LoopContext, x)
73 if (
s->time != INT64_MAX) {
76 s->time_pts = time_pts;
80 #if CONFIG_ALOOP_FILTER
91 if (!
s->fifo || !
s->left)
114 while (
s->loop != 0 &&
i < nb_samples) {
126 i +=
out->nb_samples;
127 s->current_sample +=
out->nb_samples;
133 if (
s->current_sample >=
s->nb_samples) {
134 s->current_sample = 0;
152 if (((
s->start >= 0 &&
s->ignored_samples +
frame->nb_samples >
s->start) ||
154 frame->pts >=
s->time_pts)) &&
155 s->size > 0 &&
s->loop != 0) {
156 if (
s->nb_samples <
s->size) {
157 int written =
FFMIN(
frame->nb_samples,
s->size -
s->nb_samples);
166 if (!
s->nb_samples) {
167 drain =
FFMAX(0,
s->start -
s->ignored_samples);
172 s->nb_samples +=
ret - drain;
173 drain =
frame->nb_samples - written;
174 if (
s->nb_samples ==
s->size && drain > 0) {
186 int nb_samples =
frame->nb_samples;
192 s->ignored_samples +=
frame->nb_samples;
208 (
s->nb_samples <
s->size) ||
209 (
s->nb_samples >=
s->size &&
s->loop == 0)) {
212 if (
s->loop == 0 && nb_samples > 0) {
230 if (
s->eof &&
s->nb_samples > 0 &&
s->loop != 0) {
249 if (!
s->eof && (
s->nb_samples <
s->size || !
s->loop || !
s->size)) {
250 const int in_nb_samples =
FFMIN(1024,
s->size -
s->nb_samples);
251 if (in_nb_samples == 0)
263 s->size =
s->nb_samples;
268 if (
s->eof && (!
s->loop || !
s->size)) {
273 if (!
s->eof && (!
s->size ||
274 (
s->nb_samples <
s->size) ||
275 (
s->nb_samples >=
s->size &&
s->loop == 0))) {
277 }
else if (
s->loop &&
s->nb_samples ==
s->size) {
278 return arequest_frame(outlink);
284 static const AVOption aloop_options[] = {
298 .config_props = aconfig_input,
306 .priv_class = &aloop_class,
314 #if CONFIG_LOOP_FILTER
335 for (
int i = 0;
i <
s->nb_frames;
i++)
358 out->pts +=
s->pts_offset;
362 if (
s->current_frame >=
s->nb_frames) {
363 s->current_frame = 0;
365 s->pts_offset +=
s->duration;
387 frame->pts >=
s->time_pts)) &&
388 s->size > 0 &&
s->loop != 0) {
389 if (
s->nb_frames <
s->size) {
391 if (!
s->frames[
s->nb_frames]) {
401 s->pts_offset =
s->duration;
408 frame->pts +=
s->pts_offset -
s->duration;
432 if (!
s->eof && (
s->nb_frames <
s->size || !
s->loop || !
s->size)) {
442 s->size =
s->nb_frames;
447 if (
s->eof && (!
s->loop || !
s->size)) {
453 if (!
s->eof && (!
s->size ||
454 (
s->nb_frames <
s->size) ||
455 (
s->nb_frames >=
s->size &&
s->loop == 0))) {
457 }
else if (
s->loop &&
s->nb_frames ==
s->size) {
464 static const AVOption loop_options[] = {
478 .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.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
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.
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.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
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.