comparison vp3.c @ 7972:6cf217dad67d libavcodec

Cosmetics: reindent
author conrad
date Wed, 01 Oct 2008 14:48:54 +0000
parents 2d93e4e1358b
children 1fbfce20cb79
comparison
equal deleted inserted replaced
7971:2d93e4e1358b 7972:6cf217dad67d
812 int current_fragment; 812 int current_fragment;
813 813
814 if (s->keyframe) 814 if (s->keyframe)
815 return 0; 815 return 0;
816 816
817 memset(motion_x, 0, 6 * sizeof(int)); 817 memset(motion_x, 0, 6 * sizeof(int));
818 memset(motion_y, 0, 6 * sizeof(int)); 818 memset(motion_y, 0, 6 * sizeof(int));
819 819
820 /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */ 820 /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */
821 coding_mode = get_bits1(gb); 821 coding_mode = get_bits1(gb);
822 822
823 /* iterate through all of the macroblocks that contain 1 or more 823 /* iterate through all of the macroblocks that contain 1 or more
824 * coded fragments */ 824 * coded fragments */
825 for (i = 0; i < s->u_superblock_start; i++) { 825 for (i = 0; i < s->u_superblock_start; i++) {
826 826
827 for (j = 0; j < 4; j++) { 827 for (j = 0; j < 4; j++) {
828 current_macroblock = s->superblock_macroblocks[i * 4 + j]; 828 current_macroblock = s->superblock_macroblocks[i * 4 + j];
829 if ((current_macroblock == -1) || 829 if ((current_macroblock == -1) ||
830 (s->macroblock_coding[current_macroblock] == MODE_COPY)) 830 (s->macroblock_coding[current_macroblock] == MODE_COPY))
831 continue; 831 continue;
832 if (current_macroblock >= s->macroblock_count) { 832 if (current_macroblock >= s->macroblock_count) {
833 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad macroblock number (%d >= %d)\n", 833 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad macroblock number (%d >= %d)\n",
834 current_macroblock, s->macroblock_count); 834 current_macroblock, s->macroblock_count);
835 return 1; 835 return 1;
836 } 836 }
837 837
838 current_fragment = s->macroblock_fragments[current_macroblock * 6]; 838 current_fragment = s->macroblock_fragments[current_macroblock * 6];
839 if (current_fragment >= s->fragment_count) { 839 if (current_fragment >= s->fragment_count) {
840 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad fragment number (%d >= %d\n", 840 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad fragment number (%d >= %d\n",
841 current_fragment, s->fragment_count); 841 current_fragment, s->fragment_count);
842 return 1; 842 return 1;
843 } 843 }
844 switch (s->macroblock_coding[current_macroblock]) { 844 switch (s->macroblock_coding[current_macroblock]) {
845 845
846 case MODE_INTER_PLUS_MV: 846 case MODE_INTER_PLUS_MV:
847 case MODE_GOLDEN_MV: 847 case MODE_GOLDEN_MV:
848 /* all 6 fragments use the same motion vector */ 848 /* all 6 fragments use the same motion vector */
849 if (coding_mode == 0) { 849 if (coding_mode == 0) {
850 motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; 850 motion_x[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
851 motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)]; 851 motion_y[0] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
852 } else { 852 } else {
853 motion_x[0] = fixed_motion_vector_table[get_bits(gb, 6)]; 853 motion_x[0] = fixed_motion_vector_table[get_bits(gb, 6)];
854 motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)]; 854 motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)];
855 } 855 }
856 856
857 for (k = 1; k < 6; k++) { 857 for (k = 1; k < 6; k++) {
858 motion_x[k] = motion_x[0]; 858 motion_x[k] = motion_x[0];
859 motion_y[k] = motion_y[0]; 859 motion_y[k] = motion_y[0];
860 } 860 }
861 861
862 /* vector maintenance, only on MODE_INTER_PLUS_MV */ 862 /* vector maintenance, only on MODE_INTER_PLUS_MV */
863 if (s->macroblock_coding[current_macroblock] == 863 if (s->macroblock_coding[current_macroblock] ==
864 MODE_INTER_PLUS_MV) { 864 MODE_INTER_PLUS_MV) {
865 prior_last_motion_x = last_motion_x;
866 prior_last_motion_y = last_motion_y;
867 last_motion_x = motion_x[0];
868 last_motion_y = motion_y[0];
869 }
870 break;
871
872 case MODE_INTER_FOURMV:
873 /* vector maintenance */
874 prior_last_motion_x = last_motion_x;
875 prior_last_motion_y = last_motion_y;
876
877 /* fetch 4 vectors from the bitstream, one for each
878 * Y fragment, then average for the C fragment vectors */
879 motion_x[4] = motion_y[4] = 0;
880 for (k = 0; k < 4; k++) {
881 for (l = 0; l < s->coded_fragment_list_index; l++)
882 if (s->coded_fragment_list[l] == s->macroblock_fragments[6*current_macroblock + k])
883 break;
884 if (l < s->coded_fragment_list_index) {
885 if (coding_mode == 0) {
886 motion_x[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
887 motion_y[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
888 } else {
889 motion_x[k] = fixed_motion_vector_table[get_bits(gb, 6)];
890 motion_y[k] = fixed_motion_vector_table[get_bits(gb, 6)];
891 }
892 last_motion_x = motion_x[k];
893 last_motion_y = motion_y[k];
894 } else {
895 motion_x[k] = 0;
896 motion_y[k] = 0;
897 }
898 motion_x[4] += motion_x[k];
899 motion_y[4] += motion_y[k];
900 }
901
902 motion_x[5]=
903 motion_x[4]= RSHIFT(motion_x[4], 2);
904 motion_y[5]=
905 motion_y[4]= RSHIFT(motion_y[4], 2);
906 break;
907
908 case MODE_INTER_LAST_MV:
909 /* all 6 fragments use the last motion vector */
910 motion_x[0] = last_motion_x;
911 motion_y[0] = last_motion_y;
912 for (k = 1; k < 6; k++) {
913 motion_x[k] = motion_x[0];
914 motion_y[k] = motion_y[0];
915 }
916
917 /* no vector maintenance (last vector remains the
918 * last vector) */
919 break;
920
921 case MODE_INTER_PRIOR_LAST:
922 /* all 6 fragments use the motion vector prior to the
923 * last motion vector */
924 motion_x[0] = prior_last_motion_x;
925 motion_y[0] = prior_last_motion_y;
926 for (k = 1; k < 6; k++) {
927 motion_x[k] = motion_x[0];
928 motion_y[k] = motion_y[0];
929 }
930
931 /* vector maintenance */
932 prior_last_motion_x = last_motion_x; 865 prior_last_motion_x = last_motion_x;
933 prior_last_motion_y = last_motion_y; 866 prior_last_motion_y = last_motion_y;
934 last_motion_x = motion_x[0]; 867 last_motion_x = motion_x[0];
935 last_motion_y = motion_y[0]; 868 last_motion_y = motion_y[0];
936 break; 869 }
937 870 break;
938 default: 871
939 /* covers intra, inter without MV, golden without MV */ 872 case MODE_INTER_FOURMV:
940 memset(motion_x, 0, 6 * sizeof(int)); 873 /* vector maintenance */
941 memset(motion_y, 0, 6 * sizeof(int)); 874 prior_last_motion_x = last_motion_x;
942 875 prior_last_motion_y = last_motion_y;
943 /* no vector maintenance */ 876
944 break; 877 /* fetch 4 vectors from the bitstream, one for each
945 } 878 * Y fragment, then average for the C fragment vectors */
946 879 motion_x[4] = motion_y[4] = 0;
947 /* assign the motion vectors to the correct fragments */ 880 for (k = 0; k < 4; k++) {
948 for (k = 0; k < 6; k++) { 881 for (l = 0; l < s->coded_fragment_list_index; l++)
949 current_fragment = 882 if (s->coded_fragment_list[l] == s->macroblock_fragments[6*current_macroblock + k])
950 s->macroblock_fragments[current_macroblock * 6 + k]; 883 break;
951 if (current_fragment == -1) 884 if (l < s->coded_fragment_list_index) {
952 continue; 885 if (coding_mode == 0) {
953 if (current_fragment >= s->fragment_count) { 886 motion_x[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
954 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad fragment number (%d >= %d)\n", 887 motion_y[k] = motion_vector_table[get_vlc2(gb, s->motion_vector_vlc.table, 6, 2)];
955 current_fragment, s->fragment_count); 888 } else {
956 return 1; 889 motion_x[k] = fixed_motion_vector_table[get_bits(gb, 6)];
890 motion_y[k] = fixed_motion_vector_table[get_bits(gb, 6)];
891 }
892 last_motion_x = motion_x[k];
893 last_motion_y = motion_y[k];
894 } else {
895 motion_x[k] = 0;
896 motion_y[k] = 0;
957 } 897 }
958 s->all_fragments[current_fragment].motion_x = motion_x[k]; 898 motion_x[4] += motion_x[k];
959 s->all_fragments[current_fragment].motion_y = motion_y[k]; 899 motion_y[4] += motion_y[k];
960 } 900 }
901
902 motion_x[5]=
903 motion_x[4]= RSHIFT(motion_x[4], 2);
904 motion_y[5]=
905 motion_y[4]= RSHIFT(motion_y[4], 2);
906 break;
907
908 case MODE_INTER_LAST_MV:
909 /* all 6 fragments use the last motion vector */
910 motion_x[0] = last_motion_x;
911 motion_y[0] = last_motion_y;
912 for (k = 1; k < 6; k++) {
913 motion_x[k] = motion_x[0];
914 motion_y[k] = motion_y[0];
915 }
916
917 /* no vector maintenance (last vector remains the
918 * last vector) */
919 break;
920
921 case MODE_INTER_PRIOR_LAST:
922 /* all 6 fragments use the motion vector prior to the
923 * last motion vector */
924 motion_x[0] = prior_last_motion_x;
925 motion_y[0] = prior_last_motion_y;
926 for (k = 1; k < 6; k++) {
927 motion_x[k] = motion_x[0];
928 motion_y[k] = motion_y[0];
929 }
930
931 /* vector maintenance */
932 prior_last_motion_x = last_motion_x;
933 prior_last_motion_y = last_motion_y;
934 last_motion_x = motion_x[0];
935 last_motion_y = motion_y[0];
936 break;
937
938 default:
939 /* covers intra, inter without MV, golden without MV */
940 memset(motion_x, 0, 6 * sizeof(int));
941 memset(motion_y, 0, 6 * sizeof(int));
942
943 /* no vector maintenance */
944 break;
961 } 945 }
962 } 946
947 /* assign the motion vectors to the correct fragments */
948 for (k = 0; k < 6; k++) {
949 current_fragment =
950 s->macroblock_fragments[current_macroblock * 6 + k];
951 if (current_fragment == -1)
952 continue;
953 if (current_fragment >= s->fragment_count) {
954 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vectors(): bad fragment number (%d >= %d)\n",
955 current_fragment, s->fragment_count);
956 return 1;
957 }
958 s->all_fragments[current_fragment].motion_x = motion_x[k];
959 s->all_fragments[current_fragment].motion_y = motion_y[k];
960 }
961 }
962 }
963 963
964 return 0; 964 return 0;
965 } 965 }
966 966
967 /* 967 /*