annotate libmpcodecs/native/qtrle.c @ 8294:8e00b6a9e40b

DMO interfaces (copied/converted(c++->c) from avifile)
author arpi
date Tue, 26 Nov 2002 22:54:11 +0000
parents 180e27f21ff2
children 306ea9a02ebe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3687
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
1 /*
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
2 Quicktime Animation (RLE) Decoder for MPlayer
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
3
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
4 (C) 2001 Mike Melanson
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
5 8 and 16bpp support by Alex Beregszaszi
3687
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
6 */
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
7
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
8 #include "config.h"
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
9 #include "bswap.h"
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
10
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
11 #define BE_16(x) (be2me_16(*(unsigned short *)(x)))
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
12 #define BE_32(x) (be2me_32(*(unsigned int *)(x)))
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
13
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
14 void qt_decode_rle8(
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
15 unsigned char *encoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
16 int encoded_size,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
17 unsigned char *decoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
18 int width,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
19 int height,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
20 int bytes_per_pixel)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
21 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
22 int stream_ptr;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
23 int header;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
24 int start_line;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
25 int lines_to_change;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
26 signed char rle_code;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
27 int row_ptr, pixel_ptr;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
28 int row_inc = bytes_per_pixel * width;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
29 unsigned char pixel;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
30
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
31 // check if this frame is even supposed to change
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
32 if (encoded_size < 8)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
33 return;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
34
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
35 // start after the chunk size
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
36 stream_ptr = 4;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
37
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
38 // fetch the header
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
39 header = BE_16(&encoded[stream_ptr]);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
40 stream_ptr += 2;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
41
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
42 // if a header is present, fetch additional decoding parameters
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
43 if (header & 0x0008)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
44 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
45 start_line = BE_16(&encoded[stream_ptr]);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
46 stream_ptr += 4;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
47 lines_to_change = BE_16(&encoded[stream_ptr]);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
48 stream_ptr += 4;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
49 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
50 else
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
51 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
52 start_line = 0;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
53 lines_to_change = height;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
54 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
55
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
56 row_ptr = row_inc * start_line;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
57 while (lines_to_change--)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
58 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
59 pixel_ptr = row_ptr + ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
60
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
61 while (stream_ptr < encoded_size &&
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
62 (rle_code = (signed char)encoded[stream_ptr++]) != -1)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
63 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
64 if (rle_code == 0)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
65 // there's another skip code in the stream
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
66 pixel_ptr += ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
67 else if (rle_code < 0)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
68 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
69 // decode the run length code
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
70 rle_code = -rle_code;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
71 pixel = encoded[stream_ptr++];
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
72 while (rle_code--)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
73 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
74 decoded[pixel_ptr++] = pixel;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
75 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
76 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
77 else
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
78 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
79 // copy pixels directly to output
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
80 while (rle_code--)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
81 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
82 decoded[pixel_ptr++] = encoded[stream_ptr + 0];
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
83 stream_ptr += 1;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
84 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
85 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
86 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
87
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
88 row_ptr += row_inc;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
89 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
90 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
91
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
92 void qt_decode_rle16(
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
93 unsigned char *encoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
94 int encoded_size,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
95 unsigned char *decoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
96 int width,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
97 int height,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
98 int bytes_per_pixel)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
99 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
100 int stream_ptr;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
101 int header;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
102 int start_line;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
103 int lines_to_change;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
104 signed char rle_code;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
105 int row_ptr, pixel_ptr;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
106 int row_inc = bytes_per_pixel * width;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
107 unsigned char p1, p2;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
108
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
109 // check if this frame is even supposed to change
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
110 if (encoded_size < 8)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
111 return;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
112
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
113 // start after the chunk size
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
114 stream_ptr = 4;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
115
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
116 // fetch the header
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
117 header = BE_16(&encoded[stream_ptr]);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
118 stream_ptr += 2;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
119
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
120 // if a header is present, fetch additional decoding parameters
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
121 if (header & 0x0008)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
122 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
123 start_line = BE_16(&encoded[stream_ptr]);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
124 stream_ptr += 4;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
125 lines_to_change = BE_16(&encoded[stream_ptr]);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
126 stream_ptr += 4;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
127 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
128 else
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
129 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
130 start_line = 0;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
131 lines_to_change = height;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
132 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
133
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
134 row_ptr = row_inc * start_line;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
135 while (lines_to_change--)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
136 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
137 pixel_ptr = row_ptr + ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
138
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
139 while (stream_ptr < encoded_size &&
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
140 (rle_code = (signed char)encoded[stream_ptr++]) != -1)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
141 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
142 if (rle_code == 0)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
143 // there's another skip code in the stream
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
144 pixel_ptr += ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
145 else if (rle_code < 0)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
146 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
147 // decode the run length code
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
148 rle_code = -rle_code;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
149 p1 = encoded[stream_ptr++];
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
150 p2 = encoded[stream_ptr++];
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
151 while (rle_code--)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
152 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
153 decoded[pixel_ptr++] = p2;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
154 decoded[pixel_ptr++] = p1;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
155 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
156 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
157 else
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
158 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
159 // copy pixels directly to output
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
160 while (rle_code--)
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
161 {
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
162 decoded[pixel_ptr++] = encoded[stream_ptr + 1];
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
163 decoded[pixel_ptr++] = encoded[stream_ptr + 0];
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
164 stream_ptr += 2;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
165 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
166 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
167 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
168
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
169 row_ptr += row_inc;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
170 }
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
171 }
3687
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
172
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
173 void qt_decode_rle24(
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
174 unsigned char *encoded,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
175 int encoded_size,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
176 unsigned char *decoded,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
177 int width,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
178 int height,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
179 int bytes_per_pixel)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
180 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
181 int stream_ptr;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
182 int header;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
183 int start_line;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
184 int lines_to_change;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
185 signed char rle_code;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
186 int row_ptr, pixel_ptr;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
187 int row_inc = bytes_per_pixel * width;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
188 unsigned char r, g, b;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
189
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
190 // check if this frame is even supposed to change
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
191 if (encoded_size < 8)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
192 return;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
193
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
194 // start after the chunk size
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
195 stream_ptr = 4;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
196
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
197 // fetch the header
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
198 header = BE_16(&encoded[stream_ptr]);
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
199 stream_ptr += 2;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
200
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
201 // if a header is present, fetch additional decoding parameters
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
202 if (header & 0x0008)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
203 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
204 start_line = BE_16(&encoded[stream_ptr]);
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
205 stream_ptr += 4;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
206 lines_to_change = BE_16(&encoded[stream_ptr]);
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
207 stream_ptr += 4;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
208 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
209 else
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
210 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
211 start_line = 0;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
212 lines_to_change = height;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
213 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
214
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
215 row_ptr = row_inc * start_line;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
216 while (lines_to_change--)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
217 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
218 pixel_ptr = row_ptr + ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
219
6656
92b29c3ed0c0 bugfix by Michael.Lampe@iwr.uni-heidelberg.de
arpi
parents: 5602
diff changeset
220 while (stream_ptr < encoded_size &&
92b29c3ed0c0 bugfix by Michael.Lampe@iwr.uni-heidelberg.de
arpi
parents: 5602
diff changeset
221 (rle_code = (signed char)encoded[stream_ptr++]) != -1)
3687
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
222 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
223 if (rle_code == 0)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
224 // there's another skip code in the stream
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
225 pixel_ptr += ((encoded[stream_ptr++] - 1) * bytes_per_pixel);
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
226 else if (rle_code < 0)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
227 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
228 // decode the run length code
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
229 rle_code = -rle_code;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
230 r = encoded[stream_ptr++];
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
231 g = encoded[stream_ptr++];
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
232 b = encoded[stream_ptr++];
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
233 while (rle_code--)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
234 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
235 decoded[pixel_ptr++] = b;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
236 decoded[pixel_ptr++] = g;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
237 decoded[pixel_ptr++] = r;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
238 if (bytes_per_pixel == 4)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
239 pixel_ptr++;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
240 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
241 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
242 else
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
243 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
244 // copy pixels directly to output
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
245 while (rle_code--)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
246 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
247 decoded[pixel_ptr++] = encoded[stream_ptr + 2];
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
248 decoded[pixel_ptr++] = encoded[stream_ptr + 1];
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
249 decoded[pixel_ptr++] = encoded[stream_ptr + 0];
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
250 stream_ptr += 3;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
251 if (bytes_per_pixel == 4)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
252 pixel_ptr++;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
253 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
254 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
255 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
256
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
257 row_ptr += row_inc;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
258 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
259 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
260
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
261 void qt_decode_rle(
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
262 unsigned char *encoded,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
263 int encoded_size,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
264 unsigned char *decoded,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
265 int width,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
266 int height,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
267 int encoded_bpp,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
268 int bytes_per_pixel)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
269 {
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
270 switch (encoded_bpp)
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
271 {
6720
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
272 case 8:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
273 qt_decode_rle8(
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
274 encoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
275 encoded_size,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
276 decoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
277 width,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
278 height,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
279 bytes_per_pixel);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
280 break;
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
281 case 16:
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
282 qt_decode_rle16(
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
283 encoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
284 encoded_size,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
285 decoded,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
286 width,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
287 height,
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
288 bytes_per_pixel);
180e27f21ff2 8 and 16bpp qtrle support
alex
parents: 6656
diff changeset
289 break;
3687
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
290 case 24:
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
291 qt_decode_rle24(
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
292 encoded,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
293 encoded_size,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
294 decoded,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
295 width,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
296 height,
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
297 bytes_per_pixel);
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
298 break;
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
299 }
7fb817c9060b This commit adds initial support for Quicktime Animation (RLE) video. It
melanson
parents:
diff changeset
300 }