Mercurial > libavcodec.hg
comparison vp3.c @ 10620:972b17631531 libavcodec
Small refactoring: Instead of 4 loops for decoding AC coefficients based
on their grouping, create one loop that indexes into a table of AC VLC
tables.
There is also a small optimization here: Do not call unpack_vlcs()
if there are no fragments in the list with outstanding coefficients.
My profiling indicates that this can save upwards of 1 million
dezicycles per frame throughout the course of unpack_dct_coeffs().
author | melanson |
---|---|
date | Wed, 02 Dec 2009 04:06:27 +0000 |
parents | d930f99edbf9 |
children | 0139a62827ce |
comparison
equal
deleted
inserted
replaced
10619:d930f99edbf9 | 10620:972b17631531 |
---|---|
1161 int dc_y_table; | 1161 int dc_y_table; |
1162 int dc_c_table; | 1162 int dc_c_table; |
1163 int ac_y_table; | 1163 int ac_y_table; |
1164 int ac_c_table; | 1164 int ac_c_table; |
1165 int residual_eob_run = 0; | 1165 int residual_eob_run = 0; |
1166 VLC *y_tables[64]; | |
1167 VLC *c_tables[64]; | |
1166 | 1168 |
1167 /* fetch the DC table indexes */ | 1169 /* fetch the DC table indexes */ |
1168 dc_y_table = get_bits(gb, 4); | 1170 dc_y_table = get_bits(gb, 4); |
1169 dc_c_table = get_bits(gb, 4); | 1171 dc_c_table = get_bits(gb, 4); |
1170 | 1172 |
1190 | 1192 |
1191 /* fetch the AC table indexes */ | 1193 /* fetch the AC table indexes */ |
1192 ac_y_table = get_bits(gb, 4); | 1194 ac_y_table = get_bits(gb, 4); |
1193 ac_c_table = get_bits(gb, 4); | 1195 ac_c_table = get_bits(gb, 4); |
1194 | 1196 |
1195 /* unpack the group 1 AC coefficients (coeffs 1-5) */ | 1197 /* build tables of AC VLC tables */ |
1196 for (i = 1; i <= 5; i++) { | 1198 for (i = 1; i <= 5; i++) { |
1197 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_y_table], i, | 1199 y_tables[i] = &s->ac_vlc_1[ac_y_table]; |
1198 1, residual_eob_run); | 1200 c_tables[i] = &s->ac_vlc_1[ac_c_table]; |
1199 | 1201 } |
1200 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_1[ac_c_table], i, | |
1201 0, residual_eob_run); | |
1202 } | |
1203 | |
1204 /* unpack the group 2 AC coefficients (coeffs 6-14) */ | |
1205 for (i = 6; i <= 14; i++) { | 1202 for (i = 6; i <= 14; i++) { |
1206 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_y_table], i, | 1203 y_tables[i] = &s->ac_vlc_2[ac_y_table]; |
1207 1, residual_eob_run); | 1204 c_tables[i] = &s->ac_vlc_2[ac_c_table]; |
1208 | 1205 } |
1209 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_2[ac_c_table], i, | |
1210 0, residual_eob_run); | |
1211 } | |
1212 | |
1213 /* unpack the group 3 AC coefficients (coeffs 15-27) */ | |
1214 for (i = 15; i <= 27; i++) { | 1206 for (i = 15; i <= 27; i++) { |
1215 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_y_table], i, | 1207 y_tables[i] = &s->ac_vlc_3[ac_y_table]; |
1216 1, residual_eob_run); | 1208 c_tables[i] = &s->ac_vlc_3[ac_c_table]; |
1217 | 1209 } |
1218 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_3[ac_c_table], i, | |
1219 0, residual_eob_run); | |
1220 } | |
1221 | |
1222 /* unpack the group 4 AC coefficients (coeffs 28-63) */ | |
1223 for (i = 28; i <= 63; i++) { | 1210 for (i = 28; i <= 63; i++) { |
1224 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_y_table], i, | 1211 y_tables[i] = &s->ac_vlc_4[ac_y_table]; |
1225 1, residual_eob_run); | 1212 c_tables[i] = &s->ac_vlc_4[ac_c_table]; |
1226 | 1213 } |
1227 residual_eob_run = unpack_vlcs(s, gb, &s->ac_vlc_4[ac_c_table], i, | 1214 |
1228 0, residual_eob_run); | 1215 /* decode all AC coefficents */ |
1216 for (i = 1; i <= 63; i++) { | |
1217 if (s->fragment_list_y_head != -1) | |
1218 residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, | |
1219 1, residual_eob_run); | |
1220 | |
1221 if (s->fragment_list_c_head != -1) | |
1222 residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, | |
1223 0, residual_eob_run); | |
1229 } | 1224 } |
1230 | 1225 |
1231 return 0; | 1226 return 0; |
1232 } | 1227 } |
1233 | 1228 |