-
Notifications
You must be signed in to change notification settings - Fork 229
/
codec_unknown.cpp
76 lines (59 loc) · 1.85 KB
/
codec_unknown.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "codec.h"
#include "log.h"
////it might be encode each sample (1-4) bytes as a packet (AARGH!)
Match Codec::unknownMatch(const unsigned char *start, int maxlength) {
Match match;
if(name == "rtmd") {
int32_t begin32 = readBE<int32_t>(start);
if(stats.beginnings32.count(begin32))
match.chances = 10*stats.beginnings32[begin32];
match.length = 1024;
// match.length = 5120; sometimes found with this size (use stats!)
return match;
}
//probably no samples
if(!stats.fixed_size)
return match;
if(stats.fixed_size)
match.length = stats.fixed_size;
if(name == "samr") {
//samr special thing might be 160... or different values.
static const uint8_t amrnb_packed_size[16] = {
13, 14, 16, 18, 20, 21, 27, 32, 6, 1, 1, 1, 1, 1, 1, 1
};
static const uint8_t amrwb_packed_size[16] = {
18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 1, 1, 1, 1, 1, 1
};
int mode = (start[0] >> 3) & 0xf;
if (mode > 9 || (start[0] & 0x4) != 0x4) {
match.chances = 0;
return match;
}
match.length = amrnb_packed_size[mode];
match.chances = 4;
}
int64_t begin64 = readBE<int64_t>(start);
int32_t begin32 = readBE<int32_t>(start);
/*if(stats.fixed_begin64) {
if(stats.fixed_begin64 == begin64)
match.chances = 1e40f;
else
match.chances = 0.0f;
return match;
}
if(stats.fixed_begin32) {
if(stats.fixed_begin32 == begin32)
match.chances = 1e20f;
else
match.chances = 0.0f;
return match;
}*/
//if we have a probability with the beginnig we can do something otherwise just lower it below 2 (for pcm)
//we will have to look up for patterns, and when chances are really low, use search!
if(stats.beginnings32.count(begin32))
match.chances = stats.beginnings32[begin32];
if(stats.beginnings64.count(begin64))
match.chances = stats.beginnings64[begin64];
//match.chances = 0.0f; //we really have no idea
return match;
}