Go to the documentation of this file.
35 char *
name,
unsigned argc,
char **argv)
37 void *log_ctx = expand_text->
log_ctx;
44 if (argc < functions[
i].argc_min) {
46 name, functions[
i].argc_min);
49 if (argc > functions[
i].argc_max) {
51 name, functions[
i].argc_max);
61 return functions[
i].
func(log_ctx, bp,
name, argc, argv);
83 void *log_ctx = expand_text->
log_ctx;
84 const char *text = *rtext;
85 char *argv[16] = {
NULL };
114 *rtext = (
char *)text + 1;
117 for (
i = 0;
i < argc;
i++)
131 if (*text ==
'\\' && text[1]) {
134 }
else if (*text ==
'%') {
149 const char *fmt,
const char *strftime_fmt)
162 if (!strcmp(fmt,
"flt")) {
164 }
else if (!strcmp(fmt,
"hms") ||
165 !strcmp(fmt,
"hms24hh")) {
175 if (!strcmp(fmt,
"hms24hh")) {
177 ms %= 24 * 60 * 60 * 1000;
180 (
int)(ms / (60 * 60 * 1000)),
181 (
int)(ms / (60 * 1000)) % 60,
182 (
int)(ms / 1000) % 60,
185 }
else if (!strcmp(fmt,
"localtime") ||
186 !strcmp(fmt,
"gmtime")) {
188 time_t ms = (time_t)
pts;
189 if (!strcmp(fmt,
"localtime"))
202 const char *strftime_fmt,
char localtime)
204 const char *fmt =
av_x_if_null(strftime_fmt,
"%Y-%m-%d %H:%M:%S");
205 const char *fmt_begin = fmt;
218 now = unow / 1000000;
226 while ((begin = strchr(begin,
'%'))) {
248 num_digits =
av_clip(*(begin + 1) -
'0', 1, 6);
249 }
else if (
len > 1) {
250 av_log(log_ctx,
AV_LOG_WARNING,
"Invalid number of decimals for %%N, using default of %i\n", num_digits);
255 div = pow(10, 6 - num_digits);
257 av_bprintf(&fmt_bp,
"%.*s%0*d", (
int)(begin - fmt_begin), fmt_begin, num_digits, (
int)(unow % 1000000) / div);
282 const char *
const *fun_names,
const ff_eval_func2 *fun_values,
283 const char *
const *
var_names,
const double *var_values,
291 eval_ctx, 0, log_ctx);
294 "Text expansion expression '%s' is not valid\n",
304 const char *
const *fun_names,
const ff_eval_func2 *fun_values,
305 const char *
const *
var_names,
const double *var_values,
312 char fmt_str[30] =
"%";
316 eval_ctx, 0, log_ctx);
319 "Text expansion expression '%s' is not valid\n",
324 if (!strchr(
"xXdu",
format)) {
326 " allowed values: 'x', 'X', 'd', 'u'\n",
format);
330 feclearexcept(FE_ALL_EXCEPT);
332 #if defined(FE_INVALID) && defined(FE_OVERFLOW) && defined(FE_UNDERFLOW)
333 if ((
ret = fetestexcept(FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW))) {
334 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);
353 unsigned char **text,
size_t *text_size)
360 if ((err =
av_file_map(textfile, &textbuf, &textbuf_size, 0, log_ctx)) < 0) {
362 "The text file '%s' could not be read or is empty\n",
367 if (textbuf_size > 0 && ff_is_newline(textbuf[textbuf_size - 1]))
369 if (textbuf_size > SIZE_MAX - 1 || !(
tmp =
av_realloc(*text, textbuf_size + 1))) {
374 memcpy(*text, textbuf, textbuf_size);
375 (*text)[textbuf_size] = 0;
377 *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
int ff_expand_text(FFExpandTextContext *expand_text, char *text, AVBPrint *bp)
Expand text template.
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)
FFExpandTextFunction * functions
list of functions to use to expand sequences in the format FUNCTION_NAME{PARAMS}
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...
static int ff_expand_text_function(FFExpandTextContext *expand_text, AVBPrint *bp, char **rtext)
Expand text template pointed to by *rtext.
void * log_ctx
log context to pass to the function, used for logging and for accessing the context for the function
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().
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.
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.