Go to the documentation of this file.
48 #define OFFSET(x) offsetof(APadContext, x)
49 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
52 {
"packet_size",
"set silence packet size",
OFFSET(packet_size),
AV_OPT_TYPE_INT, { .i64 = 4096 }, 0, INT_MAX,
A },
53 {
"pad_len",
"set number of samples of silence to add",
OFFSET(pad_len),
AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX,
A },
54 {
"whole_len",
"set minimum target number of samples in the audio stream",
OFFSET(whole_len),
AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX,
A },
56 {
"whole_dur",
"set minimum target duration in the audio stream",
OFFSET(whole_dur),
AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT64_MAX,
A },
67 if (
s->whole_len >= 0 &&
s->pad_len >= 0) {
80 if (
s->whole_len >= 0) {
81 s->whole_len_left =
FFMAX(
s->whole_len_left -
frame->nb_samples, 0);
83 "n_out:%d whole_len_left:%"PRId64
"\n",
frame->nb_samples,
s->whole_len_left);
99 int n_out =
s->packet_size;
102 if (
s->whole_len >= 0 &&
s->pad_len < 0) {
103 s->pad_len =
s->pad_len_left =
s->whole_len_left;
105 if (
s->pad_len >=0 ||
s->whole_len >= 0) {
106 n_out =
FFMIN(n_out,
s->pad_len_left);
107 s->pad_len_left -= n_out;
109 "padding n_out:%d pad_len_left:%"PRId64
"\n", n_out,
s->pad_len_left);
127 outsamplesref->
pts =
s->next_pts;
146 s->pad_len_left =
s->pad_len;
147 s->whole_len_left =
s->whole_len;
178 .priv_class = &apad_class,
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
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
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
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
static int config_output(AVFilterLink *outlink)
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.
static const AVOption apad_options[]
static av_cold int init(AVFilterContext *ctx)
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int channels
number of audio channels, only used for audio.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const AVFilterPad outputs[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVFILTER_DEFINE_CLASS(apad)
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.
Rational number (pair of numerator and denominator).
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int sample_rate
Sample rate of the audio data.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const AVFilterPad apad_inputs[]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
int sample_rate
samples per second
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_TIME_BASE
Internal time base represented as integer.
uint8_t ** extended_data
pointers to the data planes/channels.
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int request_frame(AVFilterLink *outlink)
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
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 const AVFilterPad apad_outputs[]
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)