forked from ponchio/untrunc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec_gpmd.cpp
37 lines (30 loc) · 970 Bytes
/
codec_gpmd.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
#include "codec.h"
#include <set>
#include <iostream>
using namespace std;
Match Codec::gpmdMatch(const unsigned char *start, int maxlength) {
Match match;
set<string> fourcc = {"DEVC", "DVID", "DVNM", "STRM", "STNM", "RMRK", "SCAL",
"SIUN", "UNIT", "TYPE", "TSMP", "TIMO", "EMPT"};
if(!fourcc.count(string((char *)start, 4)))
return match;
match.chances = 1<<20;
match.length = (readBE<int32_t>(start + 4) & 0xffff) + 8;
return match;
}
Match Codec::gpmdSearch(const unsigned char *start, int maxlength, int maxskip) {
Match match;
const unsigned char *end = start + maxskip;
const unsigned char *current = start;
set<string> fourcc = {"DEVC", "DVID", "DVNM", "STRM", "STNM", "RMRK", "SCAL",
"SIUN", "UNIT", "TYPE", "TSMP", "TIMO", "EMPT"};
while(current < end) {
if(fourcc.count(string((char *)current, 4))) {
match.chances = 1<<20;
match.offset = current - start;
return match;
}
current++;
}
return match;
}