36 #define OFFSET(x) offsetof(AVFilterGraph,x)
66 if (graph->
filters[i] == filter) {
80 while ((*graph)->nb_filters)
85 av_freep(&(*graph)->aresample_swr_opts);
86 av_freep(&(*graph)->resample_lavr_opts);
91 #if FF_API_AVFILTER_OPEN
103 graph->filter_count_unused = graph->
nb_filters;
106 filter->
graph = graph;
113 const char *
name,
const char *
args,
void *opaque,
160 graph->filter_count_unused = graph->
nb_filters;
189 "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
199 "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
332 int scaler_count = 0, resampler_count = 0;
333 int count_queried = 0;
334 int count_merged = 0;
335 int count_already_merged = 0;
336 int count_delayed = 0;
346 if (ret < 0 && ret !=
AVERROR(EAGAIN))
349 count_queried += ret >= 0;
356 for (j = 0; j < filter->
nb_inputs; j++) {
358 int convert_needed = 0;
363 #define MERGE_DISPATCH(field, statement) \
364 if (!(link->in_ ## field && link->out_ ## field)) { \
366 } else if (link->in_ ## field == link->out_ ## field) { \
367 count_already_merged++; \
389 #undef MERGE_DISPATCH
391 if (convert_needed) {
395 char scale_args[256];
399 switch (link->
type) {
403 "not present, cannot convert pixel formats.\n");
407 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted scaler %d",
418 "not present, cannot convert audio formats.\n");
422 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted resampler %d",
424 scale_args[0] =
'\0';
426 snprintf(scale_args,
sizeof(scale_args),
"%s",
441 inlink = convert->
inputs[0];
461 "Impossible to convert between the formats supported by the filter "
470 "%d queried, %d merged, %d already done, %d delayed\n",
471 count_queried, count_merged, count_already_merged, count_delayed);
480 if (count_queried || count_merged)
488 "The following filters could not choose their formats: %s\n"
489 "Consider inserting the (a)format filter near their input or "
490 "output.\n", bp.str);
523 " the link between filters %s and %s.\n", link->
src->
name,
532 " the link between filters %s and %s.\n", link->
src->
name,
554 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
556 for (i = 0; i < filter->nb_inputs; i++) { \
557 AVFilterLink *link = filter->inputs[i]; \
560 if (!link->out_ ## list || link->out_ ## list->nb != 1) \
562 fmt = link->out_ ## list->var[0]; \
564 for (j = 0; j < filter->nb_outputs; j++) { \
565 AVFilterLink *out_link = filter->outputs[j]; \
568 if (link->type != out_link->type || \
569 out_link->in_ ## list->nb == 1) \
571 fmts = out_link->in_ ## list; \
573 if (!out_link->in_ ## list->nb) { \
574 add_format(&out_link->in_ ##list, fmt); \
578 for (k = 0; k < out_link->in_ ## list->nb; k++) \
579 if (fmts->var[k] == fmt) { \
580 fmts->var[0] = fmt; \
591 int i, j, k,
ret = 0;
599 for (i = 0; i < filter->
nb_inputs; i++) {
655 for (i = 0; i < filter->
nb_inputs; i++) {
669 int best_idx, best_diff = INT_MAX;
678 if (diff < best_diff) {
696 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
697 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
698 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
699 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
700 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
701 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
702 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
735 for (i = 0; i < filter->
nb_inputs; i++) {
747 int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
758 int count_diff = out_channels - in_channels;
759 int matched_channels, extra_channels;
771 score -= 10000 +
FFABS(out_channels - in_channels) +
772 (in_channels > out_channels ? 10000 : 0);
773 in_chlayout = out_chlayout = 0;
780 uint64_t cmp0 = ch_subst[k][0];
781 uint64_t cmp1 = ch_subst[k][1];
782 if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
783 (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
784 in_chlayout &= ~cmp0;
785 out_chlayout &= ~cmp1;
794 (out_chlayout & AV_CH_LOW_FREQUENCY))
796 in_chlayout &= ~AV_CH_LOW_FREQUENCY;
797 out_chlayout &= ~AV_CH_LOW_FREQUENCY;
803 score += 10 * matched_channels - 5 * extra_channels;
805 if (score > best_score ||
806 (count_diff < best_count_diff && score == best_score)) {
809 best_count_diff = count_diff;
833 for (i = 0; i < filter->
nb_inputs; i++) {
848 int best_idx = -1, best_score = INT_MIN;
866 if (bps == 4 && out_bps == 8) {
872 score = -abs(out_bps - bps);
876 if (score > best_score) {
982 int sink_links_count = 0,
n = 0;
997 if (f->
nb_inputs > INT_MAX - sink_links_count)
1002 sinks =
av_calloc(sink_links_count,
sizeof(*sinks));
1042 snprintf(name,
sizeof(name),
"auto-inserted fifo %d", fifo_count++);
1094 if (!strcmp(target,
"all") || (filter->
name && !strcmp(target, filter->
name)) || !strcmp(target, filter->
filter->
name)) {
1097 if ((flags & AVFILTER_CMD_FLAG_ONE) || r < 0)
1115 if(filter && (!strcmp(target,
"all") || !strcmp(target, filter->
name) || !strcmp(target, filter->
filter->
name))){
1117 while (*queue && (*queue)->
time <= ts)
1118 queue = &(*queue)->
next;
1123 (*queue)->time = ts;
1124 (*queue)->flags =
flags;
1125 (*queue)->next =
next;
1140 int parent = (index - 1) >> 1;
1141 if (links[parent]->current_pts >= link->
current_pts)
1143 links[
index] = links[parent];
1147 links[
index] = link;
1157 int child = 2 * index + 1;
1169 links[
index] = link;