Go to the documentation of this file.
53 #define AFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
54 #define VFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
55 #define OFFSET(x) offsetof(LoopContext, x)
66 #if CONFIG_ALOOP_FILTER
75 if (!
s->fifo || !
s->left)
98 while (
s->loop != 0 &&
i < nb_samples) {
110 i +=
out->nb_samples;
111 s->current_sample +=
out->nb_samples;
117 if (
s->current_sample >=
s->nb_samples) {
118 s->duration =
s->pts;
119 s->current_sample = 0;
136 if (
s->ignored_samples +
frame->nb_samples >
s->start &&
s->size > 0 &&
s->loop != 0) {
137 if (
s->nb_samples <
s->size) {
138 int written =
FFMIN(
frame->nb_samples,
s->size -
s->nb_samples);
144 if (!
s->nb_samples) {
145 drain =
FFMAX(0,
s->start -
s->ignored_samples);
150 s->nb_samples +=
ret - drain;
151 drain =
frame->nb_samples - written;
152 if (
s->nb_samples ==
s->size && drain > 0) {
164 int nb_samples =
frame->nb_samples;
170 s->ignored_samples +=
frame->nb_samples;
186 (
s->nb_samples <
s->size) ||
187 (
s->nb_samples >=
s->size &&
s->loop == 0)) {
190 if (
s->loop == 0 && nb_samples > 0) {
208 if (
s->eof &&
s->nb_samples > 0 &&
s->loop != 0) {
226 if (!
s->eof && (
s->nb_samples <
s->size || !
s->loop || !
s->size)) {
236 s->size =
s->nb_samples;
241 if (
s->eof && (!
s->loop || !
s->size)) {
246 if (!
s->eof && (!
s->size ||
247 (
s->nb_samples <
s->size) ||
248 (
s->nb_samples >=
s->size &&
s->loop == 0))) {
250 }
else if (
s->loop &&
s->nb_samples ==
s->size) {
251 return arequest_frame(outlink);
257 static const AVOption aloop_options[] = {
270 .config_props = aconfig_input,
285 .priv_class = &aloop_class,
293 #if CONFIG_LOOP_FILTER
313 for (
i = 0;
i <
s->nb_frames;
i++)
331 out->pts +=
s->duration -
s->start_pts;
332 if (
out->pkt_duration)
340 if (
s->current_frame >=
s->nb_frames) {
342 s->current_frame = 0;
359 if (
inlink->frame_count_out >=
s->start &&
s->size > 0 &&
s->loop != 0) {
360 if (
s->nb_frames <
s->size) {
362 s->start_pts =
frame->pts;
364 if (!
s->frames[
s->nb_frames]) {
369 if (
frame->pkt_duration)
380 frame->pts +=
s->duration;
398 if (!
s->eof && (
s->nb_frames <
s->size || !
s->loop || !
s->size)) {
408 s->size =
s->nb_frames;
413 if (
s->eof && (!
s->loop || !
s->size)) {
418 if (!
s->eof && (!
s->size ||
419 (
s->nb_frames <
s->size) ||
420 (
s->nb_frames >=
s->size &&
s->loop == 0))) {
422 }
else if (
s->loop &&
s->nb_frames ==
s->size) {
429 static const AVOption loop_options[] = {
456 .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.
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
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)
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.
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 void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
static const AVFilterPad outputs[]
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.
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
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
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 inputs
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset)
Peek data from an AVAudioFifo.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples)
Read data from an AVAudioFifo.
#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
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
const AVFilter ff_vf_loop
#define FILTER_OUTPUTS(array)
static av_cold int uninit(AVCodecContext *avctx)
static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)