libavfilter/avfiltergraph.c:208: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `pick_format`.

libavfilter/avfiltergraph.c:208:13: Call
206. 
207.         for (j = 0; j < filter->input_count; j++)
208.             pick_format(filter->inputs[j]);
                 ^
209.         for (j = 0; j < filter->output_count; j++)
210.             pick_format(filter->outputs[j]);

libavfilter/avfiltergraph.c:188:1: Parameter `link->out_formats->refcount`
  186. }
  187. 
  188. static void pick_format(AVFilterLink *link)
       ^
  189. {
  190.     if (!link || !link->in_formats)

libavfilter/avfiltergraph.c:208:13: Call
206. 
207.         for (j = 0; j < filter->input_count; j++)
208.             pick_format(filter->inputs[j]);
                 ^
209.         for (j = 0; j < filter->output_count; j++)
210.             pick_format(filter->outputs[j]);

libavfilter/avfiltergraph.c:188:1: Parameter `link->out_formats->refcount`
  186. }
  187. 
  188. static void pick_format(AVFilterLink *link)
       ^
  189. {
  190.     if (!link || !link->in_formats)

libavfilter/avfiltergraph.c:197:5: Call
  195. 
  196.     avfilter_formats_unref(&link->in_formats);
  197.     avfilter_formats_unref(&link->out_formats);
           ^
  198. }
  199. 

libavfilter/formats.c:137:1: <LHS trace>
135. }
136. 
137. void avfilter_formats_unref(AVFilterFormats **ref)
     ^
138. {
139.     int idx;

libavfilter/formats.c:137:1: Parameter `(*ref)->refcount`
    135. }
    136. 
    137. void avfilter_formats_unref(AVFilterFormats **ref)
         ^
    138. {
    139.     int idx;

libavfilter/formats.c:144:11: Call
    142.         return;
    143. 
    144.     idx = find_ref_index(ref);
                   ^
    145. 
    146.     if(idx >= 0)

libavfilter/formats.c:128:1: Parameter `(*ref)->refcount`
      126. }
      127. 
      128. static int find_ref_index(AVFilterFormats **ref)
           ^
      129. {
      130.     int i;

libavfilter/formats.c:150:9: Binary operation: ([0, +oo] - 1):unsigned32 by call to `pick_format` 
    148.             sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1));
    149. 
    150.     if(!--(*ref)->refcount) {
                 ^
    151.         av_free((*ref)->formats);
    152.         av_free((*ref)->refs);

void avfilter_formats_unref(AVFilterFormats **ref)
{
    int idx;
    if (!*ref)
        return;
    idx = find_ref_index(ref);
    if(idx >= 0)
        memmove((*ref)->refs + idx, (*ref)->refs + idx+1,
            sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1));
    if(!--(*ref)->refcount) {
        av_free((*ref)->formats);
        av_free((*ref)->refs);
        av_free(*ref);
    }
    *ref = NULL;
}
['static void pick_formats(AVFilterGraph *graph)\n{\n    int i, j;\n    for (i = 0; i < graph->filter_count; i++) {\n        AVFilterContext *filter = graph->filters[i];\n        for (j = 0; j < filter->input_count; j++)\n            pick_format(filter->inputs[j]);\n        for (j = 0; j < filter->output_count; j++)\n            pick_format(filter->outputs[j]);\n    }\n}', 'static void pick_format(AVFilterLink *link)\n{\n    if (!link || !link->in_formats)\n        return;\n    link->in_formats->format_count = 1;\n    link->format = link->in_formats->formats[0];\n    avfilter_formats_unref(&link->in_formats);\n    avfilter_formats_unref(&link->out_formats);\n}', 'void avfilter_formats_unref(AVFilterFormats **ref)\n{\n    int idx;\n    if (!*ref)\n        return;\n    idx = find_ref_index(ref);\n    if(idx >= 0)\n        memmove((*ref)->refs + idx, (*ref)->refs + idx+1,\n            sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1));\n    if(!--(*ref)->refcount) {\n        av_free((*ref)->formats);\n        av_free((*ref)->refs);\n        av_free(*ref);\n    }\n    *ref = NULL;\n}', 'static int find_ref_index(AVFilterFormats **ref)\n{\n    int i;\n    for(i = 0; i < (*ref)->refcount; i ++)\n        if((*ref)->refs[i] == ref)\n            return i;\n    return -1;\n}']