Mercurial > mplayer.hg
annotate msvidc.c @ 3038:fa8665a91729
subtitles looked bad here (inverted colors sometimes)
looked like values wrapped around the byte
(not sure of the side effects but subtitles look good now)
author | pl |
---|---|
date | Tue, 20 Nov 2001 21:45:07 +0000 |
parents | 6b69f306cf6e |
children | d930dbae8473 |
rev | line source |
---|---|
2960 | 1 /* |
2 Microsoft Video 1 Decoder | |
3 | |
4 (C) 2001 Mike Melanson | |
5 | |
6 The description of the algorithm you can read here: | |
7 http://www.pcisys.net/~melanson/video1.txt | |
8 */ | |
2827
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
9 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
10 #define LE_16(x) *(unsigned short *)(x) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
11 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
12 #define DECODE_BGR555_TO_BGR888(x) \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
13 x.c1_b = (x.c1 >> 7) & 0xF8; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
14 x.c1_g = (x.c1 >> 2) & 0xF8; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
15 x.c1_r = (x.c1 << 3) & 0xF8; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
16 x.c2_b = (x.c2 >> 7) & 0xF8; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
17 x.c2_g = (x.c2 >> 2) & 0xF8; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
18 x.c2_r = (x.c2 << 3) & 0xF8; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
19 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
20 #define DECODE_PALETTE_TO_BGR888(x) \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
21 x.c1_b = palette_map[x.c1 * 4 + 2]; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
22 x.c1_g = palette_map[x.c1 * 4 + 1]; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
23 x.c1_r = palette_map[x.c1 * 4 + 0]; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
24 x.c2_b = palette_map[x.c2 * 4 + 2]; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
25 x.c2_g = palette_map[x.c2 * 4 + 1]; \ |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
26 x.c2_r = palette_map[x.c2 * 4 + 0]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
27 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
28 struct |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
29 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
30 unsigned short c1, c2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
31 unsigned char c1_r, c1_g, c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
32 unsigned char c2_r, c2_g, c2_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
33 } quad[2][2]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
34 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
35 void AVI_Decode_Video1_16( |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
36 char *encoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
37 int encoded_size, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
38 char *decoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
39 int width, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
40 int height, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
41 int bytes_per_pixel) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
42 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
43 int block_ptr, pixel_ptr; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
44 int pixel_x, pixel_y; // pixel width and height iterators |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
45 int block_x, block_y; // block width and height iterators |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
46 int blocks_wide, blocks_high; // width and height in 4x4 blocks |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
47 int block_inc; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
48 int row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
49 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
50 // decoding parameters |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
51 int stream_ptr; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
52 unsigned char byte_a, byte_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
53 unsigned short flags; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
54 int skip_blocks; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
55 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
56 stream_ptr = 0; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
57 skip_blocks = 0; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
58 blocks_wide = width / 4; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
59 blocks_high = height / 4; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
60 block_inc = 4 * bytes_per_pixel; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
61 row_dec = (width + 4) * bytes_per_pixel; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
62 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
63 for (block_y = blocks_high; block_y > 0; block_y--) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
64 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
65 block_ptr = ((block_y * 4) - 1) * (width * bytes_per_pixel); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
66 for (block_x = blocks_wide; block_x > 0; block_x--) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
67 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
68 // check if this block should be skipped |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
69 if (skip_blocks) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
70 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
71 block_ptr += block_inc; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
72 skip_blocks--; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
73 continue; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
74 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
75 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
76 pixel_ptr = block_ptr; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
77 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
78 // get the next two bytes in the encoded data stream |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
79 byte_a = encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
80 byte_b = encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
81 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
82 // check if the decode is finished |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
83 if ((byte_a == 0) && (byte_b == 0)) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
84 return; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
85 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
86 // check if this is a skip code |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
87 else if ((byte_b & 0xFC) == 0x84) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
88 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
89 // but don't count the current block |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
90 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
91 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
92 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
93 // check if this is in the 2- or 8-color classes |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
94 else if (byte_b < 0x80) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
95 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
96 flags = (byte_b << 8) | byte_a; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
97 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
98 quad[0][0].c1 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
99 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
100 quad[0][0].c2 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
101 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
102 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
103 DECODE_BGR555_TO_BGR888(quad[0][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
104 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
105 if (quad[0][0].c1 & 0x8000) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
106 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
107 // 8-color encoding |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
108 quad[1][0].c1 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
109 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
110 quad[1][0].c2 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
111 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
112 quad[0][1].c1 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
113 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
114 quad[0][1].c2 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
115 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
116 quad[1][1].c1 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
117 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
118 quad[1][1].c2 = LE_16(&encoded[stream_ptr]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
119 stream_ptr += 2; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
120 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
121 DECODE_BGR555_TO_BGR888(quad[0][1]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
122 DECODE_BGR555_TO_BGR888(quad[1][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
123 DECODE_BGR555_TO_BGR888(quad[1][1]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
124 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
125 for (pixel_y = 0; pixel_y < 4; pixel_y++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
126 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
127 for (pixel_x = 0; pixel_x < 4; pixel_x++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
128 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
129 if (flags & 1) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
130 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
131 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
132 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
133 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
134 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
135 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
136 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
137 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
138 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
139 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
140 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
141 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
142 // get the next flag ready to go |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
143 flags >>= 1; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
144 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
145 pixel_ptr -= row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
146 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
147 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
148 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
149 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
150 // 2-color encoding |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
151 for (pixel_y = 0; pixel_y < 4; pixel_y++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
152 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
153 for (pixel_x = 0; pixel_x < 4; pixel_x++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
154 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
155 if (flags & 1) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
156 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
157 decoded[pixel_ptr++] = quad[0][0].c1_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
158 decoded[pixel_ptr++] = quad[0][0].c1_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
159 decoded[pixel_ptr++] = quad[0][0].c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
160 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
161 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
162 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
163 decoded[pixel_ptr++] = quad[0][0].c2_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
164 decoded[pixel_ptr++] = quad[0][0].c2_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
165 decoded[pixel_ptr++] = quad[0][0].c2_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
166 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
167 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
168 // get the next flag ready to go |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
169 flags >>= 1; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
170 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
171 pixel_ptr -= row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
172 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
173 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
174 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
175 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
176 // otherwise, it's a 1-color block |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
177 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
178 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
179 quad[0][0].c1 = (byte_b << 8) | byte_a; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
180 DECODE_BGR555_TO_BGR888(quad[0][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
181 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
182 for (pixel_y = 0; pixel_y < 4; pixel_y++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
183 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
184 for (pixel_x = 0; pixel_x < 4; pixel_x++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
185 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
186 decoded[pixel_ptr++] = quad[0][0].c1_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
187 decoded[pixel_ptr++] = quad[0][0].c1_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
188 decoded[pixel_ptr++] = quad[0][0].c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
189 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
190 pixel_ptr -= row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
191 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
192 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
193 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
194 block_ptr += block_inc; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
195 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
196 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
197 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
198 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
199 void AVI_Decode_Video1_8( |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
200 char *encoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
201 int encoded_size, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
202 char *decoded, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
203 int width, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
204 int height, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
205 unsigned char *palette_map, |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
206 int bytes_per_pixel) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
207 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
208 int block_ptr, pixel_ptr; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
209 int pixel_x, pixel_y; // pixel width and height iterators |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
210 int block_x, block_y; // block width and height iterators |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
211 int blocks_wide, blocks_high; // width and height in 4x4 blocks |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
212 int block_inc; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
213 int row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
214 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
215 // decoding parameters |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
216 int stream_ptr; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
217 unsigned char byte_a, byte_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
218 unsigned short flags; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
219 int skip_blocks; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
220 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
221 stream_ptr = 0; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
222 skip_blocks = 0; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
223 blocks_wide = width / 4; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
224 blocks_high = height / 4; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
225 block_inc = 4 * bytes_per_pixel; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
226 row_dec = (width + 4) * bytes_per_pixel; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
227 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
228 for (block_y = blocks_high; block_y > 0; block_y--) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
229 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
230 block_ptr = ((block_y * 4) - 1) * (width * bytes_per_pixel); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
231 for (block_x = blocks_wide; block_x > 0; block_x--) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
232 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
233 // check if this block should be skipped |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
234 if (skip_blocks) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
235 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
236 block_ptr += block_inc; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
237 skip_blocks--; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
238 continue; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
239 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
240 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
241 pixel_ptr = block_ptr; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
242 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
243 // get the next two bytes in the encoded data stream |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
244 byte_a = encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
245 byte_b = encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
246 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
247 // check if the decode is finished |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
248 if ((byte_a == 0) && (byte_b == 0)) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
249 return; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
250 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
251 // check if this is a skip code |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
252 else if ((byte_b & 0xFC) == 0x84) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
253 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
254 // but don't count the current block |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
255 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
256 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
257 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
258 // check if this is a 2-color block |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
259 else if (byte_b < 0x80) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
260 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
261 flags = (byte_b << 8) | byte_a; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
262 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
263 quad[0][0].c1 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
264 quad[0][0].c2 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
265 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
266 DECODE_PALETTE_TO_BGR888(quad[0][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
267 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
268 // 2-color encoding |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
269 for (pixel_y = 0; pixel_y < 4; pixel_y++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
270 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
271 for (pixel_x = 0; pixel_x < 4; pixel_x++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
272 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
273 if (flags & 1) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
274 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
275 decoded[pixel_ptr++] = quad[0][0].c1_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
276 decoded[pixel_ptr++] = quad[0][0].c1_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
277 decoded[pixel_ptr++] = quad[0][0].c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
278 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
279 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
280 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
281 decoded[pixel_ptr++] = quad[0][0].c2_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
282 decoded[pixel_ptr++] = quad[0][0].c2_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
283 decoded[pixel_ptr++] = quad[0][0].c2_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
284 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
285 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
286 // get the next flag ready to go |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
287 flags >>= 1; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
288 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
289 pixel_ptr -= row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
290 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
291 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
292 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
293 // check if it's an 8-color block |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
294 else if (byte_b >= 0x90) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
295 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
296 // 8-color encoding |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
297 quad[0][0].c1 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
298 quad[0][0].c2 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
299 quad[1][0].c1 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
300 quad[1][0].c2 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
301 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
302 quad[0][1].c1 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
303 quad[0][1].c2 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
304 quad[1][1].c1 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
305 quad[1][1].c2 = (unsigned char)encoded[stream_ptr++]; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
306 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
307 DECODE_PALETTE_TO_BGR888(quad[0][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
308 DECODE_PALETTE_TO_BGR888(quad[0][1]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
309 DECODE_PALETTE_TO_BGR888(quad[1][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
310 DECODE_PALETTE_TO_BGR888(quad[1][1]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
311 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
312 for (pixel_y = 0; pixel_y < 4; pixel_y++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
313 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
314 for (pixel_x = 0; pixel_x < 4; pixel_x++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
315 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
316 if (flags & 1) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
317 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
318 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
319 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
320 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
321 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
322 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
323 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
324 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
325 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
326 decoded[pixel_ptr++] = quad[pixel_x >> 1][pixel_y >> 1].c2_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
327 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
328 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
329 // get the next flag ready to go |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
330 flags >>= 1; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
331 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
332 pixel_ptr -= row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
333 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
334 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
335 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
336 // otherwise, it's a 1-color block |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
337 else |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
338 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
339 // init c2 along with c1 just so c2 is a known value for macro |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
340 quad[0][0].c1 = quad[0][0].c2 = byte_a; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
341 DECODE_PALETTE_TO_BGR888(quad[0][0]); |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
342 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
343 for (pixel_y = 0; pixel_y < 4; pixel_y++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
344 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
345 for (pixel_x = 0; pixel_x < 4; pixel_x++) |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
346 { |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
347 decoded[pixel_ptr++] = quad[0][0].c1_r; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
348 decoded[pixel_ptr++] = quad[0][0].c1_g; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
349 decoded[pixel_ptr++] = quad[0][0].c1_b; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
350 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
351 pixel_ptr -= row_dec; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
352 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
353 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
354 |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
355 block_ptr += block_inc; |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
356 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
357 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
358 } |
b4d46817f050
ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff
changeset
|
359 |