52 #define OFFSET(x) offsetof(ASyncContext, x)
53 #define A AV_OPT_FLAG_AUDIO_PARAM
54 #define F AV_OPT_FLAG_FILTERING_PARAM
57 {
"min_delta",
"Minimum difference between timestamps and audio data "
58 "(in seconds) to trigger padding/trimmin the data.",
OFFSET(min_delta_sec),
AV_OPT_TYPE_FLOAT, { .dbl = 0.1 }, 0, INT_MAX,
A|
F },
59 {
"max_comp",
"Maximum compensation in samples per second.",
OFFSET(max_comp),
AV_OPT_TYPE_INT, { .i64 = 500 }, 0, INT_MAX,
A|
F },
210 out_size = av_clipl_int32((int64_t)out_size + delta);
217 if (comp != s->
comp) {
238 int planes = planar ? nb_channels : 1;
245 nb_channels, buf->
format);
247 for (ch = 0; ch < planes; ch++)
252 for (ch = 0; ch < planes; ch++)
259 delta, nb_channels, buf->
format);
277 if (new_pts > s->
pts) {
319 .priv_class = &asyncts_class,
320 .
inputs = avfilter_af_asyncts_inputs,
321 .
outputs = avfilter_af_asyncts_outputs,
This structure describes decoded (raw) audio or video data.
static const AVFilterPad avfilter_af_asyncts_inputs[]
int min_delta
pad/trim min threshold in samples
#define AV_LOG_WARNING
Something somehow does not look correct.
int avresample_convert(AVAudioResampleContext *avr, uint8_t **output, int out_plane_size, int out_samples, uint8_t *const *input, int in_plane_size, int in_samples)
Convert input samples and write them to the output FIFO.
Main libavfilter public API header.
int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples)
Read samples from the output FIFO.
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, int compensation_distance)
Set compensation for resampling.
void avresample_free(AVAudioResampleContext **avr)
Free AVAudioResampleContext and associated AVOption values.
Macro definitions for various function/variable attributes.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
static av_cold int init(AVFilterContext *ctx)
static int resample(ResampleContext *c, void *dst, const void *src, int *consumed, int src_size, int dst_size, int update_ctx, int nearest_neighbour)
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold void uninit(AVFilterContext *ctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
void avresample_close(AVAudioResampleContext *avr)
Close AVAudioResampleContext.
static int request_frame(AVFilterLink *link)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
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.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int comp
current resample compensation
void * priv
private data for use by the filter
int64_t pts
timestamp in samples of the first sample in fifo
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
uint64_t channel_layout
Channel layout of the audio data.
static int config_props(AVFilterLink *link)
static const AVOption asyncts_options[]
AVAudioResampleContext * avr
int first_frame
1 until filter_frame() has processed at least 1 frame with a pts != AV_NOPTS_VALUE ...
AVFILTER_DEFINE_CLASS(asyncts)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
int64_t first_pts
user-specified first expected pts, in samples
int format
agreed upon media format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int avresample_get_delay(AVAudioResampleContext *avr)
Return the number of samples currently in the resampling delay buffer.
int avresample_available(AVAudioResampleContext *avr)
Return the number of available samples in the output FIFO.
static const AVFilterPad inputs[]
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int write_to_fifo(ASyncContext *s, AVFrame *buf)
Describe the class of an AVClass context structure.
rational number numerator/denominator
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static int64_t get_delay(ASyncContext *s)
static int64_t pts
Global timestamp for the audio frames.
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
AVAudioResampleContext * avresample_alloc_context(void)
Allocate AVAudioResampleContext and set options.
common internal and external API header
static void handle_trimming(AVFilterContext *ctx)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
static const AVFilterPad avfilter_af_asyncts_outputs[]
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
uint8_t ** extended_data
pointers to the data planes/channels.
int avresample_open(AVAudioResampleContext *avr)
Initialize AVAudioResampleContext.
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_NOPTS_VALUE
Undefined timestamp value.