mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-24 17:12:34 +02:00
Factor duplicated loop
Originally committed as revision 11899 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
d3a4e41c8a
commit
37e0b997a8
@ -21,6 +21,16 @@
|
|||||||
|
|
||||||
#include "avfilter.h"
|
#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 *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
|
||||||
{
|
{
|
||||||
AVFilterFormats *ret;
|
AVFilterFormats *ret;
|
||||||
@ -43,16 +53,10 @@ AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* merge and update all the references */
|
|
||||||
ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
|
ret->refs = av_malloc(sizeof(AVFilterFormats**)*(a->refcount+b->refcount));
|
||||||
for(i = 0; i < a->refcount; i ++) {
|
|
||||||
ret->refs[ret->refcount] = a->refs[i];
|
merge_ref(ret, a);
|
||||||
*ret->refs[ret->refcount++] = ret;
|
merge_ref(ret, b);
|
||||||
}
|
|
||||||
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->refs);
|
||||||
av_free(a->formats);
|
av_free(a->formats);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user