*@brief Decode a single subframe (block). *@param s codec context *@return 0 on success, < 0 when decoding failed */
| 1043 | *@return 0 on success, < 0 when decoding failed |
| 1044 | */ |
| 1045 | static int decode_subframe(WMAProDecodeCtx *s) |
| 1046 | { |
| 1047 | int offset = s->samples_per_frame; |
| 1048 | int subframe_len = s->samples_per_frame; |
| 1049 | int i; |
| 1050 | int total_samples = s->samples_per_frame * s->num_channels; |
| 1051 | int transmit_coeffs = 0; |
| 1052 | int cur_subwoofer_cutoff; |
| 1053 | |
| 1054 | s->subframe_offset = get_bits_count(&s->gb); |
| 1055 | |
| 1056 | /** reset channel context and find the next block offset and size |
| 1057 | == the next block of the channel with the smallest number of |
| 1058 | decoded samples |
| 1059 | */ |
| 1060 | for (i = 0; i < s->num_channels; i++) { |
| 1061 | s->channel[i].grouped = 0; |
| 1062 | if (offset > s->channel[i].decoded_samples) { |
| 1063 | offset = s->channel[i].decoded_samples; |
| 1064 | subframe_len = |
| 1065 | s->channel[i].subframe_len[s->channel[i].cur_subframe]; |
| 1066 | } |
| 1067 | } |
| 1068 | |
| 1069 | dprintf(s->avctx, |
| 1070 | "processing subframe with offset %i len %i\n", offset, subframe_len); |
| 1071 | |
| 1072 | /** get a list of all channels that contain the estimated block */ |
| 1073 | s->channels_for_cur_subframe = 0; |
| 1074 | for (i = 0; i < s->num_channels; i++) { |
| 1075 | const int cur_subframe = s->channel[i].cur_subframe; |
| 1076 | /** substract already processed samples */ |
| 1077 | total_samples -= s->channel[i].decoded_samples; |
| 1078 | |
| 1079 | /** and count if there are multiple subframes that match our profile */ |
| 1080 | if (offset == s->channel[i].decoded_samples && |
| 1081 | subframe_len == s->channel[i].subframe_len[cur_subframe]) { |
| 1082 | total_samples -= s->channel[i].subframe_len[cur_subframe]; |
| 1083 | s->channel[i].decoded_samples += |
| 1084 | s->channel[i].subframe_len[cur_subframe]; |
| 1085 | s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i; |
| 1086 | ++s->channels_for_cur_subframe; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | /** check if the frame will be complete after processing the |
| 1091 | estimated block */ |
| 1092 | if (!total_samples) |
| 1093 | s->parsed_all_subframes = 1; |
| 1094 | |
| 1095 | |
| 1096 | dprintf(s->avctx, "subframe is part of %i channels\n", |
| 1097 | s->channels_for_cur_subframe); |
| 1098 | |
| 1099 | /** calculate number of scale factor bands and their offsets */ |
| 1100 | s->table_idx = av_log2(s->samples_per_frame/subframe_len); |
| 1101 | s->num_bands = s->num_sfb[s->table_idx]; |
| 1102 | s->cur_sfb_offsets = s->sfb_offsets[s->table_idx]; |
no test coverage detected