Mercurial > libavcodec.hg
comparison xan.c @ 2967:ef2149182f1c libavcodec
COSMETICS: Remove all trailing whitespace.
author | diego |
---|---|
date | Sat, 17 Dec 2005 18:14:38 +0000 |
parents | ad9d121cc6e9 |
children | 0b546eab515d |
comparison
equal
deleted
inserted
replaced
2966:564788471dd4 | 2967:ef2149182f1c |
---|---|
59 XanContext *s = avctx->priv_data; | 59 XanContext *s = avctx->priv_data; |
60 | 60 |
61 s->avctx = avctx; | 61 s->avctx = avctx; |
62 s->frame_size = 0; | 62 s->frame_size = 0; |
63 | 63 |
64 if ((avctx->codec->id == CODEC_ID_XAN_WC3) && | 64 if ((avctx->codec->id == CODEC_ID_XAN_WC3) && |
65 (s->avctx->palctrl == NULL)) { | 65 (s->avctx->palctrl == NULL)) { |
66 av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n"); | 66 av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n"); |
67 return -1; | 67 return -1; |
68 } | 68 } |
69 | 69 |
70 avctx->pix_fmt = PIX_FMT_PAL8; | 70 avctx->pix_fmt = PIX_FMT_PAL8; |
71 avctx->has_b_frames = 0; | 71 avctx->has_b_frames = 0; |
72 | 72 |
73 if(avcodec_check_dimensions(avctx, avctx->width, avctx->height)) | 73 if(avcodec_check_dimensions(avctx, avctx->width, avctx->height)) |
74 return -1; | 74 return -1; |
75 | 75 |
76 s->buffer1_size = avctx->width * avctx->height; | 76 s->buffer1_size = avctx->width * avctx->height; |
77 s->buffer1 = av_malloc(s->buffer1_size); | 77 s->buffer1 = av_malloc(s->buffer1_size); |
78 s->buffer2_size = avctx->width * avctx->height; | 78 s->buffer2_size = avctx->width * avctx->height; |
79 s->buffer2 = av_malloc(s->buffer2_size); | 79 s->buffer2 = av_malloc(s->buffer2_size); |
80 if (!s->buffer1 || !s->buffer2) | 80 if (!s->buffer1 || !s->buffer2) |
81 return -1; | 81 return -1; |
82 | 82 |
83 return 0; | 83 return 0; |
84 } | 84 } |
85 | 85 |
86 /* This function is used in lieu of memcpy(). This decoder can not use | 86 /* This function is used in lieu of memcpy(). This decoder can not use |
87 * memcpy because the memory locations often overlap and | 87 * memcpy because the memory locations often overlap and |
88 * memcpy doesn't like that; it's not uncommon, for example, for | 88 * memcpy doesn't like that; it's not uncommon, for example, for |
89 * dest = src+1, to turn byte A into pattern AAAAAAAA. | 89 * dest = src+1, to turn byte A into pattern AAAAAAAA. |
90 * This was originally repz movsb in Intel x86 ASM. */ | 90 * This was originally repz movsb in Intel x86 ASM. */ |
91 static inline void bytecopy(unsigned char *dest, unsigned char *src, int count) | 91 static inline void bytecopy(unsigned char *dest, unsigned char *src, int count) |
94 | 94 |
95 for (i = 0; i < count; i++) | 95 for (i = 0; i < count; i++) |
96 dest[i] = src[i]; | 96 dest[i] = src[i]; |
97 } | 97 } |
98 | 98 |
99 static int xan_huffman_decode(unsigned char *dest, unsigned char *src, | 99 static int xan_huffman_decode(unsigned char *dest, unsigned char *src, |
100 int dest_len) | 100 int dest_len) |
101 { | 101 { |
102 unsigned char byte = *src++; | 102 unsigned char byte = *src++; |
103 unsigned char ival = byte + 0x16; | 103 unsigned char ival = byte + 0x16; |
104 unsigned char * ptr = src + byte*2; | 104 unsigned char * ptr = src + byte*2; |
204 | 204 |
205 size = opcode & 3; | 205 size = opcode & 3; |
206 bytecopy(dest, src, size); dest += size; src += size; | 206 bytecopy(dest, src, size); dest += size; src += size; |
207 } | 207 } |
208 | 208 |
209 static void inline xan_wc3_output_pixel_run(XanContext *s, | 209 static void inline xan_wc3_output_pixel_run(XanContext *s, |
210 unsigned char *pixel_buffer, int x, int y, int pixel_count) | 210 unsigned char *pixel_buffer, int x, int y, int pixel_count) |
211 { | 211 { |
212 int stride; | 212 int stride; |
213 int line_inc; | 213 int line_inc; |
214 int index; | 214 int index; |
233 current_x = 0; | 233 current_x = 0; |
234 } | 234 } |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 static void inline xan_wc3_copy_pixel_run(XanContext *s, | 238 static void inline xan_wc3_copy_pixel_run(XanContext *s, |
239 int x, int y, int pixel_count, int motion_x, int motion_y) | 239 int x, int y, int pixel_count, int motion_x, int motion_y) |
240 { | 240 { |
241 int stride; | 241 int stride; |
242 int line_inc; | 242 int line_inc; |
243 int curframe_index, prevframe_index; | 243 int curframe_index, prevframe_index; |
253 curframe_x = x; | 253 curframe_x = x; |
254 prevframe_index = (y + motion_y) * stride + x + motion_x; | 254 prevframe_index = (y + motion_y) * stride + x + motion_x; |
255 prevframe_x = x + motion_x; | 255 prevframe_x = x + motion_x; |
256 while((pixel_count--) && (curframe_index < s->frame_size)) { | 256 while((pixel_count--) && (curframe_index < s->frame_size)) { |
257 | 257 |
258 palette_plane[curframe_index++] = | 258 palette_plane[curframe_index++] = |
259 prev_palette_plane[prevframe_index++]; | 259 prev_palette_plane[prevframe_index++]; |
260 | 260 |
261 curframe_x++; | 261 curframe_x++; |
262 if (curframe_x >= width) { | 262 if (curframe_x >= width) { |
263 curframe_index += line_inc; | 263 curframe_index += line_inc; |
300 imagedata_segment = s->buf + LE_16(&s->buf[6]); | 300 imagedata_segment = s->buf + LE_16(&s->buf[6]); |
301 | 301 |
302 xan_huffman_decode(opcode_buffer, huffman_segment, opcode_buffer_size); | 302 xan_huffman_decode(opcode_buffer, huffman_segment, opcode_buffer_size); |
303 | 303 |
304 if (imagedata_segment[0] == 2) | 304 if (imagedata_segment[0] == 2) |
305 xan_unpack(imagedata_buffer, &imagedata_segment[1], | 305 xan_unpack(imagedata_buffer, &imagedata_segment[1], |
306 imagedata_buffer_size); | 306 imagedata_buffer_size); |
307 else | 307 else |
308 imagedata_buffer = &imagedata_segment[1]; | 308 imagedata_buffer = &imagedata_segment[1]; |
309 | 309 |
310 /* use the decoded data segments to build the frame */ | 310 /* use the decoded data segments to build the frame */ |
421 | 421 |
422 if (!s->frame_size) | 422 if (!s->frame_size) |
423 s->frame_size = s->current_frame.linesize[0] * s->avctx->height; | 423 s->frame_size = s->current_frame.linesize[0] * s->avctx->height; |
424 | 424 |
425 palette_control->palette_changed = 0; | 425 palette_control->palette_changed = 0; |
426 memcpy(s->current_frame.data[1], palette_control->palette, | 426 memcpy(s->current_frame.data[1], palette_control->palette, |
427 AVPALETTE_SIZE); | 427 AVPALETTE_SIZE); |
428 s->current_frame.palette_has_changed = 1; | 428 s->current_frame.palette_has_changed = 1; |
429 | 429 |
430 s->buf = buf; | 430 s->buf = buf; |
431 s->size = buf_size; | 431 s->size = buf_size; |