comparison xan.c @ 6302:81be720492ac libavcodec

const
author michael
date Fri, 01 Feb 2008 16:24:33 +0000
parents 2b72f9bc4f06
children d78e2ce9b088
comparison
equal deleted inserted replaced
6301:9c5eed7cd0ae 6302:81be720492ac
39 39
40 AVCodecContext *avctx; 40 AVCodecContext *avctx;
41 AVFrame last_frame; 41 AVFrame last_frame;
42 AVFrame current_frame; 42 AVFrame current_frame;
43 43
44 unsigned char *buf; 44 const unsigned char *buf;
45 int size; 45 int size;
46 46
47 /* scratch space */ 47 /* scratch space */
48 unsigned char *buffer1; 48 unsigned char *buffer1;
49 int buffer1_size; 49 int buffer1_size;
85 /* This function is used in lieu of memcpy(). This decoder cannot use 85 /* This function is used in lieu of memcpy(). This decoder cannot use
86 * memcpy because the memory locations often overlap and 86 * memcpy because the memory locations often overlap and
87 * memcpy doesn't like that; it's not uncommon, for example, for 87 * memcpy doesn't like that; it's not uncommon, for example, for
88 * dest = src+1, to turn byte A into pattern AAAAAAAA. 88 * dest = src+1, to turn byte A into pattern AAAAAAAA.
89 * This was originally repz movsb in Intel x86 ASM. */ 89 * This was originally repz movsb in Intel x86 ASM. */
90 static inline void bytecopy(unsigned char *dest, unsigned char *src, int count) 90 static inline void bytecopy(unsigned char *dest, const unsigned char *src, int count)
91 { 91 {
92 int i; 92 int i;
93 93
94 for (i = 0; i < count; i++) 94 for (i = 0; i < count; i++)
95 dest[i] = src[i]; 95 dest[i] = src[i];
96 } 96 }
97 97
98 static int xan_huffman_decode(unsigned char *dest, unsigned char *src, 98 static int xan_huffman_decode(unsigned char *dest, const unsigned char *src,
99 int dest_len) 99 int dest_len)
100 { 100 {
101 unsigned char byte = *src++; 101 unsigned char byte = *src++;
102 unsigned char ival = byte + 0x16; 102 unsigned char ival = byte + 0x16;
103 unsigned char * ptr = src + byte*2; 103 const unsigned char * ptr = src + byte*2;
104 unsigned char val = ival; 104 unsigned char val = ival;
105 int counter = 0; 105 int counter = 0;
106 unsigned char *dest_end = dest + dest_len; 106 unsigned char *dest_end = dest + dest_len;
107 107
108 unsigned char bits = *ptr++; 108 unsigned char bits = *ptr++;
127 } 127 }
128 128
129 return 0; 129 return 0;
130 } 130 }
131 131
132 static void xan_unpack(unsigned char *dest, unsigned char *src, int dest_len) 132 static void xan_unpack(unsigned char *dest, const unsigned char *src, int dest_len)
133 { 133 {
134 unsigned char opcode; 134 unsigned char opcode;
135 int size; 135 int size;
136 int offset; 136 int offset;
137 int byte1, byte2, byte3; 137 int byte1, byte2, byte3;
286 int opcode_buffer_size = s->buffer1_size; 286 int opcode_buffer_size = s->buffer1_size;
287 unsigned char *imagedata_buffer = s->buffer2; 287 unsigned char *imagedata_buffer = s->buffer2;
288 int imagedata_buffer_size = s->buffer2_size; 288 int imagedata_buffer_size = s->buffer2_size;
289 289
290 /* pointers to segments inside the compressed chunk */ 290 /* pointers to segments inside the compressed chunk */
291 unsigned char *huffman_segment; 291 const unsigned char *huffman_segment;
292 unsigned char *size_segment; 292 const unsigned char *size_segment;
293 unsigned char *vector_segment; 293 const unsigned char *vector_segment;
294 unsigned char *imagedata_segment; 294 const unsigned char *imagedata_segment;
295 295
296 huffman_segment = s->buf + AV_RL16(&s->buf[0]); 296 huffman_segment = s->buf + AV_RL16(&s->buf[0]);
297 size_segment = s->buf + AV_RL16(&s->buf[2]); 297 size_segment = s->buf + AV_RL16(&s->buf[2]);
298 vector_segment = s->buf + AV_RL16(&s->buf[4]); 298 vector_segment = s->buf + AV_RL16(&s->buf[4]);
299 imagedata_segment = s->buf + AV_RL16(&s->buf[6]); 299 imagedata_segment = s->buf + AV_RL16(&s->buf[6]);
404 static void xan_wc4_decode_frame(XanContext *s) { 404 static void xan_wc4_decode_frame(XanContext *s) {
405 } 405 }
406 406
407 static int xan_decode_frame(AVCodecContext *avctx, 407 static int xan_decode_frame(AVCodecContext *avctx,
408 void *data, int *data_size, 408 void *data, int *data_size,
409 uint8_t *buf, int buf_size) 409 const uint8_t *buf, int buf_size)
410 { 410 {
411 XanContext *s = avctx->priv_data; 411 XanContext *s = avctx->priv_data;
412 AVPaletteControl *palette_control = avctx->palctrl; 412 AVPaletteControl *palette_control = avctx->palctrl;
413 413
414 if (avctx->get_buffer(avctx, &s->current_frame)) { 414 if (avctx->get_buffer(avctx, &s->current_frame)) {