diff --git a/aegisub/FFmpegSource2/ffms.cpp b/aegisub/FFmpegSource2/ffms.cpp index 35174426b..4ff2f4477 100644 --- a/aegisub/FFmpegSource2/ffms.cpp +++ b/aegisub/FFmpegSource2/ffms.cpp @@ -31,33 +31,14 @@ extern "C" { #define _snprintf snprintf #endif -static int InitCount = 0; static bool FFmpegInited = false; -FFMS_API(int) FFMS_Init() { +FFMS_API(void) FFMS_Init() { if (!FFmpegInited) { av_register_all(); av_log_set_level(AV_LOG_QUIET); + FFmpegInited = true; } - - if (!InitCount) { -#ifdef HAALISOURCE - ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); -#endif - } - - InitCount++; - return InitCount; -} - -FFMS_API(int) FFMS_DeInit() { - InitCount--; - if (!InitCount) { -#ifdef HAALISOURCE - ::CoUninitialize(); -#endif - } - return InitCount; } FFMS_API(int) FFMS_GetLogLevel() { diff --git a/aegisub/FFmpegSource2/ffms.h b/aegisub/FFmpegSource2/ffms.h index 59accdafa..50d0c8886 100644 --- a/aegisub/FFmpegSource2/ffms.h +++ b/aegisub/FFmpegSource2/ffms.h @@ -122,8 +122,7 @@ typedef int (FFMS_CC *TAudioNameCallback)(const char *SourceFile, int Track, con // Most functions return 0 on success // Functions without error message output can be assumed to never fail -FFMS_API(int) FFMS_Init(); -FFMS_API(int) FFMS_DeInit(); +FFMS_API(void) FFMS_Init(); FFMS_API(int) FFMS_GetLogLevel(); FFMS_API(void) FFMS_SetLogLevel(int Level); FFMS_API(FFVideo *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FFIndex *Index, const char *PP, int Threads, int SeekMode, char *ErrorMsg, unsigned MsgSize); diff --git a/aegisub/FFmpegSource2/ffms2rt.cpp b/aegisub/FFmpegSource2/ffms2rt.cpp index 0e77cca06..9ecc0f2ff 100644 --- a/aegisub/FFmpegSource2/ffms2rt.cpp +++ b/aegisub/FFmpegSource2/ffms2rt.cpp @@ -51,9 +51,9 @@ static int FFMS_CC UpdateProgress(int64_t Current, int64_t Total, void *Private) void TestFullDump1(char *SrcFile, bool WithAudio) { int Private; + int ret; char ErrorMsg[2000]; - int ret = FFMS_Init(); - assert(!ret); + FFMS_Init(); FFIndexer *FIdx = FFMS_CreateIndexer(SrcFile, ErrorMsg, sizeof(ErrorMsg)); assert(FIdx); @@ -61,6 +61,8 @@ void TestFullDump1(char *SrcFile, bool WithAudio) { FIdx = FFMS_CreateIndexer(SrcFile, ErrorMsg, sizeof(ErrorMsg)); assert(FIdx); + const char *Name = FFMS_GetCodecNameI(FIdx, 0); + FFIndex *FI = FFMS_DoIndexing(FIdx, -1, -1, FFMS_DefaultAudioFilename, NULL, false, UpdateProgress, &Private, ErrorMsg, sizeof(ErrorMsg)); assert(FI); @@ -95,7 +97,6 @@ void TestFullDump1(char *SrcFile, bool WithAudio) { FFMS_DestroyFFIndex(FI); FFMS_DestroyVideoSource(V); - FFMS_DeInit(); } int main(int argc, char *argv[]) { @@ -109,7 +110,7 @@ int main(int argc, char *argv[]) { TestFiles1[6] = "pyramid-adaptive-10-bframes.mkv"; for (int i = 0; i < 5; i++) - TestFullDump1(TestFiles1[i], true); + TestFullDump1(TestFiles1[3], true); /* TestFullDump1(TestFiles1[5], false); diff --git a/aegisub/FFmpegSource2/ffmsindex.cpp b/aegisub/FFmpegSource2/ffmsindex.cpp index bcb1116c3..779ae9f9a 100644 --- a/aegisub/FFmpegSource2/ffmsindex.cpp +++ b/aegisub/FFmpegSource2/ffmsindex.cpp @@ -186,10 +186,7 @@ int main(int argc, char *argv[]) { return 1; } - if (FFMS_Init()) { - std::cout << std::endl << "Error: initialization failed" << std::endl; - return 1; - } + FFMS_Init(); if (Verbose) FFMS_SetLogLevel(AV_LOG_INFO); @@ -211,6 +208,5 @@ int main(int argc, char *argv[]) { } FFMS_DestroyFFIndex(Index); - FFMS_DeInit(); return 0; }