FFmpeg
Loading...
Searching...
No Matches
avtextformat.c File Reference
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
#include "libavutil/avutil.h"
#include "libavutil/base64.h"
#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/error.h"
#include "libavutil/hash.h"
#include "libavutil/macros.h"
#include "libavutil/opt.h"
#include "avtextformat.h"

Go to the source code of this file.

Data Structures

struct  unit_value
 

Macros

#define SECTION_ID_NONE   (-1)
 
#define SHOW_OPTIONAL_FIELDS_AUTO   (-1)
 
#define SHOW_OPTIONAL_FIELDS_NEVER   0
 
#define SHOW_OPTIONAL_FIELDS_ALWAYS   1
 
#define OFFSET(x)
 

Functions

static const char * textcontext_get_formatter_name (void *p)
 
static void * textcontext_child_next (void *obj, void *prev)
 
static void bprint_bytes (AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
 
int avtext_context_close (AVTextFormatContext **ptctx)
 
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)
 
void avtext_print_section_header (AVTextFormatContext *tctx, const void *data, int section_id)
 
void avtext_print_section_footer (AVTextFormatContext *tctx)
 
void avtext_print_integer (AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
 
static int validate_string (AVTextFormatContext *tctx, char **dstp, const char *src)
 
static char * value_string (const AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
 
void avtext_print_unit_integer (AVTextFormatContext *tctx, const char *key, int64_t val, AVTextFormatValueFormat fmt, const char *unit)
 
void avtext_print_unit_double (AVTextFormatContext *tctx, const char *key, double val, AVTextFormatValueFormat fmt, const char *unit)
 
int avtext_print_string (AVTextFormatContext *tctx, const char *key, const char *val, int flags)
 
void avtext_print_rational (AVTextFormatContext *tctx, const char *key, AVRational q, char sep)
 
void avtext_print_time (AVTextFormatContext *tctx, const char *key, int64_t ts, const AVRational *time_base, int is_duration)
 
void avtext_print_ts (AVTextFormatContext *tctx, const char *key, int64_t ts, int is_duration)
 
static void print_data_xxd (AVBPrint *bp, const uint8_t *data, int size)
 
static void print_data_base64 (AVBPrint *bp, const uint8_t *data, int size)
 
void avtext_print_data (AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
 
void avtext_print_data_hash (AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size)
 
static const char * writercontext_get_writer_name (void *p)
 
static void * writercontext_child_next (void *obj, void *prev)
 
int avtextwriter_context_close (AVTextWriterContext **pwctx)
 
int avtextwriter_context_open (AVTextWriterContext **pwctx, const AVTextWriter *writer)
 
const AVTextFormatteravtext_get_formatter_by_name (const char *name)
 

Variables

struct { 
 
   double   bin_val 
 
   double   dec_val 
 
   char   bin_str [4] 
 
   char   dec_str [4] 
 
si_prefixes [] 
 
static const AVOption textcontext_options []
 
static const AVClass textcontext_class
 
static const char unit_second_str [] = "s"
 
static const char float_fmt_full [] = "%f"
 
static const char float_fmt_singledigit [] = "%.1f"
 
static const AVClass textwriter_class
 
static const AVTextFormatter *const registered_formatters []
 

Macro Definition Documentation

◆ SECTION_ID_NONE

#define SECTION_ID_NONE   (-1)

Definition at line 40 of file avtextformat.c.

Referenced by avtext_print_section_footer().

◆ SHOW_OPTIONAL_FIELDS_AUTO

#define SHOW_OPTIONAL_FIELDS_AUTO   (-1)

Definition at line 42 of file avtextformat.c.

◆ SHOW_OPTIONAL_FIELDS_NEVER

#define SHOW_OPTIONAL_FIELDS_NEVER   0

Definition at line 43 of file avtextformat.c.

◆ SHOW_OPTIONAL_FIELDS_ALWAYS

#define SHOW_OPTIONAL_FIELDS_ALWAYS   1

Definition at line 44 of file avtextformat.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 66 of file avtextformat.c.

Function Documentation

◆ textcontext_get_formatter_name()

static const char * textcontext_get_formatter_name ( void * p)
static

Definition at line 60 of file avtextformat.c.

◆ textcontext_child_next()

static void * textcontext_child_next ( void * obj,
void * prev )
static

Definition at line 81 of file avtextformat.c.

◆ bprint_bytes()

static void bprint_bytes ( AVBPrint * bp,
const uint8_t * ubuf,
size_t ubuf_size )
static

Definition at line 97 of file avtextformat.c.

Referenced by avtext_context_open(), and validate_string().

◆ avtext_context_close()

int avtext_context_close ( AVTextFormatContext ** ptctx)

Definition at line 104 of file avtextformat.c.

Referenced by avtext_context_open(), init_graphprint(), main(), and uninit_graphprint().

◆ 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 at line 129 of file avtextformat.c.

Referenced by init_graphprint(), and main().

◆ avtext_print_section_header()

◆ avtext_print_section_footer()

◆ avtext_print_integer()

void avtext_print_integer ( AVTextFormatContext * tctx,
const char * key,
int64_t val,
int flags )

Definition at line 284 of file avtextformat.c.

Referenced by avtext_print_ts().

◆ validate_string()

static int validate_string ( AVTextFormatContext * tctx,
char ** dstp,
const char * src )
inlinestatic

Definition at line 304 of file avtextformat.c.

Referenced by avtext_print_string().

◆ value_string()

static char * value_string ( const AVTextFormatContext * tctx,
char * buf,
int buf_size,
struct unit_value uv )
static

◆ avtext_print_unit_integer()

void avtext_print_unit_integer ( AVTextFormatContext * tctx,
const char * key,
int64_t val,
AVTextFormatValueFormat fmt,
const char * unit )

Definition at line 432 of file avtextformat.c.

◆ avtext_print_unit_double()

void avtext_print_unit_double ( AVTextFormatContext * tctx,
const char * key,
double val,
AVTextFormatValueFormat fmt,
const char * unit )

Definition at line 446 of file avtextformat.c.

◆ avtext_print_string()

int avtext_print_string ( AVTextFormatContext * tctx,
const char * key,
const char * val,
int flags )

◆ avtext_print_rational()

void avtext_print_rational ( AVTextFormatContext * tctx,
const char * key,
AVRational q,
char sep )

Definition at line 501 of file avtextformat.c.

◆ avtext_print_time()

void avtext_print_time ( AVTextFormatContext * tctx,
const char * key,
int64_t ts,
const AVRational * time_base,
int is_duration )

Definition at line 508 of file avtextformat.c.

◆ avtext_print_ts()

void avtext_print_ts ( AVTextFormatContext * tctx,
const char * key,
int64_t ts,
int is_duration )

Definition at line 525 of file avtextformat.c.

◆ print_data_xxd()

static void print_data_xxd ( AVBPrint * bp,
const uint8_t * data,
int size )
static

Definition at line 533 of file avtextformat.c.

Referenced by avtext_print_data().

◆ print_data_base64()

static void print_data_base64 ( AVBPrint * bp,
const uint8_t * data,
int size )
static

Definition at line 557 of file avtextformat.c.

Referenced by avtext_print_data().

◆ avtext_print_data()

void avtext_print_data ( AVTextFormatContext * tctx,
const char * key,
const uint8_t * data,
int size )

Definition at line 570 of file avtextformat.c.

Referenced by print_pkt_side_data(), show_packet(), and show_stream().

◆ avtext_print_data_hash()

void avtext_print_data_hash ( AVTextFormatContext * tctx,
const char * key,
const uint8_t * data,
int size )

Definition at line 589 of file avtextformat.c.

Referenced by print_pkt_side_data(), show_packet(), and show_stream().

◆ writercontext_get_writer_name()

static const char * writercontext_get_writer_name ( void * p)
static

Definition at line 605 of file avtextformat.c.

◆ writercontext_child_next()

static void * writercontext_child_next ( void * obj,
void * prev )
static

Definition at line 611 of file avtextformat.c.

◆ avtextwriter_context_close()

int avtextwriter_context_close ( AVTextWriterContext ** pwctx)

◆ avtextwriter_context_open()

int avtextwriter_context_open ( AVTextWriterContext ** pwctx,
const AVTextWriter * writer )

◆ avtext_get_formatter_by_name()

const AVTextFormatter * avtext_get_formatter_by_name ( const char * name)

Definition at line 705 of file avtextformat.c.

Referenced by init_graphprint(), and main().

Variable Documentation

◆ bin_val

double bin_val

Definition at line 47 of file avtextformat.c.

◆ dec_val

double dec_val

Definition at line 48 of file avtextformat.c.

◆ bin_str

char bin_str[4]

Definition at line 49 of file avtextformat.c.

◆ dec_str

char dec_str[4]

Definition at line 50 of file avtextformat.c.

◆ [struct]

const struct { ... } si_prefixes[]
Initial value:
= {
{ 1.0, 1.0, "", "" },
{ 1.024e3, 1e3, "Ki", "K" },
{ 1.048576e6, 1e6, "Mi", "M" },
{ 1.073741824e9, 1e9, "Gi", "G" },
{ 1.099511627776e12, 1e12, "Ti", "T" },
{ 1.125899906842624e15, 1e15, "Pi", "P" },
}

Referenced by av_strtod(), and value_string().

◆ textcontext_options

const AVOption textcontext_options[]
static
Initial value:
= {
{ "string_validation", "set string validation mode",
{ "sv", "set string validation mode",
{ "ignore", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_TEXTFORMAT_STRING_VALIDATION_IGNORE }, .unit = "sv" },
{ "replace", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_TEXTFORMAT_STRING_VALIDATION_REPLACE }, .unit = "sv" },
{ "fail", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_TEXTFORMAT_STRING_VALIDATION_FAIL }, .unit = "sv" },
{ "string_validation_replacement", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, { .str = "" } },
{ "svr", "set string validation replacement string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, { .str = "\xEF\xBF\xBD" } },
{ NULL }
}
@ AV_TEXTFORMAT_STRING_VALIDATION_NB
@ AV_TEXTFORMAT_STRING_VALIDATION_FAIL
@ AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
@ AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ 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...
Definition opt.h:275

Definition at line 68 of file avtextformat.c.

◆ textcontext_class

const AVClass textcontext_class
static
Initial value:
= {
.class_name = "AVTextContext",
.child_next = textcontext_child_next,
}
static void * textcontext_child_next(void *obj, void *prev)
static const char * textcontext_get_formatter_name(void *p)
static const AVOption textcontext_options[]
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 89 of file avtextformat.c.

Referenced by avtext_context_open().

◆ unit_second_str

const char unit_second_str[] = "s"
static

Definition at line 243 of file avtextformat.c.

Referenced by avtext_print_time().

◆ float_fmt_full

const char float_fmt_full[] = "%f"
static

Definition at line 371 of file avtextformat.c.

Referenced by value_string().

◆ float_fmt_singledigit

const char float_fmt_singledigit[] = "%.1f"
static

Definition at line 372 of file avtextformat.c.

Referenced by value_string().

◆ textwriter_class

const AVClass textwriter_class
static
Initial value:
= {
.class_name = "AVTextWriterContext",
.child_next = writercontext_child_next,
}
static void * writercontext_child_next(void *obj, void *prev)
static const char * writercontext_get_writer_name(void *p)

Definition at line 619 of file avtextformat.c.

Referenced by avtextwriter_context_open().

◆ registered_formatters

const AVTextFormatter* const registered_formatters[]
static
Initial value:
=
{
}
const AVTextFormatter avtextformatter_compact
Definition tf_compact.c:239
const AVTextFormatter avtextformatter_ini
Definition tf_ini.c:140
const AVTextFormatter avtextformatter_csv
Definition tf_compact.c:270
const AVTextFormatter avtextformatter_default
Definition tf_default.c:128
const AVTextFormatter avtextformatter_mermaid
Definition tf_mermaid.c:650
const AVTextFormatter avtextformatter_json
Definition tf_json.c:202
const AVTextFormatter avtextformatter_flat
Definition tf_flat.c:150
const AVTextFormatter avtextformatter_mermaidhtml
Definition tf_mermaid.c:664
const AVTextFormatter avtextformatter_xml
Definition tf_xml.c:202

Definition at line 691 of file avtextformat.c.

Referenced by avtext_get_formatter_by_name().