Go to the documentation of this file.
37 #define SECTION_ID_NONE -1
39 #define SHOW_OPTIONAL_FIELDS_AUTO -1
40 #define SHOW_OPTIONAL_FIELDS_NEVER 0
41 #define SHOW_OPTIONAL_FIELDS_ALWAYS 1
50 { 1.024e3, 1e3,
"Ki",
"K" },
51 { 1.048576e6, 1e6,
"Mi",
"M" },
52 { 1.073741824e9, 1e9,
"Gi",
"G" },
53 { 1.099511627776e12, 1e12,
"Ti",
"T" },
54 { 1.125899906842624e15, 1e15,
"Pi",
"P" },
63 #define OFFSET(x) offsetof(AVTextFormatContext, x)
66 {
"string_validation",
"set string validation mode",
68 {
"sv",
"set string validation mode",
73 {
"string_validation_replacement",
"set string validation replacement string",
OFFSET(string_validation_replacement),
AV_OPT_TYPE_STRING, {.str=
""}},
74 {
"svr",
"set string validation replacement string",
OFFSET(string_validation_replacement),
AV_OPT_TYPE_STRING, {.str=
"\xEF\xBF\xBD"}},
81 if (!prev &&
ctx->formatter &&
ctx->formatter->priv_class &&
ctx->priv)
94 static void bprint_bytes(AVBPrint *bp,
const uint8_t *ubuf,
size_t ubuf_size)
98 for (
i = 0;
i < ubuf_size;
i++)
167 tctx->
writer = writer_context;
172 void *priv_ctx = tctx->
priv;
183 av_log(tctx,
AV_LOG_ERROR,
"Failed to parse option string '%s' provided to textformat context\n", args);
190 av_log(tctx,
AV_LOG_ERROR,
"Failed to set option '%s' with value '%s' provided to textformat context\n",
216 const uint8_t *endp = p + strlen(p);
218 const uint8_t *p0 = p;
226 "Invalid UTF8 sequence %s found in string validation replace '%s'\n",
275 int parent_section_id = tctx->
level ?
301 const uint8_t *p, *endp;
303 int invalid_chars_nb = 0,
ret = 0;
311 const uint8_t *p0 = p;
318 "Invalid UTF-8 sequence %s found in string '%s'\n", bp.str,
src);
328 "Invalid UTF-8 sequence found in string '%s'\n",
src);
345 "%d invalid UTF-8 sequence(s) found in string '%s', replaced with '%s'\n",
369 vald = vali = uv.
val.
i;
376 mins = (int)secs / 60;
377 secs = secs - mins * 60;
380 snprintf(buf, buf_size,
"%d:%02d:%09.6f", hours, mins, secs);
382 const char *prefix_string =
"";
402 snprintf(buf, buf_size,
"%f", vald);
404 snprintf(buf, buf_size,
"%"PRId64, vali);
438 if (
ret < 0)
goto end;
440 if (
ret < 0)
goto end;
445 "Invalid key=value string combination %s=%s in section %s\n",
474 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
477 double d = ts *
av_q2d(*time_base);
488 if ((!is_duration && ts ==
AV_NOPTS_VALUE) || (is_duration && ts == 0)) {
506 for (
i = 0;
i < l;
i++) {
512 for (
i = 0;
i < l;
i++)
533 p = buf + strlen(buf);
540 int columns,
int bytes,
int offset_add)
550 for (
i = 0;
i < l;
i++) {
573 if (!prev &&
ctx->formatter &&
ctx->formatter->priv_class &&
ctx->priv)
620 void *priv_ctx = wctx->
priv;
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
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
static int use_byte_value_binary_prefix
#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.
AVDictionary * entries_to_show
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 AVOption textcontext_options[]
const struct AVTextFormatSection * section[SECTION_MAX_NB_LEVELS]
section per each level
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]
const AVTextFormatter avtextformatter_compact
@ AV_TEXTFORMAT_STRING_VALIDATION_NB
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *name, const uint8_t *data, int size)
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
int level
current level, starting from 0
static int show_optional_fields
const char * av_hash_get_name(const AVHashContext *ctx)
static const char * textcontext_get_formatter_name(void *p)
void av_opt_free(void *obj)
Free all allocated objects in obj.
#define AV_BPRINT_SIZE_AUTOMATIC
static double val(void *priv, double ch)
static const struct @11 si_prefixes[]
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE
void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val)
AVTextWriterContext * writer
the AVTextWriterContext
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
const AVTextFormatter avtextformatter_default
static const char unit_bit_per_second_str[]
const struct AVTextFormatSection * sections
array containing all sections
void(* print_string)(AVTextFormatContext *tctx, const char *, const char *)
static void * textcontext_child_next(void *obj, void *prev)
#define SECTION_MAX_NB_SECTIONS
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
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.
const AVTextFormatter avtextformatter_ini
static char * value_string(AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
const AVClass * priv_class
private class of the writer, if any
void * priv
private data for use by the filter
int priv_size
private size for the formatter context
int use_byte_value_binary_prefix
const char * unique_name
unique section name, in case the name is ambiguous
#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.
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).
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.
static void formatters_register_all(void)
static int show_value_unit
const AVTextFormatter avtextformatter_flat
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
int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args, const struct AVTextFormatSection *sections, int nb_sections, int show_value_unit, int use_value_prefix, int use_byte_value_binary_prefix, int use_value_sexagesimal_format, int show_optional_fields, char *show_data_hash)
int use_value_sexagesimal_format
#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
static int use_value_prefix
#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.
static const AVClass textwriter_class
void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep)
const AVClass * class
class of the formatter
#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
static const AVTextFormatter * registered_formatters[7+1]
union unit_value::@12 val
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 value
const AVTextFormatter avtextformatter_xml
void(* uninit)(AVTextFormatContext *tctx)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void(* uninit)(AVTextWriterContext *wctx)
unsigned int string_validation_utf8_flags
static void * writercontext_child_next(void *obj, void *prev)
static int use_value_sexagesimal_format
const AVTextFormatter avtextformatter_json
void(* print_section_footer)(AVTextFormatContext *tctx)
static struct AVTextFormatSection sections[]
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)
void avtext_print_integers(AVTextFormatContext *tctx, const char *name, uint8_t *data, int size, const char *format, int columns, int bytes, int offset_add)
@ AV_OPT_TYPE_INT
Underlying C type is int.
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[]
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 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...
void avtext_print_unit_int(AVTextFormatContext *tctx, const char *key, int value, const char *unit)
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.
void avtext_print_data(AVTextFormatContext *tctx, const char *name, const uint8_t *data, int size)
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
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