comparison aac.c @ 7632:ac583bd8f8b3 libavcodec

Last hunk of the AAC decoder code to be OKed and build system and documentation alterations as appropriate
author superdump
date Thu, 21 Aug 2008 07:21:26 +0000
parents 3f6fc60f1ed3
children bf34cb99da5b
comparison
equal deleted inserted replaced
7631:b5b4bf0944b8 7632:ac583bd8f8b3
1102 break; 1102 break;
1103 }; 1103 };
1104 return res; 1104 return res;
1105 } 1105 }
1106 1106
1107 /**
1108 * Decode Temporal Noise Shaping filter coefficients and apply all-pole filters; reference: 4.6.9.3.
1109 *
1110 * @param decode 1 if tool is used normally, 0 if tool is used in LTP.
1111 * @param coef spectral coefficients
1112 */
1113 static void apply_tns(float coef[1024], TemporalNoiseShaping * tns, IndividualChannelStream * ics, int decode) {
1114 const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);
1115 int w, filt, m, i, ib;
1116 int bottom, top, order, start, end, size, inc;
1117 float lpc[TNS_MAX_ORDER];
1118
1119 for (w = 0; w < ics->num_windows; w++) {
1120 bottom = ics->num_swb;
1121 for (filt = 0; filt < tns->n_filt[w]; filt++) {
1122 top = bottom;
1123 bottom = FFMAX(0, top - tns->length[w][filt]);
1124 order = tns->order[w][filt];
1125 if (order == 0)
1126 continue;
1127
1128 /* tns_decode_coef
1129 * FIXME: This duplicates the functionality of some double code in lpc.c.
1130 */
1131 for (m = 0; m < order; m++) {
1132 float tmp;
1133 lpc[m] = tns->coef[w][filt][m];
1134 for (i = 0; i < m/2; i++) {
1135 tmp = lpc[i];
1136 lpc[i] += lpc[m] * lpc[m-1-i];
1137 lpc[m-1-i] += lpc[m] * tmp;
1138 }
1139 if(m & 1)
1140 lpc[i] += lpc[m] * lpc[i];
1141 }
1142
1107 start = ics->swb_offset[FFMIN(bottom, mmm)]; 1143 start = ics->swb_offset[FFMIN(bottom, mmm)];
1108 end = ics->swb_offset[FFMIN( top, mmm)]; 1144 end = ics->swb_offset[FFMIN( top, mmm)];
1109 if ((size = end - start) <= 0) 1145 if ((size = end - start) <= 0)
1110 continue; 1146 continue;
1111 if (tns->direction[w][filt]) { 1147 if (tns->direction[w][filt]) {
1116 start += w * 128; 1152 start += w * 128;
1117 1153
1118 // ar filter 1154 // ar filter
1119 for (m = 0; m < size; m++, start += inc) 1155 for (m = 0; m < size; m++, start += inc)
1120 for (i = 1; i <= FFMIN(m, order); i++) 1156 for (i = 1; i <= FFMIN(m, order); i++)
1121 coef[start] -= coef[start - i*inc] * lpc[i]; 1157 coef[start] -= coef[start - i*inc] * lpc[i-1];
1122 } 1158 }
1123 } 1159 }
1124 } 1160 }
1125 1161
1126 /** 1162 /**