Go to the documentation of this file.
21 #include "config_components.h"
95 #define OFFSET(x) offsetof(GraphMonitorContext, x)
96 #define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
97 #define VFR AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
142 8192 *
sizeof(*(
s->cache)));
167 const int h =
out->height;
168 const int w =
out->width;
169 uint8_t *
dst =
out->data[0];
172 for (
int j = 0; j <
w; j++)
175 for (
int i = 1;
i <
h;
i++) {
176 memcpy(
dst,
out->data[0],
w * 4);
190 if (y + 8 >= pic->
height ||
194 for (
i = 0; txt[
i];
i++) {
197 uint8_t *p = pic->
data[0] + y*pic->
linesize[0] + (x +
i*8)*4;
198 for (char_y = 0; char_y < font_height; char_y++) {
200 if (font[txt[
i] * font_height + char_y] &
mask) {
214 for (
int j = 0; j <
filter->nb_inputs; j++) {
221 for (
int j = 0; j <
filter->nb_outputs; j++) {
233 for (
int j = 0; j <
filter->nb_inputs; j++) {
241 for (
int j = 0; j <
filter->nb_outputs; j++) {
261 int64_t previous_pts_us =
s->cache[
s->cache_index].previous_pts_us;
263 const int flags =
s->flags;
264 const int mode =
s->mode;
265 char buffer[1024] = { 0 };
371 s->cache[
s->cache_index].previous_pts_us = current_pts_us;
373 if (
s->cache_index + 1 >=
s->cache_size /
sizeof(*(
s->cache))) {
389 int ret,
len, xpos, ypos = 0;
397 s->bg[3] = 255 *
s->opacity;
402 for (
int i = 0;
i <
ctx->graph->nb_filters;
i++) {
417 xpos +=
len * 8 + 10;
421 for (
int j = 0; j <
filter->nb_inputs; j++) {
437 xpos +=
len * 8 + 10;
445 for (
int j = 0; j <
filter->nb_outputs; j++) {
461 xpos +=
len * 8 + 10;
510 s->next_pts =
s->pts + 1;
513 if (
s->eof &&
s->eof_frames == 0) {
543 s->white[0] =
s->white[1] =
s->white[2] = 255;
544 s->yellow[0] =
s->yellow[1] = 255;
548 s->gray[0] =
s->gray[1] =
s->gray[2] = 128;
565 s->cache_size =
s->cache_index = 0;
578 #if CONFIG_GRAPHMONITOR_FILTER
581 .
name =
"graphmonitor",
584 .priv_class = &graphmonitor_class,
594 #endif // CONFIG_GRAPHMONITOR_FILTER
596 #if CONFIG_AGRAPHMONITOR_FILTER
599 .
name =
"agraphmonitor",
601 .priv_class = &graphmonitor_class,
611 #endif // CONFIG_AGRAPHMONITOR_FILTER
static void error(const char *err)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVPixelFormat
Pixel format.
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
static void drawtext(AVFrame *pic, int x, int y, const char *txt, const int len, uint8_t *color)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AVERROR_EOF
End of file.
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int64_t sample_count_in
Number of past samples sent through the link.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
void(* filter)(uint8_t *src, int stride, int qscale)
const char * name
Filter name.
static av_cold void uninit(AVFilterContext *ctx)
int nb_channels
Number of channels in this layout.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
static int create_frame(AVFilterContext *ctx, int64_t pts)
int64_t current_pts_us
Current timestamp of the link, as defined by the most recent frame(s), in AV_TIME_BASE units.
static int draw_items(AVFilterContext *ctx, AVFilterContext *filter, AVFrame *out, int xpos, int ypos, AVFilterLink *l, size_t frames)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
const AVFilter ff_avf_agraphmonitor
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
void * priv
private data for use by the filter
if it could not because there are no more frames
static int query_formats(AVFilterContext *ctx)
A filter pad used for either input or output.
enum AVMediaType type
filter media type
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static enum AVPixelFormat pix_fmts[]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
#define FILTER_OUTPUTS(array)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Describe the class of an AVClass context structure.
Rational number (pair of numerator and denominator).
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
char * name
name of this filter instance
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
static FilterLink * ff_filter_link(AVFilterLink *link)
static int activate(AVFilterContext *ctx)
#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.
static av_cold int init(AVFilterContext *ctx)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
int format
agreed upon media format
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVFilterContext * dst
dest filter
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.
AVFilterFormatsConfig incfg
Lists of supported formats / etc.
FF_FILTER_FORWARD_WANTED(outlink, inlink)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
static const AVFilterPad graphmonitor_outputs[]
int sample_rate
samples per second
static int filter_have_eof(AVFilterContext *filter)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static const AVOption graphmonitor_options[]
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
static int filter_have_queued(AVFilterContext *filter)
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static void clear_image(GraphMonitorContext *s, AVFrame *out, AVFilterLink *outlink)
static int config_output(AVFilterLink *outlink)
int h
agreed upon image height
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
const uint8_t avpriv_cga_font[2048]
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
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.
AVFILTER_DEFINE_CLASS_EXT(graphmonitor, "(a)graphmonitor", graphmonitor_options)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
#define FILTER_QUERY_FUNC(func)
int64_t frame_count_in
Number of past frames sent through the link.
const AVFilter ff_vf_graphmonitor
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.