21#include "config_components.h"
56#define OFFSET(x) offsetof(DrawGraphContext, x)
57#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
98 if (
s->max <=
s->min) {
103 for (
i = 0;
i < 4;
i++) {
113 s->first[0] =
s->first[1] =
s->first[2] =
s->first[3] = 1;
121 if (!
s->values[0] || !
s->values[1] ||
122 !
s->values[2] || !
s->values[3]) {
152 for (
i = 0;
i <
out->height;
i++)
153 for (j = 0; j <
out->width; j++)
171 int64_t in_pts, out_pts, in_duration;
174 if (
s->slide == 4 &&
s->nb_values >=
s->values_size[0] /
sizeof(
float)) {
198 if (
s->slide != 4 ||
s->nb_values == 0) {
199 if (!
s->out ||
s->out->width != outlink->
w ||
200 s->out->height != outlink->
h) {
216 for (
i = 0;
i < 4;
i++) {
223 s->values[
i][
s->nb_values] =
NAN;
235 s->values[
i][
s->nb_values] =
vf;
246 if (
i == 0 && (
s->x >= outlink->
w ||
s->slide == 3)) {
247 if (
s->slide == 0 ||
s->slide == 1)
251 s->x = outlink->
w - 1;
252 for (j = 0; j < outlink->
h; j++) {
253 memmove(
out->data[0] + j *
out->linesize[0] ,
254 out->data[0] + j *
out->linesize[0] + 4,
255 (outlink->
w - 1) * 4);
257 }
else if (
s->slide == 3) {
259 for (j = 0; j < outlink->
h; j++) {
260 memmove(
out->data[0] + j *
out->linesize[0] + 4,
261 out->data[0] + j *
out->linesize[0],
262 (outlink->
w - 1) * 4);
264 }
else if (
s->slide == 0) {
270 y = (outlink->
h - 1) * (1 - ((
vf -
s->min) / (
s->max -
s->min)));
274 if (
i == 0 && (
s->slide > 0))
275 for (j = 0; j < outlink->
h; j++)
279 for (j = y; j < outlink->
h; j++) {
281 (
AV_RN32(
out->data[0] + j *
out->linesize[0] + x * 4) != old) ||
290 if (
i == 0 && (
s->slide > 0))
291 for (j = 0; j < outlink->
h; j++)
301 if (
i == 0 && (
s->slide > 0)) {
302 for (j = 0; j < y; j++)
304 for (j = outlink->
h - 1; j > y; j--)
307 if (y <= s->prev_y[
i]) {
308 for (j = y; j <=
s->prev_y[
i]; j++)
311 for (j =
s->prev_y[
i]; j <= y; j++)
332 if (out_pts ==
s->prev_pts)
339 clone->
pts =
s->prev_pts = out_pts;
349 int ret,
i, k, step, l;
353 if (
s->slide == 4 && ret ==
AVERROR_EOF &&
s->nb_values > 0) {
355 step =
ceil(
s->nb_values / (
float)
s->w);
357 for (k = 0; k <
s->nb_values; k++) {
358 for (
i = 0;
i < 4;
i++) {
362 float vf =
s->values[
i][k];
375 y = (outlink->
h - 1) * (1 - ((
vf -
s->min) / (
s->max -
s->min)));
380 for (j = y; j < outlink->
h; j++) {
382 (
AV_RN32(
out->data[0] + j *
out->linesize[0] + x * 4) != old) ||
399 if (y <= s->prev_y[
i]) {
400 for (j = y; j <=
s->prev_y[
i]; j++)
403 for (j =
s->prev_y[
i]; j <= y; j++)
446 for (
i = 0;
i < 4;
i++)
467#if CONFIG_DRAWGRAPH_FILTER
478 .p.name =
"drawgraph",
480 .p.priv_class = &drawgraph_class,
491#if CONFIG_ADRAWGRAPH_FILTER
502 .p.name =
"adrawgraph",
504 .p.priv_class = &drawgraph_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int const int8_t const int8_t * vf
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int request_frame(AVFilterLink *outlink)
const FFFilter ff_vf_drawgraph
const FFFilter ff_avf_adrawgraph
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Main libavfilter public API header.
int av_sscanf(const char *string, const char *format,...)
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define i(width, name, range_min, range_max)
static __device__ float ceil(float a)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
simple arithmetic expression evaluator
static void draw_dot(int fg, int x, int y, AVFrame *out)
static int request_frame(AVFilterLink *outlink)
static const AVOption drawgraph_options[]
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static void clear_image(DrawGraphContext *s, AVFrame *out, AVFilterLink *outlink)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad drawgraph_outputs[]
static int config_output(AVFilterLink *outlink)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ 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_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_EOF
End of file.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define AVFILTER_DEFINE_CLASS_EXT(name, desc, options)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_QUERY_FUNC2(func)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
static const char *const var_names[]
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Describe the class of an AVClass context structure.
void * priv
private data for use by the filter
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.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVDictionary * metadata
metadata.
int64_t duration
Duration of the frame, in the same units as pts.
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.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.