Mercurial > libavcodec.hg
comparison vp3.c @ 10202:d0456fd306d2 libavcodec
Modify unpack_vlcs() so that there are fewer dereferences through the
main (heavily iterated) loop.
author | melanson |
---|---|
date | Mon, 21 Sep 2009 01:37:50 +0000 |
parents | 420728852dc0 |
children | b08865f6d4e3 |
comparison
equal
deleted
inserted
replaced
10201:1b2ef85867a9 | 10202:d0456fd306d2 |
---|---|
1033 int i; | 1033 int i; |
1034 int token; | 1034 int token; |
1035 int zero_run = 0; | 1035 int zero_run = 0; |
1036 DCTELEM coeff = 0; | 1036 DCTELEM coeff = 0; |
1037 Vp3Fragment *fragment; | 1037 Vp3Fragment *fragment; |
1038 int bits_to_get; | |
1039 | |
1040 /* local references to structure members to avoid repeated deferences */ | |
1038 uint8_t *perm= s->scantable.permutated; | 1041 uint8_t *perm= s->scantable.permutated; |
1039 int bits_to_get; | 1042 int *coded_fragment_list = s->coded_fragment_list; |
1043 Vp3Fragment *all_fragments = s->all_fragments; | |
1044 uint8_t *coeff_counts = s->coeff_counts; | |
1045 VLC_TYPE (*vlc_table)[2] = table->table; | |
1040 | 1046 |
1041 if ((first_fragment >= s->fragment_count) || | 1047 if ((first_fragment >= s->fragment_count) || |
1042 (last_fragment >= s->fragment_count)) { | 1048 (last_fragment >= s->fragment_count)) { |
1043 | 1049 |
1044 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vlcs(): bad fragment number (%d -> %d ?)\n", | 1050 av_log(s->avctx, AV_LOG_ERROR, " vp3:unpack_vlcs(): bad fragment number (%d -> %d ?)\n", |
1045 first_fragment, last_fragment); | 1051 first_fragment, last_fragment); |
1046 return 0; | 1052 return 0; |
1047 } | 1053 } |
1048 | 1054 |
1049 for (i = first_fragment; i <= last_fragment; i++) { | 1055 for (i = first_fragment; i <= last_fragment; i++) { |
1050 int fragment_num = s->coded_fragment_list[i]; | 1056 int fragment_num = coded_fragment_list[i]; |
1051 | 1057 |
1052 if (s->coeff_counts[fragment_num] > coeff_index) | 1058 if (coeff_counts[fragment_num] > coeff_index) |
1053 continue; | 1059 continue; |
1054 fragment = &s->all_fragments[fragment_num]; | 1060 fragment = &all_fragments[fragment_num]; |
1055 | 1061 |
1056 if (!eob_run) { | 1062 if (!eob_run) { |
1057 /* decode a VLC into a token */ | 1063 /* decode a VLC into a token */ |
1058 token = get_vlc2(gb, table->table, 5, 3); | 1064 token = get_vlc2(gb, vlc_table, 5, 3); |
1059 /* use the token to get a zero run, a coefficient, and an eob run */ | 1065 /* use the token to get a zero run, a coefficient, and an eob run */ |
1060 if (token <= 6) { | 1066 if (token <= 6) { |
1061 eob_run = eob_run_base[token]; | 1067 eob_run = eob_run_base[token]; |
1062 if (eob_run_get_bits[token]) | 1068 if (eob_run_get_bits[token]) |
1063 eob_run += get_bits(gb, eob_run_get_bits[token]); | 1069 eob_run += get_bits(gb, eob_run_get_bits[token]); |
1074 zero_run += get_bits(gb, zero_run_get_bits[token]); | 1080 zero_run += get_bits(gb, zero_run_get_bits[token]); |
1075 } | 1081 } |
1076 } | 1082 } |
1077 | 1083 |
1078 if (!eob_run) { | 1084 if (!eob_run) { |
1079 s->coeff_counts[fragment_num] += zero_run; | 1085 coeff_counts[fragment_num] += zero_run; |
1080 if (s->coeff_counts[fragment_num] < 64){ | 1086 if (coeff_counts[fragment_num] < 64){ |
1081 fragment->next_coeff->coeff= coeff; | 1087 fragment->next_coeff->coeff= coeff; |
1082 fragment->next_coeff->index= perm[s->coeff_counts[fragment_num]++]; //FIXME perm here already? | 1088 fragment->next_coeff->index= perm[coeff_counts[fragment_num]++]; //FIXME perm here already? |
1083 fragment->next_coeff->next= s->next_coeff; | 1089 fragment->next_coeff->next= s->next_coeff; |
1084 s->next_coeff->next=NULL; | 1090 s->next_coeff->next=NULL; |
1085 fragment->next_coeff= s->next_coeff++; | 1091 fragment->next_coeff= s->next_coeff++; |
1086 } | 1092 } |
1087 } else { | 1093 } else { |
1088 s->coeff_counts[fragment_num] |= 128; | 1094 coeff_counts[fragment_num] |= 128; |
1089 eob_run--; | 1095 eob_run--; |
1090 } | 1096 } |
1091 } | 1097 } |
1092 | 1098 |
1093 return eob_run; | 1099 return eob_run; |