MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / mp_decode_layer2

Function mp_decode_layer2

libavcodec/mpegaudiodec.c:1132–1316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1130}
1131
1132static int mp_decode_layer2(MPADecodeContext *s)
1133{
1134 int sblimit; /* number of used subbands */
1135 const unsigned char *alloc_table;
1136 int table, bit_alloc_bits, i, j, ch, bound, v;
1137 unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
1138 unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT];
1139 unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3], *sf;
1140 int scale, qindex, bits, steps, k, l, m, b;
1141
1142 /* select decoding table */
1143 table = ff_mpa_l2_select_table(s->bit_rate / 1000, s->nb_channels,
1144 s->sample_rate, s->lsf);
1145 sblimit = ff_mpa_sblimit_table[table];
1146 alloc_table = ff_mpa_alloc_tables[table];
1147
1148 if (s->mode == MPA_JSTEREO)
1149 bound = (s->mode_ext + 1) * 4;
1150 else
1151 bound = sblimit;
1152
1153 dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
1154
1155 /* sanity check */
1156 if( bound > sblimit ) bound = sblimit;
1157
1158 /* parse bit allocation */
1159 j = 0;
1160 for(i=0;i<bound;i++) {
1161 bit_alloc_bits = alloc_table[j];
1162 for(ch=0;ch<s->nb_channels;ch++) {
1163 bit_alloc[ch][i] = get_bits(&s->gb, bit_alloc_bits);
1164 }
1165 j += 1 << bit_alloc_bits;
1166 }
1167 for(i=bound;i<sblimit;i++) {
1168 bit_alloc_bits = alloc_table[j];
1169 v = get_bits(&s->gb, bit_alloc_bits);
1170 bit_alloc[0][i] = v;
1171 bit_alloc[1][i] = v;
1172 j += 1 << bit_alloc_bits;
1173 }
1174
1175 /* scale codes */
1176 for(i=0;i<sblimit;i++) {
1177 for(ch=0;ch<s->nb_channels;ch++) {
1178 if (bit_alloc[ch][i])
1179 scale_code[ch][i] = get_bits(&s->gb, 2);
1180 }
1181 }
1182
1183 /* scale factors */
1184 for(i=0;i<sblimit;i++) {
1185 for(ch=0;ch<s->nb_channels;ch++) {
1186 if (bit_alloc[ch][i]) {
1187 sf = scale_factors[ch][i];
1188 switch(scale_code[ch][i]) {
1189 default:

Callers 1

mp_decode_frameFunction · 0.85

Calls 4

ff_mpa_l2_select_tableFunction · 0.85
get_bitsFunction · 0.85
l2_unscale_groupFunction · 0.85
l1_unscaleFunction · 0.85

Tested by

no test coverage detected