[FFmpeg-soc] [soc]: r1628 - libavfilter/formats.c

koorogi subversion at mplayerhq.hu
Fri Dec 21 00:28:41 CET 2007


Author: koorogi
Date: Fri Dec 21 00:28:40 2007
New Revision: 1628

Log:
avfilter_formats_unref() should remove the given reference, not the last
reference.


Modified:
   libavfilter/formats.c

Modified: libavfilter/formats.c
==============================================================================
--- libavfilter/formats.c	(original)
+++ libavfilter/formats.c	Fri Dec 21 00:28:40 2007
@@ -109,8 +109,23 @@ void avfilter_formats_ref(AVFilterFormat
     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)
 {
+    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) {
         av_free((*ref)->formats);
         av_free((*ref)->refs);



More information about the FFmpeg-soc mailing list