45 #define VMD_HEADER_SIZE 0x330
46 #define PALETTE_COUNT 256
53 const unsigned char *
buf;
63 #define QUEUE_SIZE 0x1000
64 #define QUEUE_MASK 0x0FFF
67 unsigned char *dest,
int dest_len)
73 unsigned int dataleft;
74 unsigned int chainofs;
75 unsigned int chainlen;
84 dataleft = bytestream2_get_le32(&gb);
88 if (bytestream2_peek_le32(&gb) == 0x56781234) {
98 tag = bytestream2_get_byteu(&gb);
99 if ((tag == 0xFF) && (dataleft > 8)) {
102 for (i = 0; i < 8; i++) {
103 queue[qpos++] = *d++ = bytestream2_get_byteu(&gb);
108 for (i = 0; i < 8; i++) {
114 queue[qpos++] = *d++ = bytestream2_get_byteu(&gb);
118 chainofs = bytestream2_get_byte(&gb);
119 chainofs |= ((bytestream2_peek_byte(&gb) & 0xF0) << 4);
120 chainlen = (bytestream2_get_byte(&gb) & 0x0F) + 3;
121 if (chainlen == speclen) {
122 chainlen = bytestream2_get_byte(&gb) + 0xF + 3;
124 if (d_end - d < chainlen)
126 for (j = 0; j < chainlen; j++) {
128 queue[qpos++] = *d++;
131 dataleft -= chainlen;
140 int src_count,
int src_size,
int dest_len)
144 unsigned char *dest_end = dest + dest_len;
153 *pd++ = bytestream2_get_byteu(&gb);
160 l = bytestream2_get_byteu(&gb);
171 for (i = 0; i < l; i++) {
178 }
while (used < src_count);
186 unsigned int *palette32;
187 unsigned char r,
g,
b;
197 int frame_x, frame_y;
198 int frame_width, frame_height;
202 frame_width =
AV_RL16(&s->
buf[10]) - frame_x + 1;
203 frame_height =
AV_RL16(&s->
buf[12]) - frame_y + 1;
206 (frame_x || frame_y)) {
214 if (frame_x < 0 || frame_width < 0 ||
219 "Invalid horizontal range %d-%d\n",
220 frame_x, frame_width);
223 if (frame_y < 0 || frame_height < 0 ||
228 "Invalid vertical range %d-%d\n",
229 frame_x, frame_width);
236 (frame_x || frame_y || (frame_width != s->
avctx->
width) ||
245 if (s->
buf[15] & 0x02) {
247 palette32 = (
unsigned int *)s->
palette;
250 r = bytestream2_get_byteu(&gb) * 4;
251 g = bytestream2_get_byteu(&gb) * 4;
252 b = bytestream2_get_byteu(&gb) * 4;
253 palette32[i] = 0xFF
U << 24 | (r << 16) | (g << 8) | (
b);
254 palette32[i] |= palette32[i] >> 6 & 0x30303;
268 meth = bytestream2_get_byteu(&gb);
273 "Trying to unpack LZ-compressed frame with no LZ buffer\n");
284 dp = &frame->
data[0][frame_y * frame->
linesize[0] + frame_x];
288 for (i = 0; i < frame_height; i++) {
291 len = bytestream2_get_byte(&gb);
293 len = (len & 0x7F) + 1;
294 if (ofs + len > frame_width ||
303 memcpy(&dp[ofs], &pp[ofs], len + 1);
306 }
while (ofs < frame_width);
307 if (ofs > frame_width) {
309 "offset > width (%d > %d)\n",
319 for (i = 0; i < frame_height; i++) {
327 for (i = 0; i < frame_height; i++) {
330 len = bytestream2_get_byte(&gb);
332 len = (len & 0x7F) + 1;
333 if (bytestream2_peek_byte(&gb) == 0xFF) {
335 bytestream2_get_byte(&gb);
349 memcpy(&dp[ofs], &pp[ofs], len + 1);
352 }
while (ofs < frame_width);
353 if (ofs > frame_width) {
355 "offset > width (%d > %d)\n",
382 unsigned int *palette32;
383 int palette_index = 0;
384 unsigned char r,
g,
b;
385 unsigned char *vmd_header;
386 unsigned char *raw_palette;
397 vmd_header = (
unsigned char *)avctx->
extradata;
407 raw_palette = &vmd_header[28];
408 palette32 = (
unsigned int *)s->
palette;
410 r = raw_palette[palette_index++] * 4;
411 g = raw_palette[palette_index++] * 4;
412 b = raw_palette[palette_index++] * 4;
413 palette32[i] = 0xFF
U << 24 | (r << 16) | (g << 8) | (
b);
414 palette32[i] |= palette32[i] >> 6 & 0x30303;
427 void *
data,
int *got_frame,
431 int buf_size = avpkt->
size;