FFmpeg
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

◆ DEF_CHOOSE_FORMAT

#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); \
return av_strdup(name); \
} else if (ofilter->supported_list) { \
const type *p; \
AVIOContext *s = NULL; \
uint8_t *ret; \
int len; \
exit_program(1); \
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; \
} else \
return NULL; \
}

Definition at line 160 of file ffmpeg_filter.c.

◆ AUTO_INSERT_FILTER

#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)

◆ AUTO_INSERT_FILTER_INPUT

#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)

Function Documentation

◆ get_compliance_unofficial_pix_fmts()

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().

◆ 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().

◆ choose_sample_fmt()

void choose_sample_fmt ( AVStream st,
AVCodec codec 
)

Definition at line 93 of file ffmpeg_filter.c.

◆ choose_pix_fmts()

static char* choose_pix_fmts ( OutputFilter ofilter)
static

Definition at line 116 of file ffmpeg_filter.c.

Referenced by configure_output_video_filter().

◆ DEF_CHOOSE_FORMAT() [1/2]

DEF_CHOOSE_FORMAT ( sample_fmts  ,
enum  AVSampleFormat,
format  ,
formats  ,
AV_SAMPLE_FMT_NONE  ,
GET_SAMPLE_FMT_NAME   
)

◆ DEF_CHOOSE_FORMAT() [2/2]

GET_SAMPLE_RATE_NAME DEF_CHOOSE_FORMAT ( channel_layouts  ,
uint64_t  ,
channel_layout  ,
channel_layouts  ,
,
GET_CH_LAYOUT_NAME   
)

Definition at line 195 of file ffmpeg_filter.c.

◆ describe_filter_link()

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

Definition at line 235 of file ffmpeg_filter.c.

Referenced by init_complex_filtergraph(), and init_input_filter().

◆ init_input_filter()

static void init_input_filter ( FilterGraph fg,
AVFilterInOut in 
)
static

Definition at line 254 of file ffmpeg_filter.c.

Referenced by init_complex_filtergraph().

◆ init_complex_filtergraph()

int init_complex_filtergraph ( FilterGraph fg)

Definition at line 341 of file ffmpeg_filter.c.

Referenced by init_complex_filters().

◆ insert_trim()

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

◆ insert_filter()

static int insert_filter ( AVFilterContext **  last_filter,
int pad_idx,
const char *  filter_name,
const char *  args 
)
static

Definition at line 433 of file ffmpeg_filter.c.

Referenced by configure_input_video_filter().

◆ configure_output_video_filter()

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

Definition at line 455 of file ffmpeg_filter.c.

Referenced by configure_output_filter().

◆ configure_output_audio_filter()

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

Definition at line 549 of file ffmpeg_filter.c.

Referenced by configure_output_filter().

◆ configure_output_filter()

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

Definition at line 677 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

◆ check_filter_outputs()

void check_filter_outputs ( void  )

Definition at line 691 of file ffmpeg_filter.c.

◆ sub2video_prepare()

static int sub2video_prepare ( InputStream ist,
InputFilter ifilter 
)
static

Definition at line 706 of file ffmpeg_filter.c.

Referenced by configure_input_video_filter().

◆ configure_input_video_filter()

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

Definition at line 753 of file ffmpeg_filter.c.

Referenced by configure_input_filter().

◆ configure_input_audio_filter()

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

Definition at line 875 of file ffmpeg_filter.c.

Referenced by configure_input_filter().

◆ configure_input_filter()

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

Definition at line 985 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

◆ cleanup_filtergraph()

static void cleanup_filtergraph ( FilterGraph fg)
static

Definition at line 1001 of file ffmpeg_filter.c.

Referenced by configure_filtergraph().

◆ configure_filtergraph()

int configure_filtergraph ( FilterGraph fg)

Definition at line 1011 of file ffmpeg_filter.c.

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

◆ ifilter_parameters_from_frame()

int ifilter_parameters_from_frame ( InputFilter ifilter,
const AVFrame frame 
)

Definition at line 1183 of file ffmpeg_filter.c.

Referenced by ifilter_send_frame().

◆ ist_in_filtergraph()

int ist_in_filtergraph ( FilterGraph fg,
InputStream ist 
)

Definition at line 1206 of file ffmpeg_filter.c.

◆ filtergraph_is_simple()

int filtergraph_is_simple ( FilterGraph fg)

Definition at line 1215 of file ffmpeg_filter.c.

Referenced by configure_filtergraph(), and transcode_init().

Variable Documentation

◆ int

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

Definition at line 192 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(), avf_read_packet(), avfilter_config_links(), avfilter_transform(), calculate_visual_weight(), capture_screen(), cdtoons_render_sprite(), celt_gauge_psy_weight(), check_eq(), 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_default_clut(), compute_vmaf_score(), config_input(), config_output(), config_props(), construct_vector(), 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(), decfloat(), decode_block(), decode_blocks(), decode_envelope(), decode_fixed_vector(), decode_inter_block(), decode_intra_block(), decode_ppc(), decode_spectrum_and_dequant(), decode_str(), decode_subband_slice_buffered(), decor_c(), decorrelate_stereo(), deshake_opencl_init(), diff_bytes_c(), diff_int16_c(), distortion_correction_filter_slice(), dng_decode_tiles(), do_apply_filter(), do_chromakey_pixel(), do_chromakey_pixel16(), do_colorkey_pixel(), draw_mandelbrot(), draw_sierpinski(), dss_sp_shift_sq_sub(), dv_write_pack(), dxv_decode(), encode_block(), encode_dvb_subtitles(), encode_write_frame(), eval_expr(), exr_half2float(), ff_convert_matrix(), ff_dirac_golomb_read_16bit(), ff_dirac_golomb_read_32bit(), 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_vc1_pred_dc(), ff_wma_init(), ffio_fdopen(), ffio_geturlcontext(), fic_idct(), filter16_3x3(), filter16_5x5(), filter16_7x7(), filter16_column(), filter16_row(), filter_3x3(), filter_5x5(), filter_7x7(), filter_column(), filter_frame(), filter_row(), finish_file(), fir_to_phase(), fixed_exp(), fixed_log(), fixed_sqrt(), flac_decorrelate_indep_c(), get_audio_frame(), get_high_utility_cell(), get_matching_parameters(), get_qminmax(), get_qtable(), get_utc_date_time_insec(), get_vcd_padding_size(), get_video_config(), global_mv(), glslang_compile(), guess_mv(), horizontal_compose_dd137i_TMPL(), horizontal_compose_dd97i_TMPL(), hq_decode_block(), hScale8To15_c(), hScale8To19_c(), hScale_real(), ict_int(), id3v2_encode_string(), idct248_ref(), idct2_1d(), idct_1d(), idct_col(), idct_col_3(), idct_col_4(), idct_col_8(), idct_row(), idctRowCondDC(), idctSparseCol(), init(), init_axis_color(), init_noise(), init_pass2(), interleave_TMPL(), interpolate(), INTERPOLATE_METHOD(), iterate_frame(), libopenjpeg_copy_packed12(), libopenjpeg_copy_packed16(), libopenjpeg_copy_packed8(), libopenjpeg_copy_unpacked16(), libopenjpeg_copy_unpacked8(), LLVMFuzzerTestOneInput(), load_data(), lpc_prediction(), lpf(), lum(), luma_mc_bi(), lumRangeToJpeg16_c(), main(), make_bands(), make_filters_from_proto(), mediumthresh_c(), mf_enca_output_score(), mlp_encode_init(), mov_read_default(), mov_read_tkhd(), mov_read_udta_string(), MPA_encode_init(), 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(), predictor_update_3930(), predictor_update_filter(), 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(), sbc_synthesize_eight(), sbc_synthesize_four(), 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(), scale_eval_dimensions(), scc_write_packet(), segment_end(), set_noise_profile(), set_roi_map(), 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(), svq3_mc_dir_part(), sws_getGaussianVec(), sws_init_context(), sws_printVec2(), synchronize_audio(), tansig_approx(), tm2_low_chroma(), tm2_low_res_block(), truespeech_synth(), udp_port(), unquantize_dct_coeffs(), unsharp_opencl_make_filter_params(), vaapi_encode_init_rate_control(), value_string(), vector_fmul_add_c(), vector_fmul_c(), vector_fmul_reverse_c(), vector_pow43(), vertical_compose53iL0_TMPL(), viv_read_packet(), 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_rate

◆ sample_rates

sample_rates
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
avfilter_graph_create_filter
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.
Definition: avfiltergraph.c:142
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
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1401
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1356
s
#define s(width, name)
Definition: cbs_vp9.c:257
arg
const char * arg
Definition: jacosubdec.c:66
if
if(ret)
Definition: filter_design.txt:179
avfilter_get_by_name
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: allfilters.c:520
NULL
#define NULL
Definition: coverity.c:32
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
avfilter_link
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:135
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
len
int len
Definition: vorbis_enc_data.h:452
ret
ret
Definition: filter_design.txt:187
suffix
const char * suffix
Definition: checkasm.c:198
OutputFilter
Definition: ffmpeg.h:258
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:253
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
snprintf
#define snprintf
Definition: snprintf.h:34