Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 5052:d981eb275c8f libavcodec
remove dependency of mpeg audio encoder over mpeg audio decoder
author | aurel |
---|---|
date | Sun, 20 May 2007 22:50:29 +0000 |
parents | b908c67063c8 |
children | 796c2a5481ad |
comparison
equal
deleted
inserted
replaced
5051:b908c67063c8 | 5052:d981eb275c8f |
---|---|
1138 } | 1138 } |
1139 } | 1139 } |
1140 return 12; | 1140 return 12; |
1141 } | 1141 } |
1142 | 1142 |
1143 /* bitrate is in kb/s */ | |
1144 int l2_select_table(int bitrate, int nb_channels, int freq, int lsf) | |
1145 { | |
1146 int ch_bitrate, table; | |
1147 | |
1148 ch_bitrate = bitrate / nb_channels; | |
1149 if (!lsf) { | |
1150 if ((freq == 48000 && ch_bitrate >= 56) || | |
1151 (ch_bitrate >= 56 && ch_bitrate <= 80)) | |
1152 table = 0; | |
1153 else if (freq != 48000 && ch_bitrate >= 96) | |
1154 table = 1; | |
1155 else if (freq != 32000 && ch_bitrate <= 48) | |
1156 table = 2; | |
1157 else | |
1158 table = 3; | |
1159 } else { | |
1160 table = 4; | |
1161 } | |
1162 return table; | |
1163 } | |
1164 | |
1165 static int mp_decode_layer2(MPADecodeContext *s) | 1143 static int mp_decode_layer2(MPADecodeContext *s) |
1166 { | 1144 { |
1167 int sblimit; /* number of used subbands */ | 1145 int sblimit; /* number of used subbands */ |
1168 const unsigned char *alloc_table; | 1146 const unsigned char *alloc_table; |
1169 int table, bit_alloc_bits, i, j, ch, bound, v; | 1147 int table, bit_alloc_bits, i, j, ch, bound, v; |
1171 unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT]; | 1149 unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT]; |
1172 unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3], *sf; | 1150 unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3], *sf; |
1173 int scale, qindex, bits, steps, k, l, m, b; | 1151 int scale, qindex, bits, steps, k, l, m, b; |
1174 | 1152 |
1175 /* select decoding table */ | 1153 /* select decoding table */ |
1176 table = l2_select_table(s->bit_rate / 1000, s->nb_channels, | 1154 table = ff_mpa_l2_select_table(s->bit_rate / 1000, s->nb_channels, |
1177 s->sample_rate, s->lsf); | 1155 s->sample_rate, s->lsf); |
1178 sblimit = ff_mpa_sblimit_table[table]; | 1156 sblimit = ff_mpa_sblimit_table[table]; |
1179 alloc_table = ff_mpa_alloc_tables[table]; | 1157 alloc_table = ff_mpa_alloc_tables[table]; |
1180 | 1158 |
1181 if (s->mode == MPA_JSTEREO) | 1159 if (s->mode == MPA_JSTEREO) |