Go to the documentation of this file.
26 #include "config_components.h"
40 #define COMMAND_FLAG_ENTER 1
41 #define COMMAND_FLAG_LEAVE 2
42 #define COMMAND_FLAG_EXPR 4
76 static const char *
const flag_strings[] = {
"enter",
"leave",
"expr" };
116 #define OFFSET(x) offsetof(SendCmdContext, x)
117 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM
126 #define SPACES " \f\t\n\r"
132 *buf += strspn(*buf,
SPACES);
139 *buf += strcspn(*buf,
"\n");
145 #define COMMAND_DELIMS " \f\t\n\r,;"
148 const char **buf,
void *log_ctx)
152 memset(cmd, 0,
sizeof(
Command));
153 cmd->
index = cmd_count;
156 *buf += strspn(*buf,
SPACES);
163 int len = strcspn(*buf,
"|+]");
172 "Unknown flag '%s' in interval #%d, command #%d\n",
173 flag_buf, interval_count, cmd_count);
179 if (!strspn(*buf,
"+|")) {
181 "Invalid flags char '%c' in interval #%d, command #%d\n",
182 **buf, interval_count, cmd_count);
191 "Missing flag terminator or extraneous data found at the end of flags "
192 "in interval #%d, command #%d\n", interval_count, cmd_count);
200 *buf += strspn(*buf,
SPACES);
204 "No target specified in interval #%d, command #%d\n",
205 interval_count, cmd_count);
210 *buf += strspn(*buf,
SPACES);
214 "No command specified in interval #%d, command #%d\n",
215 interval_count, cmd_count);
220 *buf += strspn(*buf,
SPACES);
233 const char **buf,
void *log_ctx)
245 if ((
ret =
parse_command(&cmd, cmd_count, interval_count, buf, log_ctx)) < 0)
255 "Could not (re)allocate command array\n");
260 (*cmds)[(*nb_cmds)++] = cmd;
262 *buf += strspn(*buf,
SPACES);
263 if (**buf && **buf !=
';' && **buf !=
',') {
265 "Missing separator or extraneous data found at the end of "
266 "interval #%d, in command #%d\n",
267 interval_count, cmd_count);
269 "Command was parsed as: flags:[%s] target:%s command:%s arg:%s\n",
282 #define DELIMS " \f\t\n\r,;"
285 const char **buf,
void *log_ctx)
290 *buf += strspn(*buf,
SPACES);
295 memset(interval, 0,
sizeof(
Interval));
296 interval->
index = interval_count;
302 if (intervalstr && intervalstr[0]) {
305 start =
av_strtok(intervalstr,
"-", &end);
309 "Invalid interval specification '%s' in interval #%d\n",
310 intervalstr, interval_count);
315 "Invalid start time specification '%s' in interval #%d\n",
316 start, interval_count);
323 "Invalid end time specification '%s' in interval #%d\n",
324 end, interval_count);
328 interval->
end_ts = INT64_MAX;
332 "Invalid end time '%s' in interval #%d: "
333 "cannot be lesser than start time '%s'\n",
334 end, interval_count, start);
340 "No interval specified for interval #%d\n", interval_count);
347 interval_count, buf, log_ctx);
355 const char *buf,
void *log_ctx)
357 int interval_count = 0;
376 buf += strspn(buf,
SPACES);
380 "Missing terminator or extraneous data found at the end of interval #%d\n",
389 if (*nb_intervals == n) {
394 "Could not (re)allocate intervals array\n");
399 (*intervals)[(*nb_intervals)++] = interval;
417 if ((!!
s->commands_filename + !!
s->commands_str) != 1) {
419 "One and only one of the filename or commands options must be specified\n");
423 if (
s->commands_filename) {
424 uint8_t *file_buf, *buf;
427 &file_buf, &file_bufsize, 0,
ctx);
437 memcpy(buf, file_buf, file_bufsize);
438 buf[file_bufsize] = 0;
440 s->commands_str = buf;
444 s->commands_str,
ctx)) < 0)
447 if (
s->nb_intervals == 0) {
455 for (
i = 0;
i <
s->nb_intervals;
i++) {
463 " [%s] target:%s command:%s arg:%s index:%d\n",
476 for (
i = 0;
i <
s->nb_intervals;
i++) {
502 #define WITHIN_INTERVAL(ts, start_ts, end_ts) ((ts) >= (start_ts) && (ts) < (end_ts))
504 for (
i = 0;
i <
s->nb_intervals;
i++) {
522 "[%s] interval #%d start_ts:%f end_ts:%f ts:%f\n",
524 (
double)interval->
start_ts/1000000, (
double)interval->
end_ts/1000000,
529 char *cmd_arg = cmd->
arg;
546 var_values[
VAR_T] = current;
547 var_values[
VAR_TS] = start;
549 var_values[
VAR_TI] = (current - start) / (end - start);
567 "Processing command #%d target:%s command:%s arg:%s\n",
574 "Command reply for command #%d: ret:%s res:%s\n",
595 #if CONFIG_SENDCMD_FILTER
614 .priv_class = &sendcmd_class,
619 #if CONFIG_ASENDCMD_FILTER
632 .priv_class = &sendcmd_class,
#define FF_ENABLE_DEPRECATION_WARNINGS
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
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
#define WITHIN_INTERVAL(ts, start_ts, end_ts)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
static char * make_command_flags_str(AVBPrint *pbuf, int flags)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int cmp_intervals(const void *a, const void *b)
static int parse_command(Command *cmd, int cmd_count, int interval_count, const char **buf, void *log_ctx)
#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
char * av_asprintf(const char *fmt,...)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
#define AV_LOG_VERBOSE
Detailed information.
int index
unique index for these interval commands
const char * name
Filter name.
A link between two filters.
Link properties exposed to filter code, but not external callers.
#define COMMAND_FLAG_LEAVE
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
#define AV_BPRINT_SIZE_AUTOMATIC
A filter pad used for either input or output.
#define FFDIFFSIGN(x, y)
Comparator.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
#define COMMAND_FLAG_ENTER
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int parse_interval(Interval *interval, int interval_count, const char **buf, void *log_ctx)
#define FILTER_OUTPUTS(array)
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
static const AVOption options[]
#define av_realloc_f(p, o, n)
Describe the class of an AVClass context structure.
static av_cold void uninit(AVFilterContext *ctx)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int64_t end_ts
end timestamp expressed as microseconds units
static const char *const var_names[]
static FilterLink * ff_filter_link(AVFilterLink *link)
static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static av_cold int init(AVFilterContext *ctx)
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
#define i(width, name, range_min, range_max)
static int parse_commands(Command **cmds, int *nb_cmds, int interval_count, const char **buf, void *log_ctx)
const AVFilter ff_vf_sendcmd
const char * name
Pad name.
static void skip_comments(const char **buf)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define COMMAND_FLAG_EXPR
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
static int ref[MAX_W *MAX_W]
struct AVFilterGraph * graph
Graph the filter belongs to.
const AVFilter ff_af_asendcmd
AVFILTER_DEFINE_CLASS_EXT(sendcmd, "(a)sendcmd", options)
int enabled
current time detected inside this interval
#define FF_DISABLE_DEPRECATION_WARNINGS
#define flags(name, subs,...)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
@ 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...
static int parse_intervals(Interval **intervals, int *nb_intervals, const char *buf, void *log_ctx)
int64_t start_ts
start timestamp expressed as microseconds units
int64_t frame_count_in
Number of past frames sent through the link.