311 uint32_t *pal, *dst2;
319 if (
r->x < 0 ||
r->x +
r->w >
w ||
r->y < 0 ||
r->y +
r->h >
h) {
321 r->x,
r->y,
r->w,
r->h,
w,
h
326 dst +=
r->y * dst_linesize +
r->x * 4;
328 pal = (uint32_t *)
r->data[1];
329 for (y = 0; y <
r->h; y++) {
330 dst2 = (uint32_t *)
dst;
332 for (x = 0; x <
r->w; x++)
333 *(dst2++) = pal[*(
src2++)];
335 src +=
r->linesize[0];
351 "Error while add the frame to buffer source(%s).\n",
382 "Impossible to get a blank canvas.\n");
386 dst_linesize =
frame->linesize[0];
387 for (
int i = 0;
i < num_rects;
i++)
396#define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name) \
397static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
399 if (ofp->var == none && !ofp->supported_list) \
401 av_bprintf(bprint, #name "="); \
402 if (ofp->var != none) { \
403 av_bprintf(bprint, printf_format, get_name(ofp->var)); \
407 for (p = ofp->supported_list; *p != none; p++) { \
408 av_bprintf(bprint, printf_format "|", get_name(*p)); \
410 if (bprint->len > 0) \
411 bprint->str[--bprint->len] = '\0'; \
413 av_bprint_chars(bprint, ':', 1); \
437 av_bprintf(bprint,
"channel_layouts=");
438 av_channel_layout_describe_bprint(&ofp->ch_layout, bprint);
439 }
else if (ofp->ch_layouts) {
440 const AVChannelLayout *p;
442 av_bprintf(bprint,
"channel_layouts=");
443 for (p = ofp->ch_layouts; p->nb_channels; p++) {
444 av_channel_layout_describe_bprint(p, bprint);
445 av_bprintf(bprint,
"|");
448 bprint->str[--bprint->len] =
'\0';
487 ret = ret < 0 ? ret :
AVERROR(EIO);
504 const char *
key,
const char *
val)
549 "Error applying option '%s' to filter '%s': %s\n",
554 "Error loading value for option '%s' from file '%s'\n",
609 if (!
f->hw_device_ctx) {
644 int nb_pads = in ?
ctx->nb_inputs :
ctx->nb_outputs;
670 .class_name =
"OutputFilter",
808 if (!layouts_allowed) {
817 if (layouts_allowed[
i].nb_channels == layout_requested->
nb_channels)
820 if (layouts_allowed[
i].nb_channels) {
838 char *ptr, *str, *substr =
NULL;
854 const char *subtoken;
855 char *subptr, *endptr;
862 subtoken =
av_strtok(substr,
"|", &subptr);
863 if (subtoken && subptr) {
869 o.
pts = strtoll(subtoken, &endptr, 0);
870 if (*endptr || o.
pts < 0) {
890 ptr += strspn(ptr,
" \n\t\r");
929 if (
opts->reinit_opts) {
954 switch (ofilter->
type) {
1002 if (
opts->sample_rate) {
1006 if (
opts->ch_layout.nb_channels) {
1093 ifilter->
graph = fg;
1121 for (
int j = 0; j < fg->
nb_inputs; j++) {
1186 .class_name =
"FilterGraph",
1272 if (!ifilter->
name) {
1294 if (!ofilter->
name) {
1366 "to have exactly 1 input and 1 output. "
1367 "However, it had %d input(s) and %d output(s). Please adjust, "
1368 "or use a complex filtergraph (-filter_complex) instead.\n",
1374 "it to %s output stream\n",
1388 if (
opts->nb_threads >= 0)
1408 dec_idx = strtol(ifilter->
linklabel + 4, &p, 0);
1416 spec = *p ==
':' ? p + 1 : p;
1440 for (
int j = 0; j < fg_src->
nb_outputs; j++) {
1447 "Binding input with label '%s' to filtergraph output %d:%d\n",
1464 file_idx = strtol(ifilter->
linklabel, &p, 0);
1479 spec =
ss.remainder ?
ss.remainder :
"";
1487 for (
i = 0;
i <
s->nb_streams;
i++) {
1488 enum AVMediaType stream_type =
s->streams[
i]->codecpar->codec_type;
1489 if (stream_type !=
type &&
1508 "Binding input with label '%s' to input stream %d:%d\n",
1518 for (
int j = 0; j < fg_src->
nb_outputs; j++) {
1521 if (!ofilter->
bound) {
1524 "Binding unlabeled filtergraph input to filtergraph output %d:%d\n",
i, j);
1541 "Cannot find an unused %s input stream to feed the "
1542 "unlabeled input pad %s.\n",
1549 "Binding unlabeled input %d to input stream %d:%d\n",
1558 "Error binding an input stream to complex filtergraph input %s.\n",
1605 "Filter '%s' has output %d (%s) unconnected\n",
1612 "Internal filter '%s' has output %d (%s) unconnected. Removing graph\n",
1638 const char *filter_name)
1653 "recording time.\n",
name);
1688 const char *filter_name,
const char *args)
1700 filter_name, args,
NULL, graph);
1719 int pad_idx =
out->pad_idx;
1733 snprintf(crop_buf,
sizeof(crop_buf),
"w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
1737 ret =
insert_filter(&last_filter, &pad_idx,
"crop", crop_buf);
1748 if (
fabs(theta - 90) < 1.0) {
1750 displaymatrix[3] > 0 ?
"cclock_flip" :
"clock");
1751 }
else if (
fabs(theta - 180) < 1.0) {
1752 if (displaymatrix[0] < 0) {
1757 if (displaymatrix[4] < 0) {
1760 }
else if (
fabs(theta - 270) < 1.0) {
1762 displaymatrix[3] < 0 ?
"clock_flip" :
"cclock");
1763 }
else if (
fabs(theta) > 1.0) {
1764 char rotate_buf[64];
1765 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
1766 ret =
insert_filter(&last_filter, &pad_idx,
"rotate", rotate_buf);
1767 }
else if (
fabs(theta) < 1.0) {
1768 if (displaymatrix && displaymatrix[4] < 0) {
1786 snprintf(args,
sizeof(args),
"%d:%d",
1807 choose_pix_fmts(ofp, &bprint);
1808 choose_color_spaces(ofp, &bprint);
1809 choose_color_ranges(ofp, &bprint);
1810 choose_alpha_modes(ofp, &bprint);
1819 "format", bprint.str,
NULL, graph);
1832 &last_filter, &pad_idx,
name);
1848 int pad_idx =
out->pad_idx;
1860#define AUTO_INSERT_FILTER(opt_name, filter_name, arg) do { \
1861 AVFilterContext *filt_ctx; \
1863 av_log(ofilter, AV_LOG_INFO, opt_name " is forwarded to lavfi " \
1864 "similarly to -af " filter_name "=%s.\n", arg); \
1866 ret = avfilter_graph_create_filter(&filt_ctx, \
1867 avfilter_get_by_name(filter_name), \
1868 filter_name, arg, NULL, graph); \
1872 ret = avfilter_link(last_filter, pad_idx, filt_ctx, 0); \
1876 last_filter = filt_ctx; \
1881 choose_sample_fmts(ofp, &args);
1882 choose_sample_rates(ofp, &args);
1883 choose_channel_layouts(ofp, &args);
1911 &last_filter, &pad_idx,
name);
1926 switch (ofilter->
type) {
1953 int ret, pad_idx = 0;
1993 last_filter = ifilter->
filter;
2000 snprintf(crop_buf,
sizeof(crop_buf),
"w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
2004 ret =
insert_filter(&last_filter, &pad_idx,
"crop", crop_buf);
2018 if (
fabs(theta - 90) < 1.0) {
2020 displaymatrix[3] > 0 ?
"cclock_flip" :
"clock");
2021 }
else if (
fabs(theta - 180) < 1.0) {
2022 if (displaymatrix[0] < 0) {
2027 if (displaymatrix[4] < 0) {
2030 }
else if (
fabs(theta - 270) < 1.0) {
2032 displaymatrix[3] < 0 ?
"clock_flip" :
"cclock");
2033 }
else if (
fabs(theta) > 1.0) {
2034 char rotate_buf[64];
2035 snprintf(rotate_buf,
sizeof(rotate_buf),
"%f*PI/180", theta);
2036 ret =
insert_filter(&last_filter, &pad_idx,
"rotate", rotate_buf);
2037 }
else if (
fabs(theta) < 1.0) {
2038 if (displaymatrix && displaymatrix[4] < 0) {
2050 &last_filter, &pad_idx,
name);
2072 int ret, pad_idx = 0;
2075 av_bprintf(&args,
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
2100 last_filter = ifilter->
filter;
2104 &last_filter, &pad_idx,
name);
2117 switch (ifilter->
type) {
2135 return f->nb_inputs == 0 &&
2136 (!strcmp(
f->filter->name,
"buffer") ||
2137 !strcmp(
f->filter->name,
"abuffer"));
2150 f->nb_outputs == 0 ||
2165 int have_input_eof = 0;
2265 fr.
num > 0 && fr.
den > 0)
2278 for (
int j = 0; j < nb_sd; j++) {
2319 if (have_input_eof) {
2361 for (
int i = 0;
i <
frame->nb_side_data;
i++) {
2438 double time,
const char *target,
2439 const char *
command,
const char *
arg,
int all_filters)
2447 char response[4096];
2449 response,
sizeof(response),
2451 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
2452 fg->
index, ret, response);
2453 }
else if (!all_filters) {
2454 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
2458 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(ret));
2464 int nb_requests, nb_requests_max = -1;
2465 int best_input = -1;
2474 if (nb_requests > nb_requests_max) {
2475 nb_requests_max = nb_requests;
2499 "Demuxing timebase not available - cannot use it for encoding\n");
2518 if (fr_sink.
num > 0 && fr_sink.
den > 0)
2527 "about the input framerate is available. Falling "
2528 "back to a default value of 25fps. Use the -r option "
2529 "if you want a different framerate.\n");
2549 if (!(tb.
num > 0 && tb.
den > 0))
2551 if (!(tb.
num > 0 && tb.
den > 0))
2552 tb =
frame->time_base;
2581 if (float_pts !=
llrint(float_pts))
2582 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
2586 frame->time_base = tb_dst;
2592 "filter -> pts:%s pts_time:%s exact:%f time_base:%d/%d\n",
2595 float_pts, tb_dst.
num, tb_dst.
den);
2612 m = (
c >= max2) ? max2 :
c;
2614 return (m >= min2) ? m : min2;
2648 delta0 = sync_ipts - ofp->
next_pts;
2653 *nb_frames_prev = 0;
2660 if (delta0 < -0.6) {
2682 }
else if (
delta < -1.1)
2684 else if (
delta > 1.1) {
2687 *nb_frames_prev =
llrintf(delta0 - 0.6);
2689 frame->duration = 1;
2694 else if (
delta > 0.6)
2715 "*** dropping frame %"PRId64
" at ts %"PRId64
"\n",
2718 if (*nb_frames > (*nb_frames_prev && fps->
last_dropped) + (*nb_frames > *nb_frames_prev)) {
2719 uint64_t nb_frames_dup;
2721 av_log(ofp,
AV_LOG_ERROR,
"%"PRId64
" frame duplication too large, skipping\n", *nb_frames - 1);
2727 *nb_frames - (*nb_frames_prev && fps->
last_dropped) - (*nb_frames > *nb_frames_prev));
2789 "No filtered frames for output stream, trying to "
2790 "initialize anyway.\n");
2822 AVFrame *frame_in = (
i < nb_frames_prev && frame_prev->
buf[0]) ?
2870 if (
i == nb_frames_prev &&
frame)
2877 if (
frame && frame_prev) {
2900 return (ret < 0) ? ret : 1;
2903 }
else if (ret < 0) {
2905 "Error in retrieving a frame from the filtergraph: %s\n",
2956 if (!
frame->duration) {
2958 if (fr.
num > 0 && fr.
den > 0)
3017 }
else if (ret < 0) {
3022 "Error requesting a frame from the filtergraph: %s\n",
3045 if (pts2 <= ifp->sub2video.last_pts)
3158 "Cannot determine format of input %s after EOF\n",
3177 return str ? str :
"unknown";
3187 int need_reinit = 0, ret;
3190 switch (ifilter->
type) {
3258 if (need_reinit || force_reinit || !fgt->
graph) {
3284 av_bprintf(&reason,
"audio parameters changed to %d Hz, ",
frame->sample_rate);
3293 av_bprintf(&reason,
"video parameters changed to %s(%s, %s), %dx%d, %s alpha, ",
3299 av_bprintf(&reason,
"display matrix changed, ");
3301 av_bprintf(&reason,
"downmix medatata changed, ");
3305 av_bprintf(&reason,
"reinitialization arguments were provided, ");
3307 reason.str[reason.len - 2] =
'\0';
3308 av_log(fg,
AV_LOG_INFO,
"Reconfiguring filter graph%s%s\n", reason.len ?
" because " :
"", reason.str);
3377 memset(fgt, 0,
sizeof(*fgt));
3382 memset(fgt, 0,
sizeof(*fgt));
3449 int ret = 0, input_status = 0;
3471 unsigned input_idx = fgt.
next_in;
3474 &input_idx, fgt.
frame);
3478 }
else if (input_status ==
AVERROR(EAGAIN)) {
3501 ifilter = fg->
inputs[input_idx];
3534 }
else if (ret < 0) {
3574 const char *
command,
const char *
arg,
int all_filters)
3593 if (!
fc->target || !
fc->command || !
fc->arg) {
3599 fc->all_filters = all_filters;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static enum AVSampleFormat sample_fmts[]
static double val(void *priv, double ch)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static const char *const format[]
static int64_t fsize(FILE *f)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Main libavfilter public API header.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
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.
#define AVIO_FLAG_READ
read-only
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
char * av_asprintf(const char *fmt,...)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define AV_BPRINT_SIZE_AUTOMATIC
memory buffer sink API for audio and video
Memory buffer source API.
#define i(width, name, range_min, range_max)
#define ss(width, name, subs,...)
Public libavutil channel layout APIs header.
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.
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.
char * read_file_to_string(const char *filename)
unsigned stream_specifier_match(const StreamSpecifier *ss, const AVFormatContext *s, const AVStream *st, void *logctx)
double get_rotation(const int32_t *displaymatrix)
void stream_specifier_uninit(StreamSpecifier *ss)
static __device__ float fabs(float a)
static const int sample_rates[]
static const uint16_t fc[]
const FrameData * frame_data_c(AVFrame *frame)
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
const AVIOInterruptCB int_cb
FilterGraph ** filtergraphs
@ IFILTER_FLAG_DROPCHANGED
@ IFILTER_FLAG_AUTOROTATE
int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, const ViewSpecifier *vs, InputFilterOptions *opts, SchedulerNode *src)
AVBufferRef * hw_device_for_filter(void)
Get a hardware device to be used with this filtergraph.
@ LATENCY_PROBE_FILTER_POST
@ LATENCY_PROBE_FILTER_PRE
float dts_error_threshold
@ VIEW_SPECIFIER_TYPE_NONE
int filter_complex_nbthreads
float frame_drop_threshold
@ FRAME_OPAQUE_SEND_COMMAND
@ FRAME_OPAQUE_SUB_HEARTBEAT
int auto_conversion_filters
InputStream * ist_find_unused(enum AVMediaType type)
Find an unused input stream of given type.
@ OFILTER_FLAG_AUTOROTATE
@ OFILTER_FLAG_AUDIO_24BIT
@ OFILTER_FLAG_DISABLE_CONVERT
int filter_buffered_frames
int dec_filter_add(Decoder *dec, InputFilter *ifilter, InputFilterOptions *opts, const ViewSpecifier *vs, SchedulerNode *src)
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter, int commit)
static int read_binary(void *logctx, const char *path, uint8_t **data, int *len)
static int ifilter_parameters_from_ofilter(InputFilter *ifilter, OutputFilter *ofilter)
static int choose_out_timebase(OutputFilterPriv *ofp, AVFrame *frame)
static int configure_input_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilter *ifilter, AVFilterInOut *in)
static void fg_thread_set_name(const FilterGraph *fg)
static const FilterGraphPriv * cfgp_from_cfg(const FilterGraph *fg)
int fg_finalise_bindings(void)
static int bind_inputs(FilterGraph *fg, int commit)
static int configure_output_audio_filter(FilterGraphPriv *fgp, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
static int filter_thread(void *arg)
static void sub2video_prepare(InputFilterPriv *ifp)
static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec, const ViewSpecifier *vs)
static OutputFilterPriv * ofp_from_ofilter(OutputFilter *ofilter)
static FilterGraphPriv * fgp_from_fg(FilterGraph *fg)
static const AVClass fg_class
static void sub2video_push_ref(InputFilterPriv *ifp, int64_t pts)
static int configure_output_filter(FilterGraphPriv *fgp, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
void fg_send_command(FilterGraph *fg, double time, const char *target, const char *command, const char *arg, int all_filters)
static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt, AVFrame *frame)
static int choose_input(const FilterGraph *fg, const FilterGraphThread *fgt)
static int parse_reinit_opts(AVFifo **pout, const char *opts, void *logctx)
static int filter_is_buffersrc(const AVFilterContext *f)
static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilter *ifilter, AVFilterInOut *in)
static int graph_opts_apply(void *logctx, AVFilterGraphSegment *seg)
static OutputFilter * ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, AVFrame *frame)
static int fg_output_frame(OutputFilterPriv *ofp, FilterGraphThread *fgt, AVFrame *frame)
static double adjust_frame_pts_to_encoder_tb(void *logctx, AVFrame *frame, AVRational tb_dst, int64_t start_time)
static int fg_thread_init(FilterGraphThread *fgt, const FilterGraph *fg)
static void fg_thread_uninit(FilterGraphThread *fgt)
static InputFilter * ifilter_alloc(FilterGraph *fg)
static void close_input(InputFilterPriv *ifp)
static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp, const OutputFilterOptions *opts)
static void sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational tb)
static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
static void cleanup_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
static const char * unknown_if_null(const char *str)
static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r)
static int graph_parse(void *logctx, AVFilterGraph *graph, const char *desc, AVFilterInOut **inputs, AVFilterInOut **outputs, AVBufferRef *hw_device)
static int check_reinit(FilterGraph *fg, FilterGraphThread *fgt)
static char * describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
static const AVClass ofilter_class
static const char * fg_item_name(void *obj)
static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch, const OutputFilterOptions *opts)
Create a new filtergraph in the global filtergraph list.
static int insert_trim(void *logctx, int64_t start_time, int64_t duration, AVFilterContext **last_filter, int *pad_idx, const char *filter_name)
static int sub2video_frame(InputFilter *ifilter, AVFrame *frame, int buffer)
#define AUTO_INSERT_FILTER(opt_name, filter_name, arg)
static int send_frame(FilterGraph *fg, FilterGraphThread *fgt, InputFilter *ifilter, AVFrame *frame, int force_reinit)
static int ifilter_has_all_input_formats(FilterGraph *fg)
static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist, const ViewSpecifier *vs)
static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *graph, OutputFilter *ofilter, AVFilterInOut *out)
int fg_create_simple(FilterGraph **pfg, InputStream *ist, char **graph_desc, Scheduler *sch, unsigned sched_idx_enc, const OutputFilterOptions *opts)
static int graph_is_meta(AVFilterGraph *graph)
int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc, const OutputFilterOptions *opts)
static int sub2video_get_blank_frame(InputFilterPriv *ifp)
static void filter_command_free(void *opaque, uint8_t *data)
static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, InputFilter *ifilter, AVFilterInOut *in)
static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter, int64_t pts, AVRational tb)
static InputFilterPriv * ifp_from_ifilter(InputFilter *ifilter)
static int insert_filter(AVFilterContext **last_filter, int *pad_idx, const char *filter_name, const char *args)
#define DEF_CHOOSE_FORMAT(name, type, var, supported_list, none, printf_format, get_name)
int filtergraph_is_simple(const FilterGraph *fg)
static int filter_opt_apply(void *logctx, AVFilterContext *f, const char *key, const char *val)
static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame, int64_t *nb_frames, int64_t *nb_frames_prev)
static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layouts_allowed, const AVChannelLayout *layout_requested)
static void send_command(FilterGraph *fg, AVFilterGraph *graph, double time, const char *target, const char *command, const char *arg, int all_filters)
static int ifilter_bind_fg(InputFilterPriv *ifp, FilterGraph *fg_src, int out_idx)
static void sub2video_update(InputFilterPriv *ifp, int64_t heartbeat_pts, const AVSubtitle *sub)
void fg_free(FilterGraph **pfg)
static const AVOption ofilter_options[]
static const char * ofilter_item_name(void *obj)
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 sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs, SchThreadFunc func, void *ctx)
Add a filtergraph to the scheduler.
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.
void sch_remove_filtergraph(Scheduler *sch, int idx)
int sch_filter_receive(Scheduler *sch, unsigned fg_idx, unsigned *in_idx, AVFrame *frame)
Called by filtergraph tasks to obtain frames for filtering.
void sch_filter_choke_inputs(Scheduler *sch, unsigned fg_idx)
Called by filtergraph tasks to choke all filter inputs, preventing them from receiving more frames un...
int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst)
int sch_filter_command(Scheduler *sch, unsigned fg_idx, AVFrame *frame)
#define SCH_FILTER_IN(filter, input)
#define SCH_FILTER_OUT(filter, output)
static int clone_side_data(AVFrameSideData ***dst, int *nb_dst, AVFrameSideData *const *src, int nb_src, unsigned int flags)
Wrapper calling av_frame_side_data_clone() in a loop for all source entries.
static int64_t start_time
int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph)
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
@ 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...
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_CHLAYOUT
Underlying C type is AVChannelLayout.
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
int av_buffersink_get_format(const AVFilterContext *ctx)
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
const AVFrameSideData *const * av_buffersink_get_side_data(const AVFilterContext *ctx, int *nb_side_data)
enum AVAlphaMode av_buffersink_get_alpha_mode(const AVFilterContext *ctx)
int av_buffersink_get_h(const AVFilterContext *ctx)
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
enum AVColorSpace av_buffersink_get_colorspace(const AVFilterContext *ctx)
int av_buffersink_get_ch_layout(const AVFilterContext *ctx, AVChannelLayout *out)
enum AVColorRange av_buffersink_get_color_range(const AVFilterContext *ctx)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
int av_buffersink_get_w(const AVFilterContext *ctx)
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.
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
int av_buffersrc_get_status(AVFilterContext *ctx)
Returns 0 or a negative AVERROR code.
int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
Initialize the buffersrc or abuffersrc filter with the provided parameters.
int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Add a frame to the buffer source.
int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
Close the buffer source after EOF.
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
Get the number of failed requests.
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
@ AV_BUFFERSRC_FLAG_KEEP_REF
Keep a reference to the frame.
@ AV_BUFFERSRC_FLAG_PUSH
Immediately push the frame to the output.
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
int avfilter_init_str(AVFilterContext *filter, const char *args)
Initialize a filter with the supplied parameters.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
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 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.
void avfilter_graph_segment_free(AVFilterGraphSegment **seg)
Free the provided AVFilterGraphSegment and everything associated with it.
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
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.
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
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.
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
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 avfilter_graph_segment_create_filters(AVFilterGraphSegment *seg, int flags)
Create filters specified in a graph segment.
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
Enable or disable automatic format conversion inside the graph.
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
@ AVFILTER_AUTO_CONVERT_NONE
all automatic conversions disabled
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout, AVBPrint *bp)
bprint variant of av_channel_layout_describe().
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
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.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
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.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
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_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
#define AVERROR_FILTER_NOT_FOUND
Filter not found.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AVERROR_OPTION_NOT_FOUND
Option not found.
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.
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
size_t av_fifo_can_read(const AVFifo *f)
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd)
Free all side data entries and their contents, then zeroes out the values which the pointers are poin...
#define AV_FRAME_SIDE_DATA_FLAG_REPLACE
Don't add a new entry if another of the same type exists.
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_side_data_remove(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type from an array.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
const AVSideDataDescriptor * av_frame_side_data_desc(enum AVFrameSideDataType type)
int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags)
Add a new side data entry to an array based on existing side data, taking a reference towards the con...
static const AVFrameSideData * av_frame_side_data_get(AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conver...
@ AV_SIDE_DATA_PROP_GLOBAL
The side data type can be used in stream-global structures.
@ AV_FRAME_DATA_DOWNMIX_MATRIX
Metadata relevant to a downmix procedure in the form of a remixig matrix.
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
@ AV_FRAME_DATA_DOWNMIX_INFO
Metadata relevant to a downmix procedure.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
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.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
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.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
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.
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.
AVSampleFormat
Audio sample formats.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
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.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int search_flags)
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
static void reinit(Jpeg2000EncoderContext *s)
Macro definitions for various function/variable attributes.
static int ff_thread_setname(const char *name)
static enum AVPixelFormat pix_fmts[]
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
@ AV_CLASS_CATEGORY_FILTER
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
const char * av_color_space_name(enum AVColorSpace space)
const char * av_color_range_name(enum AVColorRange range)
const char * av_alpha_mode_name(enum AVAlphaMode mode)
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
AVColorRange
Visual content value range.
@ AVCOL_RANGE_UNSPECIFIED
AVAlphaMode
Correlation between the alpha channel and color values.
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
AVPixelFormat
Pixel format.
AVColorSpace
YUV colorspace type.
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
uint8_t * data
The data buffer.
This structure contains the parameters describing the frames that will be passed to this filter.
AVRational frame_rate
Video only, the frame rate of the input video.
AVFrameSideData ** side_data
enum AVColorRange color_range
int format
video: the pixel format, value corresponds to enum AVPixelFormat audio: the sample format,...
int width
Video only, the display dimensions of the input frames.
enum AVColorSpace color_space
Video only, the YUV colorspace and range.
enum AVAlphaMode alpha_mode
Video only, the alpha mode.
AVRational time_base
The timebase to be used for the timestamps on the input frames.
AVBufferRef * hw_frames_ctx
Video with a hwaccel pixel format only.
AVRational sample_aspect_ratio
Video only, the sample (pixel) aspect ratio.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVChannelOrder order
Channel order used in this layout.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
enum AVMediaType codec_type
General type of the encoded data.
This structure describes optional metadata relevant to a downmix procedure.
A filterchain is a list of filter specifications.
AVFilterParams ** filters
A parsed representation of a filtergraph segment.
AVFilterChain ** chains
A list of filter chain contained in this segment.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
AVFilterContext ** filters
int nb_threads
Maximum number of threads used by filters in this graph.
A linked-list of the inputs/outputs of the filter chain.
AVFilterContext * filter_ctx
filter context associated to this input/output
int pad_idx
index of the filt_ctx pad to use for linking
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
A filter pad used for either input or output.
Parameters describing a filter to be created in a filtergraph.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVRational time_base
Time base for the timestamps in this frame.
void * opaque
Frame owner's private data.
AVFrameSideData ** side_data
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
enum AVColorSpace colorspace
YUV colorspace type.
enum AVAlphaMode alpha_mode
Indicates how the alpha channel of the video is to be handled.
int sample_rate
Sample rate of the audio data.
AVChannelLayout ch_layout
Channel layout of the audio data.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
This struct describes the properties of a side data type.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int index
stream index in AVFormatContext
uint32_t start_display_time
uint32_t end_display_time
int64_t pts
Same as packet pts, in AV_TIME_BASE.
const AVRational * framerate_supported
int64_t frames_prev_hist[3]
enum VideoSyncMethod vsync_method
struct FrameData::@304126211346234154321045014345346376220164157123 dec
AVRational frame_rate_filter
int64_t wallclock[LATENCY_PROBE_NB]
AVFrameSideData ** side_data
AVDictionary * reinit_opts
enum AVColorRange * color_ranges
enum AVPixelFormat * pix_fmts
AVFifo * reinit_opts_fifo
AVChannelLayout ch_layout
enum AVColorSpace color_space
enum AVAlphaMode alpha_mode
enum AVColorRange color_range
AVRational sample_aspect_ratio
enum AVSampleFormat * sample_fmts
const AVChannelLayout * ch_layouts
enum AVAlphaMode * alpha_modes
enum AVColorSpace * color_spaces
AVFrameSideData ** side_data
atomic_uint_least64_t nb_frames_drop
atomic_uint_least64_t nb_frames_dup
struct FilterGraph * graph
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static AVFormatContext * ctx
static AVDictionary * opts
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
timestamp utils, mostly useful for debugging/logging purposes
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
#define atomic_fetch_add(object, operand)