40 #define OFFSET(x) offsetof(AVFilterGraph, x)
41 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
46 {
"threads",
"Maximum number of threads",
OFFSET(nb_threads),
93 if (graph->
filters[i] == filter) {
107 while ((*graph)->nb_filters)
112 av_freep(&(*graph)->scale_sws_opts);
113 av_freep(&(*graph)->resample_lavr_opts);
119 #if FF_API_AVFILTER_OPEN
136 filter->
graph = graph;
143 const char *
name,
const char *args,
void *opaque,
226 "Input pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any source\n",
235 "Output pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any destination\n",
281 int scaler_count = 0, resampler_count = 0;
295 for (j = 0; j < filter->
nb_inputs; j++) {
297 int convert_needed = 0;
317 if (convert_needed) {
321 char scale_args[256];
325 switch (link->
type) {
329 "not present, cannot convert pixel formats.\n");
333 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted scaler %d",
344 "not present, cannot convert audio formats.\n");
348 snprintf(inst_name,
sizeof(inst_name),
"auto-inserted resampler %d",
350 scale_args[0] =
'\0';
352 snprintf(scale_args,
sizeof(scale_args),
"%s",
355 inst_name, scale_args,
367 inlink = convert->
inputs[0];
387 "Impossible to convert between the formats supported by the filter "
409 " the link between filters %s and %s.\n", link->
src->
name,
418 "the link between filters %s and %s.\n", link->
src->
name,
436 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \
438 for (i = 0; i < filter->nb_inputs; i++) { \
439 AVFilterLink *link = filter->inputs[i]; \
442 if (!link->out_ ## list || link->out_ ## list->nb != 1) \
444 fmt = link->out_ ## list->var[0]; \
446 for (j = 0; j < filter->nb_outputs; j++) { \
447 AVFilterLink *out_link = filter->outputs[j]; \
450 if (link->type != out_link->type || \
451 out_link->in_ ## list->nb == 1) \
453 fmts = out_link->in_ ## list; \
455 if (!out_link->in_ ## list->nb) { \
456 add_format(&out_link->in_ ##list, fmt); \
460 for (k = 0; k < out_link->in_ ## list->nb; k++) \
461 if (fmts->var[k] == fmt) { \
462 fmts->var[0] = fmt; \
473 int i, j, k, ret = 0;
503 for (i = 0; i < filter->
nb_inputs; i++) {
517 int best_idx, best_diff = INT_MAX;
526 if (diff < best_diff) {
544 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)
545 #define CH_FRONT_PAIR (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)
546 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)
547 #define CH_WIDE_PAIR (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)
548 #define CH_SIDE_PAIR (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)
549 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)
550 #define CH_BACK_PAIR (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)
583 for (i = 0; i < filter->
nb_inputs; i++) {
595 int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
606 int count_diff = out_channels - in_channels;
607 int matched_channels, extra_channels;
612 uint64_t cmp0 = ch_subst[k][0];
613 uint64_t cmp1 = ch_subst[k][1];
614 if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
615 (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
616 in_chlayout &= ~cmp0;
617 out_chlayout &= ~cmp1;
626 (out_chlayout & AV_CH_LOW_FREQUENCY))
628 in_chlayout &= ~AV_CH_LOW_FREQUENCY;
629 out_chlayout &= ~AV_CH_LOW_FREQUENCY;
635 score += 10 * matched_channels - 5 * extra_channels;
637 if (score > best_score ||
638 (count_diff < best_count_diff && score == best_score)) {
641 best_count_diff = count_diff;
665 for (i = 0; i < filter->
nb_inputs; i++) {
680 int best_idx = -1, best_score = INT_MIN;
698 if (bps == 4 && out_bps == 8) {
704 score = -abs(out_bps - bps);
708 if (score > best_score) {
795 snprintf(name,
sizeof(name),
"auto-inserted fifo %d", fifo_count++);