-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash-frames.c
31 lines (27 loc) · 947 Bytes
/
hash-frames.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <RSImg.h>
#include <RSUtil.h>
#include <ccity.h>
#include <stdlib.h>
int main() {
uint32_t width, height, headerSize;
uint32_t firstWidth, firstHeight, firstHeaderSize;
if (!RSImgFreadPPMP6Header(stdin, &firstWidth, &firstHeight, &firstHeaderSize)) {
RSFatalError("RSImgFreadPPMP6Header");
}
uint64_t hash;
uint32_t pixelDataSize = firstWidth * firstHeight * 3;
uint8_t *pixelData = RSMallocOrDie(pixelDataSize);
RSFReadOrDie(pixelData, pixelDataSize, stdin);
while (1) {
hash = ccity_hash128_64(pixelData, pixelDataSize);
RSFWriteOrDie(&hash, sizeof(uint64_t), stdout);
if (!RSImgFreadPPMP6Header(stdin, &width, &height, &headerSize)) {
break;
}
if ((width != firstWidth) || (height != firstHeight)) {
RSFatalError("dimensions changed");
}
RSFReadOrDie(pixelData, pixelDataSize, stdin);
}
return 0;
}