comparison flicvideo.c @ 2967:ef2149182f1c libavcodec

COSMETICS: Remove all trailing whitespace.
author diego
date Sat, 17 Dec 2005 18:14:38 +0000
parents f7114e03d8dd
children 0b546eab515d
comparison
equal deleted inserted replaced
2966:564788471dd4 2967:ef2149182f1c
85 s->avctx = avctx; 85 s->avctx = avctx;
86 avctx->has_b_frames = 0; 86 avctx->has_b_frames = 0;
87 87
88 s->fli_type = LE_16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */ 88 s->fli_type = LE_16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
89 depth = LE_16(&fli_header[12]); 89 depth = LE_16(&fli_header[12]);
90 90
91 if (depth == 0) { 91 if (depth == 0) {
92 depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */ 92 depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
93 } 93 }
94 94
95 if (s->avctx->extradata_size == 12) { 95 if (s->avctx->extradata_size == 12) {
113 return -1; 113 return -1;
114 break; 114 break;
115 default : 115 default :
116 av_log(avctx, AV_LOG_ERROR, "Unkown FLC/FLX depth of %d Bpp is unsupported.\n",depth); 116 av_log(avctx, AV_LOG_ERROR, "Unkown FLC/FLX depth of %d Bpp is unsupported.\n",depth);
117 return -1; 117 return -1;
118 } 118 }
119 119
120 s->frame.data[0] = NULL; 120 s->frame.data[0] = NULL;
121 s->new_palette = 0; 121 s->new_palette = 0;
122 122
123 return 0; 123 return 0;
157 signed char byte_run; 157 signed char byte_run;
158 int pixel_skip; 158 int pixel_skip;
159 int pixel_countdown; 159 int pixel_countdown;
160 unsigned char *pixels; 160 unsigned char *pixels;
161 int pixel_limit; 161 int pixel_limit;
162 162
163 s->frame.reference = 1; 163 s->frame.reference = 1;
164 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; 164 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
165 if (avctx->reget_buffer(avctx, &s->frame) < 0) { 165 if (avctx->reget_buffer(avctx, &s->frame) < 0) {
166 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); 166 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
167 return -1; 167 return -1;
188 case FLI_256_COLOR: 188 case FLI_256_COLOR:
189 case FLI_COLOR: 189 case FLI_COLOR:
190 stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6; 190 stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6;
191 s->new_palette = 1; 191 s->new_palette = 1;
192 192
193 /* check special case: If this file is from the Magic Carpet 193 /* check special case: If this file is from the Magic Carpet
194 * game and uses 6-bit colors even though it reports 256-color 194 * game and uses 6-bit colors even though it reports 256-color
195 * chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during 195 * chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during
196 * initialization) */ 196 * initialization) */
197 if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE)) 197 if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE))
198 color_shift = 0; 198 color_shift = 0;
199 else 199 else
541 pixel_ptr = y_ptr; 541 pixel_ptr = y_ptr;
542 /* disregard the line packets; instead, iterate through all 542 /* disregard the line packets; instead, iterate through all
543 * pixels on a row */ 543 * pixels on a row */
544 stream_ptr++; 544 stream_ptr++;
545 pixel_countdown = (s->avctx->width * 2); 545 pixel_countdown = (s->avctx->width * 2);
546 546
547 while (pixel_countdown > 0) { 547 while (pixel_countdown > 0) {
548 byte_run = buf[stream_ptr++]; 548 byte_run = buf[stream_ptr++];
549 if (byte_run > 0) { 549 if (byte_run > 0) {
550 palette_idx1 = buf[stream_ptr++]; 550 palette_idx1 = buf[stream_ptr++];
551 CHECK_PIXEL_PTR(byte_run); 551 CHECK_PIXEL_PTR(byte_run);
570 } 570 }
571 } 571 }
572 572
573 /* Now FLX is strange, in that it is "byte" as opposed to "pixel" run length compressed. 573 /* Now FLX is strange, in that it is "byte" as opposed to "pixel" run length compressed.
574 * This doesnt give us any good oportunity to perform word endian conversion 574 * This doesnt give us any good oportunity to perform word endian conversion
575 * during decompression. So if its requried (ie, this isnt a LE target, we do 575 * during decompression. So if its requried (ie, this isnt a LE target, we do
576 * a second pass over the line here, swapping the bytes. 576 * a second pass over the line here, swapping the bytes.
577 */ 577 */
578 pixel = 0xFF00; 578 pixel = 0xFF00;
579 if (0xFF00 != LE_16(&pixel)) /* Check if its not an LE Target */ 579 if (0xFF00 != LE_16(&pixel)) /* Check if its not an LE Target */
580 { 580 {
581 pixel_ptr = y_ptr; 581 pixel_ptr = y_ptr;
582 pixel_countdown = s->avctx->width; 582 pixel_countdown = s->avctx->width;
583 while (pixel_countdown > 0) { 583 while (pixel_countdown > 0) {
584 *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[pixel_ptr]); 584 *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[pixel_ptr]);
585 pixel_ptr += 2; 585 pixel_ptr += 2;
586 } 586 }
587 } 587 }
588 y_ptr += s->frame.linesize[0]; 588 y_ptr += s->frame.linesize[0];
589 } 589 }
590 break; 590 break;
591 591
592 case FLI_DTA_BRUN: 592 case FLI_DTA_BRUN:
595 pixel_ptr = y_ptr; 595 pixel_ptr = y_ptr;
596 /* disregard the line packets; instead, iterate through all 596 /* disregard the line packets; instead, iterate through all
597 * pixels on a row */ 597 * pixels on a row */
598 stream_ptr++; 598 stream_ptr++;
599 pixel_countdown = s->avctx->width; /* Width is in pixels, not bytes */ 599 pixel_countdown = s->avctx->width; /* Width is in pixels, not bytes */
600 600
601 while (pixel_countdown > 0) { 601 while (pixel_countdown > 0) {
602 byte_run = buf[stream_ptr++]; 602 byte_run = buf[stream_ptr++];
603 if (byte_run > 0) { 603 if (byte_run > 0) {
604 pixel = LE_16(&buf[stream_ptr]); 604 pixel = LE_16(&buf[stream_ptr]);
605 stream_ptr += 2; 605 stream_ptr += 2;
606 CHECK_PIXEL_PTR(byte_run); 606 CHECK_PIXEL_PTR(byte_run);
607 for (j = 0; j < byte_run; j++) { 607 for (j = 0; j < byte_run; j++) {
608 *((signed short*)(&pixels[pixel_ptr])) = pixel; 608 *((signed short*)(&pixels[pixel_ptr])) = pixel;
609 pixel_ptr += 2; 609 pixel_ptr += 2;
610 pixel_countdown--; 610 pixel_countdown--;
611 if (pixel_countdown < 0) 611 if (pixel_countdown < 0)
612 av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", 612 av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n",
613 pixel_countdown); 613 pixel_countdown);
614 } 614 }
637 if (chunk_size - 6 > (unsigned int)(s->avctx->width * s->avctx->height)*2) { 637 if (chunk_size - 6 > (unsigned int)(s->avctx->width * s->avctx->height)*2) {
638 av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ 638 av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \
639 "bigger than image, skipping chunk\n", chunk_size - 6); 639 "bigger than image, skipping chunk\n", chunk_size - 6);
640 stream_ptr += chunk_size - 6; 640 stream_ptr += chunk_size - 6;
641 } else { 641 } else {
642 642
643 for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height; 643 for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height;
644 y_ptr += s->frame.linesize[0]) { 644 y_ptr += s->frame.linesize[0]) {
645 645
646 pixel_countdown = s->avctx->width; 646 pixel_countdown = s->avctx->width;
647 pixel_ptr = 0; 647 pixel_ptr = 0;
648 while (pixel_countdown > 0) { 648 while (pixel_countdown > 0) {
649 *((signed short*)(&pixels[y_ptr + pixel_ptr])) = LE_16(&buf[stream_ptr+pixel_ptr]); 649 *((signed short*)(&pixels[y_ptr + pixel_ptr])) = LE_16(&buf[stream_ptr+pixel_ptr]);
650 pixel_ptr += 2; 650 pixel_ptr += 2;
651 pixel_countdown--; 651 pixel_countdown--;
652 } 652 }
653 stream_ptr += s->avctx->width*2; 653 stream_ptr += s->avctx->width*2;
654 } 654 }
655 } 655 }
656 break; 656 break;
657 657
700 } 700 }
701 else if ((avctx->pix_fmt == PIX_FMT_RGB555) || 701 else if ((avctx->pix_fmt == PIX_FMT_RGB555) ||
702 (avctx->pix_fmt == PIX_FMT_RGB565)) { 702 (avctx->pix_fmt == PIX_FMT_RGB565)) {
703 return flic_decode_frame_15_16BPP(avctx, data, data_size, 703 return flic_decode_frame_15_16BPP(avctx, data, data_size,
704 buf, buf_size); 704 buf, buf_size);
705 } 705 }
706 else if (avctx->pix_fmt == PIX_FMT_BGR24) { 706 else if (avctx->pix_fmt == PIX_FMT_BGR24) {
707 return flic_decode_frame_24BPP(avctx, data, data_size, 707 return flic_decode_frame_24BPP(avctx, data, data_size,
708 buf, buf_size); 708 buf, buf_size);
709 } 709 }
710 710
711 /* Shouldnt get here, ever as the pix_fmt is processed */ 711 /* Shouldnt get here, ever as the pix_fmt is processed */
712 /* in flic_decode_init and the above if should deal with */ 712 /* in flic_decode_init and the above if should deal with */
713 /* the finite set of possibilites allowable by here. */ 713 /* the finite set of possibilites allowable by here. */
714 /* but in case we do, just error out. */ 714 /* but in case we do, just error out. */
715 av_log(avctx, AV_LOG_ERROR, "Unknown Format of FLC. My Science cant explain how this happened\n"); 715 av_log(avctx, AV_LOG_ERROR, "Unknown Format of FLC. My Science cant explain how this happened\n");
716 return -1; 716 return -1;
717 } 717 }
718 718
719 719
720 static int flic_decode_end(AVCodecContext *avctx) 720 static int flic_decode_end(AVCodecContext *avctx)
721 { 721 {
722 FlicDecodeContext *s = avctx->priv_data; 722 FlicDecodeContext *s = avctx->priv_data;