49#define OFFSET(x) offsetof(APadContext, x)
50#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
53 {
"packet_size",
"set silence packet size",
OFFSET(packet_size),
AV_OPT_TYPE_INT, { .i64 = 4096 }, 0, INT_MAX,
A },
54 {
"pad_len",
"set number of samples of silence to add",
OFFSET(pad_len),
AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX,
A },
55 {
"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 },
57 {
"whole_dur",
"set minimum target duration in the audio stream",
OFFSET(whole_dur),
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX,
A },
68 if (
s->whole_len >= 0 &&
s->pad_len >= 0) {
81 if (
s->whole_len >= 0) {
82 s->whole_len_left =
FFMAX(
s->whole_len_left -
frame->nb_samples, 0);
84 "n_out:%d whole_len_left:%"PRId64
"\n",
frame->nb_samples,
s->whole_len_left);
100 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;
180 if (
s->whole_dur >= 0)
183 s->pad_len_left =
s->pad_len;
184 s->whole_len_left =
s->whole_len;
200 .p.priv_class = &apad_class,
static const AVOption apad_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static int push_frame(AVFilterLink *outlink)
static int activate(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static const AVFilterPad apad_outputs[]
const FFFilter ff_af_apad
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.
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.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
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.
Public libavutil channel layout APIs header.
int(* init)(AVBSFContext *ctx)
@ 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.
#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 *const *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.
static int activate(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#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.
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
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 sample_rate
Sample rate of the audio data.
AVChannelLayout ch_layout
Channel layout 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).
static AVFormatContext * ctx