Mercurial > libavcodec.hg
comparison bethsoftvideo.c @ 4813:a7f058c55491 libavcodec
indention cleanup
author | michael |
---|---|
date | Sat, 07 Apr 2007 23:16:05 +0000 |
parents | d9cff0d54fdd |
children | d2fbd9c6df06 |
comparison
equal
deleted
inserted
replaced
4812:d9cff0d54fdd | 4813:a7f058c55491 |
---|---|
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 < 256; a++) | 54 for(a = 0; a < 256; a++){ |
55 { | |
56 palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4; // multiply all colors by 4 | 55 palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4; // multiply all colors by 4 |
57 } | 56 } |
58 frame->palette_has_changed = 1; | 57 frame->palette_has_changed = 1; |
59 } | 58 } |
60 | 59 |
79 return -1; | 78 return -1; |
80 } | 79 } |
81 destination = vid->frame.data[0]; | 80 destination = vid->frame.data[0]; |
82 frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height; | 81 frame_end = vid->frame.data[0] + vid->frame.linesize[0] * avctx->height; |
83 | 82 |
84 switch(block_type = *buf++) | 83 switch(block_type = *buf++){ |
85 { | 84 case PALETTE_BLOCK: |
86 case PALETTE_BLOCK: set_palette(&vid->frame, buf); return 0; | 85 set_palette(&vid->frame, buf); |
86 return 0; | |
87 case VIDEO_YOFF_P_FRAME: | 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) |
90 return -1; | |
90 destination += vid->frame.linesize[0] * yoffset; | 91 destination += vid->frame.linesize[0] * yoffset; |
91 } | 92 } |
92 | 93 |
93 // main code | 94 // main code |
94 while((rle_num_bytes = *buf++)) | 95 while((rle_num_bytes = *buf++)){ |
95 { | |
96 int length = rle_num_bytes & 0x7f; | 96 int length = rle_num_bytes & 0x7f; |
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 if(rle_num_bytes < 0x80) |
101 if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, line_remaining); } | 101 bytestream_get_buffer(&buf, destination, line_remaining); |
102 else if(block_type == VIDEO_I_FRAME) { memset(destination, buf[0], line_remaining); } | 102 else if(block_type == VIDEO_I_FRAME) |
103 memset(destination, buf[0], line_remaining); | |
103 length -= line_remaining; // decrement the number of bytes to be copied | 104 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 | 105 destination += line_remaining + wrap_to_next_line; // skip over extra bytes at end of frame |
105 line_remaining = avctx->width; | 106 line_remaining = avctx->width; |
106 if(destination == frame_end) { goto end; } | 107 if(destination == frame_end) |
108 goto end; | |
107 } | 109 } |
108 | 110 |
109 // copy any remaining bytes after / if line overflows | 111 // copy any remaining bytes after / if line overflows |
110 if(rle_num_bytes < 0x80) { bytestream_get_buffer(&buf, destination, length); } | 112 if(rle_num_bytes < 0x80) |
111 else if(block_type == VIDEO_I_FRAME) { memset(destination, *buf++, length); } | 113 bytestream_get_buffer(&buf, destination, length); |
114 else if(block_type == VIDEO_I_FRAME) | |
115 memset(destination, *buf++, length); | |
112 line_remaining -= length; | 116 line_remaining -= length; |
113 destination += length; | 117 destination += length; |
114 } | 118 } |
115 end: | 119 end: |
116 | 120 |
122 | 126 |
123 static int bethsoftvid_decode_end(AVCodecContext *avctx) | 127 static int bethsoftvid_decode_end(AVCodecContext *avctx) |
124 { | 128 { |
125 BethsoftvidContext * vid = avctx->priv_data; | 129 BethsoftvidContext * vid = avctx->priv_data; |
126 av_log(avctx, AV_LOG_DEBUG, "[bethsoftvid video decoder] closing\n"); | 130 av_log(avctx, AV_LOG_DEBUG, "[bethsoftvid video decoder] closing\n"); |
127 if(vid->frame.data[0]) { avctx->release_buffer(avctx, &vid->frame); } | 131 if(vid->frame.data[0]) |
132 avctx->release_buffer(avctx, &vid->frame); | |
128 return 0; | 133 return 0; |
129 } | 134 } |
130 | 135 |
131 AVCodec bethsoftvid_decoder = { | 136 AVCodec bethsoftvid_decoder = { |
132 .name = "bethsoftvid", | 137 .name = "bethsoftvid", |