Go to the documentation of this file.
50 #define OFFSET(x) offsetof(APadContext, x)
51 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
54 {
"packet_size",
"set silence packet size",
OFFSET(packet_size),
AV_OPT_TYPE_INT, { .i64 = 4096 }, 0, INT_MAX,
A },
55 {
"pad_len",
"set number of samples of silence to add",
OFFSET(pad_len),
AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX,
A },
56 {
"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 },
58 {
"whole_dur",
"set minimum target duration in the audio stream",
OFFSET(whole_dur),
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX,
A },
69 if (
s->whole_len >= 0 &&
s->pad_len >= 0) {
82 if (
s->whole_len >= 0) {
85 "n_out:%d whole_len_left:%"PRId64
"\n",
frame->
nb_samples,
s->whole_len_left);
101 n_out =
s->packet_size;
103 if (
s->whole_len >= 0 &&
s->pad_len < 0) {
104 s->pad_len =
s->pad_len_left =
s->whole_len_left;
106 if (
s->pad_len >=0 ||
s->whole_len >= 0) {
107 n_out =
FFMIN(n_out,
s->pad_len_left);
108 s->pad_len_left -= n_out;
110 "padding n_out:%d pad_len_left:%"PRId64
"\n", n_out,
s->pad_len_left);
128 outsamplesref->
pts =
s->next_pts;
181 if (
s->whole_dur >= 0)
184 s->pad_len_left =
s->pad_len;
185 s->whole_len_left =
s->whole_len;
206 .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 av_samples_set_silence(uint8_t *const *audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
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.
static const AVOption apad_options[]
static av_cold int init(AVFilterContext *ctx)
AVChannelLayout ch_layout
Channel layout of the audio data.
A filter pad used for either input or output.
static int push_frame(AVFilterLink *outlink)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 av_assert0(cond)
assert() equivalent, that is always enabled.
#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.
#define FILTER_INPUTS(array)
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
#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.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
const AVFilter ff_af_apad
FF_FILTER_FORWARD_WANTED(outlink, inlink)
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 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)
static int activate(AVFilterContext *ctx)
#define FILTER_OUTPUTS(array)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...