FFmpeg
Data Structures | Macros | Functions | Variables
avtextformat.c File Reference
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
#include "libavutil/bprint.h"
#include "libavutil/error.h"
#include "libavutil/hash.h"
#include "libavutil/intreadwrite.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)   offsetof(AVTextFormatContext, 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 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)
 
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)
 
static int validate_string (AVTextFormatContext *tctx, char **dstp, const char *src)
 
static char * value_string (AVTextFormatContext *tctx, char *buf, int buf_size, struct unit_value uv)
 
void avtext_print_unit_int (AVTextFormatContext *tctx, const char *key, int value, 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)
 
void avtext_print_data (AVTextFormatContext *tctx, const char *name, const uint8_t *data, int size)
 
void avtext_print_data_hash (AVTextFormatContext *tctx, const char *name, const uint8_t *data, int size)
 
void avtext_print_integers (AVTextFormatContext *tctx, const char *name, uint8_t *data, int size, const char *format, int columns, int bytes, int offset_add)
 
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)
 
static void formatters_register_all (void)
 
const AVTextFormatteravtext_get_formatter_by_name (const char *name)
 

Variables

struct {
   double   bin_val
 
   double   dec_val
 
   const char *   bin_str
 
   const char *   dec_str
 
si_prefixes []
 
static const AVOption textcontext_options []
 
static const AVClass textcontext_class
 
static const char unit_second_str [] = "s"
 
static const char unit_hertz_str [] = "Hz"
 
static const char unit_byte_str [] = "byte"
 
static const char unit_bit_per_second_str [] = "bit/s"
 
static const AVClass textwriter_class
 
static const AVTextFormatterregistered_formatters [7+1]
 

Macro Definition Documentation

◆ SECTION_ID_NONE

#define SECTION_ID_NONE   -1

Definition at line 37 of file avtextformat.c.

◆ SHOW_OPTIONAL_FIELDS_AUTO

#define SHOW_OPTIONAL_FIELDS_AUTO   -1

Definition at line 39 of file avtextformat.c.

◆ SHOW_OPTIONAL_FIELDS_NEVER

#define SHOW_OPTIONAL_FIELDS_NEVER   0

Definition at line 40 of file avtextformat.c.

◆ SHOW_OPTIONAL_FIELDS_ALWAYS

#define SHOW_OPTIONAL_FIELDS_ALWAYS   1

Definition at line 41 of file avtextformat.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(AVTextFormatContext, x)

Definition at line 63 of file avtextformat.c.

Function Documentation

◆ textcontext_get_formatter_name()

static const char* textcontext_get_formatter_name ( void *  p)
static

Definition at line 57 of file avtextformat.c.

◆ textcontext_child_next()

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

Definition at line 78 of file avtextformat.c.

◆ bprint_bytes()

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

Definition at line 94 of file avtextformat.c.

Referenced by avtext_context_open(), and validate_string().

◆ avtext_context_close()

int avtext_context_close ( AVTextFormatContext **  ptctx)

Definition at line 102 of file avtextformat.c.

Referenced by avtext_context_open(), and main().

◆ avtext_context_open()

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 
)

Definition at line 128 of file avtextformat.c.

Referenced by main().

◆ avtext_print_section_header()

void avtext_print_section_header ( AVTextFormatContext tctx,
const void *  data,
int  section_id 
)

◆ avtext_print_section_footer()

void avtext_print_section_footer ( AVTextFormatContext tctx)

◆ avtext_print_integer()

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

Definition at line 288 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 299 of file avtextformat.c.

Referenced by avtext_print_string().

◆ value_string()

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

Definition at line 359 of file avtextformat.c.

Referenced by avtext_print_time(), and avtext_print_unit_int().

◆ avtext_print_unit_int()

void avtext_print_unit_int ( AVTextFormatContext tctx,
const char *  key,
int  value,
const char *  unit 
)

Definition at line 413 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 460 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 469 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 486 of file avtextformat.c.

◆ avtext_print_data()

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

Definition at line 495 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 *  name,
const uint8_t *  data,
int  size 
)

Definition at line 523 of file avtextformat.c.

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

◆ avtext_print_integers()

void avtext_print_integers ( AVTextFormatContext tctx,
const char *  name,
uint8_t *  data,
int  size,
const char *  format,
int  columns,
int  bytes,
int  offset_add 
)

Definition at line 538 of file avtextformat.c.

Referenced by print_frame_side_data(), and print_pkt_side_data().

◆ writercontext_get_writer_name()

static const char* writercontext_get_writer_name ( void *  p)
static

Definition at line 564 of file avtextformat.c.

◆ writercontext_child_next()

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

Definition at line 570 of file avtextformat.c.

◆ avtextwriter_context_close()

int avtextwriter_context_close ( AVTextWriterContext **  pwctx)

Definition at line 586 of file avtextformat.c.

Referenced by avtextwriter_context_open(), avtextwriter_create_file(), and main().

◆ avtextwriter_context_open()

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

◆ formatters_register_all()

static void formatters_register_all ( void  )
static

Definition at line 646 of file avtextformat.c.

Referenced by avtext_get_formatter_by_name().

◆ avtext_get_formatter_by_name()

const AVTextFormatter* avtext_get_formatter_by_name ( const char *  name)

Definition at line 663 of file avtextformat.c.

Referenced by main().

Variable Documentation

◆ bin_val

double bin_val

Definition at line 44 of file avtextformat.c.

◆ dec_val

double dec_val

Definition at line 45 of file avtextformat.c.

◆ bin_str

const char* bin_str

Definition at line 46 of file avtextformat.c.

◆ dec_str

const char* dec_str

Definition at line 47 of file avtextformat.c.

◆ si_prefixes

const { ... } 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 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 }
}

Definition at line 65 of file avtextformat.c.

◆ textcontext_class

const AVClass textcontext_class
static
Initial value:
= {
.class_name = "AVTextContext",
.child_next = textcontext_child_next,
}

Definition at line 86 of file avtextformat.c.

Referenced by avtext_context_open().

◆ unit_second_str

const char unit_second_str[] = "s"
static

Definition at line 251 of file avtextformat.c.

Referenced by avtext_print_time(), and value_string().

◆ unit_hertz_str

const char unit_hertz_str[] = "Hz"
static

Definition at line 252 of file avtextformat.c.

◆ unit_byte_str

const char unit_byte_str[] = "byte"
static

Definition at line 253 of file avtextformat.c.

Referenced by value_string().

◆ unit_bit_per_second_str

const char unit_bit_per_second_str[] = "bit/s"
static

Definition at line 254 of file avtextformat.c.

◆ textwriter_class

const AVClass textwriter_class
static
Initial value:
= {
.class_name = "AVTextWriterContext",
.child_next = writercontext_child_next,
}

Definition at line 578 of file avtextformat.c.

Referenced by avtextwriter_context_open().

◆ registered_formatters

const AVTextFormatter* registered_formatters[7+1]
static

Definition at line 645 of file avtextformat.c.

Referenced by avtext_get_formatter_by_name(), and formatters_register_all().

writercontext_get_writer_name
static const char * writercontext_get_writer_name(void *p)
Definition: avtextformat.c:564
textcontext_options
static const AVOption textcontext_options[]
Definition: avtextformat.c:65
AV_TEXTFORMAT_STRING_VALIDATION_NB
@ AV_TEXTFORMAT_STRING_VALIDATION_NB
Definition: avtextformat.h:66
textcontext_get_formatter_name
static const char * textcontext_get_formatter_name(void *p)
Definition: avtextformat.c:57
textcontext_child_next
static void * textcontext_child_next(void *obj, void *prev)
Definition: avtextformat.c:78
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
@ AV_TEXTFORMAT_STRING_VALIDATION_IGNORE
Definition: avtextformat.h:65
AV_TEXTFORMAT_STRING_VALIDATION_FAIL
@ AV_TEXTFORMAT_STRING_VALIDATION_FAIL
Definition: avtextformat.h:63
writercontext_child_next
static void * writercontext_child_next(void *obj, void *prev)
Definition: avtextformat.c:570
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
OFFSET
#define OFFSET(x)
Definition: avtextformat.c:63
AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
@ AV_TEXTFORMAT_STRING_VALIDATION_REPLACE
Definition: avtextformat.h:64
AV_OPT_TYPE_STRING
@ 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:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299