FFmpeg
Macros | Enumerations | Functions | Variables
opt_common.c File Reference
#include "config.h"
#include <stdio.h>
#include "cmdutils.h"
#include "fopen_utf8.h"
#include "opt_common.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/cpu.h"
#include "libavutil/dict.h"
#include "libavutil/error.h"
#include "libavutil/ffversion.h"
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/version.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
#include "libavcodec/codec.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/version.h"
#include "libavformat/avformat.h"
#include "libavformat/version.h"
#include "libavdevice/avdevice.h"
#include "libavdevice/version.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/version.h"
#include "libswscale/swscale.h"
#include "libswscale/version.h"
#include "libswresample/swresample.h"
#include "libswresample/version.h"

Go to the source code of this file.

Macros

#define INDENT   1
 
#define SHOW_VERSION   2
 
#define SHOW_CONFIG   4
 
#define SHOW_COPYRIGHT   8
 
#define PRINT_LIB_INFO(libname, LIBNAME, flags, level)
 
#define PRINT_CODEC_SUPPORTED(codec, config, type, name, elem, fmt, ...)
 
#define sws_isSupportedInput(x)   0
 
#define sws_isSupportedOutput(x)   0
 

Enumerations

enum  show_muxdemuxers { SHOW_DEFAULT, SHOW_DEMUXERS, SHOW_MUXERS }
 

Functions

int show_license (void *optctx, const char *opt, const char *arg)
 Print the license of the program to stdout. More...
 
static void print_all_libs_info (int flags, int level)
 
static void print_program_info (int flags, int level)
 
static void print_buildconf (int flags, int level)
 
void show_banner (int argc, char **argv, const OptionDef *options)
 Print the program banner to stderr. More...
 
int show_version (void *optctx, const char *opt, const char *arg)
 Print the version of the program to stdout. More...
 
int show_buildconf (void *optctx, const char *opt, const char *arg)
 Print the build configuration of the program to stdout. More...
 
static const char * get_channel_layout_desc (const AVChannelLayout *layout, AVBPrint *bp)
 
static void print_codec (const AVCodec *c)
 
static const AVCodecnext_codec_for_id (enum AVCodecID id, void **iter, int encoder)
 
static void show_help_codec (const char *name, int encoder)
 
static void show_help_demuxer (const char *name)
 
static void show_help_protocol (const char *name)
 
static void show_help_muxer (const char *name)
 
static void show_help_bsf (const char *name)
 
int show_help (void *optctx, const char *opt, const char *arg)
 Generic -h handler common to all fftools. More...
 
static void print_codecs_for_id (enum AVCodecID id, int encoder)
 
static int compare_codec_desc (const void *a, const void *b)
 
static int get_codecs_sorted (const AVCodecDescriptor ***rcodecs)
 
static char get_media_type_char (enum AVMediaType type)
 
int show_codecs (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the codecs supported by the program. More...
 
static int print_codecs (int encoder)
 
int show_decoders (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the decoders supported by the program. More...
 
int show_encoders (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the encoders supported by the program. More...
 
int show_bsfs (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the bit stream filters supported by the program. More...
 
int show_filters (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the filters supported by the program. More...
 
static int is_device (const AVClass *avclass)
 
static int show_formats_devices (void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
 
int show_formats (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the formats supported by the program (including devices). More...
 
int show_muxers (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the muxers supported by the program (including devices). More...
 
int show_demuxers (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the demuxer supported by the program (including devices). More...
 
int show_devices (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the devices supported by the program. More...
 
int show_protocols (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the protocols supported by the program. More...
 
int show_colors (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the color names and values recognized by the program. More...
 
int show_pix_fmts (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the pixel formats supported by the program. More...
 
int show_layouts (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the standard channel layouts supported by the program. More...
 
int show_sample_fmts (void *optctx, const char *opt, const char *arg)
 Print a listing containing all the sample formats supported by the program. More...
 
int show_dispositions (void *optctx, const char *opt, const char *arg)
 Print a listing containing all supported stream dispositions. More...
 
int opt_cpuflags (void *optctx, const char *opt, const char *arg)
 Override the cpuflags. More...
 
int opt_cpucount (void *optctx, const char *opt, const char *arg)
 Override the cpucount. More...
 
static void expand_filename_template (AVBPrint *bp, const char *template, struct tm *tm)
 
static void log_callback_report (void *ptr, int level, const char *fmt, va_list vl)
 
int init_report (const char *env, FILE **file)
 
int opt_report (void *optctx, const char *opt, const char *arg)
 
int opt_max_alloc (void *optctx, const char *opt, const char *arg)
 
int opt_loglevel (void *optctx, const char *opt, const char *arg)
 Set the libav* libraries log level. More...
 

Variables

static FILE * report_file
 
static int report_file_level = AV_LOG_DEBUG
 
static int warned_cfg = 0
 

Macro Definition Documentation

◆ INDENT

#define INDENT   1

Definition at line 150 of file opt_common.c.

◆ SHOW_VERSION

#define SHOW_VERSION   2

Definition at line 151 of file opt_common.c.

◆ SHOW_CONFIG

#define SHOW_CONFIG   4

Definition at line 152 of file opt_common.c.

◆ SHOW_COPYRIGHT

#define SHOW_COPYRIGHT   8

Definition at line 153 of file opt_common.c.

◆ PRINT_LIB_INFO

#define PRINT_LIB_INFO (   libname,
  LIBNAME,
  flags,
  level 
)
Value:
if (CONFIG_##LIBNAME) { \
const char *indent = flags & INDENT? " " : ""; \
if (flags & SHOW_VERSION) { \
unsigned int version = libname##_version(); \
av_log(NULL, level, \
"%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \
indent, #libname, \
LIB##LIBNAME##_VERSION_MAJOR, \
LIB##LIBNAME##_VERSION_MINOR, \
LIB##LIBNAME##_VERSION_MICRO, \
} \
if (flags & SHOW_CONFIG) { \
const char *cfg = libname##_configuration(); \
if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \
if (!warned_cfg) { \
av_log(NULL, level, \
"%sWARNING: library configuration mismatch\n", \
indent); \
warned_cfg = 1; \
} \
av_log(NULL, level, "%s%-11s configuration: %s\n", \
indent, #libname, cfg); \
} \
} \
} \

Definition at line 155 of file opt_common.c.

◆ PRINT_CODEC_SUPPORTED

#define PRINT_CODEC_SUPPORTED (   codec,
  config,
  type,
  name,
  elem,
  fmt,
  ... 
)
Value:
do { \
int num = 0; \
const type *elem = NULL; \
avcodec_get_supported_config(NULL, codec, config, 0, \
(const void **) &elem, &num); \
if (elem) { \
printf(" Supported " name ":"); \
for (int i = 0; i < num; i++) { \
printf(" " fmt, __VA_ARGS__); \
elem++; \
} \
printf("\n"); \
} \
} while (0)

Definition at line 263 of file opt_common.c.

◆ sws_isSupportedInput

#define sws_isSupportedInput (   x)    0

◆ sws_isSupportedOutput

#define sws_isSupportedOutput (   x)    0

Enumeration Type Documentation

◆ show_muxdemuxers

Enumerator
SHOW_DEFAULT 
SHOW_DEMUXERS 
SHOW_MUXERS 

Definition at line 65 of file opt_common.c.

Function Documentation

◆ show_license()

int show_license ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print the license of the program to stdout.

The license depends on the license of the libraries compiled into the program. This option processing function does not utilize the arguments.

Definition at line 74 of file opt_common.c.

◆ print_all_libs_info()

static void print_all_libs_info ( int  flags,
int  level 
)
static

Definition at line 184 of file opt_common.c.

Referenced by show_banner(), and show_version().

◆ print_program_info()

static void print_program_info ( int  flags,
int  level 
)
static

Definition at line 195 of file opt_common.c.

Referenced by show_banner(), and show_version().

◆ print_buildconf()

static void print_buildconf ( int  flags,
int  level 
)
static

Definition at line 209 of file opt_common.c.

Referenced by show_buildconf().

◆ show_banner()

void show_banner ( int  argc,
char **  argv,
const OptionDef options 
)

Print the program banner to stderr.

The banner contents depend on the current version of the repository and of the libav* libraries used by the program.

Definition at line 235 of file opt_common.c.

Referenced by main().

◆ show_version()

int show_version ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print the version of the program to stdout.

The version message depends on the current versions of the repository and of the libav* libraries. This option processing function does not utilize the arguments.

Definition at line 246 of file opt_common.c.

◆ show_buildconf()

int show_buildconf ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print the build configuration of the program to stdout.

The contents depend on the definition of FFMPEG_CONFIGURATION. This option processing function does not utilize the arguments.

Definition at line 255 of file opt_common.c.

◆ get_channel_layout_desc()

static const char* get_channel_layout_desc ( const AVChannelLayout layout,
AVBPrint *  bp 
)
static

Definition at line 279 of file opt_common.c.

Referenced by print_codec().

◆ print_codec()

static void print_codec ( const AVCodec c)
static

Definition at line 289 of file opt_common.c.

Referenced by show_help_codec().

◆ next_codec_for_id()

static const AVCodec* next_codec_for_id ( enum AVCodecID  id,
void **  iter,
int  encoder 
)
static

Definition at line 380 of file opt_common.c.

Referenced by print_codecs(), print_codecs_for_id(), show_codecs(), and show_help_codec().

◆ show_help_codec()

static void show_help_codec ( const char *  name,
int  encoder 
)
static

Definition at line 392 of file opt_common.c.

Referenced by show_help().

◆ show_help_demuxer()

static void show_help_demuxer ( const char *  name)
static

Definition at line 428 of file opt_common.c.

Referenced by show_help().

◆ show_help_protocol()

static void show_help_protocol ( const char *  name)
static

Definition at line 446 of file opt_common.c.

Referenced by show_help().

◆ show_help_muxer()

static void show_help_muxer ( const char *  name)
static

Definition at line 464 of file opt_common.c.

Referenced by show_help().

◆ show_help_bsf()

static void show_help_bsf ( const char *  name)
static

Definition at line 553 of file opt_common.c.

Referenced by show_help().

◆ show_help()

int show_help ( void *  optctx,
const char *  opt,
const char *  arg 
)

Generic -h handler common to all fftools.

Definition at line 579 of file opt_common.c.

◆ print_codecs_for_id()

static void print_codecs_for_id ( enum AVCodecID  id,
int  encoder 
)
static

Definition at line 617 of file opt_common.c.

Referenced by show_codecs().

◆ compare_codec_desc()

static int compare_codec_desc ( const void *  a,
const void *  b 
)
static

Definition at line 630 of file opt_common.c.

Referenced by get_codecs_sorted().

◆ get_codecs_sorted()

static int get_codecs_sorted ( const AVCodecDescriptor ***  rcodecs)
static

Definition at line 639 of file opt_common.c.

Referenced by print_codecs(), and show_codecs().

◆ get_media_type_char()

static char get_media_type_char ( enum AVMediaType  type)
static

Definition at line 658 of file opt_common.c.

Referenced by print_codecs(), show_codecs(), and show_filters().

◆ show_codecs()

int show_codecs ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the codecs supported by the program.

This option processing function does not utilize the arguments.

Definition at line 670 of file opt_common.c.

◆ print_codecs()

static int print_codecs ( int  encoder)
static

Definition at line 731 of file opt_common.c.

Referenced by show_decoders(), and show_encoders().

◆ show_decoders()

int show_decoders ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the decoders supported by the program.

Definition at line 775 of file opt_common.c.

◆ show_encoders()

int show_encoders ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the encoders supported by the program.

Definition at line 780 of file opt_common.c.

◆ show_bsfs()

int show_bsfs ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the bit stream filters supported by the program.

This option processing function does not utilize the arguments.

Definition at line 785 of file opt_common.c.

◆ show_filters()

int show_filters ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the filters supported by the program.

This option processing function does not utilize the arguments.

Definition at line 797 of file opt_common.c.

◆ is_device()

static int is_device ( const AVClass avclass)
static

Definition at line 844 of file opt_common.c.

Referenced by show_formats_devices().

◆ show_formats_devices()

static int show_formats_devices ( void *  optctx,
const char *  opt,
const char *  arg,
int  device_only,
int  muxdemuxers 
)
static

Definition at line 851 of file opt_common.c.

Referenced by show_demuxers(), show_devices(), show_formats(), and show_muxers().

◆ show_formats()

int show_formats ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the formats supported by the program (including devices).

This option processing function does not utilize the arguments.

Definition at line 926 of file opt_common.c.

◆ show_muxers()

int show_muxers ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the muxers supported by the program (including devices).

This option processing function does not utilize the arguments.

Definition at line 931 of file opt_common.c.

◆ show_demuxers()

int show_demuxers ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the demuxer supported by the program (including devices).

This option processing function does not utilize the arguments.

Definition at line 936 of file opt_common.c.

◆ show_devices()

int show_devices ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the devices supported by the program.

This option processing function does not utilize the arguments.

Definition at line 941 of file opt_common.c.

◆ show_protocols()

int show_protocols ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the protocols supported by the program.

This option processing function does not utilize the arguments.

Definition at line 946 of file opt_common.c.

◆ show_colors()

int show_colors ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the color names and values recognized by the program.

Definition at line 961 of file opt_common.c.

◆ show_pix_fmts()

int show_pix_fmts ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the pixel formats supported by the program.

This option processing function does not utilize the arguments.

Definition at line 975 of file opt_common.c.

◆ show_layouts()

int show_layouts ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the standard channel layouts supported by the program.

This option processing function does not utilize the arguments.

Definition at line 1013 of file opt_common.c.

◆ show_sample_fmts()

int show_sample_fmts ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all the sample formats supported by the program.

Definition at line 1046 of file opt_common.c.

◆ show_dispositions()

int show_dispositions ( void *  optctx,
const char *  opt,
const char *  arg 
)

Print a listing containing all supported stream dispositions.

Definition at line 1055 of file opt_common.c.

◆ opt_cpuflags()

int opt_cpuflags ( void *  optctx,
const char *  opt,
const char *  arg 
)

Override the cpuflags.

Definition at line 1065 of file opt_common.c.

◆ opt_cpucount()

int opt_cpucount ( void *  optctx,
const char *  opt,
const char *  arg 
)

Override the cpucount.

Definition at line 1077 of file opt_common.c.

◆ expand_filename_template()

static void expand_filename_template ( AVBPrint *  bp,
const char *  template,
struct tm *  tm 
)
static

Definition at line 1103 of file opt_common.c.

Referenced by init_report().

◆ log_callback_report()

static void log_callback_report ( void *  ptr,
int  level,
const char *  fmt,
va_list  vl 
)
static

Definition at line 1131 of file opt_common.c.

Referenced by init_report().

◆ init_report()

int init_report ( const char *  env,
FILE **  file 
)

Definition at line 1147 of file opt_common.c.

Referenced by opt_report(), and parse_loglevel().

◆ opt_report()

int opt_report ( void *  optctx,
const char *  opt,
const char *  arg 
)

Definition at line 1232 of file opt_common.c.

◆ opt_max_alloc()

int opt_max_alloc ( void *  optctx,
const char *  opt,
const char *  arg 
)

Definition at line 1237 of file opt_common.c.

◆ opt_loglevel()

int opt_loglevel ( void *  optctx,
const char *  opt,
const char *  arg 
)

Set the libav* libraries log level.

Definition at line 1251 of file opt_common.c.

Referenced by parse_loglevel().

Variable Documentation

◆ report_file

FILE* report_file
static

Definition at line 71 of file opt_common.c.

Referenced by dump_argument(), init_report(), log_callback_report(), and parse_loglevel().

◆ report_file_level

int report_file_level = AV_LOG_DEBUG
static

Definition at line 72 of file opt_common.c.

Referenced by init_report(), and log_callback_report().

◆ warned_cfg

int warned_cfg = 0
static

Definition at line 148 of file opt_common.c.

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
level
uint8_t level
Definition: svq3.c:208
SHOW_CONFIG
#define SHOW_CONFIG
Definition: opt_common.c:152
tf_sess_config.config
config
Definition: tf_sess_config.py:33
AV_VERSION_MINOR
#define AV_VERSION_MINOR(a)
Definition: version.h:65
type
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 type
Definition: writing_filters.txt:86
NULL
#define NULL
Definition: coverity.c:32
warned_cfg
static int warned_cfg
Definition: opt_common.c:148
AV_VERSION_MICRO
#define AV_VERSION_MICRO(a)
Definition: version.h:66
version
version
Definition: libkvazaar.c:315
INDENT
#define INDENT
Definition: opt_common.c:150
SHOW_VERSION
#define SHOW_VERSION
Definition: opt_common.c:151
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV_VERSION_MAJOR
#define AV_VERSION_MAJOR(a)
Extract version components from the full AV_VERSION_INT int as returned by functions like avformat_ve...
Definition: version.h:64