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];
329 "Error while add the frame to buffer source(%s).\n",
360 "Impossible to get a blank canvas.\n");
364 dst_linesize =
frame->linesize[0];
365 for (
int i = 0;
i < num_rects;
i++)
374 #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
375 static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
377 if (ofp->var == none && !ofp->supported_list) \
379 av_bprintf(bprint, #name "="); \
380 if (ofp->var != none) { \
381 av_bprintf(bprint, printf_format, get_name(ofp->var)); \
385 for (p = ofp->supported_list; *p != none; p++) { \
386 av_bprintf(bprint, printf_format "|", get_name(*p)); \
388 if (bprint->len > 0) \
389 bprint->str[--bprint->len] = '\0'; \
391 av_bprint_chars(bprint, ':', 1); \
414 }
else if (ofp->ch_layouts) {
423 bprint->str[--bprint->len] =
'\0';
447 if (fsize < 0 || fsize > INT_MAX) {
479 const char *
key,
const char *
val)
524 "Error applying option '%s' to filter '%s': %s\n",
529 "Error loading value for option '%s' from file '%s'\n",
584 if (!
f->hw_device_ctx) {
619 int nb_pads = in ?
ctx->nb_inputs :
ctx->nb_outputs;
764 if (!layouts_allowed) {
773 if (layouts_allowed[
i].nb_channels == layout_requested->
nb_channels)
776 if (layouts_allowed[
i].nb_channels) {
835 switch (ofilter->
type) {
878 if (
opts->sample_rate) {
882 if (
opts->ch_layout.nb_channels) {
931 if (ifp->
type != ofilter_src->
type) {
994 for (
int j = 0; j < fg->
nb_inputs; j++) {
1113 !strcmp(
f->name,
"apad")) {
1143 if (!ifilter->
name) {
1163 if (!ofilter->
name) {
1216 "to have exactly 1 input and 1 output. "
1217 "However, it had %d input(s) and %d output(s). Please adjust, "
1218 "or use a complex filtergraph (-filter_complex) instead.\n",
1224 "it to %s output stream\n",
1238 if (
opts->nb_threads) {
1263 dec_idx = strtol(ifp->
linklabel + 4, &p, 0);
1271 spec = *p ==
':' ? p + 1 : p;
1295 for (
int j = 0; j < fg_src->
nb_outputs; j++) {
1301 "Binding input with label '%s' to filtergraph output %d:%d\n",
1314 file_idx = strtol(ifp->
linklabel, &p, 0);
1329 spec =
ss.remainder ?
ss.remainder :
"";
1337 for (
i = 0;
i <
s->nb_streams;
i++) {
1338 enum AVMediaType stream_type =
s->streams[
i]->codecpar->codec_type;
1339 if (stream_type !=
type &&
1351 "matches no streams.\n", p, fgp->
graph_desc);
1357 "Binding input with label '%s' to input stream %d:%d\n",
1363 "Cannot find an unused %s input stream to feed the "
1364 "unlabeled input pad %s.\n",
1370 "Binding unlabeled input %d to input stream %d:%d\n",
1378 "Error binding an input stream to complex filtergraph input %s.\n",
1422 "Filter '%s' has output %d (%s) unconnected\n",
1424 output->linklabel ? (
const char *)
output->linklabel :
"unlabeled");
1435 const char *filter_name)
1450 "recording time.\n",
name);
1485 const char *filter_name,
const char *args)
1497 filter_name, args,
NULL, graph);
1516 int pad_idx =
out->pad_idx;
1533 snprintf(args,
sizeof(args),
"%d:%d",
1554 choose_pix_fmts(ofp, &bprint);
1555 choose_color_spaces(ofp, &bprint);
1556 choose_color_ranges(ofp, &bprint);
1565 "format", bprint.str,
NULL, graph);
1578 &last_filter, &pad_idx,
name);
1594 int pad_idx =
out->pad_idx;
1606 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
1607 AVFilterContext *filt_ctx; \
1609 av_log(ofilter, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
1610 "similarly to -af " filter_name "=%s.\n", arg); \
1612 ret = avfilter_graph_create_filter(&filt_ctx, \
1613 avfilter_get_by_name(filter_name), \
1614 filter_name, arg, NULL, graph); \
1618 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
1622 last_filter = filt_ctx; \
1627 choose_sample_fmts(ofp, &args);
1628 choose_sample_rates(ofp, &args);
1629 choose_channel_layouts(ofp, &args);
1652 if (ofilter->
apad) {
1659 &last_filter, &pad_idx,
name);
1674 switch (ofilter->
type) {
1701 int ret, pad_idx = 0;
1737 last_filter = ifp->
filter;
1744 snprintf(crop_buf,
sizeof(crop_buf),
"w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
1762 if (
fabs(theta - 90) < 1.0) {
1764 displaymatrix[3] > 0 ?
"cclock_flip" :
"clock");
1765 }
else if (
fabs(theta - 180) < 1.0) {
1766 if (displaymatrix[0] < 0) {
1771 if (displaymatrix[4] < 0) {
1774 }
else if (
fabs(theta - 270) < 1.0) {
1776 displaymatrix[3] < 0 ?
"clock_flip" :
"cclock");
1777 }
else if (
fabs(theta) > 1.0) {
1778 char rotate_buf[64];
1779 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1781 }
else if (
fabs(theta) < 1.0) {
1782 if (displaymatrix && displaymatrix[4] < 0) {
1794 &last_filter, &pad_idx,
name);
1815 int ret, pad_idx = 0;
1818 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
1834 last_filter = ifp->
filter;
1838 &last_filter, &pad_idx,
name);
1869 return f->nb_inputs == 0 &&
1870 (!strcmp(
f->filter->name,
"buffer") ||
1871 !strcmp(
f->filter->name,
"abuffer"));
1884 f->nb_outputs == 0 ||
1899 int have_input_eof = 0;
1990 fr.
num > 0 && fr.
den > 0)
2029 if (have_input_eof) {
2084 double time,
const char *target,
2085 const char *
command,
const char *
arg,
int all_filters)
2093 char response[4096];
2095 response,
sizeof(response),
2097 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
2099 }
else if (!all_filters) {
2100 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
2104 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(
ret));
2110 int nb_requests, nb_requests_max = -1;
2111 int best_input = -1;
2121 if (nb_requests > nb_requests_max) {
2122 nb_requests_max = nb_requests;
2146 "Demuxing timebase not available - cannot use it for encoding\n");
2165 if (fr_sink.
num > 0 && fr_sink.
den > 0)
2174 "about the input framerate is available. Falling "
2175 "back to a default value of 25fps. Use the -r option "
2176 "if you want a different framerate.\n");
2196 if (!(tb.
num > 0 && tb.
den > 0))
2198 if (!(tb.
num > 0 && tb.
den > 0))
2199 tb =
frame->time_base;
2228 if (float_pts !=
llrint(float_pts))
2229 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
2233 frame->time_base = tb_dst;
2239 "filter -> pts:%s pts_time:%s exact:%f time_base:%d/%d\n",
2242 float_pts, tb_dst.
num, tb_dst.
den);
2278 delta0 = sync_ipts - ofp->
next_pts;
2283 *nb_frames_prev = 0;
2294 if (delta0 < -0.6) {
2315 }
else if (
delta < -1.1)
2317 else if (
delta > 1.1) {
2320 *nb_frames_prev =
llrintf(delta0 - 0.6);
2322 frame->duration = 1;
2327 else if (
delta > 0.6)
2331 #if FFMPEG_OPT_VSYNC_DROP
2351 "*** dropping frame %"PRId64
" at ts %"PRId64
"\n",
2354 if (*nb_frames > (*nb_frames_prev && fps->
last_dropped) + (*nb_frames > *nb_frames_prev)) {
2355 uint64_t nb_frames_dup;
2357 av_log(ofp,
AV_LOG_ERROR,
"%"PRId64
" frame duplication too large, skipping\n", *nb_frames - 1);
2363 *nb_frames - (*nb_frames_prev && fps->
last_dropped) - (*nb_frames > *nb_frames_prev));
2409 "No filtered frames for output stream, trying to "
2410 "initialize anyway.\n");
2442 AVFrame *frame_in = (
i < nb_frames_prev && frame_prev->
buf[0]) ?
2490 if (
i == nb_frames_prev &&
frame)
2497 if (
frame && frame_prev) {
2520 return (
ret < 0) ?
ret : 1;
2523 }
else if (
ret < 0) {
2525 "Error in retrieving a frame from the filtergraph: %s\n",
2566 if (!
frame->duration) {
2568 if (fr.
num > 0 && fr.
den > 0)
2615 }
else if (
ret < 0) {
2620 "Error requesting a frame from the filtergraph: %s\n",
2657 if (pts2 <= ifp->sub2video.last_pts)
2762 "Cannot determine format of input %s after EOF\n",
2780 return str ? str :
"unknown";
2789 int need_reinit = 0,
ret;
2792 switch (ifp->
type) {
2830 if (need_reinit || !fgt->
graph) {
2856 av_bprintf(&reason,
"audio parameters changed to %d Hz, ",
frame->sample_rate);
2864 av_bprintf(&reason,
"video parameters changed to %s(%s, %s), %dx%d, ",
2869 av_bprintf(&reason,
"display matrix changed, ");
2873 reason.str[reason.len - 2] =
'\0';
2874 av_log(fg,
AV_LOG_INFO,
"Reconfiguring filter graph%s%s\n", reason.len ?
" because " :
"", reason.str);
2938 memset(fgt, 0,
sizeof(*fgt));
2943 memset(fgt, 0,
sizeof(*fgt));
2974 int ret = 0, input_status = 0;
2996 unsigned input_idx = fgt.
next_in;
2999 &input_idx, fgt.
frame);
3003 }
else if (input_status ==
AVERROR(EAGAIN)) {
3028 ifilter = fg->
inputs[input_idx];
3057 }
else if (
ret < 0) {
3086 const char *
command,
const char *
arg,
int all_filters)
3105 if (!
fc->target || !
fc->command || !
fc->arg) {
3111 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)
enum AVColorSpace color_space
Video only, the YUV colorspace and range.
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.
int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
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)
static int read_binary(void *logctx, const char *path, uint8_t **data, int *len)
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)
#define atomic_fetch_add(object, operand)
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)
int stream_specifier_parse(StreamSpecifier *ss, const char *spec, int allow_remainder, void *logctx)
Parse a stream specifier string into a form suitable for matching.
static const AVClass ofilter_class
float frame_drop_threshold
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, const ViewSpecifier *vs, InputFilterOptions *opts, SchedulerNode *src)
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
static int configure_output_filter(FilterGraphPriv *fgp, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
char * av_asprintf(const char *fmt,...)
int dec_filter_add(Decoder *dec, InputFilter *ifilter, InputFilterOptions *opts, const ViewSpecifier *vs, SchedulerNode *src)
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).
int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc, const OutputFilterOptions *opts)
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.
static int configure_output_audio_filter(FilterGraphPriv *fgp, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
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)
void stream_specifier_uninit(StreamSpecifier *ss)
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
A convenience wrapper that allocates and initializes a filter in a single step.
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)
static int filter_opt_apply(void *logctx, AVFilterContext *f, const char *key, const char *val)
AVRational sample_aspect_ratio
Video only, the sample (pixel) aspect ratio.
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 ss(width, name, subs,...)
#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)
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 int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist, const ViewSpecifier *vs)
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
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
@ VIEW_SPECIFIER_TYPE_NONE
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec, const ViewSpecifier *vs)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int av_buffersink_get_format(const AVFilterContext *ctx)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
#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)
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.
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
int fg_create_simple(FilterGraph **pfg, InputStream *ist, char *graph_desc, Scheduler *sch, unsigned sched_idx_enc, const OutputFilterOptions *opts)
AVFilterContext ** filters
static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp, const OutputFilterOptions *opts)
AVRational sample_aspect_ratio
static OutputFilter * ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
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.
unsigned stream_specifier_match(const StreamSpecifier *ss, const AVFormatContext *s, const AVStream *st, void *logctx)
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)
AVRational frame_rate
Video only, the frame rate of the input video.
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.
#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.
@ AV_BUFFERSRC_FLAG_PUSH
Immediately push the frame to the output.
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.
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.
AVRational time_base
The timebase to be used for the timestamps on the input frames.
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)
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.
static int graph_opts_apply(void *logctx, AVFilterGraphSegment *seg)
#define i(width, name, range_min, range_max)
int width
Video only, the display dimensions of the input frames.
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)
static int graph_parse(void *logctx, AVFilterGraph *graph, const char *desc, AVFilterInOut **inputs, AVFilterInOut **outputs, AVBufferRef *hw_device)
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
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.
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.
enum AVColorRange color_range
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)
int format
video: the pixel format, value corresponds to enum AVPixelFormat audio: the sample format,...
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
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
A filterchain is a list of filter specifications.
@ AV_BUFFERSRC_FLAG_KEEP_REF
Keep a reference to the frame.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
static int insert_trim(void *logctx, int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
#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.
static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
enum ViewSpecifierType type
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)
static double adjust_frame_pts_to_encoder_tb(void *logctx, AVFrame *frame, AVRational tb_dst, int64_t start_time)
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...
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