* 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
This commit is contained in:
Stephan Aßmus
2008-06-11 08:32:44 +00:00
parent 6bead436a6
commit ad846ea0a9
3 changed files with 26 additions and 14 deletions
@@ -8,7 +8,7 @@ Addon xvid.decoder :
XvidDecoder.cpp
supported_codecs.cpp
:
libxvid.a
libxvidcore.a
be
libmedia.so
;
@@ -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;
@@ -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,