1 /* 2 * Copyright (C) 2013 Reimar Döffinger <Reimar.Doeffinger@gmx.de> 3 * 4 * This file is part of FFmpeg. 5 * 6 * FFmpeg is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * FFmpeg is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with FFmpeg; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 /** 22 * @file 23 * @ingroup lavu_murmur3 24 * Public header for MurmurHash3 hash function implementation. 25 */ 26 module ffmpeg.libavutil.murmur3; 27 extern (C) @nogc nothrow: 28 29 /** 30 * @defgroup lavu_murmur3 Murmur3 31 * @ingroup lavu_hash 32 * MurmurHash3 hash function implementation. 33 * 34 * MurmurHash3 is a non-cryptographic hash function, of which three 35 * incompatible versions were created by its inventor Austin Appleby: 36 * 37 * - 32-bit output 38 * - 128-bit output for 32-bit platforms 39 * - 128-bit output for 64-bit platforms 40 * 41 * FFmpeg only implements the last variant: 128-bit output designed for 64-bit 42 * platforms. Even though the hash function was designed for 64-bit platforms, 43 * the function in reality works on 32-bit systems too, only with reduced 44 * performance. 45 * 46 * @anchor lavu_murmur3_seedinfo 47 * By design, MurmurHash3 requires a seed to operate. In response to this, 48 * libavutil provides two functions for hash initiation, one that requires a 49 * seed (av_murmur3_init_seeded()) and one that uses a fixed arbitrary integer 50 * as the seed, and therefore does not (av_murmur3_init()). 51 * 52 * To make hashes comparable, you should provide the same seed for all calls to 53 * this hash function -- if you are supplying one yourself, that is. 54 * 55 * @{ 56 */ 57 58 /** 59 * Allocate an AVMurMur3 hash context. 60 * 61 * @return Uninitialized hash context or `NULL` in case of error 62 */ 63 struct AVMurMur3; 64 AVMurMur3* av_murmur3_alloc (); 65 66 /** 67 * Initialize or reinitialize an AVMurMur3 hash context with a seed. 68 * 69 * @param[out] c Hash context 70 * @param[in] seed Random seed 71 * 72 * @see av_murmur3_init() 73 * @see @ref lavu_murmur3_seedinfo "Detailed description" on a discussion of 74 * seeds for MurmurHash3. 75 */ 76 void av_murmur3_init_seeded (AVMurMur3* c, ulong seed); 77 78 /** 79 * Initialize or reinitialize an AVMurMur3 hash context. 80 * 81 * Equivalent to av_murmur3_init_seeded() with a built-in seed. 82 * 83 * @param[out] c Hash context 84 * 85 * @see av_murmur3_init_seeded() 86 * @see @ref lavu_murmur3_seedinfo "Detailed description" on a discussion of 87 * seeds for MurmurHash3. 88 */ 89 void av_murmur3_init (AVMurMur3* c); 90 91 /** 92 * Update hash context with new data. 93 * 94 * @param[out] c Hash context 95 * @param[in] src Input data to update hash with 96 * @param[in] len Number of bytes to read from `src` 97 */ 98 void av_murmur3_update (AVMurMur3* c, const(ubyte)* src, int len); 99 100 /** 101 * Finish hashing and output digest value. 102 * 103 * @param[in,out] c Hash context 104 * @param[out] dst Buffer where output digest value is stored 105 */ 106 void av_murmur3_final (AVMurMur3* c, ref ubyte[16] dst); 107 108 /** 109 * @} 110 */ 111 112 /* AVUTIL_MURMUR3_H */