*@brief Decode a single subframe (block). *@param s codec context *@return 0 on success, < 0 when decoding failed */
| 1201 | *@return 0 on success, < 0 when decoding failed |
| 1202 | */ |
| 1203 | static int decode_subframe(WMAProDecodeCtx *s) |
| 1204 | { |
| 1205 | int offset = s->samples_per_frame; |
| 1206 | int subframe_len = s->samples_per_frame; |
| 1207 | int i; |
| 1208 | int total_samples = s->samples_per_frame * s->nb_channels; |
| 1209 | int transmit_coeffs = 0; |
| 1210 | int cur_subwoofer_cutoff; |
| 1211 | |
| 1212 | s->subframe_offset = get_bits_count(&s->gb); |
| 1213 | |
| 1214 | /** reset channel context and find the next block offset and size |
| 1215 | == the next block of the channel with the smallest number of |
| 1216 | decoded samples |
| 1217 | */ |
| 1218 | for (i = 0; i < s->nb_channels; i++) { |
| 1219 | s->channel[i].grouped = 0; |
| 1220 | if (offset > s->channel[i].decoded_samples) { |
| 1221 | offset = s->channel[i].decoded_samples; |
| 1222 | subframe_len = |
| 1223 | s->channel[i].subframe_len[s->channel[i].cur_subframe]; |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | ff_dlog(s->avctx, |
| 1228 | "processing subframe with offset %i len %i\n", offset, subframe_len); |
| 1229 | |
| 1230 | /** get a list of all channels that contain the estimated block */ |
| 1231 | s->channels_for_cur_subframe = 0; |
| 1232 | for (i = 0; i < s->nb_channels; i++) { |
| 1233 | const int cur_subframe = s->channel[i].cur_subframe; |
| 1234 | /** subtract already processed samples */ |
| 1235 | total_samples -= s->channel[i].decoded_samples; |
| 1236 | |
| 1237 | /** and count if there are multiple subframes that match our profile */ |
| 1238 | if (offset == s->channel[i].decoded_samples && |
| 1239 | subframe_len == s->channel[i].subframe_len[cur_subframe]) { |
| 1240 | total_samples -= s->channel[i].subframe_len[cur_subframe]; |
| 1241 | s->channel[i].decoded_samples += |
| 1242 | s->channel[i].subframe_len[cur_subframe]; |
| 1243 | s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i; |
| 1244 | ++s->channels_for_cur_subframe; |
| 1245 | } |
| 1246 | } |
| 1247 | |
| 1248 | /** check if the frame will be complete after processing the |
| 1249 | estimated block */ |
| 1250 | if (!total_samples) |
| 1251 | s->parsed_all_subframes = 1; |
| 1252 | |
| 1253 | |
| 1254 | ff_dlog(s->avctx, "subframe is part of %i channels\n", |
| 1255 | s->channels_for_cur_subframe); |
| 1256 | |
| 1257 | /** calculate number of scale factor bands and their offsets */ |
| 1258 | s->table_idx = av_log2(s->samples_per_frame/subframe_len); |
| 1259 | s->num_bands = s->num_sfb[s->table_idx]; |
| 1260 | s->cur_sfb_offsets = s->sfb_offsets[s->table_idx]; |
no test coverage detected