comparison bethsoftvideo.c @ 4812:d9cff0d54fdd libavcodec

use shorter names for the block type enum
author michael
date Sat, 07 Apr 2007 23:10:22 +0000
parents 35e47a6e01e2
children a7f058c55491
comparison
equal deleted inserted replaced
4811:2e9455fd2b8c 4812:d9cff0d54fdd
49 49
50 static void set_palette(AVFrame * frame, uint8_t * palette_buffer) 50 static void set_palette(AVFrame * frame, uint8_t * palette_buffer)
51 { 51 {
52 uint32_t * palette = (uint32_t *)frame->data[1]; 52 uint32_t * palette = (uint32_t *)frame->data[1];
53 int a; 53 int a;
54 for(a = 0; a < VID_PALETTE_NUMCOLORS; a++) 54 for(a = 0; a < 256; a++)
55 { 55 {
56 palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4; // multiply all colors by 4 56 palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4; // multiply all colors by 4
57 } 57 }
58 frame->palette_has_changed = 1; 58 frame->palette_has_changed = 1;
59 } 59 }
82 frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height; 82 frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height;
83 83
84 switch(block_type = *buf++) 84 switch(block_type = *buf++)
85 { 85 {
86 case PALETTE_BLOCK: set_palette(&vid->frame, buf); return 0; 86 case PALETTE_BLOCK: set_palette(&vid->frame, buf); return 0;
87 case VIDEO_YOFFSET_DIFFERENCE_FRAME_BLOCK: 87 case VIDEO_YOFF_P_FRAME:
88 yoffset = bytestream_get_le16(&buf); 88 yoffset = bytestream_get_le16(&buf);
89 if(yoffset >= avctx->height) { return -1; } 89 if(yoffset >= avctx->height) { return -1; }
90 destination += vid->frame.linesize[0] * yoffset; 90 destination += vid->frame.linesize[0] * yoffset;
91 } 91 }
92 92
97 97
98 // copy any bytes starting at the current position, and ending at the frame width 98 // copy any bytes starting at the current position, and ending at the frame width
99 while(length > line_remaining) 99 while(length > line_remaining)
100 { 100 {
101 if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, line_remaining); } 101 if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, line_remaining); }
102 else if(block_type == VIDEO_FULL_FRAME_BLOCK) { memset(destination, buf[0], line_remaining); } 102 else if(block_type == VIDEO_I_FRAME) { memset(destination, buf[0], line_remaining); }
103 length -= line_remaining; // decrement the number of bytes to be copied 103 length -= line_remaining; // decrement the number of bytes to be copied
104 destination += line_remaining + wrap_to_next_line; // skip over extra bytes at end of frame 104 destination += line_remaining + wrap_to_next_line; // skip over extra bytes at end of frame
105 line_remaining = avctx->width; 105 line_remaining = avctx->width;
106 if(destination == frame_end) { goto end; } 106 if(destination == frame_end) { goto end; }
107 } 107 }
108 108
109 // copy any remaining bytes after / if line overflows 109 // copy any remaining bytes after / if line overflows
110 if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, length); } 110 if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, length); }
111 else if(block_type == VIDEO_FULL_FRAME_BLOCK) { memset(destination, *buf++, length); } 111 else if(block_type == VIDEO_I_FRAME) { memset(destination, *buf++, length); }
112 line_remaining -= length; 112 line_remaining -= length;
113 destination += length; 113 destination += length;
114 } 114 }
115 end: 115 end:
116 116