FFmpeg
Data Structures | Macros | Functions | Variables
tf_compact.c File Reference
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "avtextformat.h"
#include "libavutil/bprint.h"
#include "libavutil/error.h"
#include "libavutil/opt.h"

Go to the source code of this file.

Data Structures

struct  CompactContext
 

Macros

#define writer_w8(wctx_, b_)   (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_)
 
#define writer_put_str(wctx_, str_)   (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_)
 
#define writer_printf(wctx_, fmt_, ...)   (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__)
 
#define DEFINE_FORMATTER_CLASS(name)
 
#define OFFSET(x)   offsetof(CompactContext, x)
 
#define OFFSET(x)   offsetof(CompactContext, x)
 

Functions

static const char * c_escape_str (AVBPrint *dst, const char *src, const char sep, void *log_ctx)
 Apply C-language-like string escaping. More...
 
static const char * csv_escape_str (AVBPrint *dst, const char *src, const char sep, void *log_ctx)
 Quote fields containing special characters, check RFC4180. More...
 
static const char * none_escape_str (AVBPrint *dst, const char *src, const char sep, void *log_ctx)
 
 DEFINE_FORMATTER_CLASS (compact)
 
static av_cold int compact_init (AVTextFormatContext *wctx)
 
static void compact_print_section_header (AVTextFormatContext *wctx, const void *data)
 
static void compact_print_section_footer (AVTextFormatContext *wctx)
 
static void compact_print_str (AVTextFormatContext *wctx, const char *key, const char *value)
 
static void compact_print_int (AVTextFormatContext *wctx, const char *key, int64_t value)
 
 DEFINE_FORMATTER_CLASS (csv)
 

Variables

static const AVOption compact_options []
 
const AVTextFormatter avtextformatter_compact
 
static const AVOption csv_options []
 
const AVTextFormatter avtextformatter_csv
 

Macro Definition Documentation

◆ writer_w8

#define writer_w8 (   wctx_,
  b_ 
)    (wctx_)->writer->writer->writer_w8((wctx_)->writer, b_)

Definition at line 33 of file tf_compact.c.

◆ writer_put_str

#define writer_put_str (   wctx_,
  str_ 
)    (wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_)

Definition at line 34 of file tf_compact.c.

◆ writer_printf

#define writer_printf (   wctx_,
  fmt_,
  ... 
)    (wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__)

Definition at line 35 of file tf_compact.c.

◆ DEFINE_FORMATTER_CLASS

#define DEFINE_FORMATTER_CLASS (   name)
Value:
static const char *name##_get_name(void *ctx) \
{ \
return #name ; \
} \
static const AVClass name##_class = { \
.class_name = #name, \
.item_name = name##_get_name, \
.option = name##_options \
}

Definition at line 38 of file tf_compact.c.

◆ OFFSET [1/2]

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

Definition at line 253 of file tf_compact.c.

◆ OFFSET [2/2]

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

Definition at line 253 of file tf_compact.c.

Function Documentation

◆ c_escape_str()

static const char* c_escape_str ( AVBPrint *  dst,
const char *  src,
const char  sep,
void *  log_ctx 
)
static

Apply C-language-like string escaping.

Definition at line 55 of file tf_compact.c.

Referenced by compact_init().

◆ csv_escape_str()

static const char* csv_escape_str ( AVBPrint *  dst,
const char *  src,
const char  sep,
void *  log_ctx 
)
static

Quote fields containing special characters, check RFC4180.

Definition at line 78 of file tf_compact.c.

Referenced by compact_init().

◆ none_escape_str()

static const char* none_escape_str ( AVBPrint *  dst,
const char *  src,
const char  sep,
void *  log_ctx 
)
static

Definition at line 96 of file tf_compact.c.

Referenced by compact_init().

◆ DEFINE_FORMATTER_CLASS() [1/2]

DEFINE_FORMATTER_CLASS ( compact  )

◆ compact_init()

static av_cold int compact_init ( AVTextFormatContext wctx)
static

Definition at line 131 of file tf_compact.c.

◆ compact_print_section_header()

static void compact_print_section_header ( AVTextFormatContext wctx,
const void *  data 
)
static

Definition at line 153 of file tf_compact.c.

◆ compact_print_section_footer()

static void compact_print_section_footer ( AVTextFormatContext wctx)
static

Definition at line 205 of file tf_compact.c.

◆ compact_print_str()

static void compact_print_str ( AVTextFormatContext wctx,
const char *  key,
const char *  value 
)
static

Definition at line 215 of file tf_compact.c.

◆ compact_print_int()

static void compact_print_int ( AVTextFormatContext wctx,
const char *  key,
int64_t  value 
)
static

Definition at line 228 of file tf_compact.c.

◆ DEFINE_FORMATTER_CLASS() [2/2]

DEFINE_FORMATTER_CLASS ( csv  )

Variable Documentation

◆ compact_options

const AVOption compact_options[]
static
Initial value:
= {
{"item_sep", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str="|"}, 0, 0 },
{"s", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str="|"}, 0, 0 },
{"nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
{"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1 },
{"escape", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"}, 0, 0 },
{"e", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"}, 0, 0 },
{"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
{"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
{NULL},
}

Definition at line 117 of file tf_compact.c.

◆ avtextformatter_compact

const AVTextFormatter avtextformatter_compact
Initial value:
= {
.name = "compact",
.priv_size = sizeof(CompactContext),
.print_section_header = compact_print_section_header,
.print_section_footer = compact_print_section_footer,
.print_integer = compact_print_int,
.print_string = compact_print_str,
.priv_class = &compact_class,
}

Definition at line 238 of file tf_compact.c.

Referenced by formatters_register_all().

◆ csv_options

const AVOption csv_options[]
static
Initial value:
= {
{"item_sep", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=","}, 0, 0 },
{"s", "set item separator", OFFSET(item_sep_str), AV_OPT_TYPE_STRING, {.str=","}, 0, 0 },
{"nokey", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
{"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
{"escape", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="csv"}, 0, 0 },
{"e", "set escape mode", OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="csv"}, 0, 0 },
{"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
{"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1 },
{NULL},
}

Definition at line 255 of file tf_compact.c.

◆ avtextformatter_csv

const AVTextFormatter avtextformatter_csv
Initial value:
= {
.name = "csv",
.priv_size = sizeof(CompactContext),
.print_section_header = compact_print_section_header,
.print_section_footer = compact_print_section_footer,
.print_integer = compact_print_int,
.print_string = compact_print_str,
.priv_class = &csv_class,
}

Definition at line 269 of file tf_compact.c.

Referenced by formatters_register_all().

flags
const SwsFlags flags[]
Definition: swscale.c:61
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
compact_print_str
static void compact_print_str(AVTextFormatContext *wctx, const char *key, const char *value)
Definition: tf_compact.c:215
print_section
static void print_section(SectionID id, int level)
Definition: ffprobe.c:2948
CompactContext
Definition: tf_compact.c:101
compact_print_section_header
static void compact_print_section_header(AVTextFormatContext *wctx, const void *data)
Definition: tf_compact.c:153
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
compact_print_section_footer
static void compact_print_section_footer(AVTextFormatContext *wctx)
Definition: tf_compact.c:205
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
compact_init
static av_cold int compact_init(AVTextFormatContext *wctx)
Definition: tf_compact.c:131
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
compact_print_int
static void compact_print_int(AVTextFormatContext *wctx, const char *key, int64_t value)
Definition: tf_compact.c:228
OFFSET
#define OFFSET(x)
Definition: tf_compact.c:253
AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS
#define AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS
Definition: avtextformat.h:59
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