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
378 } else {378 } else {
379 379
380 /* unpack the list of partially-coded superblocks */380 /* unpack the list of partially-coded superblocks */
381 bit = get_bits1(gb);381 bit = get_bits1(gb) ^ 1;
382 current_run = 0;
383
382 while (current_superblock < s->superblock_count && get_bits_left(gb) > 0) {384 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
383 current_run = get_vlc2(gb,390 current_run = get_vlc2(gb,
384 s->superblock_run_length_vlc.table, 6, 2) + 1;391 s->superblock_run_length_vlc.table, 6, 2) + 1;
385 if (current_run == 34)392 if (current_run == 34)
@@ -395,11 +402,6 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) · 9 unmodified lines
395 current_superblock += current_run;402 current_superblock += current_run;
396 if (bit)403 if (bit)
397 num_partial_superblocks += current_run;404 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;
403 }405 }
404 406
405 /* unpack the list of fully coded superblocks if any of the blocks were407 /* 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
408 int superblocks_decoded = 0;410 int superblocks_decoded = 0;
409 411
410 current_superblock = 0;412 current_superblock = 0;
411 bit = get_bits1(gb);413 bit = get_bits1(gb) ^ 1;
414 current_run = 0;
415
412 while (superblocks_decoded < s->superblock_count - num_partial_superblocks416 while (superblocks_decoded < s->superblock_count - num_partial_superblocks
413 && get_bits_left(gb) > 0) {417 && 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
414 current_run = get_vlc2(gb,424 current_run = get_vlc2(gb,
415 s->superblock_run_length_vlc.table, 6, 2) + 1;425 s->superblock_run_length_vlc.table, 6, 2) + 1;
416 if (current_run == 34)426 if (current_run == 34)
@@ -429,11 +439,6 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) · 12 unmodified lines
429 }439 }
430 }440 }
431 superblocks_decoded += current_run;441 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;
437 }442 }
438 }443 }
439 444
@@ -800,9 +805,15 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) · 360 unmodified lines
800 for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) {805 for (qpi = 0; qpi < s->nqps-1 && num_blocks > 0; qpi++) {
801 i = blocks_decoded = num_blocks_at_qpi = 0;806 i = blocks_decoded = num_blocks_at_qpi = 0;
802 807
803 bit = get_bits1(gb);808 bit = get_bits1(gb) ^ 1;
809 run_length = 0;
804 810
805 do {811 do {
812 if (run_length == MAXIMUM_LONG_BIT_RUN)
813 bit = get_bits1(gb);
814 else
815 bit ^= 1;
816
806 run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1;817 run_length = get_vlc2(gb, s->superblock_run_length_vlc.table, 6, 2) + 1;
807 if (run_length == 34)818 if (run_length == 34)
808 run_length += get_bits(gb, 12);819 run_length += get_bits(gb, 12);
@@ -820,11 +831,6 @@ static int unpack_block_qpis(Vp3DecodeContext *s, GetBitContext *gb) · 11 unmodified lines
820 j++;831 j++;
821 }832 }
822 }833 }
823
824 if (run_length == MAXIMUM_LONG_BIT_RUN)
825 bit = get_bits1(gb);
826 else
827 bit ^= 1;
828 } while (blocks_decoded < num_blocks && get_bits_left(gb) > 0);834 } while (blocks_decoded < num_blocks && get_bits_left(gb) > 0);
829 835
830 num_blocks -= num_blocks_at_qpi;836 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