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;
154 s->size > 0 &&
s->loop != 0) {
155 if (
s->nb_samples <
s->size) {
160 s->start =
inlink->sample_count_out - written;
165 if (!
s->nb_samples) {
166 drain =
FFMAX(0,
s->start -
s->ignored_samples);
171 s->nb_samples +=
ret - drain;
173 if (
s->nb_samples ==
s->size && drain > 0) {
207 (
s->nb_samples <
s->size) ||
208 (
s->nb_samples >=
s->size &&
s->loop == 0)) {
211 if (
s->loop == 0 && nb_samples > 0) {
229 if (
s->eof &&
s->nb_samples > 0 &&
s->loop != 0) {
248 if (!
s->eof && (
s->nb_samples <
s->size || !
s->loop || !
s->size)) {
249 const int in_nb_samples =
FFMIN(1024,
s->size -
s->nb_samples);
250 if (in_nb_samples == 0)
262 s->size =
s->nb_samples;
267 if (
s->eof && (!
s->loop || !
s->size)) {
272 if (!
s->eof && (!
s->size ||
273 (
s->nb_samples <
s->size) ||
274 (
s->nb_samples >=
s->size &&
s->loop == 0))) {
276 }
else if (
s->loop &&
s->nb_samples ==
s->size) {
277 return arequest_frame(outlink);
283 static const AVOption aloop_options[] = {
297 .config_props = aconfig_input,
305 .priv_class = &aloop_class,
313 #if CONFIG_LOOP_FILTER
334 for (
int i = 0;
i <
s->nb_frames;
i++)
357 out->pts +=
s->pts_offset;
361 if (
s->current_frame >=
s->nb_frames) {
362 s->current_frame = 0;
364 s->pts_offset +=
s->duration;
382 if (((
s->start >= 0 &&
inlink->frame_count_out >=
s->start) ||
385 s->size > 0 &&
s->loop != 0) {
386 if (
s->nb_frames <
s->size) {
388 if (!
s->frames[
s->nb_frames]) {
398 s->pts_offset =
s->duration;
429 if (!
s->eof && (
s->nb_frames <
s->size || !
s->loop || !
s->size)) {
439 s->size =
s->nb_frames;
444 if (
s->eof && (!
s->loop || !
s->size)) {
450 if (!
s->eof && (!
s->size ||
451 (
s->nb_frames <
s->size) ||
452 (
s->nb_frames >=
s->size &&
s->loop == 0))) {
454 }
else if (
s->loop &&
s->nb_frames ==
s->size) {
461 static const AVOption loop_options[] = {
475 .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.
int64_t duration
Duration of the frame, in the same units as pts.
#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.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
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.
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.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
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_INPUTS(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)
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the 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.
#define AVFILTER_DEFINE_CLASS(fname)
const AVFilter ff_af_aloop
int sample_rate
samples per second
static void uninit(AVBSFContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
uint8_t ** extended_data
pointers to the data planes/channels.
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)
static void free_frames(int nb_inputs, AVFrame **input_frames)
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
#define FILTER_OUTPUTS(array)
int av_audio_fifo_peek_at(const AVAudioFifo *af, void *const *data, int nb_samples, int offset)
Peek data from an AVAudioFifo.