forked from ponchio/untrunc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec_apch.cpp
43 lines (37 loc) · 1.14 KB
/
codec_apch.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
41
42
#include "codec.h"
#include "log.h"
#include <string.h>
using namespace std;
/* mbex is a codec for some editing data I cannot find documentation for.
* for the few examples I got they are very small packets (8, 10, 100 bytes
* large packets included crec and cist atoms.
* Examples:
*
* Length 8: 00 00 00 08 00 00 00 00 01 3E 15 29
* Length 10: 00 00 00 0A 00 00 00 01 00 06 00 00 23 95
* Length 100: 00 00 00 64 00 00 00 01 00 00 00 5C 63 72 65 63 00 00 00 54 63 69 74 73 00 00 00 0C 00 00 00 02 00 00 00 01
*/
Match Codec::apchMatch(const unsigned char *start, int maxlength) {
Match match;
uint32_t length = readBE<uint32_t>(start);
if(!strncmp((char *)start + 4, "icpf", 4)) {
match.length = length;
match.chances = 1e30;
return match;
}
return match;
}
Match Codec::apchSearch(const unsigned char *start, int maxlength) {
Match match;
const unsigned char *end = start + maxlength - 8;
const unsigned char *current = start;
while(current < end) {
if(!strncmp((char *)current + 4, "icpf", 4)) {
match.offset = current - start;
match.chances = 1e30;
return match;
}
current++;
}
return match;
}