Browse code

bethsoftvideo: return proper consumed size for palette packets.

Also check for sufficient packet size.

Anton Khirnov authored on 2011/11/22 05:22:44
Showing 2 changed files
... ...
@@ -46,14 +46,19 @@ static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx)
46 46
     return 0;
47 47
 }
48 48
 
49
-static void set_palette(AVFrame * frame, const uint8_t * palette_buffer)
49
+static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)
50 50
 {
51 51
     uint32_t * palette = (uint32_t *)frame->data[1];
52 52
     int a;
53
+
54
+    if (buf_size < 256*3)
55
+        return AVERROR_INVALIDDATA;
56
+
53 57
     for(a = 0; a < 256; a++){
54 58
         palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
55 59
     }
56 60
     frame->palette_has_changed = 1;
61
+    return 256*3;
57 62
 }
58 63
 
59 64
 static int bethsoftvid_decode_frame(AVCodecContext *avctx,
... ...
@@ -80,8 +85,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
80 80
 
81 81
     switch(block_type = *buf++){
82 82
         case PALETTE_BLOCK:
83
-            set_palette(&vid->frame, buf);
84
-            return 0;
83
+            return set_palette(&vid->frame, buf, buf_size);
85 84
         case VIDEO_YOFF_P_FRAME:
86 85
             yoffset = bytestream_get_le16(&buf);
87 86
             if(yoffset >= avctx->height)
... ...
@@ -1,90 +1,91 @@
1
-0, 0, 192000, 0x00000000
1
+0, 0, 192000, 0xdecc683b
2 2
 1, 0, 1480, 0x00000000
3
-0, 1500, 192000, 0x01a6cf45
4
-0, 3000, 192000, 0xd07d57e9
5
-0, 4500, 192000, 0x3cb1dff5
3
+0, 1500, 192000, 0x00000000
4
+0, 3000, 192000, 0x01a6cf45
5
+0, 4500, 192000, 0xd07d57e9
6 6
 1, 5994, 1480, 0x20a92bd4
7
-0, 6000, 192000, 0xd1aaa8fb
8
-0, 7500, 192000, 0x75f526cd
9
-0, 9000, 192000, 0x0f673577
10
-0, 10500, 192000, 0x897b6781
7
+0, 6000, 192000, 0x3cb1dff5
8
+0, 7500, 192000, 0xd1aaa8fb
9
+0, 9000, 192000, 0x75f526cd
10
+0, 10500, 192000, 0x0f673577
11 11
 1, 11988, 1850, 0xa9e48a74
12
-0, 12000, 192000, 0x81e6b7f7
13
-0, 13500, 192000, 0x1f45ce61
14
-0, 15000, 192000, 0x5a0772a6
15
-0, 16500, 192000, 0xf78732b3
16
-0, 18000, 192000, 0x8427f9e5
12
+0, 12000, 192000, 0x897b6781
13
+0, 13500, 192000, 0x81e6b7f7
14
+0, 15000, 192000, 0x1f45ce61
15
+0, 16500, 192000, 0x5a0772a6
16
+0, 18000, 192000, 0xf78732b3
17 17
 1, 19481, 1480, 0x23ecd018
18
-0, 19500, 192000, 0x40473f11
19
-0, 21000, 192000, 0x173ceebe
20
-0, 22500, 192000, 0x136b9516
21
-0, 24000, 192000, 0x138d11ae
18
+0, 19500, 192000, 0x8427f9e5
19
+0, 21000, 192000, 0x40473f11
20
+0, 22500, 192000, 0x173ceebe
21
+0, 24000, 192000, 0x136b9516
22 22
 1, 25475, 1480, 0x206bb915
23
-0, 25500, 192000, 0x063dbff3
24
-0, 27000, 192000, 0x5280852f
25
-0, 28500, 192000, 0x99943a8f
26
-0, 30000, 192000, 0x0330a728
23
+0, 25500, 192000, 0x138d11ae
24
+0, 27000, 192000, 0x063dbff3
25
+0, 28500, 192000, 0x5280852f
26
+0, 30000, 192000, 0x99943a8f
27 27
 1, 31469, 1850, 0xb0e10e75
28
-0, 31500, 192000, 0x5d35467d
29
-0, 33000, 192000, 0xfd436343
30
-0, 34500, 192000, 0xc323fcfe
31
-0, 36000, 192000, 0x2a1530a0
32
-0, 37500, 192000, 0xbd43bb60
28
+0, 31500, 192000, 0x0330a728
29
+0, 33000, 192000, 0x5d35467d
30
+0, 34500, 192000, 0xfd436343
31
+0, 36000, 192000, 0xc323fcfe
32
+0, 37500, 192000, 0x2a1530a0
33 33
 1, 38961, 1480, 0x8d9baedd
34
-0, 39000, 192000, 0xa47f5eab
35
-0, 40500, 192000, 0xff17f5f7
36
-0, 42000, 192000, 0xb4140b55
37
-0, 43500, 192000, 0xb8782cc4
34
+0, 39000, 192000, 0xbd43bb60
35
+0, 40500, 192000, 0xa47f5eab
36
+0, 42000, 192000, 0xff17f5f7
37
+0, 43500, 192000, 0xb4140b55
38 38
 1, 44955, 1480, 0xb802aae1
39
-0, 45000, 192000, 0x92975b8b
40
-0, 46500, 192000, 0xf42a64d6
41
-0, 48000, 192000, 0x2cc7077d
42
-0, 49500, 192000, 0x00080cc8
39
+0, 45000, 192000, 0xb8782cc4
40
+0, 46500, 192000, 0x92975b8b
41
+0, 48000, 192000, 0xf42a64d6
42
+0, 49500, 192000, 0x2cc7077d
43 43
 1, 50950, 1480, 0xecd7b5cc
44
-0, 51000, 192000, 0x584b48f3
45
-0, 52500, 192000, 0xd68f57da
46
-0, 54000, 192000, 0x60158422
47
-0, 55500, 192000, 0xd7fb89e6
44
+0, 51000, 192000, 0x00080cc8
45
+0, 52500, 192000, 0x584b48f3
46
+0, 54000, 192000, 0xd68f57da
47
+0, 55500, 192000, 0x60158422
48 48
 1, 56944, 1850, 0x16861355
49
-0, 57000, 192000, 0x97f1c76a
50
-0, 58500, 192000, 0x46c4bb9e
51
-0, 60000, 192000, 0xd32f9b66
52
-0, 61500, 192000, 0x74f43886
53
-0, 63000, 192000, 0x3c4e47df
49
+0, 57000, 192000, 0xd7fb89e6
50
+0, 58500, 192000, 0x97f1c76a
51
+0, 60000, 192000, 0x46c4bb9e
52
+0, 61500, 192000, 0xd32f9b66
53
+0, 63000, 192000, 0x74f43886
54 54
 1, 64436, 1480, 0xa51690bd
55
-0, 64500, 192000, 0xb5ac0a58
56
-0, 66000, 192000, 0xcc572b31
57
-0, 67500, 192000, 0xb1739d26
58
-0, 69000, 192000, 0x73da5473
55
+0, 64500, 192000, 0x3c4e47df
56
+0, 66000, 192000, 0xb5ac0a58
57
+0, 67500, 192000, 0xcc572b31
58
+0, 69000, 192000, 0xb1739d26
59 59
 1, 70430, 1480, 0xdd0b90d1
60
-0, 70500, 192000, 0x5f79f5bc
61
-0, 72000, 192000, 0x0affc0a0
62
-0, 73500, 192000, 0x2b4d5c1c
63
-0, 75000, 192000, 0x309b41bc
60
+0, 70500, 192000, 0x73da5473
61
+0, 72000, 192000, 0x5f79f5bc
62
+0, 73500, 192000, 0x0affc0a0
63
+0, 75000, 192000, 0x2b4d5c1c
64 64
 1, 76424, 1850, 0x3ce6e333
65
-0, 76500, 192000, 0xd42b6424
66
-0, 78000, 192000, 0x4795c948
67
-0, 79500, 192000, 0xbc1a3a8b
68
-0, 81000, 192000, 0x16529c5b
69
-0, 82500, 192000, 0x6b1b31ba
65
+0, 76500, 192000, 0x309b41bc
66
+0, 78000, 192000, 0xd42b6424
67
+0, 79500, 192000, 0x4795c948
68
+0, 81000, 192000, 0xbc1a3a8b
69
+0, 82500, 192000, 0x16529c5b
70 70
 1, 83917, 1480, 0xf8ce8ea3
71
-0, 84000, 192000, 0x569182ce
72
-0, 85500, 192000, 0xe6ea9866
73
-0, 87000, 192000, 0x102c6076
74
-0, 88500, 192000, 0xb29f527a
71
+0, 84000, 192000, 0x6b1b31ba
72
+0, 85500, 192000, 0x569182ce
73
+0, 87000, 192000, 0xe6ea9866
74
+0, 88500, 192000, 0x102c6076
75 75
 1, 89911, 1480, 0xda4597af
76
-0, 90000, 192000, 0x040b4eee
77
-0, 91500, 192000, 0x92574f4a
78
-0, 93000, 192000, 0x1e8acdce
79
-0, 94500, 192000, 0x1becf516
76
+0, 90000, 192000, 0xb29f527a
77
+0, 91500, 192000, 0x040b4eee
78
+0, 93000, 192000, 0x92574f4a
79
+0, 94500, 192000, 0x1e8acdce
80 80
 1, 95905, 1480, 0x918f7cb3
81
-0, 96000, 192000, 0xb62e9776
82
-0, 97500, 192000, 0xed37a08e
83
-0, 99000, 192000, 0xc0719912
84
-0, 100500, 192000, 0x24cf7a7e
81
+0, 96000, 192000, 0x1becf516
82
+0, 97500, 192000, 0xb62e9776
83
+0, 99000, 192000, 0xed37a08e
84
+0, 100500, 192000, 0xc0719912
85 85
 1, 101899, 1850, 0xca6edb15
86
-0, 102000, 192000, 0x0307f62f
87
-0, 103500, 192000, 0x79b7417b
86
+0, 102000, 192000, 0x24cf7a7e
87
+0, 103500, 192000, 0x0307f62f
88
+0, 105000, 192000, 0x79b7417b
88 89
 1, 109392, 1480, 0xba279597
89 90
 1, 115386, 1480, 0xc5a38a9e
90 91
 1, 121380, 1850, 0x8147eef5