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) {
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,
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static const AVOption apad_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static const AVFilterPad apad_inputs[]
static int request_frame(AVFilterLink *outlink)
AVFILTER_DEFINE_CLASS(apad)
static av_cold int init(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static const AVFilterPad apad_outputs[]
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.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Main libavfilter public API header.
#define flags(name, subs,...)
audio channel layout utility functions
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define AVERROR_EOF
End of file.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE
Internal time base represented as integer.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int channels
number of audio channels, only used for audio.
int sample_rate
Sample rate of the audio data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
Rational number (pair of numerator and denominator).