in pdq/java/src/main/java/pdqhashing/hasher/PDQHasher.java [272:359]
public HashesAndQuality pdqHash256esFromFloatLuma(
float[] fullBuffer1, // image numRows x numCols as row-major array
float[] fullBuffer2, // image numRows x numCols as row-major array
int numRows,
int numCols,
float[][] buffer64x64,
float[][] buffer16x64,
float[][] buffer16x16,
float[][] buffer16x16Aux,
int dihFlags)
{
// Downsample (blur and decimate)
int windowSizeAlongRows = computeJaroszFilterWindowSize(numCols);
int windowSizeAlongCols = computeJaroszFilterWindowSize(numRows);
jaroszFilterFloat(
fullBuffer1,
fullBuffer2,
numRows,
numCols,
windowSizeAlongRows,
windowSizeAlongCols,
PDQ_NUM_JAROSZ_XY_PASSES
);
decimateFloat(fullBuffer1, numRows, numCols, buffer64x64);
// Quality metric. Reuse the 64x64 image-domain downsample
// since we already have it.
int quality = computePDQImageDomainQualityMetric(buffer64x64);
// 2D DCT
dct64To16(buffer64x64, buffer16x64, buffer16x16);
// Output bits
Hash256 hash = null;
Hash256 hashRotate90 = null;
Hash256 hashRotate180 = null;
Hash256 hashRotate270 = null;
Hash256 hashFlipX = null;
Hash256 hashFlipY = null;
Hash256 hashFlipPlus1 = null;
Hash256 hashFlipMinus1 = null;
if ((dihFlags & PDQ_DO_DIH_ORIGINAL) != 0) {
hash = pdqBuffer16x16ToBits(buffer16x16);
}
if ((dihFlags & PDQ_DO_DIH_ROTATE_90) != 0) {
dct16OriginalToRotate90(buffer16x16, buffer16x16Aux);
hashRotate90 = pdqBuffer16x16ToBits(buffer16x16Aux);
}
if ((dihFlags & PDQ_DO_DIH_ROTATE_180) != 0) {
dct16OriginalToRotate180(buffer16x16, buffer16x16Aux);
hashRotate180 = pdqBuffer16x16ToBits(buffer16x16Aux);
}
if ((dihFlags & PDQ_DO_DIH_ROTATE_270) != 0) {
dct16OriginalToRotate270(buffer16x16, buffer16x16Aux);
hashRotate270 = pdqBuffer16x16ToBits(buffer16x16Aux);
}
if ((dihFlags & PDQ_DO_DIH_FLIPX) != 0) {
dct16OriginalToFlipX(buffer16x16, buffer16x16Aux);
hashFlipX = pdqBuffer16x16ToBits(buffer16x16Aux);
}
if ((dihFlags & PDQ_DO_DIH_FLIPY) != 0) {
dct16OriginalToFlipY(buffer16x16, buffer16x16Aux);
hashFlipY = pdqBuffer16x16ToBits(buffer16x16Aux);
}
if ((dihFlags & PDQ_DO_DIH_FLIP_PLUS1) != 0) {
dct16OriginalToFlipPlus1(buffer16x16, buffer16x16Aux);
hashFlipPlus1 = pdqBuffer16x16ToBits(buffer16x16Aux);
}
if ((dihFlags & PDQ_DO_DIH_FLIP_MINUS1) != 0) {
dct16OriginalToFlipMinus1(buffer16x16, buffer16x16Aux);
hashFlipMinus1 = pdqBuffer16x16ToBits(buffer16x16Aux);
}
return new HashesAndQuality(
hash,
hashRotate90,
hashRotate180,
hashRotate270,
hashFlipX,
hashFlipY,
hashFlipPlus1,
hashFlipMinus1,
quality
);
}