35 #define OFFSET(x) offsetof(AVFilterGraph,x)
65 for (; (*graph)->filter_count > 0; (*graph)->filter_count--)
69 av_freep(&(*graph)->aresample_swr_opts);
70 av_freep(&(*graph)->resample_lavr_opts);
89 const char *
name,
const char *args,
void *opaque,
135 "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
145 "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
244 int scaler_count = 0, resampler_count = 0;
246 for (j = 0; j < 2; j++) {
267 for (j = 0; j < filter->
nb_inputs; j++) {
269 int convert_needed = 0;
289 if (convert_needed) {
293 char scale_args[256];
297 switch (link->
type) {
301 "not present, cannot convert pixel formats.\n");
305 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted scaler %d",
310 snprintf(scale_args,
sizeof(scale_args),
"0:0");
313 inst_name, scale_args,
NULL,
320 "not present, cannot convert audio formats.\n");
324 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted resampler %d",
326 scale_args[0] =
'\0';
328 snprintf(scale_args,
sizeof(scale_args),
"%s",
343 inlink = convert->
inputs[0];
363 "Impossible to convert between the formats supported by the filter "
401 " the link between filters %s and %s.\n", link->
src->
name,
410 " the link between filters %s and %s.\n", link->
src->
name,
432 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
434 for (i = 0; i < filter->nb_inputs; i++) { \
435 AVFilterLink *link = filter->inputs[i]; \
438 if (!link->out_ ## list || link->out_ ## list->nb != 1) \
440 fmt = link->out_ ## list->var[0]; \
442 for (j = 0; j < filter->nb_outputs; j++) { \
443 AVFilterLink *out_link = filter->outputs[j]; \
446 if (link->type != out_link->type || \
447 out_link->in_ ## list->nb == 1) \
449 fmts = out_link->in_ ## list; \
451 if (!out_link->in_ ## list->nb) { \
452 add_format(&out_link->in_ ##list, fmt); \
456 for (k = 0; k < out_link->in_ ## list->nb; k++) \
457 if (fmts->var[k] == fmt) { \
458 fmts->var[0] = fmt; \
469 int i, j, k, ret = 0;
477 for (i = 0; i < filter->
nb_inputs; i++) {
533 for (i = 0; i < filter->
nb_inputs; i++) {
547 int best_idx, best_diff = INT_MAX;
556 if (diff < best_diff) {
574 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
575 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
576 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
577 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
578 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
579 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
580 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
613 for (i = 0; i < filter->
nb_inputs; i++) {
625 int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
636 int count_diff = out_channels - in_channels;
637 int matched_channels, extra_channels;
649 score -= 10000 +
FFABS(out_channels - in_channels) +
650 (in_channels > out_channels ? 10000 : 0);
651 in_chlayout = out_chlayout = 0;
660 if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
661 (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
662 in_chlayout &= ~cmp0;
663 out_chlayout &= ~cmp1;
672 (out_chlayout & AV_CH_LOW_FREQUENCY))
674 in_chlayout &= ~AV_CH_LOW_FREQUENCY;
675 out_chlayout &= ~AV_CH_LOW_FREQUENCY;
681 score += 10 * matched_channels - 5 * extra_channels;
683 if (score > best_score ||
684 (count_diff < best_count_diff && score == best_score)) {
687 best_count_diff = count_diff;
711 for (i = 0; i < filter->
nb_inputs; i++) {
726 int best_idx = -1, best_score = INT_MIN;
744 if (bps == 4 && out_bps == 8) {
750 score = -abs(out_bps - bps);
754 if (score > best_score) {
873 if (f->
nb_inputs > INT_MAX - sink_links_count)
878 sinks =
av_calloc(sink_links_count,
sizeof(*sinks));
918 snprintf(name,
sizeof(name),
"auto-inserted fifo %d", fifo_count++);
970 if(!strcmp(target,
"all") || (filter->
name && !strcmp(target, filter->
name)) || !strcmp(target, filter->
filter->
name)){
973 if((flags & AVFILTER_CMD_FLAG_ONE) || r<0)
991 if(filter && (!strcmp(target,
"all") || !strcmp(target, filter->
name) || !strcmp(target, filter->
filter->
name))){
993 while (*queue && (*queue)->
time <= ts)
994 queue = &(*queue)->
next;
1000 (*queue)->flags =
flags;
1001 (*queue)->next = next;
1016 int parent = (index - 1) >> 1;
1017 if (links[parent]->current_pts >= link->
current_pts)
1019 links[
index] = links[parent];
1023 links[
index] = link;
1033 int child = 2 * index + 1;
1041 links[
index] = links[child];
1045 links[
index] = link;