Go to the documentation of this file.
38 #define SECTION_ID_NONE (-1)
40 #define SHOW_OPTIONAL_FIELDS_AUTO (-1)
41 #define SHOW_OPTIONAL_FIELDS_NEVER 0
42 #define SHOW_OPTIONAL_FIELDS_ALWAYS 1
51 { 1.024e3, 1e3,
"Ki",
"K" },
52 { 1.048576e6, 1e6,
"Mi",
"M" },
53 { 1.073741824e9, 1e9,
"Gi",
"G" },
54 { 1.099511627776e12, 1e12,
"Ti",
"T" },
55 { 1.125899906842624e15, 1e15,
"Pi",
"P" },
64 #define OFFSET(x) offsetof(AVTextFormatContext, x)
67 {
"string_validation",
"set string validation mode",
69 {
"sv",
"set string validation mode",
74 {
"string_validation_replacement",
"set string validation replacement string",
OFFSET(string_validation_replacement),
AV_OPT_TYPE_STRING, { .str =
"" } },
75 {
"svr",
"set string validation replacement string",
OFFSET(string_validation_replacement),
AV_OPT_TYPE_STRING, { .str =
"\xEF\xBF\xBD" } },
82 if (!prev &&
ctx->formatter &&
ctx->formatter->priv_class &&
ctx->priv)
95 static void bprint_bytes(AVBPrint *bp,
const uint8_t *ubuf,
size_t ubuf_size)
98 for (
unsigned i = 0;
i < ubuf_size;
i++)
163 tctx->
writer = writer_context;
166 void *priv_ctx = tctx->
priv;
177 av_log(tctx,
AV_LOG_ERROR,
"Failed to parse option string '%s' provided to textformat context\n", args);
184 av_log(tctx,
AV_LOG_ERROR,
"Failed to set option '%s' with value '%s' provided to textformat context\n",
210 const uint8_t *endp =
p + strlen((
const char *)
p);
212 const uint8_t *p0 =
p;
220 "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
250 if (section_id < 0 || section_id >= tctx->
nb_sections) {
251 av_log(tctx,
AV_LOG_ERROR,
"Invalid section_id for section_header: %d\n", section_id);
274 int parent_section_id = tctx->
level ?
309 const uint8_t *
p, *endp, *srcp = (
const uint8_t *)
src;
311 AVBPrint invalid_seq;
312 int invalid_chars_nb = 0,
ret = 0;
318 endp = srcp + strlen(
src);
319 for (
p = srcp; *
p;) {
322 const uint8_t *p0 =
p;
330 av_log(tctx,
AV_LOG_DEBUG,
"Invalid UTF-8 sequence '%s' found in string '%s'\n", invalid_seq.str,
src);
355 "%d invalid UTF-8 sequence(s) found in string '%s', replaced with '%s'\n",
391 mins = (int)secs / 60;
392 secs = secs - mins * 60;
395 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
397 const char *prefix_string =
"";
417 snprintf(buf, buf_size,
"%f", vald);
419 snprintf(buf, buf_size,
"%"PRId64, vali);
460 if (
ret < 0)
goto end;
462 if (
ret < 0)
goto end;
467 "Invalid key=value string combination %s=%s in section %s\n",
491 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
495 double d =
av_q2d(*time_base) * ts;
506 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0))
521 for (
i = 0;
i < l;
i++) {
527 for (
i = 0;
i < l;
i++)
593 if (!prev &&
ctx->formatter &&
ctx->formatter->priv_class &&
ctx->priv)
631 if (!pwctx || !writer)
645 void *priv_ctx = wctx->
priv;
689 (*end ==
'\0' || *end ==
'='))
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
static char * value_string(const AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
static int validate_string(AVTextFormatContext *tctx, char **dstp, const char *src)
void avtext_print_time(AVTextFormatContext *tctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration)
int(* init)(AVTextWriterContext *wctx)
int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, unsigned int flags)
Read and decode a single UTF-8 code point (character) from the buffer in *buf, and update *buf to poi...
static const char * writercontext_get_writer_name(void *p)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
#define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL
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
void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int is_duration)
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
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 const struct @15 si_prefixes[]
static const AVOption textcontext_options[]
int priv_size
private size for the writer private class
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_HASH_MAX_SIZE
Maximum value that av_hash_get_size() will currently return.
unsigned int nb_item_type[SECTION_MAX_NB_LEVELS][SECTION_MAX_NB_SECTIONS]
void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
const AVTextFormatter avtextformatter_compact
@ AV_TEXTFORMAT_STRING_VALIDATION_NB
void avtext_print_unit_integer(AVTextFormatContext *tctx, const char *key, int64_t val, const char *unit)
void * priv
private data for use by the writer
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static const AVClass textcontext_class
int id
unique id identifying a section
const AVTextFormatter avtextformatter_mermaid
int level
current level, starting from 0
int(* uninit)(AVTextWriterContext *wctx)
const char * av_hash_get_name(const AVHashContext *ctx)
static const char * textcontext_get_formatter_name(void *p)
@ AV_TEXTFORMAT_DATADUMP_BASE64
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define AV_BPRINT_SIZE_AUTOMATIC
static double val(void *priv, double ch)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE
AVTextWriterContext * writer
the AVTextWriterContext
AVTextFormatDataDump data_dump_format
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int(* is_key_selected)(struct AVTextFormatContext *tctx, const char *key)
Callback to discard certain elements based upon the key used.
#define FF_ARRAY_ELEMS(a)
static const AVTextFormatter *const registered_formatters[]
const AVTextFormatter avtextformatter_default
static void print_data_base64(AVBPrint *bp, const uint8_t *data, int size)
static const char unit_bit_per_second_str[]
void(* print_string)(AVTextFormatContext *tctx, const char *, const char *)
static void * textcontext_child_next(void *obj, void *prev)
#define SECTION_MAX_NB_SECTIONS
union unit_value::@16 val
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
const AVClass * class
class of the writer
int avtextwriter_context_close(AVTextWriterContext **pwctx)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int av_hash_alloc(AVHashContext **ctx, const char *name)
Allocate a hash context for the algorithm specified by name.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static AVFormatContext * ctx
const AVTextFormatter avtextformatter_ini
int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args, const AVTextFormatSection *sections, int nb_sections, AVTextFormatOptions options, char *show_data_hash)
const AVClass * priv_class
private class of the writer, if any
@ AV_TEXTFORMAT_DATADUMP_XXD
void * priv
private data for use by the filter
int priv_size
private size for the formatter context
const char * unique_name
unique section name, in case the name is ambiguous
static AVDictionary * opts
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags)
const char * av_hash_names(int i)
Get the names of available hash algorithms.
const AVTextFormatSection * section[SECTION_MAX_NB_LEVELS]
section per each level
static const char unit_second_str[]
void av_hash_init(AVHashContext *ctx)
Initialize or reset a hash context.
#define SHOW_OPTIONAL_FIELDS_AUTO
Rational number (pair of numerator and denominator).
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
void(* print_section_header)(AVTextFormatContext *tctx, const void *data)
@ AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
const AVTextFormatter * formatter
the AVTextFormatter of which this is an instance
void av_hash_update(AVHashContext *ctx, const uint8_t *src, size_t len)
Update a hash context with additional data.
const AVTextFormatter * avtext_get_formatter_by_name(const char *name)
#define SECTION_MAX_NB_LEVELS
void av_hash_freep(AVHashContext **ctx)
Free hash context and set hash context pointer to NULL.
const AVTextFormatter avtextformatter_flat
const OptionDef options[]
int avtextwriter_context_open(AVTextWriterContext **pwctx, const AVTextWriter *writer)
static const char unit_hertz_str[]
@ AV_TEXTFORMAT_STRING_VALIDATION_FAIL
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void avtext_print_section_footer(AVTextFormatContext *tctx)
const AVTextWriter * writer
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various formatters
#define SHOW_OPTIONAL_FIELDS_NEVER
int flags
a combination or AV_TEXTFORMAT__FLAG_*
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 offset
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static const AVClass textwriter_class
const AVTextFormatSection * sections
array containing all sections
void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep)
const AVClass * class
class of the formatter
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
const AVTextFormatter avtextformatter_xml
int(* uninit)(AVTextFormatContext *tctx)
unsigned int string_validation_utf8_flags
static void * writercontext_child_next(void *obj, void *prev)
const AVTextFormatter avtextformatter_json
void(* print_section_footer)(AVTextFormatContext *tctx)
int use_value_sexagesimal_format
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void av_bprintf(AVBPrint *buf, const char *fmt,...)
const AVClass * priv_class
private class of the formatter, if any
void(* print_integer)(AVTextFormatContext *tctx, const char *, int64_t)
@ AV_OPT_TYPE_INT
Underlying C type is int.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static const AVTextFormatSection sections[]
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
int(* init)(AVTextFormatContext *tctx)
static const char unit_byte_str[]
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
static void print_data_xxd(AVBPrint *bp, const uint8_t *data, int size)
const AVTextFormatter avtextformatter_csv
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
Finalize a hash context and store the hexadecimal representation of the actual hash value as a string...
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
number of the item printed in the given section, starting from 0
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
@ AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
static char * show_data_hash
#define AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS
@ 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...
int avtext_context_close(AVTextFormatContext **ptctx)
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
const AVTextFormatter avtextformatter_mermaidhtml
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
int use_byte_value_binary_prefix
int nb_sections
number of sections
struct AVHashContext * hash
void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id)
char * string_validation_replacement