Mercurial > libavcodec.hg
comparison vp3.c @ 7139:03fe3194eff7 libavcodec
make ModeAlphabet read-only and use a custom mode alphabet
only locally in unpack_modes()
author | stefang |
---|---|
date | Wed, 25 Jun 2008 14:14:58 +0000 |
parents | e943e1409077 |
children | 8002605f6aaf |
comparison
equal
deleted
inserted
replaced
7138:1f85910c9ab2 | 7139:03fe3194eff7 |
---|---|
170 | 170 |
171 /* special internal mode */ | 171 /* special internal mode */ |
172 #define MODE_COPY 8 | 172 #define MODE_COPY 8 |
173 | 173 |
174 /* There are 6 preset schemes, plus a free-form scheme */ | 174 /* There are 6 preset schemes, plus a free-form scheme */ |
175 static int ModeAlphabet[7][CODING_MODE_COUNT] = | 175 static const int ModeAlphabet[6][CODING_MODE_COUNT] = |
176 { | 176 { |
177 /* this is the custom scheme */ | |
178 { 0, 0, 0, 0, 0, 0, 0, 0 }, | |
179 | |
180 /* scheme 1: Last motion vector dominates */ | 177 /* scheme 1: Last motion vector dominates */ |
181 { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST, | 178 { MODE_INTER_LAST_MV, MODE_INTER_PRIOR_LAST, |
182 MODE_INTER_PLUS_MV, MODE_INTER_NO_MV, | 179 MODE_INTER_PLUS_MV, MODE_INTER_NO_MV, |
183 MODE_INTRA, MODE_USING_GOLDEN, | 180 MODE_INTRA, MODE_USING_GOLDEN, |
184 MODE_GOLDEN_MV, MODE_INTER_FOURMV }, | 181 MODE_GOLDEN_MV, MODE_INTER_FOURMV }, |
875 int i, j, k; | 872 int i, j, k; |
876 int scheme; | 873 int scheme; |
877 int current_macroblock; | 874 int current_macroblock; |
878 int current_fragment; | 875 int current_fragment; |
879 int coding_mode; | 876 int coding_mode; |
877 int custom_mode_alphabet[CODING_MODE_COUNT]; | |
880 | 878 |
881 debug_vp3(" vp3: unpacking encoding modes\n"); | 879 debug_vp3(" vp3: unpacking encoding modes\n"); |
882 | 880 |
883 if (s->keyframe) { | 881 if (s->keyframe) { |
884 debug_vp3(" keyframe-- all blocks are coded as INTRA\n"); | 882 debug_vp3(" keyframe-- all blocks are coded as INTRA\n"); |
894 | 892 |
895 /* is it a custom coding scheme? */ | 893 /* is it a custom coding scheme? */ |
896 if (scheme == 0) { | 894 if (scheme == 0) { |
897 debug_modes(" custom mode alphabet ahead:\n"); | 895 debug_modes(" custom mode alphabet ahead:\n"); |
898 for (i = 0; i < 8; i++) | 896 for (i = 0; i < 8; i++) |
899 ModeAlphabet[scheme][get_bits(gb, 3)] = i; | 897 custom_mode_alphabet[get_bits(gb, 3)] = i; |
900 } | 898 } |
901 | 899 |
902 for (i = 0; i < 8; i++) | 900 for (i = 0; i < 8; i++) { |
903 debug_modes(" mode[%d][%d] = %d\n", scheme, i, | 901 if(scheme) |
904 ModeAlphabet[scheme][i]); | 902 debug_modes(" mode[%d][%d] = %d\n", scheme, i, |
903 ModeAlphabet[scheme-1][i]); | |
904 else | |
905 debug_modes(" mode[0][%d] = %d\n", i, | |
906 custom_mode_alphabet[i]); | |
907 } | |
905 | 908 |
906 /* iterate through all of the macroblocks that contain 1 or more | 909 /* iterate through all of the macroblocks that contain 1 or more |
907 * coded fragments */ | 910 * coded fragments */ |
908 for (i = 0; i < s->u_superblock_start; i++) { | 911 for (i = 0; i < s->u_superblock_start; i++) { |
909 | 912 |
919 } | 922 } |
920 | 923 |
921 /* mode 7 means get 3 bits for each coding mode */ | 924 /* mode 7 means get 3 bits for each coding mode */ |
922 if (scheme == 7) | 925 if (scheme == 7) |
923 coding_mode = get_bits(gb, 3); | 926 coding_mode = get_bits(gb, 3); |
927 else if(scheme == 0) | |
928 coding_mode = custom_mode_alphabet | |
929 [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)]; | |
924 else | 930 else |
925 coding_mode = ModeAlphabet[scheme] | 931 coding_mode = ModeAlphabet[scheme-1] |
926 [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)]; | 932 [get_vlc2(gb, s->mode_code_vlc.table, 3, 3)]; |
927 | 933 |
928 s->macroblock_coding[current_macroblock] = coding_mode; | 934 s->macroblock_coding[current_macroblock] = coding_mode; |
929 for (k = 0; k < 6; k++) { | 935 for (k = 0; k < 6; k++) { |
930 current_fragment = | 936 current_fragment = |