Go to the documentation of this file.
54 #define AFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
55 #define VFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
56 #define OFFSET(x) offsetof(LoopContext, x)
67 #if CONFIG_ALOOP_FILTER
76 if (!
s->fifo || !
s->left)
99 while (
s->loop != 0 &&
i < nb_samples) {
110 s->pts +=
out->nb_samples;
111 i +=
out->nb_samples;
112 s->current_sample +=
out->nb_samples;
118 if (
s->current_sample >=
s->nb_samples) {
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);
148 s->pts +=
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;
172 s->pts +=
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) {
198 s->pts += nb_samples;
215 static const AVOption aloop_options[] = {
228 .filter_frame = afilter_frame,
229 .config_props = aconfig_input,
238 .request_frame = arequest_frame,
247 .priv_class = &aloop_class,
254 #if CONFIG_LOOP_FILTER
274 for (
i = 0;
i <
s->nb_frames;
i++)
292 out->pts +=
s->duration -
s->start_pts;
293 if (
out->pkt_duration)
301 if (
s->current_frame >=
s->nb_frames) {
303 s->current_frame = 0;
320 if (
inlink->frame_count_out >=
s->start &&
s->size > 0 &&
s->loop != 0) {
321 if (
s->nb_frames <
s->size) {
323 s->start_pts =
frame->pts;
325 if (!
s->frames[
s->nb_frames]) {
330 if (
frame->pkt_duration)
341 frame->pts +=
s->duration;
359 if (!
s->eof && (
s->nb_frames <
s->size || !
s->loop || !
s->size)) {
369 s->size =
s->nb_frames;
374 if (
s->eof && (!
s->loop || !
s->size)) {
379 if (!
s->eof && (!
s->size ||
380 (
s->nb_frames <
s->size) ||
381 (
s->nb_frames >=
s->size &&
s->loop == 0))) {
383 }
else if (
s->loop &&
s->nb_frames ==
s->size) {
390 static const AVOption loop_options[] = {
419 .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
static av_cold int init(AVCodecContext *avctx)
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.
Describe the class of an AVClass context structure.
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
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)
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 int filter_frame(DBEContext *s, AVFrame *frame)
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
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
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static av_cold int uninit(AVCodecContext *avctx)
static int push_frame(AVFilterContext *ctx, unsigned in_no, AVFrame *buf)