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];



    /* check that there was at least one common format */

    if(!(ret->format_count = k)) {

        av_free(ret->formats);

        av_free(ret);

        return NULL;

    }



    /* merge and update all the references */

    ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));

    for(i = 0; i < a->refcount; i ++) {

        ret->refs[ret->refcount] = a->refs[i];

        *ret->refs[ret->refcount++] = ret;

    }

    for(i = 0; i < b->refcount; i ++) {

        ret->refs[ret->refcount] = b->refs[i];

        *ret->refs[ret->refcount++] = ret;

    }



    av_free(a->refs);

    av_free(a->formats);

    av_free(a);



    av_free(b->refs);

    av_free(b->formats);

    av_free(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];



    

    if(!(ret->format_count = k)) {

        av_free(ret->formats);

        av_free(ret);

        return NULL;

    }



    

    ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));

    for(i = 0; i < a->refcount; i ++) {

        ret->refs[ret->refcount] = a->refs[i];

        *ret->refs[ret->refcount++] = ret;

    }

    for(i = 0; i < b->refcount; i ++) {

        ret->refs[ret->refcount] = b->refs[i];

        *ret->refs[ret->refcount++] = ret;

    }



    av_free(a->refs);

    av_free(a->formats);

    av_free(a);



    av_free(b->refs);

    av_free(b->formats);

    av_free(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];



    

    if(!(ret->format_count = VAR_2)) {

        av_free(ret->formats);

        av_free(ret);

        return NULL;

    }



    

    ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));

    for(VAR_0 = 0; VAR_0 < a->refcount; VAR_0 ++) {

        ret->refs[ret->refcount] = a->refs[VAR_0];

        *ret->refs[ret->refcount++] = ret;

    }

    for(VAR_0 = 0; VAR_0 < b->refcount; VAR_0 ++) {

        ret->refs[ret->refcount] = b->refs[VAR_0];

        *ret->refs[ret->refcount++] = ret;

    }



    av_free(a->refs);

    av_free(a->formats);

    av_free(a);



    av_free(b->refs);

    av_free(b->formats);

    av_free(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]; if(!(ret->format_count = VAR_2)) { av_free(ret->formats); av_free(ret); return NULL; } ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount)); for(VAR_0 = 0; VAR_0 < a->refcount; VAR_0 ++) { ret->refs[ret->refcount] = a->refs[VAR_0]; *ret->refs[ret->refcount++] = ret; } for(VAR_0 = 0; VAR_0 < b->refcount; VAR_0 ++) { ret->refs[ret->refcount] = b->refs[VAR_0]; *ret->refs[ret->refcount++] = ret; } av_free(a->refs); av_free(a->formats); av_free(a); av_free(b->refs); av_free(b->formats); av_free(b); return ret; }