Go to the documentation of this file.
289 uint32_t *pal, *dst2;
297 if (
r->x < 0 ||
r->x +
r->w >
w ||
r->y < 0 ||
r->y +
r->h >
h) {
299 r->x,
r->y,
r->w,
r->h,
w,
h
304 dst +=
r->y * dst_linesize +
r->x * 4;
306 pal = (uint32_t *)
r->data[1];
307 for (y = 0; y <
r->h; y++) {
308 dst2 = (uint32_t *)
dst;
310 for (x = 0; x <
r->w; x++)
311 *(dst2++) = pal[*(
src2++)];
313 src +=
r->linesize[0];
359 "Impossible to get a blank canvas.\n");
363 dst_linesize =
frame->linesize[0];
364 for (
int i = 0;
i < num_rects;
i++)
373 #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
374 static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
376 if (ofp->var == none && !ofp->supported_list) \
378 av_bprintf(bprint, #name "="); \
379 if (ofp->var != none) { \
380 av_bprintf(bprint, printf_format, get_name(ofp->var)); \
384 for (p = ofp->supported_list; *p != none; p++) { \
385 av_bprintf(bprint, printf_format "|", get_name(*p)); \
387 if (bprint->len > 0) \
388 bprint->str[--bprint->len] = '\0'; \
390 av_bprint_chars(bprint, ':', 1); \
413 }
else if (ofp->ch_layouts) {
422 bprint->str[--bprint->len] =
'\0';
445 if (fsize < 0 || fsize > INT_MAX) {
521 "Error applying option '%s' to filter '%s': %s\n",
526 "Error loading value for option '%s' from file '%s'\n",
580 if (!
f->hw_device_ctx) {
615 int nb_pads = in ?
ctx->nb_inputs :
ctx->nb_outputs;
757 if (!layouts_allowed) {
766 if (layouts_allowed[
i].nb_channels == layout_requested->
nb_channels)
769 if (layouts_allowed[
i].nb_channels) {
784 unsigned sched_idx_enc,
828 switch (ofilter->
type) {
872 if (
opts->sample_rate) {
876 if (
opts->ch_layout.nb_channels) {
925 if (ifp->
type != ofilter_src->
type) {
988 for (
int j = 0; j < fg->
nb_inputs; j++) {
1132 if (!ifilter->
name) {
1152 if (!ofilter->
name) {
1193 fg =
ost->fg_simple;
1203 "to have exactly 1 input and 1 output. "
1204 "However, it had %d input(s) and %d output(s). Please adjust, "
1205 "or use a complex filtergraph (-filter_complex) instead.\n",
1211 "it to %s output stream\n",
1227 if (
opts->nb_threads) {
1274 for (
int j = 0; j < fg_src->
nb_outputs; j++) {
1280 "Binding input with label '%s' to filtergraph output %d:%d\n",
1293 file_idx = strtol(ifp->
linklabel, &p, 0);
1301 for (
i = 0;
i <
s->nb_streams;
i++) {
1302 enum AVMediaType stream_type =
s->streams[
i]->codecpar->codec_type;
1303 if (stream_type !=
type &&
1314 "matches no streams.\n", p, fgp->
graph_desc);
1320 "Binding input with label '%s' to input stream %d:%d\n",
1326 "unlabeled input pad %s\n", ifilter->
name);
1331 "Binding unlabeled input %d to input stream %d:%d\n",
1339 "Error binding an input stream to complex filtergraph input %s.\n",
1383 "Filter %s has an unconnected output\n",
output->name);
1394 const char *filter_name)
1409 "recording time.\n",
name);
1444 const char *filter_name,
const char *args)
1452 filter_name, args,
NULL, graph);
1471 int pad_idx =
out->pad_idx;
1488 snprintf(args,
sizeof(args),
"%d:%d",
1509 choose_pix_fmts(ofp, &bprint);
1510 choose_color_spaces(ofp, &bprint);
1511 choose_color_ranges(ofp, &bprint);
1520 "format", bprint.str,
NULL, graph);
1533 &last_filter, &pad_idx,
name);
1549 int pad_idx =
out->pad_idx;
1563 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
1564 AVFilterContext *filt_ctx; \
1566 av_log(ofilter, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
1567 "similarly to -af " filter_name "=%s.\n", arg); \
1569 ret = avfilter_graph_create_filter(&filt_ctx, \
1570 avfilter_get_by_name(filter_name), \
1571 filter_name, arg, NULL, graph); \
1575 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
1579 last_filter = filt_ctx; \
1584 choose_sample_fmts(ofp, &args);
1585 choose_sample_rates(ofp, &args);
1586 choose_channel_layouts(ofp, &args);
1614 &last_filter, &pad_idx,
name);
1629 switch (ofilter->
type) {
1659 int ret, pad_idx = 0;
1672 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
1673 "pixel_aspect=%d/%d:colorspace=%d:range=%d",
1684 args.str,
NULL, graph)) < 0)
1691 last_filter = ifp->
filter;
1698 snprintf(crop_buf,
sizeof(crop_buf),
"w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
1716 if (
fabs(theta - 90) < 1.0) {
1718 displaymatrix[3] > 0 ?
"cclock_flip" :
"clock");
1719 }
else if (
fabs(theta - 180) < 1.0) {
1720 if (displaymatrix[0] < 0) {
1725 if (displaymatrix[4] < 0) {
1728 }
else if (
fabs(theta - 270) < 1.0) {
1730 displaymatrix[3] < 0 ?
"clock_flip" :
"cclock");
1731 }
else if (
fabs(theta) > 1.0) {
1732 char rotate_buf[64];
1733 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1735 }
else if (
fabs(theta) < 1.0) {
1736 if (displaymatrix && displaymatrix[4] < 0) {
1748 &last_filter, &pad_idx,
name);
1769 int ret, pad_idx = 0;
1772 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
1788 last_filter = ifp->
filter;
1792 &last_filter, &pad_idx,
name);
1823 return f->nb_inputs == 0 &&
1824 (!strcmp(
f->filter->name,
"buffer") ||
1825 !strcmp(
f->filter->name,
"abuffer"));
1838 f->nb_outputs == 0 ||
1853 int have_input_eof = 0;
1943 fr.
num > 0 && fr.
den > 0)
1982 if (have_input_eof) {
2037 double time,
const char *target,
2038 const char *
command,
const char *
arg,
int all_filters)
2046 char response[4096];
2048 response,
sizeof(response),
2050 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
2052 }
else if (!all_filters) {
2053 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
2057 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(
ret));
2063 int nb_requests, nb_requests_max = -1;
2064 int best_input = -1;
2074 if (nb_requests > nb_requests_max) {
2075 nb_requests_max = nb_requests;
2099 "Demuxing timebase not available - cannot use it for encoding\n");
2118 if (fr_sink.
num > 0 && fr_sink.
den > 0)
2127 "about the input framerate is available. Falling "
2128 "back to a default value of 25fps. Use the -r option "
2129 "if you want a different framerate.\n");
2149 if (!(tb.
num > 0 && tb.
den > 0))
2151 if (!(tb.
num > 0 && tb.
den > 0))
2152 tb =
frame->time_base;
2181 if (float_pts !=
llrint(float_pts))
2182 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
2186 frame->time_base = tb_dst;
2194 float_pts, tb_dst.
num, tb_dst.
den);
2229 delta0 = sync_ipts - ofp->
next_pts;
2234 *nb_frames_prev = 0;
2245 if (delta0 < -0.6) {
2266 }
else if (
delta < -1.1)
2268 else if (
delta > 1.1) {
2271 *nb_frames_prev =
llrintf(delta0 - 0.6);
2273 frame->duration = 1;
2278 else if (
delta > 0.6)
2282 #if FFMPEG_OPT_VSYNC_DROP
2302 "*** dropping frame %"PRId64
" at ts %"PRId64
"\n",
2305 if (*nb_frames > (*nb_frames_prev && fps->
last_dropped) + (*nb_frames > *nb_frames_prev)) {
2306 uint64_t nb_frames_dup;
2308 av_log(ofp,
AV_LOG_ERROR,
"%"PRId64
" frame duplication too large, skipping\n", *nb_frames - 1);
2314 *nb_frames - (*nb_frames_prev && fps->
last_dropped) - (*nb_frames > *nb_frames_prev));
2360 "No filtered frames for output stream, trying to "
2361 "initialize anyway.\n");
2393 AVFrame *frame_in = (
i < nb_frames_prev && frame_prev->
buf[0]) ?
2441 if (
i == nb_frames_prev &&
frame)
2448 if (
frame && frame_prev) {
2471 return (
ret < 0) ?
ret : 1;
2474 }
else if (
ret < 0) {
2476 "Error in retrieving a frame from the filtergraph: %s\n",
2517 if (!
frame->duration) {
2519 if (fr.
num > 0 && fr.
den > 0)
2566 }
else if (
ret < 0) {
2571 "Error requesting a frame from the filtergraph: %s\n",
2608 if (pts2 <= ifp->sub2video.last_pts)
2713 "Cannot determine format of input %s after EOF\n",
2731 return str ? str :
"unknown";
2740 int need_reinit = 0,
ret;
2743 switch (ifp->
type) {
2781 if (need_reinit || !fgt->
graph) {
2807 av_bprintf(&reason,
"audio parameters changed to %d Hz, ",
frame->sample_rate);
2815 av_bprintf(&reason,
"video parameters changed to %s(%s, %s), %dx%d, ",
2820 av_bprintf(&reason,
"display matrix changed, ");
2824 reason.str[reason.len - 2] =
'\0';
2825 av_log(fg,
AV_LOG_INFO,
"Reconfiguring filter graph%s%s\n", reason.len ?
" because " :
"", reason.str);
2889 memset(fgt, 0,
sizeof(*fgt));
2894 memset(fgt, 0,
sizeof(*fgt));
2925 int ret = 0, input_status = 0;
2947 unsigned input_idx = fgt.
next_in;
2950 &input_idx, fgt.
frame);
2954 }
else if (input_status ==
AVERROR(EAGAIN)) {
2979 ifilter = fg->
inputs[input_idx];
3008 }
else if (
ret < 0) {
3037 const char *
command,
const char *
arg,
int all_filters)
3056 if (!
fc->target || !
fc->command || !
fc->arg) {
3062 fc->all_filters = all_filters;
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
#define SCH_FILTER_OUT(filter, output)
static int configure_input_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilter *ifilter, AVFilterInOut *in)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
#define AV_LOG_WARNING
Something somehow does not look correct.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AV_BPRINT_SIZE_UNLIMITED
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
AVPixelFormat
Pixel format.
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
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
unsigned avfilter_filter_pad_count(const AVFilter *filter, int is_output)
Get the number of elements in an AVFilter's inputs or outputs array.
struct FilterGraph * graph
int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *frame)
Called by filtergraph tasks to send a filtered frame or EOF to consumers.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int choose_input(const FilterGraph *fg, const FilterGraphThread *fgt)
double get_rotation(const int32_t *displaymatrix)
enum AVMediaType codec_type
General type of the encoded data.
int nb_threads
Maximum number of threads used by filters in this graph.
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
static void send_command(FilterGraph *fg, AVFilterGraph *graph, double time, const char *target, const char *command, const char *arg, int all_filters)
int avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags)
Create filters specified in a graph segment.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
static enum AVSampleFormat sample_fmts[]
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
static const AVClass ofilter_class
float frame_drop_threshold
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
char * av_asprintf(const char *fmt,...)
void fg_free(FilterGraph **pfg)
int64_t frames_prev_hist[3]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
void * opaque
Frame owner's private data.
enum AVColorSpace colorspace
YUV colorspace type.
static const int sample_rates[]
This structure describes decoded (raw) audio or video data.
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int fg_output_frame(OutputFilterPriv *ofp, FilterGraphThread *fgt, AVFrame *frame)
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
static void cleanup_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
#define AV_LOG_VERBOSE
Detailed information.
void(* filter)(uint8_t *src, int stride, int qscale)
#define fc(width, name, range_min, range_max)
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
static OutputFilterPriv * ofp_from_ofilter(OutputFilter *ofilter)
enum AVChannelOrder order
Channel order used in this layout.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
@ IFILTER_FLAG_AUTOROTATE
int nb_channels
Number of channels in this layout.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int64_t avio_size(AVIOContext *s)
Get the filesize.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, AVFrame *frame)
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
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.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
@ AV_OPT_TYPE_BINARY
Underlying C type is a uint8_t* that is either NULL or points to an array allocated with the av_mallo...
const char * av_color_space_name(enum AVColorSpace space)
@ FRAME_OPAQUE_SUB_HEARTBEAT
static void fg_thread_uninit(FilterGraphThread *fgt)
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
static void sub2video_push_ref(InputFilterPriv *ifp, int64_t pts)
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
void avfilter_graph_segment_free(AVFilterGraphSegment **seg)
Free the provided AVFilterGraphSegment and everything associated with it.
static int sub2video_get_blank_frame(InputFilterPriv *ifp)
#define AV_BPRINT_SIZE_AUTOMATIC
static int ifilter_has_all_input_formats(FilterGraph *fg)
static double val(void *priv, double ch)
AVChannelLayout ch_layout
Channel layout of the audio data.
static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilter *ifilter, AVFilterInOut *in)
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
int avfilter_graph_segment_parse(AVFilterGraph *graph, const char *graph_str, int flags, AVFilterGraphSegment **seg)
Parse a textual filtergraph description into an intermediate form.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static int graph_is_meta(AVFilterGraph *graph)
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
static FilterGraphPriv * fgp_from_fg(FilterGraph *fg)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
@ LATENCY_PROBE_FILTER_PRE
A filter pad used for either input or output.
int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs, SchThreadFunc func, void *ctx)
Add a filtergraph to the scheduler.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static void sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational tb)
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
AVRational frame_rate_filter
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, int64_t pts, AVRational tb)
#define FF_ARRAY_ELEMS(a)
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
static InputFilter * ifilter_alloc(FilterGraph *fg)
AVFilterParams ** filters
static void filter_command_free(void *opaque, uint8_t *data)
static const char * ofilter_item_name(void *obj)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static int configure_output_video_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int av_buffersink_get_format(const AVFilterContext *ctx)
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, InputFilterOptions *opts)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t pts
Same as packet pts, in AV_TIME_BASE.
static int fg_thread_init(FilterGraphThread *fgt, const FilterGraph *fg)
static int graph_opts_apply(AVFilterGraphSegment *seg)
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, Scheduler *sch, unsigned sched_idx_enc, const OutputFilterOptions *opts)
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
static int64_t fsize(FILE *f)
static const char * fg_item_name(void *obj)
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
const AVChannelLayout * ch_layouts
const char * av_color_range_name(enum AVColorRange range)
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
int avfilter_graph_segment_apply(AVFilterGraphSegment *seg, int flags, AVFilterInOut **inputs, AVFilterInOut **outputs)
Apply all filter/link descriptions from a graph segment to the associated filtergraph.
int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int search_flags)
static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layouts_allowed, const AVChannelLayout *layout_requested)
AVChannelLayout ch_layout
Parameters describing a filter to be created in a filtergraph.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
int dec_filter_add(Decoder *dec, InputFilter *ifilter, InputFilterOptions *opts)
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
AVFilterContext * filter
The filter context.
Rational number (pair of numerator and denominator).
@ OFILTER_FLAG_AUDIO_24BIT
AVFilterContext ** filters
static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp, const OutputFilterOptions *opts)
static int filter_opt_apply(AVFilterContext *f, const char *key, const char *val)
AVRational sample_aspect_ratio
static OutputFilter * ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
static int configure_output_audio_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
int64_t wallclock[LATENCY_PROBE_NB]
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
AVFilterChain ** chains
A list of filter chain contained in this segment.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AVCOL_RANGE_UNSPECIFIED
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
@ AV_CLASS_CATEGORY_FILTER
A parsed representation of a filtergraph segment.
char * file_read(const char *filename)
int pad_idx
index of the filt_ctx pad to use for linking
int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
Close the buffer source after EOF.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
int filtergraph_is_simple(const FilterGraph *fg)
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
static int configure_output_filter(FilterGraph *fg, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static int filter_thread(void *arg)
@ FRAME_OPAQUE_SEND_COMMAND
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVColorRange * color_ranges
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
AVFilterContext * filter_ctx
filter context associated to this input/output
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int sample_rate
Sample rate of the audio data.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
AVBufferRef * hw_frames_ctx
Video with a hwaccel pixel format only.
static int64_t start_time
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
static double adjust_frame_pts_to_encoder_tb(AVFrame *frame, AVRational tb_dst, int64_t start_time)
static int insert_trim(int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
static int graph_parse(AVFilterGraph *graph, const char *desc, AVFilterInOut **inputs, AVFilterInOut **outputs, AVBufferRef *hw_device)
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVRational time_base
Time base for the timestamps in this frame.
static int read_binary(const char *path, uint8_t **data, int *len)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
uint32_t end_display_time
void * allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
enum VideoSyncMethod vsync_method
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
static int filter_is_buffersrc(const AVFilterContext *f)
int fg_finalise_bindings(void)
int sch_filter_receive(Scheduler *sch, unsigned fg_idx, unsigned *in_idx, AVFrame *frame)
Called by filtergraph tasks to obtain frames for filtering.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static const char * unknown_if_null(const char *str)
@ AV_BUFFERSRC_FLAG_KEEP_REF
Keep a reference to the frame.
static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, AVFrame *frame)
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
#define AV_LOG_INFO
Standard information.
static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, InputFilter *ifilter, AVFrame *frame)
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_find_nearest_q_idx(AVRational q, const AVRational *q_list)
Find the value in a list of rationals nearest a given reference rational.
enum AVColorRange color_range
int av_buffersink_get_w(const AVFilterContext *ctx)
int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
Initialize the buffersrc or abuffersrc filter with the provided parameters.
#define i(width, name, range_min, range_max)
void fg_send_command(FilterGraph *fg, double time, const char *target, const char *command, const char *arg, int all_filters)
int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Add a frame to the buffer source.
static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilter *ifilter, AVFilterInOut *in)
AVColorSpace
YUV colorspace type.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
AVSampleFormat
Audio sample formats.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
static const FilterGraphPriv * cfgp_from_cfg(const FilterGraph *fg)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
enum AVColorSpace color_space
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, unsigned sched_idx_enc, const OutputFilterOptions *opts)
void * av_calloc(size_t nmemb, size_t size)
static const AVFilterPad outputs[]
int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst)
#define FFMPEG_OPT_VSYNC_DROP
int av_buffersink_get_h(const AVFilterContext *ctx)
int sch_filter_command(Scheduler *sch, unsigned fg_idx, AVFrame *frame)
static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, int64_t *nb_frames, int64_t *nb_frames_prev)
static InputFilterPriv * ifp_from_ifilter(InputFilter *ifilter)
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
Create a new filtergraph in the global filtergraph list.
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
static int insert_filter(AVFilterContext **last_filter, int *pad_idx, const char *filter_name, const char *args)
AVDictionary * opts
Options to be apllied to the filter.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
@ AV_BUFFERSRC_FLAG_PUSH
Immediately push the frame to the output.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
int index
stream index in AVFormatContext
#define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name)
This structure contains the parameters describing the frames that will be passed to this filter.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
static char * describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
A filterchain is a list of filter specifications.
#define atomic_fetch_add(object, operand)
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int ifilter_bind_fg(InputFilterPriv *ifp, FilterGraph *fg_src, int out_idx)
static int choose_out_timebase(OutputFilterPriv *ofp, AVFrame *frame)
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r)
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
static int sub2video_frame(InputFilter *ifilter, AVFrame *frame, int buffer)
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
Get the number of failed requests.
enum AVColorSpace * color_spaces
A reference to a data buffer.
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
enum AVColorSpace av_buffersink_get_colorspace(const AVFilterContext *ctx)
atomic_uint_least64_t nb_frames_drop
int auto_conversion_filters
Structure to hold side data for an AVFrame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx)
Called by filter tasks to signal that a filter input will no longer accept input.
static const AVClass fg_class
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
@ OFILTER_FLAG_DISABLE_CONVERT
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, const AVSubtitle *sub)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
float dts_error_threshold
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
AVBufferRef * hw_device_for_filter(void)
Get a hardware device to be used with this filtergraph.
static int bind_inputs(FilterGraph *fg)
const AVFilter * filter
the AVFilter of which this is an instance
AVColorRange
Visual content value range.
const FrameData * frame_data_c(AVFrame *frame)
A linked-list of the inputs/outputs of the filter chain.
#define SCH_FILTER_IN(filter, input)
static void fg_thread_set_name(const FilterGraph *fg)
InputStream * ist_find_unused(enum AVMediaType type)
Find an unused input stream of given type.
static void sub2video_prepare(InputFilterPriv *ifp)
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
uint32_t start_display_time
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
atomic_uint_least64_t nb_frames_dup
int filter_complex_nbthreads
enum AVColorRange av_buffersink_get_color_range(const AVFilterContext *ctx)
static int ff_thread_setname(const char *name)
@ LATENCY_PROBE_FILTER_POST
const AVRational * framerate_supported