Decode fully coded superblocks in the same manner as partial superblocks and qpi

No speed difference, but it will simplify the special 4129 case.

Originally committed as revision 21929 to svn://svn.ffmpeg.org/ffmpeg/trunk
release/0.6
David Conrad 15 years ago
parent ecb51b25bb
commit 855c720c86
  1. 51
      libavcodec/vp3.c

@ -452,8 +452,7 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
int bit = 0; int bit = 0;
int current_superblock = 0; int current_superblock = 0;
int current_run = 0; int current_run = 0;
int decode_fully_flags = 0; int num_partial_superblocks = 0;
int decode_partial_blocks = 0;
int first_c_fragment_seen; int first_c_fragment_seen;
int i, j; int i, j;
@ -480,52 +479,46 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
memset(s->superblock_coding + current_superblock, bit, current_run); memset(s->superblock_coding + current_superblock, bit, current_run);
current_superblock += current_run; current_superblock += current_run;
if (bit)
/* if any of the superblocks are not partially coded, flag num_partial_superblocks += current_run;
* a boolean to decode the list of fully-coded superblocks */
if (bit == 0) {
decode_fully_flags = 1;
} else {
/* make a note of the fact that there are partially coded
* superblocks */
decode_partial_blocks = 1;
}
bit ^= 1; bit ^= 1;
} }
/* unpack the list of fully coded superblocks if any of the blocks were /* unpack the list of fully coded superblocks if any of the blocks were
* not marked as partially coded in the previous step */ * not marked as partially coded in the previous step */
if (decode_fully_flags) { if (num_partial_superblocks < s->superblock_count) {
int superblocks_decoded = 0;
current_superblock = 0; current_superblock = 0;
current_run = 0;
bit = get_bits1(gb); bit = get_bits1(gb);
/* toggle the bit because as soon as the first run length is while (superblocks_decoded < s->superblock_count - num_partial_superblocks) {
* fetched the bit will be toggled again */
bit ^= 1;
while (current_superblock < s->superblock_count) {
/* skip any superblocks already marked as partially coded */
if (s->superblock_coding[current_superblock] == SB_NOT_CODED) {
if (current_run-- == 0) {
bit ^= 1;
current_run = get_vlc2(gb, current_run = get_vlc2(gb,
s->superblock_run_length_vlc.table, 6, 2); s->superblock_run_length_vlc.table, 6, 2) + 1;
if (current_run == 33) if (current_run == 34)
current_run += get_bits(gb, 12); current_run += get_bits(gb, 12);
for (j = 0; j < current_run; current_superblock++) {
if (current_superblock >= s->superblock_count) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid fully coded superblock run length\n");
return -1;
} }
/* skip any superblocks already marked as partially coded */
if (s->superblock_coding[current_superblock] == SB_NOT_CODED) {
s->superblock_coding[current_superblock] = 2*bit; s->superblock_coding[current_superblock] = 2*bit;
j++;
} }
current_superblock++; }
superblocks_decoded += current_run;
bit ^= 1;
} }
} }
/* if there were partial blocks, initialize bitstream for /* if there were partial blocks, initialize bitstream for
* unpacking fragment codings */ * unpacking fragment codings */
if (decode_partial_blocks) { if (num_partial_superblocks) {
current_run = 0; current_run = 0;
bit = get_bits1(gb); bit = get_bits1(gb);

Loading…
Cancel
Save