37 #define OFFSET(x) offsetof(AVFilterGraph,x)
67 for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
71 av_freep(&(*graph)->aresample_swr_opts);
90 const char *
name,
const char *args,
void *opaque,
136 "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
146 "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
223 const char *filt_name,
const char *filt_args)
225 static int auto_count = 0, ret;
231 "The filters '%s' and '%s' do not have a common format "
232 "and automatic conversion is disabled.\n",
237 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted %s %d",
238 filt_name, auto_count++);
242 inst_name, filt_args,
NULL, graph)) < 0)
249 if ( ((link = filt_ctx->
inputs[0]) &&
251 ((link = filt_ctx->
outputs[0]) &&
255 "Impossible to convert between the formats supported by the filter "
261 (((link = filt_ctx->
inputs[0]) &&
263 ((link = filt_ctx->
outputs[0]) &&
267 "Impossible to convert between the channel layouts formats supported by the filter "
284 int scaler_count = 0, resampler_count = 0;
286 for (j = 0; j < 2; j++) {
307 for (j = 0; j < filter->
nb_inputs; j++) {
319 snprintf(filt_args,
sizeof(filt_args),
"0:0:%s",
335 if (!formats || !chlayouts || !samplerates)
339 int convert_needed = 0;
359 if (convert_needed) {
363 char scale_args[256];
367 switch (link->
type) {
371 "not present, cannot convert pixel formats.\n");
375 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted scaler %d",
377 av_strlcpy(scale_args,
"0:0",
sizeof(scale_args));
379 av_strlcat(scale_args,
":",
sizeof(scale_args));
383 inst_name, scale_args,
NULL,
390 "not present, cannot convert audio formats.\n");
394 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted resampler %d",
408 inlink = convert->
inputs[0];
428 "Impossible to convert between the formats supported by the filter "
467 " the link between filters %s and %s.\n", link->
src->
name,
476 "the link between filters %s and %s.\n", link->
src->
name,
495 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
497 for (i = 0; i < filter->nb_inputs; i++) { \
498 AVFilterLink *link = filter->inputs[i]; \
501 if (!link->out_ ## list || link->out_ ## list->nb != 1) \
503 fmt = link->out_ ## list->var[0]; \
505 for (j = 0; j < filter->nb_outputs; j++) { \
506 AVFilterLink *out_link = filter->outputs[j]; \
509 if (link->type != out_link->type || \
510 out_link->in_ ## list->nb == 1) \
512 fmts = out_link->in_ ## list; \
514 if (!out_link->in_ ## list->nb) { \
515 add_format(&out_link->in_ ##list, fmt); \
519 for (k = 0; k < out_link->in_ ## list->nb; k++) \
520 if (fmts->var[k] == fmt) { \
521 fmts->var[0] = fmt; \
532 int i, j, k, ret = 0;
562 for (i = 0; i < filter->
nb_inputs; i++) {
576 int best_idx, best_diff = INT_MAX;
585 if (diff < best_diff) {
603 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
604 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
605 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
606 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
607 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
608 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
609 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
642 for (i = 0; i < filter->
nb_inputs; i++) {
654 int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
665 int count_diff = out_channels - in_channels;
666 int matched_channels, extra_channels;
671 uint64_t cmp0 = ch_subst[k][0];
672 uint64_t cmp1 = ch_subst[k][1];
673 if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
674 (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
675 in_chlayout &= ~cmp0;
676 out_chlayout &= ~cmp1;
685 (out_chlayout & AV_CH_LOW_FREQUENCY))
687 in_chlayout &= ~AV_CH_LOW_FREQUENCY;
688 out_chlayout &= ~AV_CH_LOW_FREQUENCY;
694 score += 10 * matched_channels - 5 * extra_channels;
696 if (score > best_score ||
697 (count_diff < best_count_diff && score == best_score)) {
700 best_count_diff = count_diff;
724 for (i = 0; i < filter->
nb_inputs; i++) {
739 int best_idx = -1, best_score = INT_MIN;
757 if (bps == 4 && out_bps == 8) {
763 score = -abs(out_bps - bps);
767 if (score > best_score) {
886 if (f->
nb_inputs > INT_MAX - sink_links_count)
891 sinks =
av_calloc(sink_links_count,
sizeof(*sinks));
931 snprintf(name,
sizeof(name),
"auto-inserted fifo %d", fifo_count++);
983 if(!strcmp(target,
"all") || (filter->
name && !strcmp(target, filter->
name)) || !strcmp(target, filter->
filter->
name)){
986 if((flags & AVFILTER_CMD_FLAG_ONE) || r<0)
1004 if(filter && (!strcmp(target,
"all") || !strcmp(target, filter->
name) || !strcmp(target, filter->
filter->
name))){
1006 while (*queue && (*queue)->
time <= ts)
1007 queue = &(*queue)->
next;
1012 (*queue)->time = ts;
1013 (*queue)->flags =
flags;
1014 (*queue)->next = next;
1029 int parent = (index - 1) >> 1;
1030 if (links[parent]->current_pts >= link->
current_pts)
1032 links[
index] = links[parent];
1036 links[
index] = link;
1046 int child = 2 * index + 1;
1054 links[
index] = links[child];
1058 links[
index] = link;