From ad846ea0a9f035c9de2dae8e4e34294db577d4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 11 Jun 2008 08:32:44 +0000 Subject: [PATCH] * Move the global initialization of the xvid core to a static initializer, only the decoder structure is now initialized per instance, this should be better (thread safe). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25925 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../media/plugins/xvid_decoder/Jamfile | 2 +- .../plugins/xvid_decoder/XvidDecoder.cpp | 36 ++++++++++++------- .../media/plugins/xvid_decoder/XvidDecoder.h | 2 +- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/add-ons/media/plugins/xvid_decoder/Jamfile b/src/add-ons/media/plugins/xvid_decoder/Jamfile index d289a34ddc..148b84c6fd 100644 --- a/src/add-ons/media/plugins/xvid_decoder/Jamfile +++ b/src/add-ons/media/plugins/xvid_decoder/Jamfile @@ -8,7 +8,7 @@ Addon xvid.decoder : XvidDecoder.cpp supported_codecs.cpp : - libxvid.a + libxvidcore.a be libmedia.so ; diff --git a/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.cpp b/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.cpp index 3e269415b6..65dee534a5 100644 --- a/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.cpp +++ b/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.cpp @@ -378,7 +378,7 @@ XvidDecoder::NegotiateOutputFormat(media_format* _inoutFormat) PRINT(("%p->XvidDecoder: out_format=%s\n", this, buffer)); #endif - return _XvidInit(true, 0) == 0 ? B_OK : B_ERROR; + return _XvidInit() == 0 ? B_OK : B_ERROR; } @@ -622,21 +622,14 @@ this, inRequiredFrame, *_inOutFrame, inRequiredTime, *_inOutTime); // #pragma mark - -// _XvidInit -int -XvidDecoder::_XvidInit(int useAssembler, int debugLevel) +static bool +init_xvid(bool useAssembler, int debugLevel) { - if (fXvidDecoderHandle != NULL) - return 0; - + // XviD core initialization xvid_gbl_init_t xvidGlobalInit; - xvid_dec_create_t xvidDecoderCreate; // reset the structure with zeros memset(&xvidGlobalInit, 0, sizeof(xvid_gbl_init_t)); - memset(&xvidDecoderCreate, 0, sizeof(xvid_dec_create_t)); - - // XviD core initialization // version xvidGlobalInit.version = XVID_VERSION; @@ -647,11 +640,30 @@ XvidDecoder::_XvidInit(int useAssembler, int debugLevel) else xvidGlobalInit.cpu_flags = XVID_CPU_FORCE; + // debug level xvidGlobalInit.debug = debugLevel; xvid_global(NULL, 0, &xvidGlobalInit, NULL); - // XviD encoder initialization + return true; +} + + +static bool sXvidInitialized = init_xvid(true, 0); + + +// _XvidInit +int +XvidDecoder::_XvidInit() +{ + if (fXvidDecoderHandle != NULL) + return 0; + + // XviD decoder initialization + xvid_dec_create_t xvidDecoderCreate; + + // reset the structure with zeros + memset(&xvidDecoderCreate, 0, sizeof(xvid_dec_create_t)); // version xvidDecoderCreate.version = XVID_VERSION; diff --git a/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.h b/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.h index 0234476c06..fa788a6a06 100644 --- a/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.h +++ b/src/add-ons/media/plugins/xvid_decoder/XvidDecoder.h @@ -51,7 +51,7 @@ class XvidDecoder : public Decoder { bigtime_t* _inOutTime); private: - int _XvidInit(int useAssembler, int debugLevel); + int _XvidInit(); int _XvidUninit(); int _XvidDecode(uchar *istream, uchar *ostream,