Mercurial > libavcodec.hg
comparison vp3.c @ 11472:258d773b8feb libavcodec
vp3: we only need a temp MV array of size 4
author | conrad |
---|---|
date | Sat, 13 Mar 2010 05:56:11 +0000 |
parents | 623074220038 |
children | 8b6722b58f15 |
comparison
equal
deleted
inserted
replaced
11471:623074220038 | 11472:258d773b8feb |
---|---|
606 */ | 606 */ |
607 static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb) | 607 static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb) |
608 { | 608 { |
609 int j, k, sb_x, sb_y; | 609 int j, k, sb_x, sb_y; |
610 int coding_mode; | 610 int coding_mode; |
611 int motion_x[6]; | 611 int motion_x[4]; |
612 int motion_y[6]; | 612 int motion_y[4]; |
613 int last_motion_x = 0; | 613 int last_motion_x = 0; |
614 int last_motion_y = 0; | 614 int last_motion_y = 0; |
615 int prior_last_motion_x = 0; | 615 int prior_last_motion_x = 0; |
616 int prior_last_motion_y = 0; | 616 int prior_last_motion_y = 0; |
617 int current_macroblock; | 617 int current_macroblock; |
618 int current_fragment; | 618 int current_fragment; |
619 | 619 |
620 if (s->keyframe) | 620 if (s->keyframe) |
621 return 0; | 621 return 0; |
622 | |
623 memset(motion_x, 0, 6 * sizeof(int)); | |
624 memset(motion_y, 0, 6 * sizeof(int)); | |
625 | 622 |
626 /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */ | 623 /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */ |
627 coding_mode = get_bits1(gb); | 624 coding_mode = get_bits1(gb); |
628 | 625 |
629 /* iterate through all of the macroblocks that contain 1 or more | 626 /* iterate through all of the macroblocks that contain 1 or more |
668 prior_last_motion_x = last_motion_x; | 665 prior_last_motion_x = last_motion_x; |
669 prior_last_motion_y = last_motion_y; | 666 prior_last_motion_y = last_motion_y; |
670 | 667 |
671 /* fetch 4 vectors from the bitstream, one for each | 668 /* fetch 4 vectors from the bitstream, one for each |
672 * Y fragment, then average for the C fragment vectors */ | 669 * Y fragment, then average for the C fragment vectors */ |
673 motion_x[4] = motion_y[4] = 0; | |
674 for (k = 0; k < 4; k++) { | 670 for (k = 0; k < 4; k++) { |
675 current_fragment = BLOCK_Y*s->fragment_width + BLOCK_X; | 671 current_fragment = BLOCK_Y*s->fragment_width + BLOCK_X; |
676 if (s->all_fragments[current_fragment].coding_method != MODE_COPY) { | 672 if (s->all_fragments[current_fragment].coding_method != MODE_COPY) { |
677 if (coding_mode == 0) { | 673 if (coding_mode == 0) { |
678 motion_x[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; | 674 motion_x[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; |
685 last_motion_y = motion_y[k]; | 681 last_motion_y = motion_y[k]; |
686 } else { | 682 } else { |
687 motion_x[k] = 0; | 683 motion_x[k] = 0; |
688 motion_y[k] = 0; | 684 motion_y[k] = 0; |
689 } | 685 } |
690 motion_x[4] += motion_x[k]; | 686 } |
691 motion_y[4] += motion_y[k]; | |
692 } | |
693 | |
694 motion_x[5]= | |
695 motion_x[4]= RSHIFT(motion_x[4], 2); | |
696 motion_y[5]= | |
697 motion_y[4]= RSHIFT(motion_y[4], 2); | |
698 break; | 687 break; |
699 | 688 |
700 case MODE_INTER_LAST_MV: | 689 case MODE_INTER_LAST_MV: |
701 /* all 6 fragments use the last motion vector */ | 690 /* all 6 fragments use the last motion vector */ |
702 motion_x[0] = last_motion_x; | 691 motion_x[0] = last_motion_x; |
738 } else { | 727 } else { |
739 s->all_fragments[current_fragment].motion_x = motion_x[0]; | 728 s->all_fragments[current_fragment].motion_x = motion_x[0]; |
740 s->all_fragments[current_fragment].motion_y = motion_y[0]; | 729 s->all_fragments[current_fragment].motion_y = motion_y[0]; |
741 } | 730 } |
742 } | 731 } |
732 if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) { | |
733 motion_x[0] = RSHIFT(motion_x[0] + motion_x[1] + motion_x[2] + motion_x[3], 2); | |
734 motion_y[0] = RSHIFT(motion_y[0] + motion_y[1] + motion_y[2] + motion_y[3], 2); | |
735 } | |
743 for (k = 0; k < 2; k++) { | 736 for (k = 0; k < 2; k++) { |
744 current_fragment = s->fragment_start[k+1] + | 737 current_fragment = s->fragment_start[k+1] + |
745 mb_y*(s->fragment_width>>1) + mb_x; | 738 mb_y*(s->fragment_width>>1) + mb_x; |
746 if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) { | |
747 s->all_fragments[current_fragment].motion_x = motion_x[k+4]; | |
748 s->all_fragments[current_fragment].motion_y = motion_y[k+4]; | |
749 } else { | |
750 s->all_fragments[current_fragment].motion_x = motion_x[0]; | 739 s->all_fragments[current_fragment].motion_x = motion_x[0]; |
751 s->all_fragments[current_fragment].motion_y = motion_y[0]; | 740 s->all_fragments[current_fragment].motion_y = motion_y[0]; |
752 } | |
753 } | 741 } |
754 } | 742 } |
755 } | 743 } |
756 } | 744 } |
757 | 745 |