hash

package
v0.0.0-...-206b93c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Width  int = 9
	Height int = 9
)
View Source
const FileMagic string = "DHO"

The file magic for any file that contains hashes. Abbreviation of Difference Hash Object

Variables

View Source
var (
	// Returned if the header read from a hash object file is invalid.
	InvalidHeader = errors.New("Invalid Header")

	// The file extension based off of the file magic
	FileExtension string = "." + strings.ToLower(FileMagic)
)

Functions

func AvErrorStr

func AvErrorStr(averr int) error

func Compare

func Compare(file1 *File, file2 *File) error

Compares two files, returning an error if they are not equal explaining the reason.

func ShutdownVips

func ShutdownVips()

func StartVips

func StartVips()

Types

type File

type File struct {
	Hashes []Hash
	// contains filtered or unexported fields
}

TODO: Consider adding an array of strings at the beginning that has path names, and give each hash a frame index and path index

func LoadFromFile

func LoadFromFile(name string) (*File, error)

Read a given file into a hashinfo object returns InvalidHeader error if the file type is invalid, or a normal error otherwise

func NewFile

func NewFile() *File

Creates a new file with the default file version

func NewFileWithVersion

func NewFileWithVersion(version byte) *File

Creates a new file with the provided version. Currently only "1" exists as a valid option

func NewFromPath

func NewFromPath(path string) (*File, error)

If

image -> handleImage(path)
video -> ffmpegRunner(path) -> for _, f := range runnerFrames { handleImage(f, path) }
dir -> Iterate through directory, doing the above two for each

func NewFromVideo2

func NewFromVideo2(name string) (*File, error)

func (*File) Deduplicate

func (f *File) Deduplicate()

Deduplication of hashes

func (*File) Length

func (f *File) Length() int

Returns the length of the hash array, equivalent to len(*Hashes())

func (File) Version

func (f File) Version() int

func (*File) Write

func (f *File) Write(path string) error

Writes the file to the given output path, appending the appropriate file extension if necessary

type Hash

type Hash struct {
	Hash uint64

	// TODO: an ID? a Hash? what do we use to map these hashes to concrete output.
	// Maybe remove this index from the hash altogether and store it separately
	Index uint32
}

TODO: Maybe make Index a uint64 for file storage sake

func (Hash) Distance

func (i Hash) Distance(o Hash) int

Returns the hamming distance between the two hashes

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL