FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
ffmpeg_filter.c File Reference
#include <stdint.h>
#include "ffmpeg.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/buffersink.h"
#include "libavresample/avresample.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "libavutil/imgutils.h"
#include "libavutil/samplefmt.h"

Go to the source code of this file.

Macros

#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name)
 
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
 
#define DESCRIBE_FILTER_LINK(f, inout, in)
 
#define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg)
 

Functions

enum AVPixelFormat choose_pixel_fmt (AVStream *st, AVCodecContext *enc_ctx, AVCodec *codec, enum AVPixelFormat target)
 
void choose_sample_fmt (AVStream *st, AVCodec *codec)
 
static char * choose_pix_fmts (OutputStream *ost)
 
 DEF_CHOOSE_FORMAT (enum AVSampleFormat, sample_fmt, sample_fmts, AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME) DEF_CHOOSE_FORMAT(int
 
GET_SAMPLE_RATE_NAME DEF_CHOOSE_FORMAT (uint64_t, channel_layout, channel_layouts, 0, GET_CH_LAYOUT_NAME)
 
static void init_input_filter (FilterGraph *fg, AVFilterInOut *in)
 
static int insert_trim (int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
 
static int configure_output_video_filter (FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
 
static int configure_output_audio_filter (FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
 
int configure_output_filter (FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
 
static int sub2video_prepare (InputStream *ist)
 
static int configure_input_video_filter (FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
 
static int configure_input_audio_filter (FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
 
static int configure_input_filter (FilterGraph *fg, InputFilter *ifilter, AVFilterInOut *in)
 
int configure_filtergraph (FilterGraph *fg)
 
int ist_in_filtergraph (FilterGraph *fg, InputStream *ist)
 

Variables

 sample_rate
 
 supported_samplerates
 

Macro Definition Documentation

#define DEF_CHOOSE_FORMAT (   type,
  var,
  supported_list,
  none,
  get_name 
)
Value:
static char *choose_ ## var ## s(OutputStream *ost) \
{ \
if (ost->enc_ctx->var != none) { \
get_name(ost->enc_ctx->var); \
return av_strdup(name); \
} else if (ost->enc && ost->enc->supported_list) { \
const type *p; \
AVIOContext *s = NULL; \
uint8_t *ret; \
int len; \
exit_program(1); \
for (p = ost->enc->supported_list; *p != none; p++) { \
get_name(*p); \
avio_printf(s, "%s|", name); \
} \
len = avio_close_dyn_buf(s, &ret); \
ret[len - 1] = 0; \
return ret; \
} else \
return NULL; \
}

Definition at line 149 of file ffmpeg_filter.c.

#define AUTO_INSERT_FILTER (   opt_name,
  filter_name,
  arg 
)
Value:
do { \
AVFilterContext *filt_ctx; \
av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
"similarly to -af " filter_name "=%s.\n", arg); \
\
ret = avfilter_graph_create_filter(&filt_ctx, \
avfilter_get_by_name(filter_name), \
filter_name, arg, NULL, fg->graph); \
if (ret < 0) \
return ret; \
\
ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
if (ret < 0) \
return ret; \
\
last_filter = filt_ctx; \
pad_idx = 0; \
} while (0)

Referenced by configure_output_audio_filter().

#define DESCRIBE_FILTER_LINK (   f,
  inout,
  in 
)
Value:
{ \
AVFilterContext *ctx = inout->filter_ctx; \
AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads; \
int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs; \
if (avio_open_dyn_buf(&pb) < 0) \
exit_program(1); \
avio_printf(pb, "%s", ctx->filter->name); \
if (nb_pads > 1) \
avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));\
avio_w8(pb, 0); \
avio_close_dyn_buf(pb, &f->name); \
}

Definition at line 561 of file ffmpeg_filter.c.

Referenced by configure_input_filter(), and configure_output_filter().

#define AUTO_INSERT_FILTER_INPUT (   opt_name,
  filter_name,
  arg 
)
Value:
do { \
AVFilterContext *filt_ctx; \
av_log(NULL, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
"similarly to -af " filter_name "=%s.\n", arg); \
snprintf(name, sizeof(name), "graph %d %s for input stream %d:%d", \
fg->index, filter_name, ist->file_index, ist->st->index); \
ret = avfilter_graph_create_filter(&filt_ctx, \
avfilter_get_by_name(filter_name), \
name, arg, NULL, fg->graph); \
if (ret < 0) \
return ret; \
\
ret = avfilter_link(last_filter, 0, filt_ctx, 0); \
if (ret < 0) \
return ret; \
\
last_filter = filt_ctx; \
} while (0)

Referenced by configure_input_audio_filter().

Function Documentation

enum AVPixelFormat choose_pixel_fmt ( AVStream st,
AVCodecContext enc_ctx,
AVCodec codec,
enum AVPixelFormat  target 
)

Definition at line 40 of file ffmpeg_filter.c.

Referenced by choose_pix_fmts(), and read_ffserver_streams().

void choose_sample_fmt ( AVStream st,
AVCodec codec 
)

Definition at line 78 of file ffmpeg_filter.c.

Referenced by read_ffserver_streams().

static char* choose_pix_fmts ( OutputStream ost)
static

Definition at line 100 of file ffmpeg_filter.c.

Referenced by configure_output_video_filter().

DEF_CHOOSE_FORMAT ( enum  AVSampleFormat,
sample_fmt  ,
sample_fmts  ,
AV_SAMPLE_FMT_NONE  ,
GET_SAMPLE_FMT_NAME   
)
GET_SAMPLE_RATE_NAME DEF_CHOOSE_FORMAT ( uint64_t  ,
channel_layout  ,
channel_layouts  ,
,
GET_CH_LAYOUT_NAME   
)

Definition at line 184 of file ffmpeg_filter.c.

static void init_input_filter ( FilterGraph fg,
AVFilterInOut in 
)
static

Definition at line 218 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

static int insert_trim ( int64_t  start_time,
int64_t  duration,
AVFilterContext **  last_filter,
int *  pad_idx,
const char *  filter_name 
)
static
static int configure_output_video_filter ( FilterGraph fg,
OutputFilter ofilter,
AVFilterInOut out 
)
static

Definition at line 342 of file ffmpeg_filter.c.

Referenced by configure_output_filter().

static int configure_output_audio_filter ( FilterGraph fg,
OutputFilter ofilter,
AVFilterInOut out 
)
static

Definition at line 433 of file ffmpeg_filter.c.

Referenced by configure_output_filter().

int configure_output_filter ( FilterGraph fg,
OutputFilter ofilter,
AVFilterInOut out 
)

Definition at line 578 of file ffmpeg_filter.c.

Referenced by configure_filtergraph(), and init_output_filter().

static int sub2video_prepare ( InputStream ist)
static

Definition at line 590 of file ffmpeg_filter.c.

Referenced by configure_input_video_filter().

static int configure_input_video_filter ( FilterGraph fg,
InputFilter ifilter,
AVFilterInOut in 
)
static

Definition at line 626 of file ffmpeg_filter.c.

Referenced by configure_input_filter().

static int configure_input_audio_filter ( FilterGraph fg,
InputFilter ifilter,
AVFilterInOut in 
)
static

Definition at line 724 of file ffmpeg_filter.c.

Referenced by configure_input_filter().

static int configure_input_filter ( FilterGraph fg,
InputFilter ifilter,
AVFilterInOut in 
)
static

Definition at line 827 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

int configure_filtergraph ( FilterGraph fg)
int ist_in_filtergraph ( FilterGraph fg,
InputStream ist 
)

Definition at line 925 of file ffmpeg_filter.c.

Referenced by decode_audio(), and decode_video().

Variable Documentation

sample_rate
supported_samplerates

Definition at line 181 of file ffmpeg_filter.c.

Referenced by print_codec().