pHash
PHP
Evan Klinger
eklinger@phash.org
lead
1.0.1
2021-12-20
release
struct ph_audio_hash
{
uint32_t *hash;
int len;
};
struct ph_video_hash
{
ulong64 *hash;
int len;
};
struct ph_text_hash
{
TxtHashPoint *p;
int count;
};
A ulong64 resource
if(resource)
{
free(resource->hash);
free(resource);
}
A ulong64 resource
if(resource)
free(resource);
A uint32_t resource
if(resource)
{
free(resource->hash);
free(resource);
}
A TxtHashPoint resource
if(resource)
{
free(resource->p);
free(resource);
}
resource ph_video_hash ph_dct_videohash(string file)
pHash DCT video hash
Perceptual video hash based on DCT.
hash = video_hash;
p->len = len;
return_res = p;
}
else
RETURN_FALSE;
]]>
resource ph_image_hash ph_dct_imagehash(string file)
pHash DCT image hash
Perceptual image hash based on DCT.
resource ph_txt_hash ph_texthash(string file)
pHash cyclic text hash
Perceptual text hash based on cyclic polynomials.
p = txtHash;
h->count = num;
return_res = h;
}
else
RETURN_FALSE;
]]>
resource ph_audio_hash ph_audiohash(string file, int sample_rate=5512, int channels=1)
pHash audio hash
Perceptual audio hash based on bark scale.
hash = hash;
h->len = nb_frames;
return_res = h;
}
else
RETURN_FALSE;
}
else
RETURN_FALSE;
]]>
float ph_image_dist(resource ph_image_hash h1,resource ph_image_hash h2)
pHash image distance.
Calculate distance between two images.
float ph_video_dist(resource ph_video_hash h1,resource ph_video_hash h2, int thresh=21)
pHash video distance.
Calculate distance between two videos.
hash, h1->len, h2->hash, h2->len, thresh);
RETURN_DOUBLE(sim);
}
else
RETURN_DOUBLE(-1);
]]>
float ph_audio_dist(resource ph_audio_hash h1,resource ph_audio_hash h2,
int block_size=256, float thresh=0.30)
pHash audio distance.
Calculate distance between two audio files.
hash, h1->len, h2->hash, h2->len,
thresh, block_size, Nc);
if(cs)
{
double max_cs = 0.0;
for (int i = 0; i < Nc; ++i)
{
if (cs[i] > max_cs)
{
max_cs = cs[i];
}
}
free(cs);
RETURN_DOUBLE(max_cs);
}
else
RETURN_DOUBLE(-1);
}
else
RETURN_DOUBLE(-1);
]]>
array ph_compare_text_hashes(resource ph_txt_hash h1,resource ph_txt_hash h2)
pHash text distance.
Calculate distance between two text hashes.
p, h1->count, h2->p, h2->count, &count);
if(m)
{
for(int i = 0; i < count; ++i)
{
zval *array;
MAKE_STD_ZVAL(array);
array_init(array);
add_assoc_long(array, "begin", m[i].first_index);
add_assoc_long(array, "end", m[i].second_index);
add_assoc_long(array, "length", m[i].length);
add_next_index_zval(return_value, array);
}
free(m);
}
else
RETURN_FALSE;
}
else
RETURN_FALSE;
]]>