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"
#include "tf_internal.h"

Go to the source code of this file.

Data Structures

struct  CompactContext
 

Macros

#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

◆ OFFSET [1/2]

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

Definition at line 254 of file tf_compact.c.

◆ OFFSET [2/2]

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

Definition at line 254 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 39 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 62 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 81 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 116 of file tf_compact.c.

◆ compact_print_section_header()

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

Definition at line 141 of file tf_compact.c.

◆ compact_print_section_footer()

static void compact_print_section_footer ( AVTextFormatContext wctx)
static

Definition at line 196 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 210 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 226 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 102 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 239 of file tf_compact.c.

◆ 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 256 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 270 of file tf_compact.c.

flags
const SwsFlags flags[]
Definition: swscale.c:61
compact_print_str
static void compact_print_str(AVTextFormatContext *wctx, const char *key, const char *value)
Definition: tf_compact.c:210
print_section
static void print_section(SectionID id, int level)
Definition: ffprobe.c:2936
CompactContext
Definition: tf_compact.c:86
compact_print_section_header
static void compact_print_section_header(AVTextFormatContext *wctx, const void *data)
Definition: tf_compact.c:141
NULL
#define NULL
Definition: coverity.c:32
compact_print_section_footer
static void compact_print_section_footer(AVTextFormatContext *wctx)
Definition: tf_compact.c:196
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
compact_init
static av_cold int compact_init(AVTextFormatContext *wctx)
Definition: tf_compact.c:116
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:226
OFFSET
#define OFFSET(x)
Definition: tf_compact.c:254
AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS
#define AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS
Definition: avtextformat.h:71
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