Go to the documentation of this file.
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);
158 s->delay_range =
av_sub_q(
s->delay_max,
s->delay_min);
161 s->prev_intpart = INT64_MIN;
176 const double pi =
M_PI;
177 const int32_t a = ((2.0 * pi) * (1 << 24));
178 const int32_t b = (1 << 7) * (12.0 / pi - 1.0 - pi) * (1 << 24);
179 const int32_t c = (1 << 9) * 3.0 * (2.0 + pi - 16.0 / pi) * (1 << 24);
185 if (x >= (3 *
FPI / 2))
187 else if (x >
FPI / 2)
192 t2 = ((
b + t1) * x2) >> 32;
230 if (((
s->apts +
i) % (
s->period *
s->sample_rate)) == 0)
238 if (
s->beep >=
s->beep_duration) {
242 s->apts +=
out->nb_samples;
248 int x0,
int y0,
const uint8_t *text)
252 for (; *text; text++) {
265 static int offset(
int x,
int num,
int den)
274 const int w = outlink->
w;
275 const int h = outlink->
h;
295 snprintf(text,
sizeof(text),
"FRN: %"PRId64
"",
s->vpts);
301 snprintf(text,
sizeof(text),
"DLY: %d",
s->vdelay.num);
304 snprintf(text,
sizeof(text),
"FPS: %d/%d",
s->frame_rate.num,
s->frame_rate.den);
307 snprintf(text,
sizeof(text),
"P: %d",
s->period);
310 snprintf(text,
sizeof(text),
"SR: %d",
s->sample_rate);
313 snprintf(text,
sizeof(text),
"A: %1.2f",
s->amplitude);
316 snprintf(text,
sizeof(text),
"WxH: %dx%d",
w,
h);
319 temp =
s->vpts +
s->vdelay.num;
328 if (intpart == 0 &&
s->prev_intpart != intpart) {
329 if (
s->flash >=
s->period) {
341 offset(
w, 1, 3),
offset(
h, 1, 3),
offset(
w, 1, 3),
offset(
h, 1, 4));
346 s->prev_intpart = intpart;
348 for (
int i =
av_rescale(
s->delay_min.num, 1,
s->delay_min.den);
355 out->pts =
s->vpts++;
372 if (
s->duration > 0 &&
s->apts >=
s->duration) {
400 .
name =
"avsynctest",
403 .priv_class = &avsynctest_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
@ AV_ROUND_UP
Round toward +infinity.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static const AVFilterPad avsynctest_outputs[]
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.
static enum AVSampleFormat sample_fmts[]
enum MovChannelLayoutTag * layouts
#define AVERROR_EOF
End of file.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
static const int sample_rates[]
This structure describes decoded (raw) audio or video data.
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
AVFILTER_DEFINE_CLASS(avsynctest)
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
const char * name
Filter name.
AVRational av_sub_q(AVRational b, AVRational c)
Subtract one rational from another.
A link between two filters.
Link properties exposed to filter code, but not external callers.
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.
A filter pad used for either input or output.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
#define FILTER_OUTPUTS(array)
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
Rational number (pair of numerator and denominator).
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without period
static av_cold int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static FilterLink * ff_filter_link(AVFilterLink *link)
static av_cold int aconfig_props(AVFilterLink *outlink)
@ AV_ROUND_DOWN
Round toward -infinity.
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.
const AVFilter ff_avsrc_avsynctest
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int video_frame(AVFilterLink *outlink)
int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp, enum AVColorRange range, unsigned flags)
Init a draw context.
int format
agreed upon media format
static int offset(int x, int num, int den)
static const AVOption avsynctest_options[]
static AVRational av_make_q(int num, int den)
Create an AVRational.
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.
AVFilterContext * src
source filter
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.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static int draw(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
int sample_rate
samples per second
static int activate(AVFilterContext *ctx)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
#define AV_TIME_BASE
Internal time base represented as integer.
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
AVSampleFormat
Audio sample formats.
#define FILTER_QUERY_FUNC2(func)
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
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.
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color, int x0, int y0, const uint8_t *text)
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
#define AV_CHANNEL_LAYOUT_MONO
const uint8_t avpriv_cga_font[2048]
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int32_t sin32(int32_t x, AVRational scale)
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
enum AVColorSpace colorspace
For non-YUV links, these are respectively set to fallback values (as appropriate for that colorspace)...
static int audio_frame(AVFilterLink *outlink)
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
enum AVColorRange color_range
agreed upon YUV color range
@ AV_SAMPLE_FMT_S32
signed 32 bits
static av_cold int config_props(AVFilterLink *outlink)