Go to the documentation of this file.
269 uint32_t *pal, *dst2;
277 if (
r->x < 0 ||
r->x +
r->w >
w ||
r->y < 0 ||
r->y +
r->h >
h) {
279 r->x,
r->y,
r->w,
r->h,
w,
h
284 dst +=
r->y * dst_linesize +
r->x * 4;
286 pal = (uint32_t *)
r->data[1];
287 for (y = 0; y <
r->h; y++) {
288 dst2 = (uint32_t *)dst;
290 for (x = 0; x <
r->w; x++)
291 *(dst2++) = pal[*(
src2++)];
293 src +=
r->linesize[0];
339 "Impossible to get a blank canvas.\n");
344 for (
int i = 0;
i < num_rects;
i++)
383 #define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
384 static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
386 if (ofp->var == none && !ofp->supported_list) \
388 av_bprintf(bprint, #name "="); \
389 if (ofp->var != none) { \
390 av_bprintf(bprint, printf_format, get_name(ofp->var)); \
394 for (p = ofp->supported_list; *p != none; p++) { \
395 av_bprintf(bprint, printf_format "|", get_name(*p)); \
397 if (bprint->len > 0) \
398 bprint->str[--bprint->len] = '\0'; \
400 av_bprint_chars(bprint, ':', 1); \
417 }
else if (ofp->ch_layouts) {
426 bprint->str[--bprint->len] =
'\0';
449 if (fsize < 0 || fsize > INT_MAX) {
525 "Error applying option '%s' to filter '%s': %s\n",
530 "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;
739 if (!
c->ch_layouts) {
747 for (
i = 0;
c->ch_layouts[
i].nb_channels;
i++) {
748 if (
c->ch_layouts[
i].nb_channels ==
ost->enc_ctx->ch_layout.nb_channels)
751 if (
c->ch_layouts[
i].nb_channels) {
766 unsigned sched_idx_enc)
783 switch (
ost->enc_ctx->codec_type) {
796 if (!strcmp(
c->name,
"mjpeg")) {
804 int strict_val =
ost->enc_ctx->strict_std_compliance;
826 NULL :
c->supported_framerates;
841 if (
ost->enc_ctx->sample_rate) {
846 if (
ost->enc_ctx->ch_layout.nb_channels) {
850 }
else if (
c->ch_layouts) {
901 for (
int j = 0; j < fg->
nb_inputs; j++) {
1031 if (!ifilter->
name) {
1051 if (!ofilter->
name) {
1101 "to have exactly 1 input and 1 output. "
1102 "However, it had %d input(s) and %d output(s). Please adjust, "
1103 "or use a complex filtergraph (-filter_complex) instead.\n",
1150 int file_idx = strtol(ifp->
linklabel, &p, 0);
1159 for (
i = 0;
i <
s->nb_streams;
i++) {
1160 enum AVMediaType stream_type =
s->streams[
i]->codecpar->codec_type;
1161 if (stream_type !=
type &&
1172 "matches no streams.\n", p, fgp->
graph_desc);
1178 "Binding input with label '%s' to input stream %d:%d\n",
1184 "unlabeled input pad %s\n", ifilter->
name);
1189 "Binding unlabeled input %d to input stream %d:%d\n",
1197 "Error binding an input stream to complex filtergraph input %s.\n",
1224 "Filter %s has an unconnected output\n",
output->name);
1233 const char *filter_name)
1248 "recording time.\n",
name);
1283 const char *filter_name,
const char *args)
1291 filter_name, args,
NULL, graph);
1312 int pad_idx =
out->pad_idx;
1330 snprintf(args,
sizeof(args),
"%d:%d",
1373 &last_filter, &pad_idx,
name);
1391 int pad_idx =
out->pad_idx;
1405 #define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
1406 AVFilterContext *filt_ctx; \
1408 av_log(fg, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
1409 "similarly to -af " filter_name "=%s.\n", arg); \
1411 ret = avfilter_graph_create_filter(&filt_ctx, \
1412 avfilter_get_by_name(filter_name), \
1413 filter_name, arg, NULL, graph); \
1417 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
1421 last_filter = filt_ctx; \
1426 choose_sample_fmts(ofp, &args);
1427 choose_sample_rates(ofp, &args);
1467 &last_filter, &pad_idx,
name);
1482 if (!ofilter->
ost) {
1517 int ret, pad_idx = 0;
1530 "video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
1531 "pixel_aspect=%d/%d:colorspace=%d:range=%d",
1542 args.str,
NULL, graph)) < 0)
1549 last_filter = ifp->
filter;
1562 if (
fabs(theta - 90) < 1.0) {
1564 displaymatrix[3] > 0 ?
"cclock_flip" :
"clock");
1565 }
else if (
fabs(theta - 180) < 1.0) {
1566 if (displaymatrix[0] < 0) {
1571 if (displaymatrix[4] < 0) {
1574 }
else if (
fabs(theta - 270) < 1.0) {
1576 displaymatrix[3] < 0 ?
"clock_flip" :
"cclock");
1577 }
else if (
fabs(theta) > 1.0) {
1578 char rotate_buf[64];
1579 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1581 }
else if (
fabs(theta) < 1.0) {
1582 if (displaymatrix && displaymatrix[4] < 0) {
1592 &last_filter, &pad_idx,
name);
1613 int ret, pad_idx = 0;
1616 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
1632 last_filter = ifp->
filter;
1636 &last_filter, &pad_idx,
name);
1667 return f->nb_inputs == 0 &&
1668 (!strcmp(
f->filter->name,
"buffer") ||
1669 !strcmp(
f->filter->name,
"abuffer"));
1682 f->nb_outputs == 0 ||
1697 int have_input_eof = 0;
1786 fr.
num > 0 && fr.
den > 0)
1825 if (have_input_eof) {
1880 double time,
const char *target,
1881 const char *
command,
const char *
arg,
int all_filters)
1889 char response[4096];
1891 response,
sizeof(response),
1893 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
1895 }
else if (!all_filters) {
1896 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
1900 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(
ret));
1906 int nb_requests, nb_requests_max = -1;
1907 int best_input = -1;
1917 if (nb_requests > nb_requests_max) {
1918 nb_requests_max = nb_requests;
1942 "Demuxing timebase not available - cannot use it for encoding\n");
1961 if (fr_sink.
num > 0 && fr_sink.
den > 0)
1970 "about the input framerate is available. Falling "
1971 "back to a default value of 25fps. Use the -r option "
1972 "if you want a different framerate.\n");
1992 if (!(
tb.num > 0 &&
tb.den > 0))
1994 if (!(
tb.num > 0 &&
tb.den > 0))
2024 if (float_pts !=
llrint(float_pts))
2025 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
2037 float_pts, tb_dst.
num, tb_dst.
den);
2073 delta0 = sync_ipts - ofp->
next_pts;
2078 *nb_frames_prev = 0;
2089 if (delta0 < -0.6) {
2098 switch (
ost->vsync_method) {
2110 }
else if (
delta < -1.1)
2112 else if (
delta > 1.1) {
2115 *nb_frames_prev =
llrintf(delta0 - 0.6);
2122 else if (
delta > 0.6)
2126 #if FFMPEG_OPT_VSYNC_DROP
2146 "*** dropping frame %"PRId64
" at ts %"PRId64
"\n",
2149 if (*nb_frames > (*nb_frames_prev && fps->
last_dropped) + (*nb_frames > *nb_frames_prev)) {
2150 uint64_t nb_frames_dup;
2158 *nb_frames - (*nb_frames_prev && fps->
last_dropped) - (*nb_frames > *nb_frames_prev));
2204 "No filtered frames for output stream, trying to "
2205 "initialize anyway.\n");
2237 AVFrame *frame_in = (
i < nb_frames_prev && frame_prev->
buf[0]) ?
2285 if (
i == nb_frames_prev &&
frame)
2292 if (
frame && frame_prev) {
2316 return (
ret < 0) ?
ret : 1;
2319 }
else if (
ret < 0) {
2321 "Error in retrieving a frame from the filtergraph: %s\n",
2364 if (fr.
num > 0 && fr.
den > 0)
2411 }
else if (
ret < 0) {
2416 "Error requesting a frame from the filtergraph: %s\n",
2453 if (pts2 <= ifp->sub2video.last_pts)
2558 "Cannot determine format of input %s after EOF\n",
2576 return str ? str :
"unknown";
2585 int need_reinit = 0,
ret;
2588 switch (ifp->
type) {
2626 if (need_reinit || !fgt->
graph) {
2660 av_bprintf(&reason,
"video parameters changed to %s(%s, %s), %dx%d, ",
2665 av_bprintf(&reason,
"display matrix changed, ");
2669 reason.str[reason.len - 2] =
'\0';
2670 av_log(fg,
AV_LOG_INFO,
"Reconfiguring filter graph%s%s\n", reason.len ?
" because " :
"", reason.str);
2731 memset(fgt, 0,
sizeof(*fgt));
2736 memset(fgt, 0,
sizeof(*fgt));
2767 int ret = 0, input_status = 0;
2789 unsigned input_idx = fgt.
next_in;
2792 &input_idx, fgt.
frame);
2796 }
else if (input_status ==
AVERROR(EAGAIN)) {
2821 ifilter = fg->
inputs[input_idx];
2850 }
else if (
ret < 0) {
2879 const char *
command,
const char *
arg,
int all_filters)
2898 if (!
fc->target || !
fc->command || !
fc->arg) {
2904 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 set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
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)
int init_simple_filtergraph(InputStream *ist, OutputStream *ost, char *graph_desc, Scheduler *sch, unsigned sched_idx_enc)
static enum AVSampleFormat sample_fmts[]
int64_t duration
Duration of the frame, in the same units as pts.
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)
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
@ AV_BUFFERSRC_FLAG_PUSH
Immediately push the frame to the 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.
int64_t start_time
start time in microseconds == AV_TIME_BASE units
void * opaque
Frame owner's private data.
enum AVColorSpace colorspace
YUV colorspace type.
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.
#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...
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 then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
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.
@ AV_BUFFERSRC_FLAG_KEEP_REF
Keep a reference to the frame.
@ 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().
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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)
static int choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint, const char **dst)
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
int fg_finalise_bindings(FilterGraph *fg)
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
offset must point to a pointer immediately followed by an int for the length
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
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static void filter_command_free(void *opaque, uint8_t *data)
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 OutputFilter * ofilter_alloc(FilterGraph *fg)
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)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
struct OutputStream * ost
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)
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)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
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)
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).
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
AVFilterContext ** filters
static int filter_opt_apply(AVFilterContext *f, const char *key, const char *val)
AVRational sample_aspect_ratio
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
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
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.
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
AVFilterContext * filter_ctx
filter context associated to this input/output
#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.
static int filter_is_buffersrc(const AVFilterContext *f)
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)
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
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.
int av_buffersink_get_w(const AVFilterContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
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.
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost, unsigned sched_idx_enc)
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
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...
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
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.
static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint)
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.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
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 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.
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
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.
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_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
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.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
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.
const AVFilter * filter
the AVFilter of which this is an instance
AVColorRange
Visual content value range.
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
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
static int ff_thread_setname(const char *name)
@ LATENCY_PROBE_FILTER_POST
const AVRational * framerate_supported