Mercurial > libavcodec.hg
comparison vp3.c @ 11227:9aea1eaefe16 libavcodec
Decode fully coded superblocks in the same manner as partial superblocks and qpi
No speed difference, but it will simplify the special 4129 case.
author | conrad |
---|---|
date | Sun, 21 Feb 2010 00:10:54 +0000 |
parents | 386c361bf136 |
children | 6cb4b2e4af1c |
comparison
equal
deleted
inserted
replaced
11226:386c361bf136 | 11227:9aea1eaefe16 |
---|---|
450 static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) | 450 static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) |
451 { | 451 { |
452 int bit = 0; | 452 int bit = 0; |
453 int current_superblock = 0; | 453 int current_superblock = 0; |
454 int current_run = 0; | 454 int current_run = 0; |
455 int decode_fully_flags = 0; | 455 int num_partial_superblocks = 0; |
456 int decode_partial_blocks = 0; | |
457 int first_c_fragment_seen; | 456 int first_c_fragment_seen; |
458 | 457 |
459 int i, j; | 458 int i, j; |
460 int current_fragment; | 459 int current_fragment; |
461 | 460 |
478 } | 477 } |
479 | 478 |
480 memset(s->superblock_coding + current_superblock, bit, current_run); | 479 memset(s->superblock_coding + current_superblock, bit, current_run); |
481 | 480 |
482 current_superblock += current_run; | 481 current_superblock += current_run; |
483 | 482 if (bit) |
484 /* if any of the superblocks are not partially coded, flag | 483 num_partial_superblocks += current_run; |
485 * a boolean to decode the list of fully-coded superblocks */ | |
486 if (bit == 0) { | |
487 decode_fully_flags = 1; | |
488 } else { | |
489 | |
490 /* make a note of the fact that there are partially coded | |
491 * superblocks */ | |
492 decode_partial_blocks = 1; | |
493 } | |
494 | 484 |
495 bit ^= 1; | 485 bit ^= 1; |
496 } | 486 } |
497 | 487 |
498 /* unpack the list of fully coded superblocks if any of the blocks were | 488 /* unpack the list of fully coded superblocks if any of the blocks were |
499 * not marked as partially coded in the previous step */ | 489 * not marked as partially coded in the previous step */ |
500 if (decode_fully_flags) { | 490 if (num_partial_superblocks < s->superblock_count) { |
491 int superblocks_decoded = 0; | |
501 | 492 |
502 current_superblock = 0; | 493 current_superblock = 0; |
503 current_run = 0; | |
504 bit = get_bits1(gb); | 494 bit = get_bits1(gb); |
505 /* toggle the bit because as soon as the first run length is | 495 while (superblocks_decoded < s->superblock_count - num_partial_superblocks) { |
506 * fetched the bit will be toggled again */ | 496 current_run = get_vlc2(gb, |
507 bit ^= 1; | 497 s->superblock_run_length_vlc.table, 6, 2) + 1; |
508 while (current_superblock < s->superblock_count) { | 498 if (current_run == 34) |
499 current_run += get_bits(gb, 12); | |
500 | |
501 for (j = 0; j < current_run; current_superblock++) { | |
502 if (current_superblock >= s->superblock_count) { | |
503 av_log(s->avctx, AV_LOG_ERROR, "Invalid fully coded superblock run length\n"); | |
504 return -1; | |
505 } | |
509 | 506 |
510 /* skip any superblocks already marked as partially coded */ | 507 /* skip any superblocks already marked as partially coded */ |
511 if (s->superblock_coding[current_superblock] == SB_NOT_CODED) { | 508 if (s->superblock_coding[current_superblock] == SB_NOT_CODED) { |
512 | |
513 if (current_run-- == 0) { | |
514 bit ^= 1; | |
515 current_run = get_vlc2(gb, | |
516 s->superblock_run_length_vlc.table, 6, 2); | |
517 if (current_run == 33) | |
518 current_run += get_bits(gb, 12); | |
519 } | |
520 s->superblock_coding[current_superblock] = 2*bit; | 509 s->superblock_coding[current_superblock] = 2*bit; |
521 } | 510 j++; |
522 current_superblock++; | 511 } |
512 } | |
513 superblocks_decoded += current_run; | |
514 | |
515 bit ^= 1; | |
523 } | 516 } |
524 } | 517 } |
525 | 518 |
526 /* if there were partial blocks, initialize bitstream for | 519 /* if there were partial blocks, initialize bitstream for |
527 * unpacking fragment codings */ | 520 * unpacking fragment codings */ |
528 if (decode_partial_blocks) { | 521 if (num_partial_superblocks) { |
529 | 522 |
530 current_run = 0; | 523 current_run = 0; |
531 bit = get_bits1(gb); | 524 bit = get_bits1(gb); |
532 /* toggle the bit because as soon as the first run length is | 525 /* toggle the bit because as soon as the first run length is |
533 * fetched the bit will be toggled again */ | 526 * fetched the bit will be toggled again */ |