37 #define COMMAND_FLAG_ENTER 1 38 #define COMMAND_FLAG_LEAVE 2 39 #define COMMAND_FLAG_EXPR 4 65 static const char *
const flag_strings[] = {
"enter",
"leave",
"expr" };
105 #define OFFSET(x) offsetof(SendCmdContext, x) 106 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM 115 #define SPACES " \f\t\n\r" 121 *buf += strspn(*buf,
SPACES);
128 *buf += strcspn(*buf,
"\n");
134 #define COMMAND_DELIMS " \f\t\n\r,;" 137 const char **buf,
void *log_ctx)
141 memset(cmd, 0,
sizeof(
Command));
142 cmd->
index = cmd_count;
145 *buf += strspn(*buf,
SPACES);
152 int len = strcspn(*buf,
"|+]");
161 "Unknown flag '%s' in interval #%d, command #%d\n",
162 flag_buf, interval_count, cmd_count);
168 if (!strspn(*buf,
"+|")) {
170 "Invalid flags char '%c' in interval #%d, command #%d\n",
171 **buf, interval_count, cmd_count);
180 "Missing flag terminator or extraneous data found at the end of flags " 181 "in interval #%d, command #%d\n", interval_count, cmd_count);
189 *buf += strspn(*buf,
SPACES);
193 "No target specified in interval #%d, command #%d\n",
194 interval_count, cmd_count);
199 *buf += strspn(*buf,
SPACES);
203 "No command specified in interval #%d, command #%d\n",
204 interval_count, cmd_count);
209 *buf += strspn(*buf,
SPACES);
222 const char **buf,
void *log_ctx)
234 if ((ret =
parse_command(&cmd, cmd_count, interval_count, buf, log_ctx)) < 0)
244 "Could not (re)allocate command array\n");
249 (*cmds)[(*nb_cmds)++] = cmd;
251 *buf += strspn(*buf,
SPACES);
252 if (**buf && **buf !=
';' && **buf !=
',') {
254 "Missing separator or extraneous data found at the end of " 255 "interval #%d, in command #%d\n",
256 interval_count, cmd_count);
258 "Command was parsed as: flags:[%s] target:%s command:%s arg:%s\n",
271 #define DELIMS " \f\t\n\r,;" 274 const char **buf,
void *log_ctx)
279 *buf += strspn(*buf,
SPACES);
284 memset(interval, 0,
sizeof(
Interval));
285 interval->
index = interval_count;
291 if (intervalstr && intervalstr[0]) {
294 start =
av_strtok(intervalstr,
"-", &end);
298 "Invalid interval specification '%s' in interval #%d\n",
299 intervalstr, interval_count);
304 "Invalid start time specification '%s' in interval #%d\n",
305 start, interval_count);
312 "Invalid end time specification '%s' in interval #%d\n",
313 end, interval_count);
317 interval->
end_ts = INT64_MAX;
321 "Invalid end time '%s' in interval #%d: " 322 "cannot be lesser than start time '%s'\n",
323 end, interval_count, start);
329 "No interval specified for interval #%d\n", interval_count);
336 interval_count, buf, log_ctx);
344 const char *buf,
void *log_ctx)
346 int interval_count = 0;
362 if ((ret =
parse_interval(&interval, interval_count, &buf, log_ctx)) < 0)
365 buf += strspn(buf,
SPACES);
369 "Missing terminator or extraneous data found at the end of interval #%d\n",
378 if (*nb_intervals == n) {
383 "Could not (re)allocate intervals array\n");
388 (*intervals)[(*nb_intervals)++] = interval;
408 "One and only one of the filename or commands options must be specified\n");
416 &file_buf, &file_bufsize, 0, ctx);
426 memcpy(buf, file_buf, file_bufsize);
427 buf[file_bufsize] = 0;
452 " [%s] target:%s command:%s arg:%s index:%d\n",
490 #define WITHIN_INTERVAL(ts, start_ts, end_ts) ((ts) >= (start_ts) && (ts) < (end_ts)) 510 "[%s] interval #%d start_ts:%f end_ts:%f ts:%f\n",
512 (
double)interval->
start_ts/1000000, (
double)interval->
end_ts/1000000,
515 for (j = 0; flags && j < interval->
nb_commands; j++) {
517 char *cmd_arg = cmd->
arg;
520 if (cmd->
flags & flags) {
530 var_values[
VAR_T] = current;
531 var_values[
VAR_TS] = start;
533 var_values[
VAR_TI] = (current - start) / (end - start);
549 "Processing command #%d target:%s command:%s arg:%s\n",
556 "Command reply for command #%d: ret:%s res:%s\n",
566 switch (inlink->
type) {
575 #if CONFIG_SENDCMD_FILTER 577 #define sendcmd_options options 605 .priv_class = &sendcmd_class,
610 #if CONFIG_ASENDCMD_FILTER 612 #define asendcmd_options options 638 .
inputs = asendcmd_inputs,
640 .priv_class = &asendcmd_class,
int64_t frame_count_in
Number of past frames sent through the link.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
This structure describes decoded (raw) audio or video data.
#define av_realloc_f(p, o, n)
static int cmp_intervals(const void *a, const void *b)
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
Main libavfilter public API header.
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int index
unique index for these interval commands
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 parse_commands(Command **cmds, int *nb_cmds, int interval_count, const char **buf, void *log_ctx)
static int parse_interval(Interval *interval, int interval_count, const char **buf, void *log_ctx)
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static void skip_comments(const char **buf)
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_LOG_VERBOSE
Detailed information.
static int parse_intervals(Interval **intervals, int *nb_intervals, const char *buf, void *log_ctx)
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
A link between two filters.
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_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
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...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
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.
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...
static av_cold void uninit(AVFilterContext *ctx)
char * av_asprintf(const char *fmt,...)
#define FFDIFFSIGN(x, y)
Comparator.
int enabled
current time detected inside this interval
static int parse_command(Command *cmd, int cmd_count, int interval_count, const char **buf, void *log_ctx)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define COMMAND_FLAG_LEAVE
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
static const AVFilterPad outputs[]
#define FF_ARRAY_ELEMS(a)
#define AV_BPRINT_SIZE_AUTOMATIC
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
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
Describe the class of an AVClass context structure.
static av_cold int init(AVFilterContext *ctx)
#define COMMAND_FLAG_ENTER
const char * name
Filter name.
static char * make_command_flags_str(AVBPrint *pbuf, int flags)
int64_t end_ts
end timestamp expressed as microseconds units
AVFilterLink ** outputs
array of pointers to output links
#define flags(name, subs,...)
enum AVMediaType type
filter media type
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_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
struct AVFilterGraph * graph
Graph the filter belongs to.
static int ref[MAX_W *MAX_W]
int64_t start_ts
start timestamp expressed as microseconds units
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.
static const char *const var_names[]
AVFilterContext * dst
dest filter
#define AVFILTER_DEFINE_CLASS(fname)
#define WITHIN_INTERVAL(ts, start_ts, end_ts)
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 int filter_frame(AVFilterLink *inlink, AVFrame *ref)
#define COMMAND_FLAG_EXPR
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const AVOption options[]
simple arithmetic expression evaluator
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.