AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
{
    AVFilterFormats *ret;
    unsigned i, j, k = 0;
    ret = av_mallocz(sizeof(AVFilterFormats));
    /* merge list of formats */
    ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count,
                                                           b->format_count));
    for(i = 0; i < a->format_count; i ++)
        for(j = 0; j < b->format_count; j ++)
            if(a->formats[i] == b->formats[j])
                ret->formats[k++] = a->formats[i];
    ret->format_count = k;
    /* check that there was at least one common format */
    if(!ret->format_count) {
        av_free(ret->formats);
        av_free(ret);
        return NULL;
    }
    ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
    merge_ref(ret, a);
    merge_ref(ret, b);
    return ret;
}
AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
{
    AVFilterFormats *ret;
    unsigned i, j, k = 0;
    ret = av_mallocz(sizeof(AVFilterFormats));
    
    ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count,
                                                           b->format_count));
    for(i = 0; i < a->format_count; i ++)
        for(j = 0; j < b->format_count; j ++)
            if(a->formats[i] == b->formats[j])
                ret->formats[k++] = a->formats[i];
    ret->format_count = k;
    
    if(!ret->format_count) {
        av_free(ret->formats);
        av_free(ret);
        return NULL;
    }
    ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
    merge_ref(ret, a);
    merge_ref(ret, b);
    return ret;
}
AVFilterFormats *FUNC_0(AVFilterFormats *a, AVFilterFormats *b)
{
    AVFilterFormats *ret;
    unsigned VAR_0, VAR_1, VAR_2 = 0;
    ret = av_mallocz(sizeof(AVFilterFormats));
    
    ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count,
                                                           b->format_count));
    for(VAR_0 = 0; VAR_0 < a->format_count; VAR_0 ++)
        for(VAR_1 = 0; VAR_1 < b->format_count; VAR_1 ++)
            if(a->formats[VAR_0] == b->formats[VAR_1])
                ret->formats[VAR_2++] = a->formats[VAR_0];
    ret->format_count = VAR_2;
    
    if(!ret->format_count) {
        av_free(ret->formats);
        av_free(ret);
        return NULL;
    }
    ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
    merge_ref(ret, a);
    merge_ref(ret, b);
    return ret;
}
AVFilterFormats *FUNC_0(AVFilterFormats *a, AVFilterFormats *b)
{ AVFilterFormats *ret; unsigned VAR_0, VAR_1, VAR_2 = 0; ret = av_mallocz(sizeof(AVFilterFormats)); ret->formats = av_malloc(sizeof(*ret->formats) * FFMIN(a->format_count,
b->format_count)); for(VAR_0 = 0; VAR_0 < a->format_count; VAR_0 ++) for(VAR_1 = 0; VAR_1 < b->format_count; VAR_1 ++) if(a->formats[VAR_0] == b->formats[VAR_1])
ret->formats[VAR_2++] = a->formats[VAR_0]; ret->format_count = VAR_2; if(!ret->format_count) { av_free(ret->formats); av_free(ret); return NULL; } ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount)); merge_ref(ret, a); merge_ref(ret, b); return ret; }