-
Notifications
You must be signed in to change notification settings - Fork 229
/
codec_mijd.cpp
54 lines (46 loc) · 1.28 KB
/
codec_mijd.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
43
44
45
46
47
48
49
50
51
52
53
#include "codec.h"
#include "log.h"
#include <string.h>
using namespace std;
/* MIJD is a proprietary codec...
* it looks like it contains a couple of jpegs,
* at offset 28 is the relative begin of the first image
* at 32 the length of the first image
* at 34 and 36 width and height of the image
* at 44 relative begin of the second image
* at 48 length of the seocnd image
* at 52 - 54 width and height of the second image.
*
*/
Match Codec::mijdMatch(const unsigned char *start, int maxlength) {
Match match;
if(!strncmp((char *)start, "mijd", 4)) {
uint32_t off = *(uint32_t *)(start + 44);
uint32_t length = *(uint32_t *)(start + 48);
match.length = off + length;
match.chances = 1e30;
return match;
}
uint32_t word = *(uint32_t *)start;
if(word == 0x3030f800) {
match.length = 250;
match.chances = 1e30;
return match;
}
return match;
}
Match Codec::mijdSearch(const unsigned char *start, int maxlength, int maxskip) {
Match match;
const unsigned char *end = start + maxskip;
const unsigned char *current = start;
while(current < end) {
uint32_t word = *(uint32_t *)start;
if(!strncmp((char *)current, "mijd", 4) || word == 0x3030f800) {
match.offset = current - start;
match.chances = 1e30;
return match;
}
current++;
}
return match;
}