[FFmpeg-cvslog] avutil/avutil_version: Run checks just once

Michael Niedermayer git at videolan.org
Tue Apr 16 17:11:51 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Apr 16 15:22:56 2013 +0200| [e701cd96c2d5dc034e7615967d208db3d953e111] | committer: Michael Niedermayer

avutil/avutil_version: Run checks just once

This ensures that applications that call avutil_version() often
would not run the checls every time

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavutil/utils.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavutil/utils.c b/libavutil/utils.c
index 8f83c02..c157aa8 100644
--- a/libavutil/utils.c
+++ b/libavutil/utils.c
@@ -29,6 +29,10 @@
 
 unsigned avutil_version(void)
 {
+    static int checks_done;
+    if (checks_done)
+        return LIBAVUTIL_VERSION_INT;
+
     av_assert0(AV_PIX_FMT_VDA_VLD == 81); //check if the pix fmt enum has not had anything inserted or removed by mistake
     av_assert0(AV_SAMPLE_FMT_DBLP == 9);
     av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4);
@@ -42,7 +46,7 @@ unsigned avutil_version(void)
     }
 
     ff_check_pixfmt_descriptors();
-
+    checks_done = 1;
     return LIBAVUTIL_VERSION_INT;
 }
 



More information about the ffmpeg-cvslog mailing list