Mercurial > libavcodec.hg
comparison interplayvideo.c @ 9302:0469949a5224 libavcodec
Avoid "reloading" code by using a 64 bit type for the flags and loading all at once.
author | reimar |
---|---|
date | Tue, 31 Mar 2009 13:58:40 +0000 |
parents | 37ef0d0eb1c2 |
children | 2ae6ab3fa3ba |
comparison
equal
deleted
inserted
replaced
9301:37ef0d0eb1c2 | 9302:0469949a5224 |
---|---|
377 | 377 |
378 static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) | 378 static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s) |
379 { | 379 { |
380 int x, y; | 380 int x, y; |
381 unsigned char P[4]; | 381 unsigned char P[4]; |
382 unsigned int flags = 0; | |
383 | 382 |
384 /* 4-color encoding */ | 383 /* 4-color encoding */ |
385 CHECK_STREAM_PTR(4); | 384 CHECK_STREAM_PTR(4); |
386 | 385 |
387 memcpy(P, s->stream_ptr, 4); | 386 memcpy(P, s->stream_ptr, 4); |
392 /* 1 of 4 colors for each pixel, need 16 more bytes */ | 391 /* 1 of 4 colors for each pixel, need 16 more bytes */ |
393 CHECK_STREAM_PTR(16); | 392 CHECK_STREAM_PTR(16); |
394 | 393 |
395 for (y = 0; y < 8; y++) { | 394 for (y = 0; y < 8; y++) { |
396 /* get the next set of 8 2-bit flags */ | 395 /* get the next set of 8 2-bit flags */ |
397 flags = bytestream_get_le16(&s->stream_ptr); | 396 int flags = bytestream_get_le16(&s->stream_ptr); |
398 for (x = 0; x < 8; x++, flags >>= 2) { | 397 for (x = 0; x < 8; x++, flags >>= 2) { |
399 *s->pixel_ptr++ = P[flags & 0x03]; | 398 *s->pixel_ptr++ = P[flags & 0x03]; |
400 } | 399 } |
401 s->pixel_ptr += s->line_inc; | 400 s->pixel_ptr += s->line_inc; |
402 } | 401 } |
403 | 402 |
404 } else if ((P[0] <= P[1]) && (P[2] > P[3])) { | 403 } else if ((P[0] <= P[1]) && (P[2] > P[3])) { |
404 uint32_t flags; | |
405 | 405 |
406 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ | 406 /* 1 of 4 colors for each 2x2 block, need 4 more bytes */ |
407 CHECK_STREAM_PTR(4); | 407 CHECK_STREAM_PTR(4); |
408 | 408 |
409 flags = bytestream_get_le32(&s->stream_ptr); | 409 flags = bytestream_get_le32(&s->stream_ptr); |
417 } | 417 } |
418 s->pixel_ptr += s->stride * 2; | 418 s->pixel_ptr += s->stride * 2; |
419 } | 419 } |
420 | 420 |
421 } else if ((P[0] > P[1]) && (P[2] <= P[3])) { | 421 } else if ((P[0] > P[1]) && (P[2] <= P[3])) { |
422 uint64_t flags; | |
422 | 423 |
423 /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ | 424 /* 1 of 4 colors for each 2x1 block, need 8 more bytes */ |
424 CHECK_STREAM_PTR(8); | 425 CHECK_STREAM_PTR(8); |
425 | 426 |
427 flags = bytestream_get_le64(&s->stream_ptr); | |
426 for (y = 0; y < 8; y++) { | 428 for (y = 0; y < 8; y++) { |
427 /* time to reload flags? */ | |
428 if ((y == 0) || (y == 4)) { | |
429 flags = bytestream_get_le32(&s->stream_ptr); | |
430 } | |
431 for (x = 0; x < 8; x += 2, flags >>= 2) { | 429 for (x = 0; x < 8; x += 2, flags >>= 2) { |
432 s->pixel_ptr[x ] = | 430 s->pixel_ptr[x ] = |
433 s->pixel_ptr[x + 1] = P[flags & 0x03]; | 431 s->pixel_ptr[x + 1] = P[flags & 0x03]; |
434 } | 432 } |
435 s->pixel_ptr += s->stride; | 433 s->pixel_ptr += s->stride; |
436 } | 434 } |
437 | 435 |
438 } else { | 436 } else { |
437 uint64_t flags; | |
439 | 438 |
440 /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ | 439 /* 1 of 4 colors for each 1x2 block, need 8 more bytes */ |
441 CHECK_STREAM_PTR(8); | 440 CHECK_STREAM_PTR(8); |
442 | 441 |
442 flags = bytestream_get_le64(&s->stream_ptr); | |
443 for (y = 0; y < 8; y += 2) { | 443 for (y = 0; y < 8; y += 2) { |
444 /* time to reload flags? */ | |
445 if ((y == 0) || (y == 4)) { | |
446 flags = bytestream_get_le32(&s->stream_ptr); | |
447 } | |
448 for (x = 0; x < 8; x++, flags >>= 2) { | 444 for (x = 0; x < 8; x++, flags >>= 2) { |
449 s->pixel_ptr[x ] = | 445 s->pixel_ptr[x ] = |
450 s->pixel_ptr[x + s->stride] = P[flags & 0x03]; | 446 s->pixel_ptr[x + s->stride] = P[flags & 0x03]; |
451 } | 447 } |
452 s->pixel_ptr += s->stride * 2; | 448 s->pixel_ptr += s->stride * 2; |