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 "libavfilter/buffersrc.h"
#include "libavresample/avresample.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/display.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(suffix, type, var, supported_list, none, get_name)
 
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
 
#define AUTO_INSERT_FILTER_INPUT(opt_name, filter_name, arg)
 

Functions

static enum AVPixelFormatget_compliance_unofficial_pix_fmts (enum AVCodecID codec_id, const enum AVPixelFormat default_formats[])
 
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 (OutputFilter *ofilter)
 
 DEF_CHOOSE_FORMAT (sample_fmts, enum AVSampleFormat, format, formats, AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME) DEF_CHOOSE_FORMAT(sample_rates
 
GET_SAMPLE_RATE_NAME DEF_CHOOSE_FORMAT (channel_layouts, uint64_t, channel_layout, channel_layouts, 0, GET_CH_LAYOUT_NAME)
 
static char * describe_filter_link (FilterGraph *fg, AVFilterInOut *inout, int in)
 
static void init_input_filter (FilterGraph *fg, AVFilterInOut *in)
 
int init_complex_filtergraph (FilterGraph *fg)
 
static int insert_trim (int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
 
static int insert_filter (AVFilterContext **last_filter, int *pad_idx, const char *filter_name, const char *args)
 
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)
 
void check_filter_outputs (void)
 
static int sub2video_prepare (InputStream *ist, InputFilter *ifilter)
 
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)
 
static void cleanup_filtergraph (FilterGraph *fg)
 
int configure_filtergraph (FilterGraph *fg)
 
int ifilter_parameters_from_frame (InputFilter *ifilter, const AVFrame *frame)
 
int ist_in_filtergraph (FilterGraph *fg, InputStream *ist)
 
int filtergraph_is_simple (FilterGraph *fg)
 

Variables

 int
 
 sample_rate
 
 sample_rates
 

Macro Definition Documentation

#define DEF_CHOOSE_FORMAT (   suffix,
  type,
  var,
  supported_list,
  none,
  get_name 
)
Value:
static char *choose_ ## suffix (OutputFilter *ofilter) \
{ \
if (ofilter->var != none) { \
get_name(ofilter->var); \
} else if (ofilter->supported_list) { \
const type *p; \
AVIOContext *s = NULL; \
uint8_t *ret; \
for (p = ofilter->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; \
}
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1420
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1391
uint8_t
const char * suffix
Definition: checkasm.c:179
return
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
Definition: cmdutils.c:136
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:251
GLint GLenum type
Definition: opengl_enc.c:105
int
if(ret< 0)
Definition: vf_mcdeint.c:279
int len
for(j=16;j >0;--j)
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
const char * name
Definition: opengl_enc.c:103

Definition at line 158 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)
#define NULL
Definition: coverity.c:32
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:135
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
#define av_log(a,...)
const char * arg
Definition: jacosubdec.c:66
return
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:428
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
if(ret< 0)
Definition: vf_mcdeint.c:279

Referenced by configure_output_audio_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_in_%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)
#define NULL
Definition: coverity.c:32
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:135
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
#define av_log(a,...)
const char * arg
Definition: jacosubdec.c:66
return
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:428
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
#define snprintf
Definition: snprintf.h:34
if(ret< 0)
Definition: vf_mcdeint.c:279
const char * name
Definition: opengl_enc.c:103

Referenced by configure_input_audio_filter().

Function Documentation

static enum AVPixelFormat* get_compliance_unofficial_pix_fmts ( enum AVCodecID  codec_id,
const enum AVPixelFormat  default_formats[] 
)
static

Definition at line 42 of file ffmpeg_filter.c.

Referenced by choose_pix_fmts(), and choose_pixel_fmt().

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

Definition at line 63 of file ffmpeg_filter.c.

Referenced by choose_pix_fmts().

void choose_sample_fmt ( AVStream st,
AVCodec codec 
)

Definition at line 92 of file ffmpeg_filter.c.

static char* choose_pix_fmts ( OutputFilter ofilter)
static

Definition at line 114 of file ffmpeg_filter.c.

Referenced by configure_output_video_filter().

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

Definition at line 193 of file ffmpeg_filter.c.

static char* describe_filter_link ( FilterGraph fg,
AVFilterInOut inout,
int  in 
)
static

Definition at line 233 of file ffmpeg_filter.c.

Referenced by init_complex_filtergraph(), and init_input_filter().

static void init_input_filter ( FilterGraph fg,
AVFilterInOut in 
)
static

Definition at line 252 of file ffmpeg_filter.c.

Referenced by init_complex_filtergraph().

int init_complex_filtergraph ( FilterGraph fg)

Definition at line 332 of file ffmpeg_filter.c.

Referenced by init_complex_filters().

static int insert_trim ( int64_t  start_time,
int64_t  duration,
AVFilterContext **  last_filter,
int pad_idx,
const char *  filter_name 
)
static
static int insert_filter ( AVFilterContext **  last_filter,
int pad_idx,
const char *  filter_name,
const char *  args 
)
static

Definition at line 424 of file ffmpeg_filter.c.

Referenced by configure_input_video_filter().

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

Definition at line 446 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 540 of file ffmpeg_filter.c.

Referenced by configure_output_filter().

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

Definition at line 668 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

void check_filter_outputs ( void  )

Definition at line 682 of file ffmpeg_filter.c.

Referenced by ffmpeg_parse_options().

static int sub2video_prepare ( InputStream ist,
InputFilter ifilter 
)
static

Definition at line 697 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 737 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 860 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 970 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

static void cleanup_filtergraph ( FilterGraph fg)
static

Definition at line 986 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

int configure_filtergraph ( FilterGraph fg)

Definition at line 996 of file ffmpeg_filter.c.

Referenced by flush_encoders(), ifilter_send_frame(), and transcode_step().

int ifilter_parameters_from_frame ( InputFilter ifilter,
const AVFrame frame 
)

Definition at line 1176 of file ffmpeg_filter.c.

Referenced by ifilter_send_frame().

int ist_in_filtergraph ( FilterGraph fg,
InputStream ist 
)

Definition at line 1199 of file ffmpeg_filter.c.

int filtergraph_is_simple ( FilterGraph fg)

Definition at line 1208 of file ffmpeg_filter.c.

Referenced by configure_filtergraph(), and transcode_init().

Variable Documentation

int
Examples:
encode_audio.c, muxing.c, and transcoding.c.

Definition at line 190 of file ffmpeg_filter.c.

Referenced by adaptive_quantization(), add_bytes_c(), add_bytes_l2_c(), add_int16_c(), add_peak(), adpcm_decode_frame(), adpcm_ms_expand_nibble(), amf_encode_init_h264(), amf_encode_init_hevc(), amf_parse_object(), apply_dependent_coupling_fixed(), apply_independent_coupling_fixed(), asf_write_packet(), async_seek(), autocorr_calc(), av_lfg_init_from_data(), av_opt_query_ranges(), av_opt_set_image_size(), av_sincos_sf(), av_sqrt_sf(), av_vlog(), avfilter_config_links(), avfilter_transform(), avs_bytes_per_channel_sample(), calculate_visual_weight(), capture_screen(), celt_gauge_psy_weight(), check_idct(), check_idct_multiple(), check_loopfilter_16y(), check_loopfilter_8uv(), check_loopfilter_simple(), checkasm_check_h264pred(), chroma_mc_bi(), chs_parse_header(), color_distance(), compare_fields(), compute_vmaf_score(), config_input(), config_output(), config_props(), dct_quantize_trellis_c(), dct_unquantize_mpeg1_inter_c(), dct_unquantize_mpeg1_intra_c(), dct_unquantize_mpeg2_inter_c(), dct_unquantize_mpeg2_intra_bitexact(), dct_unquantize_mpeg2_intra_c(), decode_fixed_vector(), decode_ppc(), decode_spectrum_and_dequant(), decode_str(), decode_subband_slice_buffered(), decor_c(), decorrelation(), diff_bytes_c(), diff_int16_c(), do_chromakey_pixel(), do_colorkey_pixel(), draw_mandelbrot(), dss_sp_shift_sq_sub(), dxv_decode(), encode_block(), encode_write_frame(), eval_expr(), exr_half2float(), ff_convert_matrix(), ff_decklink_list_formats(), ff_eval_refl(), ff_filter_frame_framed(), ff_h264_chroma422_dc_dequant_idct(), ff_h264_chroma_dc_dequant_idct(), ff_h264_init_poc(), ff_h264_luma_dc_dequant_idct(), ff_init_block_index(), ff_intra_pred_8_16x16_msa(), ff_intra_pred_8_32x32_msa(), ff_opus_parse_extradata(), ff_rate_estimate_qscale(), ff_rtp_send_mpegvideo(), ff_scale_eval_dimensions(), ff_socket(), ff_wma_init(), fic_idct(), filter16_3x3(), filter16_5x5(), filter16_7x7(), filter_3x3(), filter_5x5(), filter_7x7(), filter_frame(), finish_file(), fixed_exp(), fixed_log(), fixed_sqrt(), flac_decorrelate_indep_c(), get_high_utility_cell(), get_matching_parameters(), get_qminmax(), get_utc_date_time_insec(), get_vcd_padding_size(), get_video_config(), global_mv(), guess_mv(), horizontal_compose_dd137i_TMPL(), horizontal_compose_dd97i_TMPL(), hq_decode_block(), hScale8To15_c(), hScale8To19_c(), ict_int(), id3v2_encode_string(), idct248_ref(), idct_col(), idct_col_3(), idct_col_4(), idct_col_8(), idctRowCondDC(), init(), init_axis_color(), init_noise(), init_pass2(), interpolate(), INTERPOLATE_METHOD(), iterate_frame(), libopenjpeg_copy_packed12(), libopenjpeg_copy_packed16(), libopenjpeg_copy_packed8(), libopenjpeg_copy_unpacked16(), libopenjpeg_copy_unpacked8(), LLVMFuzzerTestOneInput(), load_data(), lum(), luma_mc_bi(), lumRangeToJpeg16_c(), main(), make_bands(), make_filters_from_proto(), map_val_34_to_20(), mediumthresh_c(), mlp_encode_init(), mov_read_default(), mov_read_tkhd(), mov_read_udta_string(), MPA_encode_init(), mpsub_read_header(), multiple_resample(), multiply(), noise_scale(), nvenc_setup_rate_control(), open_filter_param(), open_output_file(), opt_size(), optimize_colors(), optimum_block_height(), optimum_block_width(), plot_gamuts(), plot_white_point(), postProcess_TMPL(), process(), process_c(), ps_hybrid_analysis_c(), ps_tableinit(), psy_3gpp_init(), psycho_acoustic_model(), put_float(), qdm2_decode(), quantize_bands(), read_diff_float_data(), ring2_test(), round_sample(), sbr_hf_apply_noise(), sbr_hf_assemble(), sbr_hf_g_filt_c(), sbr_hf_gen_c(), sbr_hf_inverse_filter(), sbr_make_f_derived(), sbr_make_f_master(), sbr_qmf_deint_bfly_c(), scc_write_packet(), segment_end(), set_volume(), sgi_rle_encode(), sign_extend(), softthresh_c(), spx_coordinates(), sr_1d53(), ssim_end1(), ssim_plane(), stream_read(), stream_seek(), stream_skip(), stream_write(), subband_scale(), svq3_luma_dc_dequant_idct_c(), sws_getGaussianVec(), sws_init_context(), sws_printVec2(), synchronize_audio(), udp_port(), unsharp_opencl_make_filter_params(), vaapi_encode_h264_configure(), vaapi_encode_h265_configure(), vaapi_encode_init_rate_control(), value_string(), vector_fmul_add_c(), vector_fmul_c(), vector_fmul_reverse_c(), vector_pow43(), vertical_compose53iL0_TMPL(), vtenc_cm_to_avpacket(), wma_decode_block(), wmv2_idct_col(), wmv2_idct_row(), write_packet(), wv_unpack_mono(), wv_unpack_stereo(), xvid_correct_framerate(), yae_adjust_position(), yae_flush(), and zero_extend().

sample_rate
sample_rates