38 #define PALETTE_COUNT 256
39 #define CHECK_STREAM_PTR(n) \
40 if ((stream_ptr + n) > s->size ) { \
41 av_log(s->avctx, AV_LOG_ERROR, " MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \
42 stream_ptr + n, s->size); \
51 const unsigned char *
buf;
82 int block_ptr, pixel_ptr;
86 int blocks_wide, blocks_high;
92 unsigned char byte_a, byte_b;
95 unsigned char colors[8];
103 total_blocks = blocks_wide * blocks_high;
105 row_dec = stride + 4;
107 for (block_y = blocks_high; block_y > 0; block_y--) {
108 block_ptr = ((block_y * 4) - 1) *
stride;
109 for (block_x = blocks_wide; block_x > 0; block_x--) {
112 block_ptr += block_inc;
118 pixel_ptr = block_ptr;
122 byte_a = s->
buf[stream_ptr++];
123 byte_b = s->
buf[stream_ptr++];
126 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
128 else if ((byte_b & 0xFC) == 0x84) {
130 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
131 }
else if (byte_b < 0x80) {
133 flags = (byte_b << 8) | byte_a;
136 colors[0] = s->
buf[stream_ptr++];
137 colors[1] = s->
buf[stream_ptr++];
139 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
140 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
141 pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
142 pixel_ptr -= row_dec;
144 }
else if (byte_b >= 0x90) {
146 flags = (byte_b << 8) | byte_a;
149 memcpy(colors, &s->
buf[stream_ptr], 8);
152 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
153 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
154 pixels[pixel_ptr++] =
155 colors[((pixel_y & 0x2) << 1) +
156 (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
157 pixel_ptr -= row_dec;
163 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
164 for (pixel_x = 0; pixel_x < 4; pixel_x++)
165 pixels[pixel_ptr++] = colors[0];
166 pixel_ptr -= row_dec;
170 block_ptr += block_inc;
182 int block_ptr, pixel_ptr;
184 int pixel_x, pixel_y;
185 int block_x, block_y;
186 int blocks_wide, blocks_high;
192 unsigned char byte_a, byte_b;
193 unsigned short flags;
195 unsigned short colors[8];
196 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
203 total_blocks = blocks_wide * blocks_high;
207 for (block_y = blocks_high; block_y > 0; block_y--) {
208 block_ptr = ((block_y * 4) - 1) *
stride;
209 for (block_x = blocks_wide; block_x > 0; block_x--) {
212 block_ptr += block_inc;
218 pixel_ptr = block_ptr;
222 byte_a = s->
buf[stream_ptr++];
223 byte_b = s->
buf[stream_ptr++];
226 if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) {
228 }
else if ((byte_b & 0xFC) == 0x84) {
230 skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
231 }
else if (byte_b < 0x80) {
233 flags = (byte_b << 8) | byte_a;
241 if (colors[0] & 0x8000) {
257 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
258 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
259 pixels[pixel_ptr++] =
260 colors[((pixel_y & 0x2) << 1) +
261 (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
262 pixel_ptr -= row_dec;
266 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
267 for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
268 pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
269 pixel_ptr -= row_dec;
274 colors[0] = (byte_b << 8) | byte_a;
276 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
277 for (pixel_x = 0; pixel_x < 4; pixel_x++)
278 pixels[pixel_ptr++] = colors[0];
279 pixel_ptr -= row_dec;
283 block_ptr += block_inc;
290 void *
data,
int *got_frame,
294 int buf_size = avpkt->
size;