Commit 2ee4d1cd authored by vitor's avatar vitor

Factor duplicated loop


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@11899 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 8829c9b7
......@@ -21,6 +21,16 @@
#include "avfilter.h"
/** merge and update all the references */
static void merge_ref(AVFilterFormats *ret, AVFilterFormats *a)
{
int i;
for(i = 0; i < a->refcount; i ++) {
ret->refs[ret->refcount] = a->refs[i];
*ret->refs[ret->refcount++] = ret;
}
}
AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
{
AVFilterFormats *ret;
......@@ -43,16 +53,10 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
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;
}
merge_ref(ret, a);
merge_ref(ret, b);
av_free(a->refs);
av_free(a->formats);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment