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) {
125 out->nb_samples = ret;
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) {
182 frame->nb_samples = ret;
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);
251 return afilter_frame(inlink,
frame);
256 s->size =
s->nb_samples;
269static const AVOption aloop_options[] = {
283 .config_props = aconfig_input,
290 .p.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) {
449static const AVOption loop_options[] = {
462 .p.priv_class = &loop_class,
static void free_frames(int nb_inputs, AVFrame **input_frames)
static int push_frame(AVFilterLink *outlink)
static int push_samples(ATempoContext *atempo, AVFilterLink *outlink, int n_out)
const FFFilter ff_af_aloop
const FFFilter ff_vf_loop
static AVFormatContext * ctx
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
static void check_size(AVFilterContext *ctx)
static void update_time(AVFilterContext *ctx, AVRational tb)
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
int av_audio_fifo_peek_at(const AVAudioFifo *af, void *const *data, int nb_samples, int offset)
Peek data from an AVAudioFifo.
int av_audio_fifo_write(AVAudioFifo *af, void *const *data, int nb_samples)
Write data to an AVAudioFifo.
int av_audio_fifo_read(AVAudioFifo *af, void *const *data, int nb_samples)
Read data from an AVAudioFifo.
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
Context for an Audio FIFO Buffer.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A link between two filters.
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Rational number (pair of numerator and denominator).
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.