comparison interplayvideo.c @ 9494:e09e4c095fdb libavcodec

Simplify ipvideo_decode_opcodes by using get_bits, this might be slower but is not performance-critical anyway.
author reimar
date Fri, 17 Apr 2009 19:28:36 +0000
parents f9828d48e19c
children 5da84f0d0a55
comparison
equal deleted inserted replaced
9493:f9828d48e19c 9494:e09e4c095fdb
40 #include <unistd.h> 40 #include <unistd.h>
41 41
42 #include "avcodec.h" 42 #include "avcodec.h"
43 #include "bytestream.h" 43 #include "bytestream.h"
44 #include "dsputil.h" 44 #include "dsputil.h"
45 #define ALT_BITSTREAM_READER_LE
46 #include "get_bits.h"
45 47
46 #define PALETTE_COUNT 256 48 #define PALETTE_COUNT 256
47 49
48 /* debugging support */ 50 /* debugging support */
49 #define DEBUG_INTERPLAY 0 51 #define DEBUG_INTERPLAY 0
564 }; 566 };
565 567
566 static void ipvideo_decode_opcodes(IpvideoContext *s) 568 static void ipvideo_decode_opcodes(IpvideoContext *s)
567 { 569 {
568 int x, y; 570 int x, y;
569 int index = 0;
570 unsigned char opcode; 571 unsigned char opcode;
571 int ret; 572 int ret;
572 static int frame = 0; 573 static int frame = 0;
574 GetBitContext gb;
573 575
574 debug_interplay("------------------ frame %d\n", frame); 576 debug_interplay("------------------ frame %d\n", frame);
575 frame++; 577 frame++;
576 578
577 /* this is PAL8, so make the palette available */ 579 /* this is PAL8, so make the palette available */
582 s->stream_end = s->buf + s->size; 584 s->stream_end = s->buf + s->size;
583 s->line_inc = s->stride - 8; 585 s->line_inc = s->stride - 8;
584 s->upper_motion_limit_offset = (s->avctx->height - 8) * s->stride 586 s->upper_motion_limit_offset = (s->avctx->height - 8) * s->stride
585 + s->avctx->width - 8; 587 + s->avctx->width - 8;
586 588
589 init_get_bits(&gb, s->decoding_map, s->decoding_map_size * 8);
587 for (y = 0; y < (s->stride * s->avctx->height); y += s->stride * 8) { 590 for (y = 0; y < (s->stride * s->avctx->height); y += s->stride * 8) {
588 for (x = y; x < y + s->avctx->width; x += 8) { 591 for (x = y; x < y + s->avctx->width; x += 8) {
589 /* bottom nibble first, then top nibble (which makes it 592 opcode = get_bits(&gb, 4);
590 * hard to use a GetBitcontext) */
591 if (index & 1)
592 opcode = s->decoding_map[index >> 1] >> 4;
593 else
594 opcode = s->decoding_map[index >> 1] & 0xF;
595 index++;
596 593
597 debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n", 594 debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
598 x - y, y / s->stride, opcode, s->stream_ptr); 595 x - y, y / s->stride, opcode, s->stream_ptr);
599 596
600 s->pixel_ptr = s->current_frame.data[0] + x; 597 s->pixel_ptr = s->current_frame.data[0] + x;