Merge branch 'master' into modernize-smartptrs-literals
commit
8fb7ba3444
|
@ -115,7 +115,7 @@ jobs:
|
||||||
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||||
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||||
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release ${{ steps.windows_extra_cmake_args.outputs.args }} ${{ steps.hunter_extra_cmake_args.outputs.args }}'
|
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release ${{ steps.windows_extra_cmake_args.outputs.args }} ${{ steps.hunter_extra_cmake_args.outputs.args }}'
|
||||||
buildWithCMakeArgs: '-- -j 24 -v'
|
buildWithCMakeArgs: '--parallel 24 -v'
|
||||||
buildDirectory: '${{ github.workspace }}/build/'
|
buildDirectory: '${{ github.workspace }}/build/'
|
||||||
|
|
||||||
- name: Exclude certain tests in Hunter specific builds
|
- name: Exclude certain tests in Hunter specific builds
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
name: CIFuzz
|
||||||
|
on: [pull_request]
|
||||||
|
jobs:
|
||||||
|
Fuzzing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Build Fuzzers
|
||||||
|
id: build
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'assimp'
|
||||||
|
dry-run: false
|
||||||
|
language: c++
|
||||||
|
- name: Run Fuzzers
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'assimp'
|
||||||
|
fuzz-seconds: 300
|
||||||
|
dry-run: false
|
||||||
|
language: c++
|
||||||
|
- name: Upload Crash
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
if: failure() && steps.build.outcome == 'success'
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out/artifacts
|
14
Build.md
14
Build.md
|
@ -27,7 +27,7 @@ pip install pyassimp
|
||||||
## Manual build instructions
|
## Manual build instructions
|
||||||
|
|
||||||
### Install CMake
|
### Install CMake
|
||||||
Asset-Importer-Lib can be build for a lot of different platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/ or for linux install it via
|
Asset-Importer-Lib can be built for a lot of different platforms. We are using cmake to generate the build environment for these via cmake. So you have to make sure that you have a working cmake-installation on your system. You can download it at https://cmake.org/ or for linux install it via
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get install cmake
|
sudo apt-get install cmake
|
||||||
```
|
```
|
||||||
|
@ -46,12 +46,12 @@ cmake --build .
|
||||||
|
|
||||||
### Build instructions for Windows with Visual-Studio
|
### Build instructions for Windows with Visual-Studio
|
||||||
|
|
||||||
First you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
|
First, you have to install Visual-Studio on your windows-system. You can get the Community-Version for free here: https://visualstudio.microsoft.com/de/downloads/
|
||||||
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
|
To generate the build environment for your IDE open a command prompt, navigate to your repo and type:
|
||||||
```bash
|
```bash
|
||||||
cmake CMakeLists.txt
|
cmake CMakeLists.txt
|
||||||
```
|
```
|
||||||
This will generate the project files for the visual studio. All dependencies used to build Asset-IMporter-Lib shall be part of the repo. If you want to use you own zlib.installation this is possible as well. Check the options for it.
|
This will generate the project files for the visual studio. All dependencies used to build Asset-Importer-Lib shall be part of the repo. If you want to use you own zlib installation this is possible as well. Check the options for it.
|
||||||
|
|
||||||
### Build instructions for Windows with UWP
|
### Build instructions for Windows with UWP
|
||||||
See <https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app>
|
See <https://stackoverflow.com/questions/40803170/cmake-uwp-using-cmake-to-build-universal-windows-app>
|
||||||
|
@ -63,9 +63,9 @@ Open a terminal and got to your repository. You can generate the makefiles and b
|
||||||
cmake CMakeLists.txt
|
cmake CMakeLists.txt
|
||||||
make -j4
|
make -j4
|
||||||
```
|
```
|
||||||
The option -j descripes the number of parallel processes for the build. In this case make will try to use 4 cores for the build.
|
The option -j describes the number of parallel processes for the build. In this case make will try to use 4 cores for the build.
|
||||||
|
|
||||||
If you want to use a IDE for linux you can try QTCreator for instance.
|
If you want to use an IDE for linux you can try QTCreator for instance.
|
||||||
|
|
||||||
### Build instructions for MinGW
|
### Build instructions for MinGW
|
||||||
Older versions of MinGW's compiler (e.g. 5.1.0) do not support the -mbig_obj flag
|
Older versions of MinGW's compiler (e.g. 5.1.0) do not support the -mbig_obj flag
|
||||||
|
@ -93,8 +93,8 @@ The cmake-build-environment provides options to configure the build. The followi
|
||||||
- **ASSIMP_ANDROID_JNIIOSYSTEM (default OFF)**: Android JNI IOSystem support is active.
|
- **ASSIMP_ANDROID_JNIIOSYSTEM (default OFF)**: Android JNI IOSystem support is active.
|
||||||
- **ASSIMP_NO_EXPORT (default OFF)**: Disable Assimp's export functionality.
|
- **ASSIMP_NO_EXPORT (default OFF)**: Disable Assimp's export functionality.
|
||||||
- **ASSIMP_BUILD_ZLIB (default OFF)**: Build our own zlib.
|
- **ASSIMP_BUILD_ZLIB (default OFF)**: Build our own zlib.
|
||||||
- **ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT (default ON)**: Build Assimp with all exporter senabled.
|
- **ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT (default ON)**: Build Assimp with all exporters enabled.
|
||||||
- **ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT (default ON)**: Build Assimp with all importer senabled.
|
- **ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT (default ON)**: Build Assimp with all importers enabled.
|
||||||
- **ASSIMP_BUILD_ASSIMP_TOOLS (default OFF)**: If the supplementary tools for Assimp are built in addition to the library.
|
- **ASSIMP_BUILD_ASSIMP_TOOLS (default OFF)**: If the supplementary tools for Assimp are built in addition to the library.
|
||||||
- **ASSIMP_BUILD_SAMPLES (default OFF)**: If the official samples are built as well (needs Glut).
|
- **ASSIMP_BUILD_SAMPLES (default OFF)**: If the official samples are built as well (needs Glut).
|
||||||
- **ASSIMP_BUILD_TESTS (default ON)**: If the test suite for Assimp is built in addition to the library.
|
- **ASSIMP_BUILD_TESTS (default ON)**: If the test suite for Assimp is built in addition to the library.
|
||||||
|
|
|
@ -199,6 +199,14 @@ const Object* LazyObject::Get(bool dieOnError) {
|
||||||
object.reset(new AnimationCurveNode(id,element,name,doc));
|
object.reset(new AnimationCurveNode(id,element,name,doc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (std::bad_alloc&) {
|
||||||
|
// out-of-memory is unrecoverable and should always lead to a failure
|
||||||
|
|
||||||
|
flags &= ~BEING_CONSTRUCTED;
|
||||||
|
flags |= FAILED_TO_CONSTRUCT;
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
catch(std::exception& ex) {
|
catch(std::exception& ex) {
|
||||||
flags &= ~BEING_CONSTRUCTED;
|
flags &= ~BEING_CONSTRUCTED;
|
||||||
flags |= FAILED_TO_CONSTRUCT;
|
flags |= FAILED_TO_CONSTRUCT;
|
||||||
|
|
|
@ -404,8 +404,13 @@ void MDLImporter::InternReadFile_Quake1() {
|
||||||
this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float));
|
this->CreateTextureARGB8_3DGS_MDL3(szCurrent + iNumImages * sizeof(float));
|
||||||
}
|
}
|
||||||
// go to the end of the skin section / the beginning of the next skin
|
// go to the end of the skin section / the beginning of the next skin
|
||||||
szCurrent += pcHeader->skinheight * pcHeader->skinwidth +
|
bool overflow = false;
|
||||||
sizeof(float) * iNumImages;
|
if ((pcHeader->skinheight > INT_MAX / pcHeader->skinwidth) || (pcHeader->skinwidth > INT_MAX / pcHeader->skinheight)){
|
||||||
|
overflow = true;
|
||||||
|
}
|
||||||
|
if (!overflow) {
|
||||||
|
szCurrent += pcHeader->skinheight * pcHeader->skinwidth +sizeof(float) * iNumImages;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
szCurrent += sizeof(uint32_t);
|
szCurrent += sizeof(uint32_t);
|
||||||
|
|
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* KHR_materials_transmission full
|
* KHR_materials_transmission full
|
||||||
* KHR_materials_volume full
|
* KHR_materials_volume full
|
||||||
* KHR_materials_ior full
|
* KHR_materials_ior full
|
||||||
|
* KHR_materials_emissive_strength full
|
||||||
*/
|
*/
|
||||||
#ifndef GLTF2ASSET_H_INC
|
#ifndef GLTF2ASSET_H_INC
|
||||||
#define GLTF2ASSET_H_INC
|
#define GLTF2ASSET_H_INC
|
||||||
|
@ -801,6 +802,13 @@ struct MaterialIOR {
|
||||||
void SetDefaults();
|
void SetDefaults();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MaterialEmissiveStrength {
|
||||||
|
float emissiveStrength = 0.f;
|
||||||
|
|
||||||
|
MaterialEmissiveStrength() { SetDefaults(); }
|
||||||
|
void SetDefaults();
|
||||||
|
};
|
||||||
|
|
||||||
//! The material appearance of a primitive.
|
//! The material appearance of a primitive.
|
||||||
struct Material : public Object {
|
struct Material : public Object {
|
||||||
//PBR metallic roughness properties
|
//PBR metallic roughness properties
|
||||||
|
@ -833,6 +841,9 @@ struct Material : public Object {
|
||||||
//extension: KHR_materials_ior
|
//extension: KHR_materials_ior
|
||||||
Nullable<MaterialIOR> materialIOR;
|
Nullable<MaterialIOR> materialIOR;
|
||||||
|
|
||||||
|
//extension: KHR_materials_emissive_strength
|
||||||
|
Nullable<MaterialEmissiveStrength> materialEmissiveStrength;
|
||||||
|
|
||||||
//extension: KHR_materials_unlit
|
//extension: KHR_materials_unlit
|
||||||
bool unlit;
|
bool unlit;
|
||||||
|
|
||||||
|
@ -1106,6 +1117,7 @@ public:
|
||||||
bool KHR_materials_transmission;
|
bool KHR_materials_transmission;
|
||||||
bool KHR_materials_volume;
|
bool KHR_materials_volume;
|
||||||
bool KHR_materials_ior;
|
bool KHR_materials_ior;
|
||||||
|
bool KHR_materials_emissive_strength;
|
||||||
bool KHR_draco_mesh_compression;
|
bool KHR_draco_mesh_compression;
|
||||||
bool FB_ngon_encoding;
|
bool FB_ngon_encoding;
|
||||||
bool KHR_texture_basisu;
|
bool KHR_texture_basisu;
|
||||||
|
@ -1120,6 +1132,7 @@ public:
|
||||||
KHR_materials_transmission(false),
|
KHR_materials_transmission(false),
|
||||||
KHR_materials_volume(false),
|
KHR_materials_volume(false),
|
||||||
KHR_materials_ior(false),
|
KHR_materials_ior(false),
|
||||||
|
KHR_materials_emissive_strength(false),
|
||||||
KHR_draco_mesh_compression(false),
|
KHR_draco_mesh_compression(false),
|
||||||
FB_ngon_encoding(false),
|
FB_ngon_encoding(false),
|
||||||
KHR_texture_basisu(false) {
|
KHR_texture_basisu(false) {
|
||||||
|
|
|
@ -1313,6 +1313,16 @@ inline void Material::Read(Value &material, Asset &r) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r.extensionsUsed.KHR_materials_emissive_strength) {
|
||||||
|
if (Value *curMaterialEmissiveStrength = FindObject(*extensions, "KHR_materials_emissive_strength")) {
|
||||||
|
MaterialEmissiveStrength emissiveStrength;
|
||||||
|
|
||||||
|
ReadMember(*curMaterialEmissiveStrength, "emissiveStrength", emissiveStrength.emissiveStrength);
|
||||||
|
|
||||||
|
this->materialEmissiveStrength = Nullable<MaterialEmissiveStrength>(emissiveStrength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
|
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1355,6 +1365,11 @@ inline void MaterialIOR::SetDefaults() {
|
||||||
ior = 1.5f;
|
ior = 1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void MaterialEmissiveStrength::SetDefaults() {
|
||||||
|
//KHR_materials_emissive_strength properties
|
||||||
|
emissiveStrength = 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
|
inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
|
||||||
Value *curName = FindMember(pJSON_Object, "name");
|
Value *curName = FindMember(pJSON_Object, "name");
|
||||||
if (nullptr != curName && curName->IsString()) {
|
if (nullptr != curName && curName->IsString()) {
|
||||||
|
@ -2026,6 +2041,7 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
|
||||||
CHECK_EXT(KHR_materials_transmission);
|
CHECK_EXT(KHR_materials_transmission);
|
||||||
CHECK_EXT(KHR_materials_volume);
|
CHECK_EXT(KHR_materials_volume);
|
||||||
CHECK_EXT(KHR_materials_ior);
|
CHECK_EXT(KHR_materials_ior);
|
||||||
|
CHECK_EXT(KHR_materials_emissive_strength);
|
||||||
CHECK_EXT(KHR_draco_mesh_compression);
|
CHECK_EXT(KHR_draco_mesh_compression);
|
||||||
CHECK_EXT(KHR_texture_basisu);
|
CHECK_EXT(KHR_texture_basisu);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* KHR_materials_transmission: full
|
* KHR_materials_transmission: full
|
||||||
* KHR_materials_volume: full
|
* KHR_materials_volume: full
|
||||||
* KHR_materials_ior: full
|
* KHR_materials_ior: full
|
||||||
|
* KHR_materials_emissive_strength: full
|
||||||
*/
|
*/
|
||||||
#ifndef GLTF2ASSETWRITER_H_INC
|
#ifndef GLTF2ASSETWRITER_H_INC
|
||||||
#define GLTF2ASSETWRITER_H_INC
|
#define GLTF2ASSETWRITER_H_INC
|
||||||
|
|
|
@ -511,6 +511,20 @@ namespace glTF2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m.materialEmissiveStrength.isPresent) {
|
||||||
|
Value materialEmissiveStrength(rapidjson::Type::kObjectType);
|
||||||
|
|
||||||
|
MaterialEmissiveStrength &emissiveStrength = m.materialEmissiveStrength.value;
|
||||||
|
|
||||||
|
if (emissiveStrength.emissiveStrength != 0.f) {
|
||||||
|
WriteFloat(materialEmissiveStrength, emissiveStrength.emissiveStrength, "emissiveStrength", w.mAl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!materialEmissiveStrength.ObjectEmpty()) {
|
||||||
|
exts.AddMember("KHR_materials_emissive_strength", materialEmissiveStrength, w.mAl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!exts.ObjectEmpty()) {
|
if (!exts.ObjectEmpty()) {
|
||||||
obj.AddMember("extensions", exts, w.mAl);
|
obj.AddMember("extensions", exts, w.mAl);
|
||||||
}
|
}
|
||||||
|
@ -935,6 +949,10 @@ namespace glTF2 {
|
||||||
exts.PushBack(StringRef("KHR_materials_ior"), mAl);
|
exts.PushBack(StringRef("KHR_materials_ior"), mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->mAsset.extensionsUsed.KHR_materials_emissive_strength) {
|
||||||
|
exts.PushBack(StringRef("KHR_materials_emissive_strength"), mAl);
|
||||||
|
}
|
||||||
|
|
||||||
if (this->mAsset.extensionsUsed.FB_ngon_encoding) {
|
if (this->mAsset.extensionsUsed.FB_ngon_encoding) {
|
||||||
exts.PushBack(StringRef("FB_ngon_encoding"), mAl);
|
exts.PushBack(StringRef("FB_ngon_encoding"), mAl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -733,6 +733,10 @@ bool glTF2Exporter::GetMatIOR(const aiMaterial &mat, glTF2::MaterialIOR &ior) {
|
||||||
return mat.Get(AI_MATKEY_REFRACTI, ior.ior) == aiReturn_SUCCESS;
|
return mat.Get(AI_MATKEY_REFRACTI, ior.ior) == aiReturn_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool glTF2Exporter::GetMatEmissiveStrength(const aiMaterial &mat, glTF2::MaterialEmissiveStrength &emissiveStrength) {
|
||||||
|
return mat.Get(AI_MATKEY_EMISSIVE_INTENSITY, emissiveStrength.emissiveStrength) == aiReturn_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void glTF2Exporter::ExportMaterials() {
|
void glTF2Exporter::ExportMaterials() {
|
||||||
aiString aiName;
|
aiString aiName;
|
||||||
for (unsigned int i = 0; i < mScene->mNumMaterials; ++i) {
|
for (unsigned int i = 0; i < mScene->mNumMaterials; ++i) {
|
||||||
|
@ -863,6 +867,12 @@ void glTF2Exporter::ExportMaterials() {
|
||||||
mAsset->extensionsUsed.KHR_materials_ior = true;
|
mAsset->extensionsUsed.KHR_materials_ior = true;
|
||||||
m->materialIOR = Nullable<MaterialIOR>(ior);
|
m->materialIOR = Nullable<MaterialIOR>(ior);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MaterialEmissiveStrength emissiveStrength;
|
||||||
|
if (GetMatEmissiveStrength(mat, emissiveStrength)) {
|
||||||
|
mAsset->extensionsUsed.KHR_materials_emissive_strength = true;
|
||||||
|
m->materialEmissiveStrength = Nullable<MaterialEmissiveStrength>(emissiveStrength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ struct MaterialClearcoat;
|
||||||
struct MaterialTransmission;
|
struct MaterialTransmission;
|
||||||
struct MaterialVolume;
|
struct MaterialVolume;
|
||||||
struct MaterialIOR;
|
struct MaterialIOR;
|
||||||
|
struct MaterialEmissiveStrength;
|
||||||
|
|
||||||
// Vec/matrix types, as raw float arrays
|
// Vec/matrix types, as raw float arrays
|
||||||
typedef float(vec2)[2];
|
typedef float(vec2)[2];
|
||||||
|
@ -121,6 +122,7 @@ protected:
|
||||||
bool GetMatTransmission(const aiMaterial &mat, glTF2::MaterialTransmission &transmission);
|
bool GetMatTransmission(const aiMaterial &mat, glTF2::MaterialTransmission &transmission);
|
||||||
bool GetMatVolume(const aiMaterial &mat, glTF2::MaterialVolume &volume);
|
bool GetMatVolume(const aiMaterial &mat, glTF2::MaterialVolume &volume);
|
||||||
bool GetMatIOR(const aiMaterial &mat, glTF2::MaterialIOR &ior);
|
bool GetMatIOR(const aiMaterial &mat, glTF2::MaterialIOR &ior);
|
||||||
|
bool GetMatEmissiveStrength(const aiMaterial &mat, glTF2::MaterialEmissiveStrength &emissiveStrength);
|
||||||
void ExportMetadata();
|
void ExportMetadata();
|
||||||
void ExportMaterials();
|
void ExportMaterials();
|
||||||
void ExportMeshes();
|
void ExportMeshes();
|
||||||
|
|
|
@ -357,6 +357,13 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
|
||||||
aimat->AddProperty(&ior.ior, 1, AI_MATKEY_REFRACTI);
|
aimat->AddProperty(&ior.ior, 1, AI_MATKEY_REFRACTI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KHR_materials_emissive_strength
|
||||||
|
if (mat.materialEmissiveStrength.isPresent) {
|
||||||
|
MaterialEmissiveStrength &emissiveStrength = mat.materialEmissiveStrength.value;
|
||||||
|
|
||||||
|
aimat->AddProperty(&emissiveStrength.emissiveStrength, 1, AI_MATKEY_EMISSIVE_INTENSITY);
|
||||||
|
}
|
||||||
|
|
||||||
return aimat;
|
return aimat;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
delete aimat;
|
delete aimat;
|
||||||
|
|
|
@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -64,11 +65,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#undef get16bits
|
#undef get16bits
|
||||||
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|
#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \
|
||||||
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
|
|| defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)
|
||||||
#define get16bits(d) (*((const uint16_t *) (d)))
|
# define get16bits(d) (*((const uint16_t *) (d)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined (get16bits)
|
#if !defined (get16bits)
|
||||||
#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
|
# define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
|
||||||
+(uint32_t)(((const uint8_t *)(d))[0]) )
|
+(uint32_t)(((const uint8_t *)(d))[0]) )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -77,8 +78,8 @@ inline uint32_t SuperFastHash (const char * data, uint32_t len = 0, uint32_t has
|
||||||
uint32_t tmp;
|
uint32_t tmp;
|
||||||
int rem;
|
int rem;
|
||||||
|
|
||||||
if (!data) return 0;
|
if (data == NULL) return 0;
|
||||||
if (!len)len = (uint32_t)::strlen(data);
|
if (len == 0)len = (uint32_t)::strlen(data);
|
||||||
|
|
||||||
rem = len & 3;
|
rem = len & 3;
|
||||||
len >>= 2;
|
len >>= 2;
|
||||||
|
|
Loading…
Reference in New Issue