66#define OFFSET(x) offsetof(AVSyncTestContext, x)
67#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
68#define V AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
69#define R AV_OPT_FLAG_RUNTIME_PARAM
107 { .nb_channels = 0 },
139 s->beep_duration =
av_rescale(
s->sample_rate,
s->frame_rate.den,
s->frame_rate.num);
159 s->delay_range =
av_sub_q(
s->delay_max,
s->delay_min);
162 s->prev_intpart = INT64_MIN;
181 const double pi =
M_PI;
182 const int32_t a = ((2.0 * pi) * (1 << 24));
183 const int32_t b = (1 << 7) * (12.0 / pi - 1.0 - pi) * (1 << 24);
184 const int32_t c = (1 << 9) * 3.0 * (2.0 + pi - 16.0 / pi) * (1 << 24);
190 if (x >= (3 *
FPI / 2))
192 else if (x >
FPI / 2)
197 t2 = ((
b + t1) * x2) >> 32;
202 result += (1U << 31);
235 if (((
s->apts +
i) % (
s->period *
s->sample_rate)) == 0)
243 if (
s->beep >=
s->beep_duration) {
247 s->apts +=
out->nb_samples;
253 int x0,
int y0,
const uint8_t *text)
258 for (; *text; text++) {
266 &
cga_font[*text * 8], 1, 8, 8, 0, 0, x, y0);
271static int offset(
int x,
int num,
int den)
280 const int w = outlink->
w;
281 const int h = outlink->
h;
301 snprintf(text,
sizeof(text),
"FRN: %"PRId64
"",
s->vpts);
307 snprintf(text,
sizeof(text),
"DLY: %d",
s->vdelay.num);
310 snprintf(text,
sizeof(text),
"FPS: %d/%d",
s->frame_rate.num,
s->frame_rate.den);
313 snprintf(text,
sizeof(text),
"P: %d",
s->period);
316 snprintf(text,
sizeof(text),
"SR: %d",
s->sample_rate);
319 snprintf(text,
sizeof(text),
"A: %1.2f",
s->amplitude);
322 snprintf(text,
sizeof(text),
"WxH: %dx%d",
w,
h);
325 temp =
s->vpts +
s->vdelay.num;
331 av_clip(new_offset + step * intpart, 0,
w - 2),
334 if (intpart == 0 &&
s->prev_intpart != intpart) {
335 if (
s->flash >=
s->period) {
347 offset(
w, 1, 3),
offset(
h, 1, 3),
offset(
w, 1, 3),
offset(
h, 1, 4));
352 s->prev_intpart = intpart;
354 for (
int i =
av_rescale(
s->delay_min.num, 1,
s->delay_min.den);
357 av_clip(new_offset + step *
i, 0,
w - 2),
361 out->pts =
s->vpts++;
378 if (
s->duration > 0 &&
s->apts >=
s->duration) {
406 .p.name =
"avsynctest",
408 .p.priv_class = &avsynctest_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static enum AVSampleFormat sample_fmts[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
const FFFilter ff_avsrc_avsynctest
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().
static int draw(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
common internal and external API header
static const int sample_rates[]
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, const uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
internal math functions header
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
#define AV_CHANNEL_LAYOUT_MONO
#define AVERROR_EOF
End of file.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static AVRational av_make_q(int num, int den)
Create an AVRational.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
AVRational av_sub_q(AVRational b, AVRational c)
Subtract one rational from another.
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_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_UP
Round toward +infinity.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S32
signed 32 bits
#define AV_TIME_BASE
Internal time base represented as integer.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_OUTPUTS(array)
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.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum MovChannelLayoutTag * layouts
static int config_props(AVBitStreamFilterLink *link)
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color, int x0, int y0, const uint8_t *text)
static int video_frame(AVFilterLink *outlink)
static int32_t sin32(int32_t x, AVRational scale)
static int audio_frame(AVFilterLink *outlink)
static av_cold int aconfig_props(AVFilterLink *outlink)
static const AVFilterPad avsynctest_outputs[]
static av_cold int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static av_cold int config_props(AVFilterLink *outlink)
static const AVOption avsynctest_options[]
An AVChannelLayout holds information about the channel layout of audio data.
Describe the class of an AVClass context structure.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
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
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Rational number (pair of numerator and denominator).
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
static AVFormatContext * ctx
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
const uint8_t * avpriv_cga_font_get(void)
static const uint8_t cga_font[2048]
CGA/EGA/VGA ROM font data.