[FFmpeg-cvslog] avfilter/allfilters: make avfilter_register_all thread safe

Muhammad Faiz git at videolan.org
Tue Mar 7 15:47:36 EET 2017


ffmpeg | branch: master | Muhammad Faiz <mfcc64 at gmail.com> | Tue Mar  7 15:54:44 2017 +0700| [af7010ad0557fe66d35886581eecebf02e92637c] | committer: Muhammad Faiz

avfilter/allfilters: make avfilter_register_all thread safe

use ff_thread_once

Suggested-by: wm4 <nfxjfg at googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af7010ad0557fe66d35886581eecebf02e92637c
---

 libavfilter/allfilters.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 15a74c4..df1af8d 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -19,6 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/thread.h"
 #include "avfilter.h"
 #include "config.h"
 #include "opencl_allkernels.h"
@@ -37,14 +38,8 @@
         avfilter_register(&ff_##x);                                     \
     }
 
-void avfilter_register_all(void)
+static void register_all(void)
 {
-    static int initialized;
-
-    if (initialized)
-        return;
-    initialized = 1;
-
     REGISTER_FILTER(ABENCH,         abench,         af);
     REGISTER_FILTER(ACOMPRESSOR,    acompressor,    af);
     REGISTER_FILTER(ACROSSFADE,     acrossfade,     af);
@@ -380,3 +375,10 @@ void avfilter_register_all(void)
     REGISTER_FILTER_UNCONDITIONAL(vf_fifo);
     ff_opencl_register_filter_kernel_code_all();
 }
+
+void avfilter_register_all(void)
+{
+    AVOnce control = AV_ONCE_INIT;
+
+    ff_thread_once(&control, register_all);
+}



More information about the ffmpeg-cvslog mailing list