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 
  140     graph->filter_count_unused = graph->
nb_filters;
 
  144     filter->
graph = graph;
 
  151                                  const char *
name, 
const char *
args, 
void *opaque,
 
  211     graph->filter_count_unused = graph->
nb_filters;
 
  241                        "Input pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any source\n",
 
  251                        "Output pad \"%s\" with type %s of the filter instance \"%s\" of %s not connected to any destination\n",
 
  407     if (is_sample_rate) {
 
  439     int scaler_count = 0, resampler_count = 0;
 
  440     int count_queried = 0;        
 
  441     int count_merged = 0;         
 
  442     int count_already_merged = 0; 
 
  443     int count_delayed = 0;        
 
  453         if (ret < 0 && ret != 
AVERROR(EAGAIN))
 
  456         count_queried += ret >= 0;
 
  463         for (j = 0; j < filter->
nb_inputs; j++) {
 
  465             int convert_needed = 0;
 
  484 #define MERGE_DISPATCH(field, statement)                                     \ 
  485             if (!(link->in_ ## field && link->out_ ## field)) {              \ 
  487             } else if (link->in_ ## field == link->out_ ## field) {          \ 
  488                 count_already_merged++;                                      \ 
  489             } else if (!convert_needed) {                                    \ 
  511 #undef MERGE_DISPATCH 
  513             if (convert_needed) {
 
  517                 char scale_args[256];
 
  521                 switch (link->
type) {
 
  525                                "not present, cannot convert pixel formats.\n");
 
  529                     snprintf(inst_name, 
sizeof(inst_name), 
"auto-inserted scaler %d",
 
  540                                "not present, cannot convert audio formats.\n");
 
  544                     snprintf(inst_name, 
sizeof(inst_name), 
"auto-inserted resampler %d",
 
  546                     scale_args[0] = 
'\0';
 
  548                         snprintf(scale_args, 
sizeof(scale_args), 
"%s",
 
  565                 inlink  = convert->
inputs[0];
 
  567                 av_assert0( inlink-> in_formats->refcount > 0);
 
  569                 av_assert0(outlink-> in_formats->refcount > 0);
 
  572                     av_assert0( inlink-> in_samplerates->refcount > 0);
 
  574                     av_assert0(outlink-> in_samplerates->refcount > 0);
 
  576                     av_assert0( inlink-> in_channel_layouts->refcount > 0);
 
  578                     av_assert0(outlink-> in_channel_layouts->refcount > 0);
 
  599                            "Impossible to convert between the formats supported by the filter " 
  608            "%d queried, %d merged, %d already done, %d delayed\n",
 
  609            count_queried, count_merged, count_already_merged, count_delayed);
 
  618         if (count_queried || count_merged)
 
  626                "The following filters could not choose their formats: %s\n" 
  627                "Consider inserting the (a)format filter near their input or " 
  628                "output.\n", bp.str);
 
  661                    " the link between filters %s and %s.\n", link->
src->
name,
 
  670                    " the link between filters %s and %s.\n", link->
src->
name,
 
  674                        "supported, try specifying a channel layout using " 
  675                        "'aformat=channel_layouts=something'.\n");
 
  696 #define REDUCE_FORMATS(fmt_type, list_type, list, var, nb, add_format) \ 
  698     for (i = 0; i < filter->nb_inputs; i++) {                          \ 
  699         AVFilterLink *link = filter->inputs[i];                        \ 
  702         if (!link->out_ ## list || link->out_ ## list->nb != 1)        \ 
  704         fmt = link->out_ ## list->var[0];                              \ 
  706         for (j = 0; j < filter->nb_outputs; j++) {                     \ 
  707             AVFilterLink *out_link = filter->outputs[j];               \ 
  710             if (link->type != out_link->type ||                        \ 
  711                 out_link->in_ ## list->nb == 1)                        \ 
  713             fmts = out_link->in_ ## list;                              \ 
  715             if (!out_link->in_ ## list->nb) {                          \ 
  716                 add_format(&out_link->in_ ##list, fmt);                \ 
  721             for (k = 0; k < out_link->in_ ## list->nb; k++)            \ 
  722                 if (fmts->var[k] == fmt) {                             \ 
  723                     fmts->var[0]  = fmt;                               \ 
  734     int i, j, k, 
ret = 0;
 
  742     for (i = 0; i < filter->
nb_inputs; i++) {
 
  799     for (i = 0; i < filter->
nb_inputs; i++) {
 
  813         int best_idx, best_diff = INT_MAX;
 
  822             if (diff < best_diff) {
 
  840 #define CH_CENTER_PAIR (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER) 
  841 #define CH_FRONT_PAIR  (AV_CH_FRONT_LEFT           | AV_CH_FRONT_RIGHT) 
  842 #define CH_STEREO_PAIR (AV_CH_STEREO_LEFT          | AV_CH_STEREO_RIGHT) 
  843 #define CH_WIDE_PAIR   (AV_CH_WIDE_LEFT            | AV_CH_WIDE_RIGHT) 
  844 #define CH_SIDE_PAIR   (AV_CH_SIDE_LEFT            | AV_CH_SIDE_RIGHT) 
  845 #define CH_DIRECT_PAIR (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT) 
  846 #define CH_BACK_PAIR   (AV_CH_BACK_LEFT            | AV_CH_BACK_RIGHT) 
  879     for (i = 0; i < filter->
nb_inputs; i++) {
 
  891         int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX;
 
  902             int count_diff        = out_channels - in_channels;
 
  903             int matched_channels, extra_channels;
 
  915                 score -= 10000 + 
FFABS(out_channels - in_channels) +
 
  916                          (in_channels > out_channels ? 10000 : 0);
 
  917                 in_chlayout = out_chlayout = 0;
 
  924                 uint64_t cmp0 = ch_subst[k][0];
 
  925                 uint64_t cmp1 = ch_subst[k][1];
 
  926                 if (( in_chlayout & cmp0) && (!(out_chlayout & cmp0)) &&
 
  927                     (out_chlayout & cmp1) && (!( in_chlayout & cmp1))) {
 
  928                     in_chlayout  &= ~cmp0;
 
  929                     out_chlayout &= ~cmp1;
 
  938                 (out_chlayout & AV_CH_LOW_FREQUENCY))
 
  940             in_chlayout  &= ~AV_CH_LOW_FREQUENCY;
 
  941             out_chlayout &= ~AV_CH_LOW_FREQUENCY;
 
  947             score += 10 * matched_channels - 5 * extra_channels;
 
  949             if (score > best_score ||
 
  950                 (count_diff < best_count_diff && score == best_score)) {
 
  953                 best_count_diff = count_diff;
 
  977     for (i = 0; i < filter->
nb_inputs; i++) {
 
  992         int best_idx = -1, best_score = INT_MIN;
 
 1010             if (bps == 4 && out_bps == 8) {
 
 1016             score = -abs(out_bps - bps);
 
 1020             if (score > best_score) {
 
 1050                 for (j = 0; j < filter->
nb_inputs; j++){
 
 1126     int sink_links_count = 0, 
n = 0;
 
 1141             if (f->
nb_inputs > INT_MAX - sink_links_count)
 
 1146     sinks = 
av_calloc(sink_links_count, 
sizeof(*sinks));
 
 1186             snprintf(name, 
sizeof(name), 
"auto-inserted fifo %d", fifo_count++);
 
 1238         if (!strcmp(target, 
"all") || (filter->
name && !strcmp(target, filter->
name)) || !strcmp(target, filter->
filter->
name)) {
 
 1241                 if ((flags & AVFILTER_CMD_FLAG_ONE) || r < 0)
 
 1259         if(filter && (!strcmp(target, 
"all") || !strcmp(target, filter->
name) || !strcmp(target, filter->
filter->
name))){
 
 1261             while (*queue && (*queue)->
time <= ts)
 
 1262                 queue = &(*queue)->
next;
 
 1267             (*queue)->time    = ts;
 
 1268             (*queue)->flags   = 
flags;
 
 1269             (*queue)->next    = 
next;
 
 1286         int parent = (index - 1) >> 1;
 
 1287         if (links[parent]->current_pts >= link->
current_pts)
 
 1289         links[
index] = links[parent];
 
 1293     links[
index] = link;
 
 1305         int child = 2 * index + 1;
 
 1317     links[
index] = link;