40 #define OFFSET(x) offsetof(AVFilterGraph, x)
41 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
46 {
"threads",
"Maximum number of threads",
OFFSET(nb_threads),
48 {
"scale_sws_opts" ,
"default scale filter options" ,
OFFSET(scale_sws_opts) ,
50 {
"aresample_swr_opts" ,
"default aresample filter options" ,
OFFSET(aresample_swr_opts) ,
98 if (graph->
filters[i] == filter) {
112 while ((*graph)->nb_filters)
119 av_freep(&(*graph)->scale_sws_opts);
120 av_freep(&(*graph)->aresample_swr_opts);
121 av_freep(&(*graph)->resample_lavr_opts);
127 #if FF_API_AVFILTER_OPEN
139 graph->filter_count_unused = graph->
nb_filters;
142 filter->
graph = graph;
149 const char *
name,
const char *
args,
void *opaque,
204 graph->filter_count_unused = graph->
nb_filters;
233 "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
243 "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
376 int scaler_count = 0, resampler_count = 0;
377 int count_queried = 0;
378 int count_merged = 0;
379 int count_already_merged = 0;
380 int count_delayed = 0;
390 if (ret < 0 && ret !=
AVERROR(EAGAIN))
393 count_queried += ret >= 0;
400 for (j = 0; j < filter->
nb_inputs; j++) {
402 int convert_needed = 0;
407 #define MERGE_DISPATCH(field, statement) \
408 if (!(link->in_ ## field && link->out_ ## field)) { \
410 } else if (link->in_ ## field == link->out_ ## field) { \
411 count_already_merged++; \
433 #undef MERGE_DISPATCH
435 if (convert_needed) {
439 char scale_args[256];
443 switch (link->
type) {
447 "not present, cannot convert pixel formats.\n");
451 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted scaler %d",
462 "not present, cannot convert audio formats.\n");
466 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted resampler %d",
468 scale_args[0] =
'\0';
470 snprintf(scale_args,
sizeof(scale_args),
"%s",
485 inlink = convert->
inputs[0];
505 "Impossible to convert between the formats supported by the filter "
514 "%d queried, %d merged, %d already done, %d delayed\n",
515 count_queried, count_merged, count_already_merged, count_delayed);
524 if (count_queried || count_merged)
532 "The following filters could not choose their formats: %s\n"
533 "Consider inserting the (a)format filter near their input or "
534 "output.\n", bp.str);
567 " the link between filters %s and %s.\n", link->
src->
name,
576 " the link between filters %s and %s.\n", link->
src->
name,
598 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
600 for (i = 0; i < filter->nb_inputs; i++) { \
601 AVFilterLink *link = filter->inputs[i]; \
604 if (!link->out_ ## list || link->out_ ## list->nb != 1) \
606 fmt = link->out_ ## list->var[0]; \
608 for (j = 0; j < filter->nb_outputs; j++) { \
609 AVFilterLink *out_link = filter->outputs[j]; \
612 if (link->type != out_link->type || \
613 out_link->in_ ## list->nb == 1) \
615 fmts = out_link->in_ ## list; \
617 if (!out_link->in_ ## list->nb) { \
618 add_format(&out_link->in_ ##list, fmt); \
622 for (k = 0; k < out_link->in_ ## list->nb; k++) \
623 if (fmts->var[k] == fmt) { \
624 fmts->var[0] = fmt; \
635 int i, j, k,
ret = 0;
643 for (i = 0; i < filter->
nb_inputs; i++) {
699 for (i = 0; i < filter->
nb_inputs; i++) {
713 int best_idx, best_diff = INT_MAX;
722 if (diff < best_diff) {
740 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
741 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
742 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
743 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
744 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
745 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
746 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
779 for (i = 0; i < filter->
nb_inputs; i++) {
791 int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
802 int count_diff = out_channels - in_channels;
803 int matched_channels, extra_channels;
815 score -= 10000 +
FFABS(out_channels - in_channels) +
816 (in_channels > out_channels ? 10000 : 0);
817 in_chlayout = out_chlayout = 0;
824 uint64_t cmp0 = ch_subst[k][0];
825 uint64_t cmp1 = ch_subst[k][1];
826 if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
827 (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
828 in_chlayout &= ~cmp0;
829 out_chlayout &= ~cmp1;
838 (out_chlayout & AV_CH_LOW_FREQUENCY))
840 in_chlayout &= ~AV_CH_LOW_FREQUENCY;
841 out_chlayout &= ~AV_CH_LOW_FREQUENCY;
847 score += 10 * matched_channels - 5 * extra_channels;
849 if (score > best_score ||
850 (count_diff < best_count_diff && score == best_score)) {
853 best_count_diff = count_diff;
877 for (i = 0; i < filter->
nb_inputs; i++) {
892 int best_idx = -1, best_score = INT_MIN;
910 if (bps == 4 && out_bps == 8) {
916 score = -abs(out_bps - bps);
920 if (score > best_score) {
1026 int sink_links_count = 0,
n = 0;
1041 if (f->
nb_inputs > INT_MAX - sink_links_count)
1046 sinks =
av_calloc(sink_links_count,
sizeof(*sinks));
1086 snprintf(name,
sizeof(name),
"auto-inserted fifo %d", fifo_count++);
1138 if (!strcmp(target,
"all") || (filter->
name && !strcmp(target, filter->
name)) || !strcmp(target, filter->
filter->
name)) {
1141 if ((flags & AVFILTER_CMD_FLAG_ONE) || r < 0)
1159 if(filter && (!strcmp(target,
"all") || !strcmp(target, filter->
name) || !strcmp(target, filter->
filter->
name))){
1161 while (*queue && (*queue)->
time <= ts)
1162 queue = &(*queue)->
next;
1167 (*queue)->time = ts;
1168 (*queue)->flags =
flags;
1169 (*queue)->next =
next;
1184 int parent = (index - 1) >> 1;
1185 if (links[parent]->current_pts >= link->
current_pts)
1187 links[
index] = links[parent];
1191 links[
index] = link;
1201 int child = 2 * index + 1;
1213 links[
index] = link;