annotate msvidc.c @ 2945:92ad139d6a7d

bugs & fixes by Bohdan 'Nexus' Horst small typos
author pl
date Sat, 17 Nov 2001 09:57:54 +0000
parents b4d46817f050
children 6b69f306cf6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2827
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
1
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
2 #define LE_16(x) *(unsigned short *)(x)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
3
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
4 #define DECODE_BGR555_TO_BGR888(x) \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
5 x.c1_b = (x.c1 >> 7) & 0xF8; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
6 x.c1_g = (x.c1 >> 2) & 0xF8; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
7 x.c1_r = (x.c1 << 3) & 0xF8; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
8 x.c2_b = (x.c2 >> 7) & 0xF8; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
9 x.c2_g = (x.c2 >> 2) & 0xF8; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
10 x.c2_r = (x.c2 << 3) & 0xF8;
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_PALETTE_TO_BGR888(x) \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
13 x.c1_b = palette_map[x.c1 * 4 + 2]; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
14 x.c1_g = palette_map[x.c1 * 4 + 1]; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
15 x.c1_r = palette_map[x.c1 * 4 + 0]; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
16 x.c2_b = palette_map[x.c2 * 4 + 2]; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
17 x.c2_g = palette_map[x.c2 * 4 + 1]; \
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
18 x.c2_r = palette_map[x.c2 * 4 + 0];
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 struct
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
21 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
22 unsigned short c1, c2;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
23 unsigned char c1_r, c1_g, c1_b;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
24 unsigned char c2_r, c2_g, c2_b;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
25 } quad[2][2];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
26
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
27 void AVI_Decode_Video1_16(
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
28 char *encoded,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
29 int encoded_size,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
30 char *decoded,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
31 int width,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
32 int height,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
33 int bytes_per_pixel)
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 int block_ptr, pixel_ptr;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
36 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
37 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
38 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
39 int block_inc;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
40 int row_dec;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
41
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
42 // decoding parameters
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
43 int stream_ptr;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
44 unsigned char byte_a, byte_b;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
45 unsigned short flags;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
46 int skip_blocks;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
47
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
48 stream_ptr = 0;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
49 skip_blocks = 0;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
50 blocks_wide = width / 4;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
51 blocks_high = height / 4;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
52 block_inc = 4 * bytes_per_pixel;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
53 row_dec = (width + 4) * bytes_per_pixel;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
54
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
55 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
56 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
57 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
58 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
59 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
60 // check if this block should be skipped
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
61 if (skip_blocks)
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 block_ptr += block_inc;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
64 skip_blocks--;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
65 continue;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
66 }
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 pixel_ptr = block_ptr;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
69
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
70 // 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
71 byte_a = encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
72 byte_b = encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
73
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
74 // check if the decode is finished
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
75 if ((byte_a == 0) && (byte_b == 0))
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
76 return;
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 // check if this is a skip code
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
79 else if ((byte_b & 0xFC) == 0x84)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
80 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
81 // but don't count the current block
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
82 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
83 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
84
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
85 // 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
86 else if (byte_b < 0x80)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
87 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
88 flags = (byte_b << 8) | byte_a;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
89
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
90 quad[0][0].c1 = LE_16(&encoded[stream_ptr]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
91 stream_ptr += 2;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
92 quad[0][0].c2 = LE_16(&encoded[stream_ptr]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
93 stream_ptr += 2;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
94
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
95 DECODE_BGR555_TO_BGR888(quad[0][0]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
96
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
97 if (quad[0][0].c1 & 0x8000)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
98 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
99 // 8-color encoding
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
100 quad[1][0].c1 = 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 quad[1][0].c2 = LE_16(&encoded[stream_ptr]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
103 stream_ptr += 2;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
104 quad[0][1].c1 = LE_16(&encoded[stream_ptr]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
105 stream_ptr += 2;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
106 quad[0][1].c2 = LE_16(&encoded[stream_ptr]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
107 stream_ptr += 2;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
108 quad[1][1].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][1].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
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
113 DECODE_BGR555_TO_BGR888(quad[0][1]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
114 DECODE_BGR555_TO_BGR888(quad[1][0]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
115 DECODE_BGR555_TO_BGR888(quad[1][1]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
116
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
117 for (pixel_y = 0; pixel_y < 4; pixel_y++)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
118 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
119 for (pixel_x = 0; pixel_x < 4; pixel_x++)
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 if (flags & 1)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
122 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
123 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
124 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
125 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
126 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
127 else
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 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
130 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
131 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
132 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
133
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
134 // get the next flag ready to go
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
135 flags >>= 1;
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 pixel_ptr -= row_dec;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
138 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
139 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
140 else
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 // 2-color encoding
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
143 for (pixel_y = 0; pixel_y < 4; pixel_y++)
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 for (pixel_x = 0; pixel_x < 4; pixel_x++)
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 if (flags & 1)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
148 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
149 decoded[pixel_ptr++] = quad[0][0].c1_r;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
150 decoded[pixel_ptr++] = quad[0][0].c1_g;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
151 decoded[pixel_ptr++] = quad[0][0].c1_b;
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 else
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 decoded[pixel_ptr++] = quad[0][0].c2_r;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
156 decoded[pixel_ptr++] = quad[0][0].c2_g;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
157 decoded[pixel_ptr++] = quad[0][0].c2_b;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
158 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
159
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
160 // get the next flag ready to go
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
161 flags >>= 1;
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 pixel_ptr -= row_dec;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
164 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
165 }
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 // otherwise, it's a 1-color block
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
169 else
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 quad[0][0].c1 = (byte_b << 8) | byte_a;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
172 DECODE_BGR555_TO_BGR888(quad[0][0]);
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 for (pixel_y = 0; pixel_y < 4; pixel_y++)
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 for (pixel_x = 0; pixel_x < 4; pixel_x++)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
177 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
178 decoded[pixel_ptr++] = quad[0][0].c1_r;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
179 decoded[pixel_ptr++] = quad[0][0].c1_g;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
180 decoded[pixel_ptr++] = quad[0][0].c1_b;
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 pixel_ptr -= row_dec;
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 }
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 block_ptr += block_inc;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
187 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
188 }
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
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
191 void AVI_Decode_Video1_8(
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
192 char *encoded,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
193 int encoded_size,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
194 char *decoded,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
195 int width,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
196 int height,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
197 unsigned char *palette_map,
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
198 int bytes_per_pixel)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
199 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
200 int block_ptr, pixel_ptr;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
201 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
202 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
203 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
204 int block_inc;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
205 int row_dec;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
206
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
207 // decoding parameters
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
208 int stream_ptr;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
209 unsigned char byte_a, byte_b;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
210 unsigned short flags;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
211 int skip_blocks;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
212
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
213 stream_ptr = 0;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
214 skip_blocks = 0;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
215 blocks_wide = width / 4;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
216 blocks_high = height / 4;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
217 block_inc = 4 * bytes_per_pixel;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
218 row_dec = (width + 4) * bytes_per_pixel;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
219
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
220 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
221 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
222 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
223 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
224 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
225 // check if this block should be skipped
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
226 if (skip_blocks)
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 block_ptr += block_inc;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
229 skip_blocks--;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
230 continue;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
231 }
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 pixel_ptr = block_ptr;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
234
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
235 // 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
236 byte_a = encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
237 byte_b = encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
238
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
239 // check if the decode is finished
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
240 if ((byte_a == 0) && (byte_b == 0))
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
241 return;
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 // check if this is a skip code
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
244 else if ((byte_b & 0xFC) == 0x84)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
245 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
246 // but don't count the current block
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
247 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
248 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
249
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
250 // check if this is a 2-color block
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
251 else if (byte_b < 0x80)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
252 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
253 flags = (byte_b << 8) | byte_a;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
254
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
255 quad[0][0].c1 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
256 quad[0][0].c2 = (unsigned char)encoded[stream_ptr++];
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 DECODE_PALETTE_TO_BGR888(quad[0][0]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
259
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
260 // 2-color encoding
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
261 for (pixel_y = 0; pixel_y < 4; pixel_y++)
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 for (pixel_x = 0; pixel_x < 4; pixel_x++)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
264 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
265 if (flags & 1)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
266 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
267 decoded[pixel_ptr++] = quad[0][0].c1_r;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
268 decoded[pixel_ptr++] = quad[0][0].c1_g;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
269 decoded[pixel_ptr++] = quad[0][0].c1_b;
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 else
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 decoded[pixel_ptr++] = quad[0][0].c2_r;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
274 decoded[pixel_ptr++] = quad[0][0].c2_g;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
275 decoded[pixel_ptr++] = quad[0][0].c2_b;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
276 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
277
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
278 // get the next flag ready to go
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
279 flags >>= 1;
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 pixel_ptr -= row_dec;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
282 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
283 }
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 // check if it's an 8-color block
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
286 else if (byte_b >= 0x90)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
287 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
288 // 8-color encoding
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
289 quad[0][0].c1 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
290 quad[0][0].c2 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
291 quad[1][0].c1 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
292 quad[1][0].c2 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
293
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
294 quad[0][1].c1 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
295 quad[0][1].c2 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
296 quad[1][1].c1 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
297 quad[1][1].c2 = (unsigned char)encoded[stream_ptr++];
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
298
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
299 DECODE_PALETTE_TO_BGR888(quad[0][0]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
300 DECODE_PALETTE_TO_BGR888(quad[0][1]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
301 DECODE_PALETTE_TO_BGR888(quad[1][0]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
302 DECODE_PALETTE_TO_BGR888(quad[1][1]);
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
303
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
304 for (pixel_y = 0; pixel_y < 4; pixel_y++)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
305 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
306 for (pixel_x = 0; pixel_x < 4; pixel_x++)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
307 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
308 if (flags & 1)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
309 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
310 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
311 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
312 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
313 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
314 else
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 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
317 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
318 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
319 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
320
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
321 // get the next flag ready to go
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
322 flags >>= 1;
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 pixel_ptr -= row_dec;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
325 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
326 }
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 // otherwise, it's a 1-color block
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
329 else
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
330 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
331 // 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
332 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
333 DECODE_PALETTE_TO_BGR888(quad[0][0]);
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 for (pixel_y = 0; pixel_y < 4; pixel_y++)
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
336 {
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
337 for (pixel_x = 0; pixel_x < 4; pixel_x++)
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 decoded[pixel_ptr++] = quad[0][0].c1_r;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
340 decoded[pixel_ptr++] = quad[0][0].c1_g;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
341 decoded[pixel_ptr++] = quad[0][0].c1_b;
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 pixel_ptr -= row_dec;
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 }
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 block_ptr += block_inc;
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
348 }
b4d46817f050 ms video1 (cram) codecs by Mike Melanson <melanson@pcisys.net>
arpi
parents:
diff changeset
349 }
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