forked from ponchio/untrunc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec_camm.cpp
41 lines (34 loc) · 995 Bytes
/
codec_camm.cpp
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
32
33
34
35
36
37
38
39
40
#include "codec.h"
//https://developers.google.com/streetview/publish/camm-spec
//TODO could tell from the working sample which types are used.
#include <set>
#include <iostream>
using namespace std;
Match Codec::cammMatch(const unsigned char *start, int maxlength) {
Match match;
int lengths[] = { 12, 8, 12, 12, 12, 24, 14*4, 12 };
while(start[0] == 0 && start[1] == 0 || start[3] == 0 && start[2] < 7) {
int type = start[2];
match.chances = 1<<20;
int len = lengths[type] + 4;
match.length += len;
start += len;
if(match.length > maxlength - 15*4)
break;
}
return match;
}
Match Codec::cammSearch(const unsigned char *start, int maxlength, int maxskip) {
Match match;
const unsigned char *end = start + maxskip;
const unsigned char *current = start;
while(current < end) {
if(start[0] == 0 && start[1] == 0 || start[3] == 0 && start[2] < 7) {
match.chances = 1<<20;
match.offset = current - start;
return match;
}
current++;
}
return match;
}