Mercurial > libavcodec.hg
comparison interplayvideo.c @ 9296:2129ee5b7e0d libavcodec
Get rid of some pointless bitmask/shifter variables in interplayvideo.c
author | reimar |
---|---|
date | Tue, 31 Mar 2009 12:44:35 +0000 |
parents | b8e5b7edb2d5 |
children | 493f6d65db83 |
comparison
equal
deleted
inserted
replaced
9295:b225f51903af | 9296:2129ee5b7e0d |
---|---|
197 static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s) | 197 static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s) |
198 { | 198 { |
199 int x, y; | 199 int x, y; |
200 unsigned char P0, P1; | 200 unsigned char P0, P1; |
201 unsigned int flags; | 201 unsigned int flags; |
202 int bitmask; | |
203 | 202 |
204 /* 2-color encoding */ | 203 /* 2-color encoding */ |
205 CHECK_STREAM_PTR(2); | 204 CHECK_STREAM_PTR(2); |
206 | 205 |
207 P0 = *s->stream_ptr++; | 206 P0 = *s->stream_ptr++; |
227 | 226 |
228 /* need 2 more bytes from the stream */ | 227 /* need 2 more bytes from the stream */ |
229 CHECK_STREAM_PTR(2); | 228 CHECK_STREAM_PTR(2); |
230 | 229 |
231 flags = bytestream_get_le16(&s->stream_ptr); | 230 flags = bytestream_get_le16(&s->stream_ptr); |
232 bitmask = 0x0001; | |
233 for (y = 0; y < 8; y += 2) { | 231 for (y = 0; y < 8; y += 2) { |
234 for (x = 0; x < 8; x += 2, bitmask <<= 1) { | 232 for (x = 0; x < 8; x += 2, flags >>= 1) { |
235 if (flags & bitmask) { | 233 if (flags & 1) { |
236 *(s->pixel_ptr + x) = P1; | 234 *(s->pixel_ptr + x) = P1; |
237 *(s->pixel_ptr + x + 1) = P1; | 235 *(s->pixel_ptr + x + 1) = P1; |
238 *(s->pixel_ptr + s->stride + x) = P1; | 236 *(s->pixel_ptr + s->stride + x) = P1; |
239 *(s->pixel_ptr + s->stride + x + 1) = P1; | 237 *(s->pixel_ptr + s->stride + x + 1) = P1; |
240 } else { | 238 } else { |
256 { | 254 { |
257 int x, y; | 255 int x, y; |
258 unsigned char P[8]; | 256 unsigned char P[8]; |
259 unsigned char B[8]; | 257 unsigned char B[8]; |
260 unsigned int flags = 0; | 258 unsigned int flags = 0; |
261 unsigned int bitmask = 0; | |
262 unsigned char P0 = 0, P1 = 0; | 259 unsigned char P0 = 0, P1 = 0; |
263 int lower_half = 0; | 260 int lower_half = 0; |
264 | 261 |
265 /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on | 262 /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on |
266 * either top and bottom or left and right halves */ | 263 * either top and bottom or left and right halves */ |
288 flags = | 285 flags = |
289 ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | | 286 ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | |
290 ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) | | 287 ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) | |
291 ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | | 288 ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | |
292 ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); | 289 ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); |
293 bitmask = 0x00000001; | |
294 lower_half = 0; /* still on top half */ | 290 lower_half = 0; /* still on top half */ |
295 } else if (y == 4) { | 291 } else if (y == 4) { |
296 flags = | 292 flags = |
297 ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | | 293 ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | |
298 ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) | | 294 ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) | |
299 ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | | 295 ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | |
300 ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); | 296 ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); |
301 bitmask = 0x00000001; | |
302 lower_half = 2; | 297 lower_half = 2; |
303 } | 298 } |
304 | 299 |
305 for (x = 0; x < 8; x++, bitmask <<= 1) { | 300 for (x = 0; x < 8; x++, flags >>= 1) { |
306 /* get the pixel values ready for this quadrant */ | 301 /* get the pixel values ready for this quadrant */ |
307 if (x == 0) { | 302 if (x == 0) { |
308 P0 = P[lower_half + 0]; | 303 P0 = P[lower_half + 0]; |
309 P1 = P[lower_half + 1]; | 304 P1 = P[lower_half + 1]; |
310 } else if (x == 4) { | 305 } else if (x == 4) { |
311 P0 = P[lower_half + 4]; | 306 P0 = P[lower_half + 4]; |
312 P1 = P[lower_half + 5]; | 307 P1 = P[lower_half + 5]; |
313 } | 308 } |
314 | 309 |
315 if (flags & bitmask) | 310 if (flags & 1) |
316 *s->pixel_ptr++ = P1; | 311 *s->pixel_ptr++ = P1; |
317 else | 312 else |
318 *s->pixel_ptr++ = P0; | 313 *s->pixel_ptr++ = P0; |
319 } | 314 } |
320 s->pixel_ptr += s->line_inc; | 315 s->pixel_ptr += s->line_inc; |
341 flags = | 336 flags = |
342 ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | | 337 ((B[0] & 0xF0) << 4) | ((B[4] & 0xF0) << 8) | |
343 ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) | | 338 ((B[0] & 0x0F) ) | ((B[4] & 0x0F) << 4) | |
344 ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | | 339 ((B[1] & 0xF0) << 20) | ((B[5] & 0xF0) << 24) | |
345 ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); | 340 ((B[1] & 0x0F) << 16) | ((B[5] & 0x0F) << 20); |
346 bitmask = 0x00000001; | |
347 } else if (y == 4) { | 341 } else if (y == 4) { |
348 flags = | 342 flags = |
349 ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | | 343 ((B[2] & 0xF0) << 4) | ((B[6] & 0xF0) << 8) | |
350 ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) | | 344 ((B[2] & 0x0F) ) | ((B[6] & 0x0F) << 4) | |
351 ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | | 345 ((B[3] & 0xF0) << 20) | ((B[7] & 0xF0) << 24) | |
352 ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); | 346 ((B[3] & 0x0F) << 16) | ((B[7] & 0x0F) << 20); |
353 bitmask = 0x00000001; | |
354 } | 347 } |
355 | 348 |
356 for (x = 0; x < 8; x++, bitmask <<= 1) { | 349 for (x = 0; x < 8; x++, flags >>= 1) { |
357 /* get the pixel values ready for this half */ | 350 /* get the pixel values ready for this half */ |
358 if (x == 0) { | 351 if (x == 0) { |
359 P0 = P[0]; | 352 P0 = P[0]; |
360 P1 = P[1]; | 353 P1 = P[1]; |
361 } else if (x == 4) { | 354 } else if (x == 4) { |
362 P0 = P[2]; | 355 P0 = P[2]; |
363 P1 = P[3]; | 356 P1 = P[3]; |
364 } | 357 } |
365 | 358 |
366 if (flags & bitmask) | 359 if (flags & 1) |
367 *s->pixel_ptr++ = P1; | 360 *s->pixel_ptr++ = P1; |
368 else | 361 else |
369 *s->pixel_ptr++ = P0; | 362 *s->pixel_ptr++ = P0; |
370 } | 363 } |
371 s->pixel_ptr += s->line_inc; | 364 s->pixel_ptr += s->line_inc; |
374 } else { | 367 } else { |
375 | 368 |
376 /* horizontal split; top & bottom halves are 2-color encoded */ | 369 /* horizontal split; top & bottom halves are 2-color encoded */ |
377 | 370 |
378 for (y = 0; y < 8; y++) { | 371 for (y = 0; y < 8; y++) { |
372 int bitmask; | |
379 | 373 |
380 flags = B[y]; | 374 flags = B[y]; |
381 if (y == 0) { | 375 if (y == 0) { |
382 P0 = P[0]; | 376 P0 = P[0]; |
383 P1 = P[1]; | 377 P1 = P[1]; |
405 static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) | 399 static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) |
406 { | 400 { |
407 int x, y; | 401 int x, y; |
408 unsigned char P[4]; | 402 unsigned char P[4]; |
409 unsigned int flags = 0; | 403 unsigned int flags = 0; |
410 int shifter = 0; | |
411 unsigned char pix; | 404 unsigned char pix; |
412 | 405 |
413 /* 4-color encoding */ | 406 /* 4-color encoding */ |
414 CHECK_STREAM_PTR(4); | 407 CHECK_STREAM_PTR(4); |
415 | 408 |
422 CHECK_STREAM_PTR(16); | 415 CHECK_STREAM_PTR(16); |
423 | 416 |
424 for (y = 0; y < 8; y++) { | 417 for (y = 0; y < 8; y++) { |
425 /* get the next set of 8 2-bit flags */ | 418 /* get the next set of 8 2-bit flags */ |
426 flags = bytestream_get_le16(&s->stream_ptr); | 419 flags = bytestream_get_le16(&s->stream_ptr); |
427 for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { | 420 for (x = 0; x < 8; x++, flags >>= 2) { |
428 *s->pixel_ptr++ = P[(flags >> shifter) & 0x03]; | 421 *s->pixel_ptr++ = P[flags & 0x03]; |
429 } | 422 } |
430 s->pixel_ptr += s->line_inc; | 423 s->pixel_ptr += s->line_inc; |
431 } | 424 } |
432 | 425 |
433 } else if ((P[0] <= P[1]) && (P[2] > P[3])) { | 426 } else if ((P[0] <= P[1]) && (P[2] > P[3])) { |
434 | 427 |
435 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ | 428 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ |
436 CHECK_STREAM_PTR(4); | 429 CHECK_STREAM_PTR(4); |
437 | 430 |
438 flags = bytestream_get_le32(&s->stream_ptr); | 431 flags = bytestream_get_le32(&s->stream_ptr); |
439 shifter = 0; | |
440 | 432 |
441 for (y = 0; y < 8; y += 2) { | 433 for (y = 0; y < 8; y += 2) { |
442 for (x = 0; x < 8; x += 2, shifter += 2) { | 434 for (x = 0; x < 8; x += 2, flags >>= 2) { |
443 pix = P[(flags >> shifter) & 0x03]; | 435 pix = P[flags & 0x03]; |
444 *(s->pixel_ptr + x) = pix; | 436 *(s->pixel_ptr + x) = pix; |
445 *(s->pixel_ptr + x + 1) = pix; | 437 *(s->pixel_ptr + x + 1) = pix; |
446 *(s->pixel_ptr + s->stride + x) = pix; | 438 *(s->pixel_ptr + s->stride + x) = pix; |
447 *(s->pixel_ptr + s->stride + x + 1) = pix; | 439 *(s->pixel_ptr + s->stride + x + 1) = pix; |
448 } | 440 } |
456 | 448 |
457 for (y = 0; y < 8; y++) { | 449 for (y = 0; y < 8; y++) { |
458 /* time to reload flags? */ | 450 /* time to reload flags? */ |
459 if ((y == 0) || (y == 4)) { | 451 if ((y == 0) || (y == 4)) { |
460 flags = bytestream_get_le32(&s->stream_ptr); | 452 flags = bytestream_get_le32(&s->stream_ptr); |
461 shifter = 0; | 453 } |
462 } | 454 for (x = 0; x < 8; x += 2, flags >>= 2) { |
463 for (x = 0; x < 8; x += 2, shifter += 2) { | 455 pix = P[flags & 0x03]; |
464 pix = P[(flags >> shifter) & 0x03]; | |
465 *(s->pixel_ptr + x) = pix; | 456 *(s->pixel_ptr + x) = pix; |
466 *(s->pixel_ptr + x + 1) = pix; | 457 *(s->pixel_ptr + x + 1) = pix; |
467 } | 458 } |
468 s->pixel_ptr += s->stride; | 459 s->pixel_ptr += s->stride; |
469 } | 460 } |
475 | 466 |
476 for (y = 0; y < 8; y += 2) { | 467 for (y = 0; y < 8; y += 2) { |
477 /* time to reload flags? */ | 468 /* time to reload flags? */ |
478 if ((y == 0) || (y == 4)) { | 469 if ((y == 0) || (y == 4)) { |
479 flags = bytestream_get_le32(&s->stream_ptr); | 470 flags = bytestream_get_le32(&s->stream_ptr); |
480 shifter = 0; | 471 } |
481 } | 472 for (x = 0; x < 8; x++, flags >>= 2) { |
482 for (x = 0; x < 8; x++, shifter += 2) { | 473 pix = P[flags & 0x03]; |
483 pix = P[(flags >> shifter) & 0x03]; | |
484 *(s->pixel_ptr + x) = pix; | 474 *(s->pixel_ptr + x) = pix; |
485 *(s->pixel_ptr + s->stride + x) = pix; | 475 *(s->pixel_ptr + s->stride + x) = pix; |
486 } | 476 } |
487 s->pixel_ptr += s->stride * 2; | 477 s->pixel_ptr += s->stride * 2; |
488 } | 478 } |
496 { | 486 { |
497 int x, y; | 487 int x, y; |
498 unsigned char P[16]; | 488 unsigned char P[16]; |
499 unsigned char B[16]; | 489 unsigned char B[16]; |
500 int flags = 0; | 490 int flags = 0; |
501 int shifter = 0; | |
502 int index; | 491 int index; |
503 int split; | 492 int split; |
504 int lower_half; | 493 int lower_half; |
505 | 494 |
506 /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on | 495 /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on |
527 for (y = 0; y < 8; y++) { | 516 for (y = 0; y < 8; y++) { |
528 | 517 |
529 lower_half = (y >= 4) ? 4 : 0; | 518 lower_half = (y >= 4) ? 4 : 0; |
530 flags = (B[y + 8] << 8) | B[y]; | 519 flags = (B[y + 8] << 8) | B[y]; |
531 | 520 |
532 for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { | 521 for (x = 0; x < 8; x++, flags >>= 2) { |
533 split = (x >= 4) ? 8 : 0; | 522 split = (x >= 4) ? 8 : 0; |
534 index = split + lower_half + ((flags >> shifter) & 0x03); | 523 index = split + lower_half + (flags & 0x03); |
535 *s->pixel_ptr++ = P[index]; | 524 *s->pixel_ptr++ = P[index]; |
536 } | 525 } |
537 | 526 |
538 s->pixel_ptr += s->line_inc; | 527 s->pixel_ptr += s->line_inc; |
539 } | 528 } |
557 for (y = 0; y < 8; y++) { | 546 for (y = 0; y < 8; y++) { |
558 | 547 |
559 flags = (B[y + 8] << 8) | B[y]; | 548 flags = (B[y + 8] << 8) | B[y]; |
560 split = 0; | 549 split = 0; |
561 | 550 |
562 for (x = 0, shifter = 0; x < 8; x++, shifter += 2) { | 551 for (x = 0; x < 8; x++, flags >>= 2) { |
563 if (x == 4) | 552 if (x == 4) |
564 split = 4; | 553 split = 4; |
565 *s->pixel_ptr++ = P[split + ((flags >> shifter) & 0x03)]; | 554 *s->pixel_ptr++ = P[split + (flags & 0x03)]; |
566 } | 555 } |
567 | 556 |
568 s->pixel_ptr += s->line_inc; | 557 s->pixel_ptr += s->line_inc; |
569 } | 558 } |
570 | 559 |
576 | 565 |
577 flags = (B[y * 2 + 1] << 8) | B[y * 2]; | 566 flags = (B[y * 2 + 1] << 8) | B[y * 2]; |
578 if (y == 4) | 567 if (y == 4) |
579 split = 4; | 568 split = 4; |
580 | 569 |
581 for (x = 0, shifter = 0; x < 8; x++, shifter += 2) | 570 for (x = 0; x < 8; x++, flags >>= 2) |
582 *s->pixel_ptr++ = P[split + ((flags >> shifter) & 0x03)]; | 571 *s->pixel_ptr++ = P[split + (flags & 0x03)]; |
583 | 572 |
584 s->pixel_ptr += s->line_inc; | 573 s->pixel_ptr += s->line_inc; |
585 } | 574 } |
586 } | 575 } |
587 } | 576 } |