1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter_formats_unref() should remove the given reference, not the last

reference.

Commited in SoC by Bobby Bingham

Originally committed as revision 11892 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Vitor Sessak 2008-02-10 18:03:18 +00:00
parent 391354656c
commit 88cfb80418

View File

@ -109,8 +109,23 @@ void avfilter_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
f->refs[f->refcount-1] = ref; f->refs[f->refcount-1] = ref;
} }
static int find_ref_index(AVFilterFormats *f, AVFilterFormats **ref)
{
int i;
for(i = 0; i < (*ref)->refcount; i ++)
if((*ref)->refs[i] == ref)
return i;
return -1;
}
void avfilter_formats_unref(AVFilterFormats **ref) void avfilter_formats_unref(AVFilterFormats **ref)
{ {
int idx;
if((idx = find_ref_index(*ref, ref)) >= 0)
memmove((*ref)->refs + idx, (*ref)->refs + idx+1,
sizeof(AVFilterFormats**) * ((*ref)->refcount-idx-1));
if(!--(*ref)->refcount) { if(!--(*ref)->refcount) {
av_free((*ref)->formats); av_free((*ref)->formats);
av_free((*ref)->refs); av_free((*ref)->refs);