Go to the documentation of this file.
37 char *
name,
unsigned argc,
char **argv)
39 void *log_ctx = expand_text->
log_ctx;
46 if (argc < functions[
i].argc_min) {
48 name, functions[
i].argc_min);
51 if (argc > functions[
i].argc_max) {
53 name, functions[
i].argc_max);
63 return functions[
i].
func(log_ctx, bp,
name, argc, argv);
85 void *log_ctx = expand_text->
log_ctx;
86 const char *text = *rtext;
87 char *argv[16] = {
NULL };
119 for (
i = 0;
i < argc;
i++)
133 if (*text ==
'\\' && text[1]) {
136 }
else if (*text ==
'%') {
151 const char *fmt,
const char *strftime_fmt)
164 if (!strcmp(fmt,
"flt")) {
166 }
else if (!strcmp(fmt,
"hms") ||
167 !strcmp(fmt,
"hms24hh")) {
177 if (!strcmp(fmt,
"hms24hh")) {
179 ms %= 24 * 60 * 60 * 1000;
182 (
int)(ms / (60 * 60 * 1000)),
183 (
int)(ms / (60 * 1000)) % 60,
184 (
int)(ms / 1000) % 60,
187 }
else if (!strcmp(fmt,
"localtime") ||
188 !strcmp(fmt,
"gmtime")) {
190 time_t ms = (time_t)
pts;
191 if (!strcmp(fmt,
"localtime"))
204 const char *strftime_fmt,
char localtime)
206 const char *fmt =
av_x_if_null(strftime_fmt,
"%Y-%m-%d %H:%M:%S");
207 const char *fmt_begin = fmt;
220 now = unow / 1000000;
228 while ((begin = strchr(begin,
'%'))) {
250 num_digits =
av_clip(*(begin + 1) -
'0', 1, 6);
251 }
else if (
len > 1) {
252 av_log(log_ctx,
AV_LOG_WARNING,
"Invalid number of decimals for %%N, using default of %i\n", num_digits);
257 div = pow(10, 6 - num_digits);
259 av_bprintf(&fmt_bp,
"%.*s%0*d", (
int)(begin - fmt_begin), fmt_begin, num_digits, (
int)(unow % 1000000) / div);
284 const char *
const *fun_names,
const ff_eval_func2 *fun_values,
285 const char *
const *
var_names,
const double *var_values,
293 eval_ctx, 0, log_ctx);
296 "Text expansion expression '%s' is not valid\n",
306 const char *
const *fun_names,
const ff_eval_func2 *fun_values,
307 const char *
const *
var_names,
const double *var_values,
314 char fmt_str[30] =
"%";
318 eval_ctx, 0, log_ctx);
321 "Text expansion expression '%s' is not valid\n",
326 if (!strchr(
"xXdu",
format)) {
328 " allowed values: 'x', 'X', 'd', 'u'\n",
format);
332 feclearexcept(FE_ALL_EXCEPT);
334 #if defined(FE_INVALID) && defined(FE_OVERFLOW) && defined(FE_UNDERFLOW)
335 if ((
ret = fetestexcept(FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW))) {
336 av_log(log_ctx,
AV_LOG_ERROR,
"Conversion of floating-point result to int failed. Control register: 0x%08x. Conversion result: %d\n",
ret, intval);
355 unsigned char **text,
size_t *text_size)
362 if ((err =
av_file_map(textfile, &textbuf, &textbuf_size, 0, log_ctx)) < 0) {
364 "The text file '%s' could not be read or is empty\n",
369 if (textbuf_size > 0 && ff_is_newline(textbuf[textbuf_size - 1]))
371 if (textbuf_size > SIZE_MAX - 1 || !(
tmp =
av_realloc(*text, textbuf_size + 1))) {
376 memcpy(*text, textbuf, textbuf_size);
377 (*text)[textbuf_size] = 0;
379 *text_size = textbuf_size;
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
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 name
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
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
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
unsigned int functions_nb
number of functions
const static uint16_t positions[][14][3]
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 * log_ctx
log context to pass to the function, used for logging and for accessing the context for the function
int ff_expand_text(FFExpandTextContext *expand_text, const char *text, AVBPrint *bp)
Expand text template.
Function used to expand a template sequence in the format %{FUNCTION_NAME[:PARAMS]},...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
int ff_load_textfile(void *log_ctx, const char *textfile, unsigned char **text, size_t *text_size)
static const char *const var_names[]
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
const FFExpandTextFunction * functions
list of functions to use to expand sequences in the format FUNCTION_NAME{PARAMS}
int ff_print_formatted_eval_expr(void *log_ctx, AVBPrint *bp, const char *expr, const char *const *fun_names, const ff_eval_func2 *fun_values, const char *const *var_names, const double *var_values, void *eval_ctx, const char format, int positions)
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
Append a formatted date and time to a print buffer.
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.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int ff_print_eval_expr(void *log_ctx, AVBPrint *bp, const char *expr, const char *const *fun_names, const ff_eval_func2 *fun_values, const char *const *var_names, const double *var_values, void *eval_ctx)
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
int(* func)(void *ctx, AVBPrint *bp, const char *function_name, unsigned argc, char **args)
actual function used to perform the expansion
int ff_print_pts(void *log_ctx, AVBPrint *bp, double pts, const char *delta, const char *fmt, const char *strftime_fmt)
#define i(width, name, range_min, range_max)
#define AV_TIME_BASE
Internal time base represented as integer.
static int ff_expand_text_function(FFExpandTextContext *expand_text, AVBPrint *bp, const char **rtext)
Expand text template pointed to by *rtext.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
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...
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
in a text template, followed by any character, always expands to the second character.
int64_t av_gettime(void)
Get the current time in microseconds.
static int ff_expand_text_function_internal(FFExpandTextContext *expand_text, AVBPrint *bp, char *name, unsigned argc, char **argv)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
int ff_print_time(void *log_ctx, AVBPrint *bp, const char *strftime_fmt, char localtime)
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.