comparison c93.c @ 4820:7470749c2384 libavcodec

factorize & 0x0F
author michael
date Sun, 08 Apr 2007 09:44:34 +0000
parents ec6c58426b82
children 2b72f9bc4f06
comparison
equal deleted inserted replaced
4819:ec6c58426b82 4820:7470749c2384
119 C93DecoderContext * const c93 = avctx->priv_data; 119 C93DecoderContext * const c93 = avctx->priv_data;
120 AVFrame * const newpic = &c93->pictures[c93->currentpic]; 120 AVFrame * const newpic = &c93->pictures[c93->currentpic];
121 AVFrame * const oldpic = &c93->pictures[c93->currentpic^1]; 121 AVFrame * const oldpic = &c93->pictures[c93->currentpic^1];
122 AVFrame *picture = data; 122 AVFrame *picture = data;
123 uint8_t *out; 123 uint8_t *out;
124 int stride, i, x, y; 124 int stride, i, x, y, bt = 0;
125 C93BlockType bt = 0;
126 125
127 c93->currentpic ^= 1; 126 c93->currentpic ^= 1;
128 127
129 newpic->reference = 1; 128 newpic->reference = 1;
130 newpic->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | 129 newpic->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
159 out = newpic->data[0] + y * stride; 158 out = newpic->data[0] + y * stride;
160 for (x = 0; x < WIDTH; x += 8) { 159 for (x = 0; x < WIDTH; x += 8) {
161 uint8_t *copy_from = oldpic->data[0]; 160 uint8_t *copy_from = oldpic->data[0];
162 unsigned int offset, j; 161 unsigned int offset, j;
163 uint8_t cols[4], grps[4]; 162 uint8_t cols[4], grps[4];
163 C93BlockType block_type;
164 164
165 if (!bt) 165 if (!bt)
166 bt = *buf++; 166 bt = *buf++;
167 167
168 switch (bt & 0x0F) { 168 block_type= bt & 0x0F;
169 switch (block_type) {
169 case C93_8X8_FROM_PREV: 170 case C93_8X8_FROM_PREV:
170 offset = bytestream_get_le16(&buf); 171 offset = bytestream_get_le16(&buf);
171 if (copy_block(avctx, out, copy_from, offset, 8, stride)) 172 if (copy_block(avctx, out, copy_from, offset, 8, stride))
172 return -1; 173 return -1;
173 break; 174 break;
197 case C93_4X4_2COLOR: 198 case C93_4X4_2COLOR:
198 case C93_4X4_4COLOR: 199 case C93_4X4_4COLOR:
199 case C93_4X4_4COLOR_GRP: 200 case C93_4X4_4COLOR_GRP:
200 for (j = 0; j < 8; j += 4) { 201 for (j = 0; j < 8; j += 4) {
201 for (i = 0; i < 8; i += 4) { 202 for (i = 0; i < 8; i += 4) {
202 if ((bt & 0x0F) == C93_4X4_2COLOR) { 203 if (block_type == C93_4X4_2COLOR) {
203 bytestream_get_buffer(&buf, cols, 2); 204 bytestream_get_buffer(&buf, cols, 2);
204 draw_n_color(out + i + j*stride, stride, 4, 4, 205 draw_n_color(out + i + j*stride, stride, 4, 4,
205 1, cols, NULL, bytestream_get_le16(&buf)); 206 1, cols, NULL, bytestream_get_le16(&buf));
206 } else if ((bt & 0x0F) == C93_4X4_4COLOR) { 207 } else if (block_type == C93_4X4_4COLOR) {
207 bytestream_get_buffer(&buf, cols, 4); 208 bytestream_get_buffer(&buf, cols, 4);
208 draw_n_color(out + i + j*stride, stride, 4, 4, 209 draw_n_color(out + i + j*stride, stride, 4, 4,
209 2, cols, NULL, bytestream_get_le32(&buf)); 210 2, cols, NULL, bytestream_get_le32(&buf));
210 } else { 211 } else {
211 bytestream_get_buffer(&buf, grps, 4); 212 bytestream_get_buffer(&buf, grps, 4);
224 bytestream_get_buffer(&buf, out + j*stride, 8); 225 bytestream_get_buffer(&buf, out + j*stride, 8);
225 break; 226 break;
226 227
227 default: 228 default:
228 av_log(avctx, AV_LOG_ERROR, "unexpected type %x at %dx%d\n", 229 av_log(avctx, AV_LOG_ERROR, "unexpected type %x at %dx%d\n",
229 bt & 0x0F, x, y); 230 block_type, x, y);
230 return -1; 231 return -1;
231 } 232 }
232 bt >>= 4; 233 bt >>= 4;
233 out += 8; 234 out += 8;
234 } 235 }