comparison interplayvideo.c @ 5089:bff60ecc02f9 libavcodec

Use AV_xx throughout libavcodec
author ramiro
date Sat, 02 Jun 2007 01:41:07 +0000
parents f99e40a7155b
children 2b72f9bc4f06
comparison
equal deleted inserted replaced
5088:8e206208db1f 5089:bff60ecc02f9
39 #include <stdlib.h> 39 #include <stdlib.h>
40 #include <string.h> 40 #include <string.h>
41 #include <unistd.h> 41 #include <unistd.h>
42 42
43 #include "avcodec.h" 43 #include "avcodec.h"
44 #include "bytestream.h"
44 #include "dsputil.h" 45 #include "dsputil.h"
45 46
46 #define PALETTE_COUNT 256 47 #define PALETTE_COUNT 256
47 48
48 /* debugging support */ 49 /* debugging support */
295 296
296 } else { 297 } else {
297 298
298 /* need 2 more bytes from the stream */ 299 /* need 2 more bytes from the stream */
299 CHECK_STREAM_PTR(2); 300 CHECK_STREAM_PTR(2);
300 B[0] = *s->stream_ptr++; 301
301 B[1] = *s->stream_ptr++; 302 flags = bytestream_get_le16(&s->stream_ptr);
302
303 flags = (B[1] << 8) | B[0];
304 bitmask = 0x0001; 303 bitmask = 0x0001;
305 for (y = 0; y < 8; y += 2) { 304 for (y = 0; y < 8; y += 2) {
306 for (x = 0; x < 8; x += 2, bitmask <<= 1) { 305 for (x = 0; x < 8; x += 2, bitmask <<= 1) {
307 if (flags & bitmask) { 306 if (flags & bitmask) {
308 *(s->pixel_ptr + x) = P1; 307 *(s->pixel_ptr + x) = P1;
476 475
477 static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) 476 static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s)
478 { 477 {
479 int x, y; 478 int x, y;
480 unsigned char P[4]; 479 unsigned char P[4];
481 unsigned char B[4];
482 unsigned int flags = 0; 480 unsigned int flags = 0;
483 int shifter = 0; 481 int shifter = 0;
484 unsigned char pix; 482 unsigned char pix;
485 483
486 /* 4-color encoding */ 484 /* 4-color encoding */
494 /* 1 of 4 colors for each pixel, need 16 more bytes */ 492 /* 1 of 4 colors for each pixel, need 16 more bytes */
495 CHECK_STREAM_PTR(16); 493 CHECK_STREAM_PTR(16);
496 494
497 for (y = 0; y < 8; y++) { 495 for (y = 0; y < 8; y++) {
498 /* get the next set of 8 2-bit flags */ 496 /* get the next set of 8 2-bit flags */
499 flags = (s->stream_ptr[1] << 8) | s->stream_ptr[0]; 497 flags = bytestream_get_le16(&s->stream_ptr);
500 s->stream_ptr += 2;
501 for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { 498 for (x = 0, shifter = 0; x < 8; x++, shifter += 2) {
502 *s->pixel_ptr++ = P[(flags >> shifter) & 0x03]; 499 *s->pixel_ptr++ = P[(flags >> shifter) & 0x03];
503 } 500 }
504 s->pixel_ptr += s->line_inc; 501 s->pixel_ptr += s->line_inc;
505 } 502 }
507 } else if ((P[0] <= P[1]) && (P[2] > P[3])) { 504 } else if ((P[0] <= P[1]) && (P[2] > P[3])) {
508 505
509 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ 506 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
510 CHECK_STREAM_PTR(4); 507 CHECK_STREAM_PTR(4);
511 508
512 B[0] = *s->stream_ptr++; 509 flags = bytestream_get_le32(&s->stream_ptr);
513 B[1] = *s->stream_ptr++;
514 B[2] = *s->stream_ptr++;
515 B[3] = *s->stream_ptr++;
516 flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
517 shifter = 0; 510 shifter = 0;
518 511
519 for (y = 0; y < 8; y += 2) { 512 for (y = 0; y < 8; y += 2) {
520 for (x = 0; x < 8; x += 2, shifter += 2) { 513 for (x = 0; x < 8; x += 2, shifter += 2) {
521 pix = P[(flags >> shifter) & 0x03]; 514 pix = P[(flags >> shifter) & 0x03];
533 CHECK_STREAM_PTR(8); 526 CHECK_STREAM_PTR(8);
534 527
535 for (y = 0; y < 8; y++) { 528 for (y = 0; y < 8; y++) {
536 /* time to reload flags? */ 529 /* time to reload flags? */
537 if ((y == 0) || (y == 4)) { 530 if ((y == 0) || (y == 4)) {
538 B[0] = *s->stream_ptr++; 531 flags = bytestream_get_le32(&s->stream_ptr);
539 B[1] = *s->stream_ptr++;
540 B[2] = *s->stream_ptr++;
541 B[3] = *s->stream_ptr++;
542 flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
543 shifter = 0; 532 shifter = 0;
544 } 533 }
545 for (x = 0; x < 8; x += 2, shifter += 2) { 534 for (x = 0; x < 8; x += 2, shifter += 2) {
546 pix = P[(flags >> shifter) & 0x03]; 535 pix = P[(flags >> shifter) & 0x03];
547 *(s->pixel_ptr + x) = pix; 536 *(s->pixel_ptr + x) = pix;
556 CHECK_STREAM_PTR(8); 545 CHECK_STREAM_PTR(8);
557 546
558 for (y = 0; y < 8; y += 2) { 547 for (y = 0; y < 8; y += 2) {
559 /* time to reload flags? */ 548 /* time to reload flags? */
560 if ((y == 0) || (y == 4)) { 549 if ((y == 0) || (y == 4)) {
561 B[0] = *s->stream_ptr++; 550 flags = bytestream_get_le32(&s->stream_ptr);
562 B[1] = *s->stream_ptr++;
563 B[2] = *s->stream_ptr++;
564 B[3] = *s->stream_ptr++;
565 flags = (B[3] << 24) | (B[2] << 16) | (B[1] << 8) | B[0];
566 shifter = 0; 551 shifter = 0;
567 } 552 }
568 for (x = 0; x < 8; x++, shifter += 2) { 553 for (x = 0; x < 8; x++, shifter += 2) {
569 pix = P[(flags >> shifter) & 0x03]; 554 pix = P[(flags >> shifter) & 0x03];
570 *(s->pixel_ptr + x) = pix; 555 *(s->pixel_ptr + x) = pix;