| 98 | } |
| 99 | |
| 100 | void decoderBaseSingleLib::loadDecoderLibrary(QString specificLibrary) |
| 101 | { |
| 102 | // Try to load the HM library from the current working directory |
| 103 | // Unfortunately relative paths like this do not work: (at least on windows) |
| 104 | // library.setFileName(".\\libde265"); |
| 105 | |
| 106 | bool libLoaded = false; |
| 107 | |
| 108 | // Try the specific library first |
| 109 | this->library.setFileName(specificLibrary); |
| 110 | this->libraryPath = specificLibrary; |
| 111 | libLoaded = this->library.load(); |
| 112 | |
| 113 | if (!libLoaded) |
| 114 | { |
| 115 | // Try various paths/names next |
| 116 | // If the file name is not set explicitly, QLibrary will try to open |
| 117 | // the decLibXXX.so file first. Since this has been compiled for linux |
| 118 | // it will fail and not even try to open the decLixXXX.dylib. |
| 119 | // On windows and linux ommitting the extension works |
| 120 | auto libNames = getLibraryNames(); |
| 121 | |
| 122 | // Get the additional search path from the settings |
| 123 | QSettings settings; |
| 124 | settings.beginGroup("Decoders"); |
| 125 | auto searchPath = settings.value("SearchPath", "").toString(); |
| 126 | if (!searchPath.endsWith("/")) |
| 127 | searchPath.append("/"); |
| 128 | searchPath.append("%1"); |
| 129 | settings.endGroup(); |
| 130 | |
| 131 | auto const libPaths = QStringList() |
| 132 | << searchPath << QDir::currentPath() + "/%1" |
| 133 | << QDir::currentPath() + "/decoder/%1" |
| 134 | << QDir::currentPath() + |
| 135 | "/libde265/%1" // for legacy installations before the decoders were |
| 136 | // moved to the "decoders" folder |
| 137 | << QCoreApplication::applicationDirPath() + "/%1" |
| 138 | << QCoreApplication::applicationDirPath() + "/decoder/%1" |
| 139 | << QCoreApplication::applicationDirPath() + "/libde265/%1" |
| 140 | << "%1"; // Try the system directories. |
| 141 | |
| 142 | for (auto &libName : libNames) |
| 143 | { |
| 144 | for (auto &libPath : libPaths) |
| 145 | { |
| 146 | this->library.setFileName(libPath.arg(libName)); |
| 147 | this->libraryPath = libPath.arg(libName); |
| 148 | libLoaded = library.load(); |
| 149 | if (libLoaded) |
| 150 | break; |
| 151 | } |
| 152 | if (libLoaded) |
| 153 | break; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | if (!libLoaded) |
no test coverage detected