FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
avtextformat.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) The FFmpeg developers
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H
22 #define FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H
23 
24 #include <stdint.h>
25 #include "libavutil/dict.h"
26 #include "libavformat/avio.h"
27 #include "libavutil/bprint.h"
28 #include "libavutil/rational.h"
29 #include "libavutil/hash.h"
30 #include "avtextwriters.h"
31 
32 #define SECTION_MAX_NB_CHILDREN 11
33 
35  char *context_id;
36  const char *context_type;
39 
40 
41 typedef struct AVTextFormatSection {
42  int id; ///< unique id identifying a section
43  const char *name;
44 
45 #define AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER 1 ///< the section only contains other sections, but has no data at its own level
46 #define AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY 2 ///< the section contains an array of elements of the same type
47 #define AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS 4 ///< the section may contain a variable number of fields with variable keys.
48  /// For these sections the element_name field is mandatory.
49 #define AV_TEXTFORMAT_SECTION_FLAG_HAS_TYPE 8 ///< the section contains a type to distinguish multiple nested elements
50 #define AV_TEXTFORMAT_SECTION_FLAG_NUMBERING_BY_TYPE 16 ///< the items in this array section should be numbered individually by type
51 #define AV_TEXTFORMAT_SECTION_FLAG_IS_SHAPE 32 ///< ...
52 #define AV_TEXTFORMAT_SECTION_FLAG_HAS_LINKS 64 ///< ...
53 #define AV_TEXTFORMAT_SECTION_PRINT_TAGS 128 ///< ...
54 #define AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH 256 ///< ...
55 
56  int flags;
57  const int children_ids[SECTION_MAX_NB_CHILDREN + 1]; ///< list of children section IDS, terminated by -1
58  const char *element_name; ///< name of the contained element, if provided
59  const char *unique_name; ///< unique section name, in case the name is ambiguous
61  const char *(*get_type)(const void *data); ///< function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
63  const char *id_key; ///< name of the key to be used as the id
64  const char *src_id_key; ///< name of the key to be used as the source id for diagram connections
65  const char *dest_id_key; ///< name of the key to be used as the target id for diagram connections
66  const char *linktype_key; ///< name of the key to be used as the link type for diagram connections (AVTextFormatLinkType)
68 
70 
71 #define AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS 1
72 #define AV_TEXTFORMAT_FLAG_SUPPORTS_MIXED_ARRAY_CONTENT 2
73 #define AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER 4
74 
75 typedef enum {
81 
82 typedef enum {
93 
94 typedef struct AVTextFormatter {
95  const AVClass *priv_class; ///< private class of the formatter, if any
96  int priv_size; ///< private size for the formatter context
97  const char *name;
98 
99  int (*init) (AVTextFormatContext *tctx);
101 
102  void (*print_section_header)(AVTextFormatContext *tctx, const void *data);
104  void (*print_integer) (AVTextFormatContext *tctx, const char *, int64_t);
105  void (*print_string) (AVTextFormatContext *tctx, const char *, const char *);
106  int flags; ///< a combination or AV_TEXTFORMAT__FLAG_*
108 
109 #define SECTION_MAX_NB_LEVELS 12
110 #define SECTION_MAX_NB_SECTIONS 100
111 
113  const AVClass *class; ///< class of the formatter
114  const AVTextFormatter *formatter; ///< the AVTextFormatter of which this is an instance
115  AVTextWriterContext *writer; ///< the AVTextWriterContext
116 
117  char *name; ///< name of this formatter instance
118  void *priv; ///< private data for use by the filter
119 
120  const AVTextFormatSection *sections; ///< array containing all sections
121  int nb_sections; ///< number of sections
122 
123  int level; ///< current level, starting from 0
124 
125  /** number of the item printed in the given section, starting from 0 */
128 
129  /** section per each level */
131  AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
132  /// used by various formatters
133 
139 
141 
145 };
146 
147 typedef struct AVTextFormatOptions {
154 
155 #define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
156 #define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
157 
158 int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *formatter, AVTextWriterContext *writer_context, const char *args,
159  const AVTextFormatSection *sections, int nb_sections, AVTextFormatOptions options, char *show_data_hash);
160 
162 
163 
164 void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id);
165 
167 
168 void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags);
169 
170 int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags);
171 
172 void avtext_print_unit_int(AVTextFormatContext *tctx, const char *key, int value, const char *unit);
173 
174 void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep);
175 
176 void avtext_print_time(AVTextFormatContext *tctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration);
177 
178 void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int is_duration);
179 
180 void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
181 
182 void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
183 
184 void avtext_print_integers(AVTextFormatContext *tctx, const char *key, uint8_t *data, int size,
185  const char *format, int columns, int bytes, int offset_add);
186 
188 
198 
199 #endif /* FFTOOLS_TEXTFORMAT_AVTEXTFORMAT_H */
flags
const SwsFlags flags[]
Definition: swscale.c:61
AVTextFormatOptions::use_value_prefix
int use_value_prefix
Definition: avtextformat.h:150
name
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
Definition: writing_filters.txt:88
AVTextFormatSection::entries_to_show
AVDictionary * entries_to_show
Definition: avtextformat.h:60
AV_TEXTFORMAT_LINKTYPE_SRCDEST
@ AV_TEXTFORMAT_LINKTYPE_SRCDEST
Definition: avtextformat.h:83
AV_TEXTFORMAT_LINKTYPE_DESTSRC
@ AV_TEXTFORMAT_LINKTYPE_DESTSRC
Definition: avtextformat.h:84
AVTextFormatContext::nb_item_type
unsigned int nb_item_type[SECTION_MAX_NB_LEVELS][SECTION_MAX_NB_SECTIONS]
Definition: avtextformat.h:127
rational.h
int64_t
long long int64_t
Definition: coverity.c:34
AVTextFormatSection::src_id_key
const char * src_id_key
name of the key to be used as the source id for diagram connections
Definition: avtextformat.h:64
AVTextFormatSectionContext::context_type
const char * context_type
Definition: avtextformat.h:36
avtextformatter_compact
const AVTextFormatter avtextformatter_compact
Definition: tf_compact.c:239
AV_TEXTFORMAT_STRING_VALIDATION_NB
@ AV_TEXTFORMAT_STRING_VALIDATION_NB
Definition: avtextformat.h:79
data
const char data[16]
Definition: mxf.c:149
AVTextFormatContext::show_value_unit
int show_value_unit
Definition: avtextformat.h:135
AVTextFormatContext::name
char * name
name of this formatter instance
Definition: avtextformat.h:117
AVTextWriterContext
Definition: avtextwriters.h:42
AVTextFormatContext
Definition: avtextformat.h:112
AVDictionary
Definition: dict.c:32
AV_TEXTFORMAT_LINKTYPE_ONETOMANY
@ AV_TEXTFORMAT_LINKTYPE_ONETOMANY
Definition: avtextformat.h:88
avtext_print_section_footer
void avtext_print_section_footer(AVTextFormatContext *tctx)
Definition: avtextformat.c:273
AVTextFormatSection::id
int id
unique id identifying a section
Definition: avtextformat.h:42
avtextformatter_mermaid
const AVTextFormatter avtextformatter_mermaid
Definition: tf_mermaid.c:662
AV_TEXTFORMAT_LINKTYPE_BIDIR
@ AV_TEXTFORMAT_LINKTYPE_BIDIR
Definition: avtextformat.h:85
AVTextFormatContext::level
int level
current level, starting from 0
Definition: avtextformat.h:123
AVTextFormatSection::name
const char * name
Definition: avtextformat.h:43
avtext_print_integers
void avtext_print_integers(AVTextFormatContext *tctx, const char *key, uint8_t *data, int size, const char *format, int columns, int bytes, int offset_add)
Definition: avtextformat.c:568
AVTextFormatLinkType
AVTextFormatLinkType
Definition: avtextformat.h:82
AV_TEXTFORMAT_LINKTYPE_MANYTOONE
@ AV_TEXTFORMAT_LINKTYPE_MANYTOONE
Definition: avtextformat.h:89
val
static double val(void *priv, double ch)
Definition: aeval.c:77
AVTextFormatSection::show_all_entries
int show_all_entries
Definition: avtextformat.h:62
avtext_get_formatter_by_name
const AVTextFormatter * avtext_get_formatter_by_name(const char *name)
Definition: avtextformat.c:698
AVTextFormatSectionContext
Definition: avtextformat.h:34
AVTextFormatContext::writer
AVTextWriterContext * writer
the AVTextWriterContext
Definition: avtextformat.h:115
avtext_context_close
int avtext_context_close(AVTextFormatContext **tctx)
Definition: avtextformat.c:101
AVTextFormatSection::flags
int flags
Definition: avtextformat.h:56
SECTION_MAX_NB_CHILDREN
#define SECTION_MAX_NB_CHILDREN
Definition: avtextformat.h:32
AVTextFormatSection::element_name
const char * element_name
name of the contained element, if provided
Definition: avtextformat.h:58
avtextformatter_default
const AVTextFormatter avtextformatter_default
Definition: tf_default.c:127
AVTextFormatter::print_string
void(* print_string)(AVTextFormatContext *tctx, const char *, const char *)
Definition: avtextformat.h:105
AVTextFormatter
Definition: avtextformat.h:94
SECTION_MAX_NB_SECTIONS
#define SECTION_MAX_NB_SECTIONS
Definition: avtextformat.h:110
AVTextFormatSection
Definition: avtextformat.h:41
avtextformatter_ini
const AVTextFormatter avtextformatter_ini
Definition: tf_ini.c:141
AVTextFormatContext::priv
void * priv
private data for use by the filter
Definition: avtextformat.h:118
avtext_print_section_header
void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, int section_id)
Definition: avtextformat.c:255
key
const char * key
Definition: hwcontext_opencl.c:189
avtext_print_time
void avtext_print_time(AVTextFormatContext *tctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration)
Definition: avtextformat.c:499
AVTextFormatter::priv_size
int priv_size
private size for the formatter context
Definition: avtextformat.h:96
AVTextFormatContext::use_byte_value_binary_prefix
int use_byte_value_binary_prefix
Definition: avtextformat.h:137
avtext_print_rational
void avtext_print_rational(AVTextFormatContext *tctx, const char *key, AVRational q, char sep)
Definition: avtextformat.c:492
AVTextFormatSection::unique_name
const char * unique_name
unique section name, in case the name is ambiguous
Definition: avtextformat.h:59
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
AVTextFormatContext::section
const AVTextFormatSection * section[SECTION_MAX_NB_LEVELS]
section per each level
Definition: avtextformat.h:130
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_TEXTFORMAT_LINKTYPE_MANYTOMANY
@ AV_TEXTFORMAT_LINKTYPE_MANYTOMANY
Definition: avtextformat.h:91
StringValidation
StringValidation
Definition: avtextformat.h:75
options
Definition: swscale.c:43
AVTextFormatter::print_section_header
void(* print_section_header)(AVTextFormatContext *tctx, const void *data)
Definition: avtextformat.h:102
AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
@ AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
Definition: avtextformat.h:78
AVTextFormatContext::formatter
const AVTextFormatter * formatter
the AVTextFormatter of which this is an instance
Definition: avtextformat.h:114
avtext_print_integer
void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
Definition: avtextformat.c:294
SECTION_MAX_NB_LEVELS
#define SECTION_MAX_NB_LEVELS
Definition: avtextformat.h:109
avtext_print_data
void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
Definition: avtextformat.c:523
avtext_print_unit_int
void avtext_print_unit_int(AVTextFormatContext *tctx, const char *key, int value, const char *unit)
Definition: avtextformat.c:440
avtextformatter_flat
const AVTextFormatter avtextformatter_flat
Definition: tf_flat.c:151
AV_TEXTFORMAT_STRING_VALIDATION_FAIL
@ AV_TEXTFORMAT_STRING_VALIDATION_FAIL
Definition: avtextformat.h:76
AVTextFormatter::name
const char * name
Definition: avtextformat.h:97
size
int size
Definition: twinvq_data.h:10344
AVTextFormatContext::use_value_sexagesimal_format
int use_value_sexagesimal_format
Definition: avtextformat.h:138
avio.h
AVTextFormatContext::section_pbuf
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]
generic print buffer dedicated to each section, used by various formatters
Definition: avtextformat.h:131
avtext_context_open
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)
Definition: avtextformat.c:129
avtext_print_ts
void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int is_duration)
Definition: avtextformat.c:515
AVTextFormatContext::show_optional_fields
int show_optional_fields
Definition: avtextformat.h:134
AVTextFormatter::flags
int flags
a combination or AV_TEXTFORMAT__FLAG_*
Definition: avtextformat.h:106
AVHashContext
Definition: hash.c:66
AVTextFormatSection::linktype_key
const char * linktype_key
name of the key to be used as the link type for diagram connections (AVTextFormatLinkType)
Definition: avtextformat.h:66
AVTextFormatContext::sections
const AVTextFormatSection * sections
array containing all sections
Definition: avtextformat.h:120
avtext_print_string
int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *val, int flags)
Definition: avtextformat.c:450
bprint.h
AVTextFormatSectionContext::context_id
char * context_id
Definition: avtextformat.h:35
value
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
Definition: writing_filters.txt:86
avtextformatter_xml
const AVTextFormatter avtextformatter_xml
Definition: tf_xml.c:202
AVTextFormatSectionContext::context_flags
int context_flags
Definition: avtextformat.h:37
AVTextFormatter::uninit
int(* uninit)(AVTextFormatContext *tctx)
Definition: avtextformat.h:100
AVTextFormatContext::string_validation_utf8_flags
unsigned int string_validation_utf8_flags
Definition: avtextformat.h:144
AV_TEXTFORMAT_LINKTYPE_ONETOONE
@ AV_TEXTFORMAT_LINKTYPE_ONETOONE
Definition: avtextformat.h:90
avtextformatter_json
const AVTextFormatter avtextformatter_json
Definition: tf_json.c:203
AVTextFormatter::print_section_footer
void(* print_section_footer)(AVTextFormatContext *tctx)
Definition: avtextformat.h:103
AVTextFormatOptions::use_value_sexagesimal_format
int use_value_sexagesimal_format
Definition: avtextformat.h:152
sections
static struct AVTextFormatSection sections[]
Definition: ffprobe.c:249
avtext_print_data_hash
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
Definition: avtextformat.c:552
AVTextFormatSection::dest_id_key
const char * dest_id_key
name of the key to be used as the target id for diagram connections
Definition: avtextformat.h:65
dict.h
hash.h
AVTextFormatter::priv_class
const AVClass * priv_class
private class of the formatter, if any
Definition: avtextformat.h:95
AVTextFormatter::print_integer
void(* print_integer)(AVTextFormatContext *tctx, const char *, int64_t)
Definition: avtextformat.h:104
AVTextFormatSection::children_ids
const int children_ids[SECTION_MAX_NB_CHILDREN+1]
list of children section IDS, terminated by -1
Definition: avtextformat.h:57
AV_TEXTFORMAT_LINKTYPE_HIDDEN
@ AV_TEXTFORMAT_LINKTYPE_HIDDEN
Definition: avtextformat.h:87
AVTextFormatOptions::show_optional_fields
int show_optional_fields
Definition: avtextformat.h:148
AVTextFormatContext::string_validation
int string_validation
Definition: avtextformat.h:142
AVTextFormatOptions
Definition: avtextformat.h:147
AVTextFormatter::init
int(* init)(AVTextFormatContext *tctx)
Definition: avtextformat.h:99
AVTextFormatContext::use_value_prefix
int use_value_prefix
Definition: avtextformat.h:136
avtextwriters.h
AVTextFormatOptions::show_value_unit
int show_value_unit
Definition: avtextformat.h:149
avtextformatter_csv
const AVTextFormatter avtextformatter_csv
Definition: tf_compact.c:270
AVTextFormatSection::id_key
const char * id_key
name of the key to be used as the id
Definition: avtextformat.h:63
AVTextFormatContext::nb_item
unsigned int nb_item[SECTION_MAX_NB_LEVELS]
number of the item printed in the given section, starting from 0
Definition: avtextformat.h:126
AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
@ AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
Definition: avtextformat.h:77
AV_TEXTFORMAT_LINKTYPE_NONDIR
@ AV_TEXTFORMAT_LINKTYPE_NONDIR
Definition: avtextformat.h:86
show_data_hash
static char * show_data_hash
Definition: ffprobe.c:140
avtextformatter_mermaidhtml
const AVTextFormatter avtextformatter_mermaidhtml
Definition: tf_mermaid.c:676
AVTextFormatOptions::use_byte_value_binary_prefix
int use_byte_value_binary_prefix
Definition: avtextformat.h:151
AVTextFormatContext::nb_sections
int nb_sections
number of sections
Definition: avtextformat.h:121
AVTextFormatContext::hash
struct AVHashContext * hash
Definition: avtextformat.h:140
AVTextFormatContext::string_validation_replacement
char * string_validation_replacement
Definition: avtextformat.h:143