• R/O
  • HTTP
  • SSH
  • HTTPS

x264-launcher: Commit

Simple x264 Launcher development repository


Commit MetaInfo

Revisionbbd2b4f6ea1640871af74c29091ea4f43d8563aa (tree)
Time2019-08-14 03:03:11
Authorlordmulder <mulder2@gmx....>
Commiterlordmulder

Log Message

Simplified VapourSynth detection code.

Change Summary

Incremental Difference

--- a/src/thread_vapoursynth.cpp
+++ b/src/thread_vapoursynth.cpp
@@ -48,6 +48,8 @@ QScopedPointer<QFile> VapourSynthCheckThread::m_vpsDllPath[2];
4848 //Const
4949 static const char* const VPS_DLL_NAME = "vapoursynth.dll";
5050 static const char* const VPS_EXE_NAME = "vspipe.exe";
51+static const char* const VPS_REG_KEY1 = "SOFTWARE\\VapourSynth";
52+static const char* const VPS_REG_KEY2 = "SOFTWARE\\VapourSynth-32";
5153 static const char* const VPS_REG_NAME = "VapourSynthDLL";
5254
5355 //Default VapurSynth architecture
@@ -60,7 +62,8 @@ static const char* const VPS_REG_NAME = "VapourSynthDLL";
6062 //Enable detection of "portabel" edition?
6163 #define ENABLE_PORTABLE_VPS true
6264
63-//Registry scope EOL flag
65+//EOL flags
66+#define REG_ROOT_EOL (MUtils::Registry::reg_root_t (-1))
6467 #define REG_SCOPE_EOL (MUtils::Registry::reg_scope_t(-1))
6568
6669 //Auxilary functions
@@ -162,10 +165,21 @@ int VapourSynthCheckThread::threadMain(void)
162165 VAPOURSYNTH_X64,
163166 NULL
164167 };
165- static const char* const VPS_REG_PATH[] =
168+ static const MUtils::Registry::reg_root_t REG_ROOTS[] =
166169 {
167- "SOFTWARE\\VapourSynth",
168- "SOFTWARE\\VapourSynth-32",
170+ MUtils::Registry::root_machine,
171+ MUtils::Registry::root_user,
172+ REG_ROOT_EOL
173+ };
174+ static const char* const REG_PATHS_HKLM[] =
175+ {
176+ VPS_REG_KEY1,
177+ NULL
178+ };
179+ static const char* const REG_PATHS_HKCU[] =
180+ {
181+ VPS_REG_KEY1,
182+ VPS_REG_KEY2,
169183 NULL
170184 };
171185 static const MUtils::Registry::reg_scope_t REG_SCOPE_X86[] =
@@ -202,46 +216,30 @@ int VapourSynthCheckThread::threadMain(void)
202216 //Read VapourSynth path from registry
203217 if (vpsDllInfo.isEmpty() && vpsExeInfo.isEmpty())
204218 {
205- //Try to detect the path from HKEY_LOCAL_MACHINE first!
206- const MUtils::Registry::reg_scope_t* const scope = (MUtils::OS::os_architecture() == MUtils::OS::ARCH_X64) ? REG_SCOPE_X64 : REG_SCOPE_X86;
207- for (size_t i = 0; scope[i] != REG_SCOPE_EOL; i++)
208- {
209- if (MUtils::Registry::reg_key_exists(MUtils::Registry::root_machine, QString::fromLatin1(VPS_REG_PATH[0U]), scope[i]))
210- {
211- QString vpsRegDllPath;
212- if (MUtils::Registry::reg_value_read(MUtils::Registry::root_machine, QString::fromLatin1(VPS_REG_PATH[0U]), QString::fromLatin1(VPS_REG_NAME), vpsRegDllPath, scope[i]))
213- {
214- QFileInfo vpsRegDllInfo(QDir::fromNativeSeparators(vpsRegDllPath));
215- vpsRegDllInfo.makeAbsolute();
216- if (vpsRegDllInfo.exists() && vpsRegDllInfo.isFile())
217- {
218- const int flag = getVapourSynthType(scope[i]);
219- if ((!vpsDllInfo.contains(flag)) || (!vpsExeInfo.contains(flag)))
220- {
221- vpsDllInfo.insert(flag, vpsRegDllInfo);
222- vpsExeInfo.insert(flag, vpsRegDllInfo.absoluteDir().absoluteFilePath(VPS_EXE_NAME)); /*derive VSPipe.EXE path from VapourSynth.DLL path for now!*/
223- }
224- }
225- }
226- }
227- }
228- //Fall back to HKEY_CURRENT_USER, if path not found yet
229- for (size_t i = 0; VPS_REG_PATH[i]; i++)
219+ for (size_t i = 0; REG_ROOTS[i] != REG_ROOT_EOL; i++)
230220 {
231- if (MUtils::Registry::reg_key_exists(MUtils::Registry::root_user, QString::fromLatin1(VPS_REG_PATH[i])))
221+ const char *const *const paths = (REG_ROOTS[i] == MUtils::Registry::root_machine) ? REG_PATHS_HKLM : REG_PATHS_HKCU;
222+ const MUtils::Registry::reg_scope_t* const scopes = (REG_ROOTS[i] == MUtils::Registry::root_machine) ? ((MUtils::OS::os_architecture() == MUtils::OS::ARCH_X64) ? REG_SCOPE_X64 : REG_SCOPE_X86) : REG_SCOPE_X86;
223+ for (size_t j = 0; paths[j]; j++)
232224 {
233- QString vpsRegDllPath;
234- if (MUtils::Registry::reg_value_read(MUtils::Registry::root_user, QString::fromLatin1(VPS_REG_PATH[i]), QString::fromLatin1(VPS_REG_NAME), vpsRegDllPath))
225+ for (size_t k = 0; scopes[k] != REG_SCOPE_EOL; k++)
235226 {
236- QFileInfo vpsRegDllInfo(QDir::fromNativeSeparators(vpsRegDllPath));
237- vpsRegDllInfo.makeAbsolute();
238- if (vpsRegDllInfo.exists() && vpsRegDllInfo.isFile())
227+ if (MUtils::Registry::reg_key_exists(REG_ROOTS[i], QString::fromLatin1(paths[j]), scopes[k]))
239228 {
240- const int flag = (i) ? VAPOURSYNTH_X86 : VAPOURSYNTH_X64;
241- if ((!vpsDllInfo.contains(flag)) || (!vpsExeInfo.contains(flag)))
229+ QString vpsRegDllPath;
230+ if (MUtils::Registry::reg_value_read(REG_ROOTS[i], QString::fromLatin1(paths[j]), QString::fromLatin1(VPS_REG_NAME), vpsRegDllPath, scopes[k]))
242231 {
243- vpsDllInfo.insert(flag, vpsRegDllInfo);
244- vpsExeInfo.insert(flag, vpsRegDllInfo.absoluteDir().absoluteFilePath(VPS_EXE_NAME)); /*derive VSPipe.EXE path from VapourSynth.DLL path for now!*/
232+ QFileInfo vpsRegDllInfo(QDir::fromNativeSeparators(vpsRegDllPath));
233+ vpsRegDllInfo.makeAbsolute();
234+ if (vpsRegDllInfo.exists() && vpsRegDllInfo.isFile())
235+ {
236+ const int vpsArch = (REG_ROOTS[i] == MUtils::Registry::root_machine) ? getVapourSynthType(scopes[k]) : ((j > 0U) ? VAPOURSYNTH_X86 : VAPOURSYNTH_X64);
237+ if ((!vpsDllInfo.contains(vpsArch)) || (!vpsExeInfo.contains(vpsArch)))
238+ {
239+ vpsDllInfo.insert(vpsArch, vpsRegDllInfo);
240+ vpsExeInfo.insert(vpsArch, vpsRegDllInfo.absoluteDir().absoluteFilePath(VPS_EXE_NAME)); /*derive VSPipe.EXE path from VapourSynth.DLL path!*/
241+ }
242+ }
245243 }
246244 }
247245 }
--- a/src/version.h
+++ b/src/version.h
@@ -26,7 +26,7 @@
2626 #define VER_X264_MAJOR 2
2727 #define VER_X264_MINOR 9
2828 #define VER_X264_PATCH 3
29-#define VER_X264_BUILD 1183
29+#define VER_X264_BUILD 1184
3030
3131 #define VER_X264_PORTABLE_EDITION (0)
3232
Show on old repository browser