History

theora: Don't read an excess bit for maximum length long bit runs if the run exactly ends the remaining blocks.

Originally committed as revision 23304 to svn://svn.ffmpeg.org/ffmpeg/trunk

David Conrad committed 16 years ago

Commit cc460051 parent 8299a7f1 file · +24 −18Browse files

Unified · Split

libavcodec/vp3.c+24−18
@@ -378,8 +378,15 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) · 377 unmodified lines
378378 } else {
379379
380380 /* unpack the list of partially-coded superblocks */
381− bit = get_bits1(gb);
381+ bit = get_bits1(gb) ^ 1;
382+ current_run = 0;
383+
382384 while (current_superblock < s->superblock_count && get_bits_left(gb) > 0) {
385+ if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
386+ bit = get_bits1(gb);
387+ else
388+ bit ^= 1;
389+
383390 current_run = get_vlc2(gb,
384391 s->superblock_run_length_vlc.table, 6, 2) + 1;
385392 if (current_run == 34)
@@ -395,11 +402,6 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) · 9 unmodified lines
395402 current_superblock += current_run;
396403 if (bit)
397404 num_partial_superblocks += current_run;
398−
399− if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
400− bit = get_bits1(gb);
401− else
402− bit ^= 1;
403405 }
404406
405407 /* unpack the list of fully coded superblocks if any of the blocks were
@@ -408,9 +410,17 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) · 2 unmodified lines
408410 int superblocks_decoded = 0;
409411
410412 current_superblock = 0;
411− bit = get_bits1(gb);
413+ bit = get_bits1(gb) ^ 1;
414+ current_run = 0;
415+
412416 while (superblocks_decoded < s->superblock_count - num_partial_superblocks
413417 && get_bits_left(gb) > 0) {
418+
419+ if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
420+ bit = get_bits1(gb);
421+ else
422+ bit ^= 1;
423+
414424 current_run = get_vlc2(gb,
415425 s->superblock_run_length_vlc.table, 6, 2) + 1;
416426 if (current_run == 34)
@@ -429,11 +439,6 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) · 12 unmodified lines
429439 }
430440 }
431441 superblocks_decoded += current_run;
432−
433− if (s->theora && current_run == MAXIMUM_LONG_BIT_RUN)
434− bit = get_bits1(gb);
435− else
436− bit ^= 1;
437442 }
438443 }
439444
@@ -800,9 +805,15 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) · 360 unmodified lines
800805 for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) {
801806 i = blocks_decoded = num_blocks_at_qpi = 0;
802807
803− bit = get_bits1(gb);
808+ bit = get_bits1(gb) ^ 1;
809+ run_length = 0;
804810
805811 do {
812+ if (run_length == MAXIMUM_LONG_BIT_RUN)
813+ bit = get_bits1(gb);
814+ else
815+ bit ^= 1;
816+
806817 run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1;
807818 if (run_length == 34)
808819 run_length += get_bits(gb, 12);
@@ -820,11 +831,6 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) · 11 unmodified lines
820831 j++;
821832 }
822833 }
823−
824− if (run_length == MAXIMUM_LONG_BIT_RUN)
825− bit = get_bits1(gb);
826− else
827− bit ^= 1;
828834 } while (blocks_decoded < num_blocks && get_bits_left(gb) > 0);
829835
830836 num_blocks -= num_blocks_at_qpi;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t