版本
menu_open
link
Wwise SDK 2022.1.12
AkMurMurHash.h
浏览该文件的文档.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Copyright (c) 2024 Audiokinetic Inc.
25 *******************************************************************************/
26 
27 #ifndef _AKMURMURHASH_H_
28 #define _AKMURMURHASH_H_
29 
32 
33 // https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp
34 
35 #define MURMUR3_SEED ( 0x41545731 )
36 #define MURMUR3_C1 ( 0xcc9e2d51 )
37 #define MURMUR3_C2 ( 0x1b873593 )
38 #define MURMUR3_C3 ( 0xe6546b64 )
39 
41 {
42  uValue ^= uValue >> 16;
43  uValue *= 0x85ebca6b;
44  uValue ^= uValue >> 13;
45  uValue *= 0xc2b2ae35;
46  uValue ^= uValue >> 16;
47  return uValue;
48 }
49 
51  uValue ^= uValue >> 33;
52  uValue *= 0xff51afd7ed558ccd;
53  uValue ^= uValue >> 33;
54  uValue *= 0xc4ceb9fe1a85ec53;
55  uValue ^= uValue >> 33;
56  return uValue;
57 }
58 
59 AkForceInline void AkHashMurMur32( AkUInt32* pHash, const void* pData, size_t uSize ) {
60  AkUInt32 uH1 = MURMUR3_SEED;
61  AkUInt8* pBytes = ( AkUInt8* )pData;
62  AkUInt32 uNumBlocks = ( AkUInt32 )( uSize / 4 );
63  AkUInt32* pBlocks = ( AkUInt32* )( pBytes + ( uNumBlocks * 4 ) );
64  for ( AkInt32 i = -( AkInt32 )uNumBlocks; i; ++i ) {
65  AkUInt32 uK1 = *( AkUInt32* )( pBlocks + i );
66  uK1 *= MURMUR3_C1;
67  uK1 = AK::ROTL32( uK1, 15 );
68  uK1 *= MURMUR3_C2;
69  uH1 ^= uK1;
70  uH1 = AK::ROTL32( uH1, 13 );
71  uH1 = uH1 * 5 + MURMUR3_C3;
72  }
73  AkUInt8* pBytesTail = ( AkUInt8* )( pBytes + ( uNumBlocks * 4 ) );
74  AkUInt32 uK1 = 0;
75  switch ( uSize & 3 ) {
76  case 3: uK1 ^= pBytesTail[ 2 ] << 16;
77  case 2: uK1 ^= pBytesTail[ 1 ] << 8;
78  case 1: uK1 ^= pBytesTail[ 0 ];
79  uK1 *= MURMUR3_C1;
80  uK1 = AK::ROTL32( uK1, 15 );
81  uK1 *= MURMUR3_C2;
82  uH1 ^= uK1;
83  }
84  uH1 ^= uSize;
85  uH1 = AkHashMurMurMix32( uH1 );
86  *pHash = uH1;
87 }
88 
89 #endif // _AKMURMURHASH_H_
AkForceInline AkUInt32 AkHashMurMurMix32(AkUInt32 uValue)
Definition: AkMurMurHash.h:40
#define MURMUR3_C3
Definition: AkMurMurHash.h:38
uint8_t AkUInt8
Unsigned 8-bit integer
AkForceInline AkUInt32 ROTL32(AkUInt32 x, AkUInt32 r)
#define MURMUR3_SEED
Definition: AkMurMurHash.h:35
int32_t AkInt32
Signed 32-bit integer
#define MURMUR3_C2
Definition: AkMurMurHash.h:37
AkForceInline void AkHashMurMur32(AkUInt32 *pHash, const void *pData, size_t uSize)
Definition: AkMurMurHash.h:59
uint64_t AkUInt64
Unsigned 64-bit integer
#define MURMUR3_C1
Definition: AkMurMurHash.h:36
uint32_t AkUInt32
Unsigned 32-bit integer
#define AkForceInline
Definition: AkTypes.h:63
AkForceInline AkUInt64 AkHashMurMurMix64(AkUInt64 uValue)
Definition: AkMurMurHash.h:50

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅