Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Reimar Döffinger authored on 2011/10/14 02:45:49... | ... |
@@ -31,13 +31,26 @@ typedef struct { |
31 | 31 |
int continue_pes; |
32 | 32 |
} PVAContext; |
33 | 33 |
|
34 |
+static int pva_check(uint8_t *p) { |
|
35 |
+ int length = AV_RB16(p + 6); |
|
36 |
+ if (AV_RB16(p) != PVA_MAGIC || !p[2] || p[2] > 2 || p[4] != 0x55 || |
|
37 |
+ (p[5] & 0xe0) || length > PVA_MAX_PAYLOAD_LENGTH) |
|
38 |
+ return -1; |
|
39 |
+ return length + 8; |
|
40 |
+} |
|
41 |
+ |
|
34 | 42 |
static int pva_probe(AVProbeData * pd) { |
35 | 43 |
unsigned char *buf = pd->buf; |
44 |
+ int len = pva_check(buf); |
|
36 | 45 |
|
37 |
- if (AV_RB16(buf) == PVA_MAGIC && buf[2] && buf[2] < 3 && buf[4] == 0x55) |
|
46 |
+ if (len < 0) |
|
47 |
+ return 0; |
|
48 |
+ |
|
49 |
+ if (pd->buf_size >= len + 8 && |
|
50 |
+ pva_check(buf + len) >= 0) |
|
38 | 51 |
return AVPROBE_SCORE_MAX / 2; |
39 | 52 |
|
40 |
- return 0; |
|
53 |
+ return AVPROBE_SCORE_MAX / 4; |
|
41 | 54 |
} |
42 | 55 |
|
43 | 56 |
static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) { |