History

Cosmetics: Pretty print the AAC encoder.

Originally committed as revision 19376 to svn://svn.ffmpeg.org/ffmpeg/trunk

Alex Converse committed 17 years ago

Commit fd257dc1 parent 78e65cd6 files · +288 −288Browse files

Unified · Split

6 files
  1. libavcodec/aaccoder.c +169 −169
  2. libavcodec/aacenc.c +72 −72
  3. libavcodec/aacenc.h +2 −2
  4. libavcodec/aacpsy.c +27 −27
  5. libavcodec/psymodel.c +11 −11
  6. libavcodec/psymodel.h +7 −7
libavcodec/aaccoder.c+169−169
@@ -119,18 +119,18 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, const · 118 unmodified lines
119119 int offs[4];
120120 #endif /* USE_REALLY_FULL_SEARCH */
121121
122− if(!cb){
123− for(i = 0; i < size; i++)
122+ if (!cb) {
123+ for (i = 0; i < size; i++)
124124 cost += in[i]*in[i]*lambda;
125125 return cost;
126126 }
127127 #ifndef USE_REALLY_FULL_SEARCH
128128 offs[0] = 1;
129− for(i = 1; i < dim; i++)
129+ for (i = 1; i < dim; i++)
130130 offs[i] = offs[i-1]*range;
131131 quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
132132 #endif /* USE_REALLY_FULL_SEARCH */
133− for(i = 0; i < size; i += dim){
133+ for (i = 0; i < size; i += dim) {
134134 float mincost;
135135 int minidx = 0;
136136 int minbits = 0;
@@ -138,69 +138,69 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, const · 1 unmodified line
138138 #ifndef USE_REALLY_FULL_SEARCH
139139 int (*quants)[2] = &s->qcoefs[i];
140140 mincost = 0.0f;
141− for(j = 0; j < dim; j++){
141+ for (j = 0; j < dim; j++) {
142142 mincost += in[i+j]*in[i+j]*lambda;
143143 }
144144 minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
145145 minbits = ff_aac_spectral_bits[cb-1][minidx];
146146 mincost += minbits;
147− for(j = 0; j < (1<<dim); j++){
147+ for (j = 0; j < (1<<dim); j++) {
148148 float rd = 0.0f;
149149 int curbits;
150150 int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
151151 int same = 0;
152− for(k = 0; k < dim; k++){
153− if((j & (1 << k)) && quants[k][0] == quants[k][1]){
152+ for (k = 0; k < dim; k++) {
153+ if ((j & (1 << k)) && quants[k][0] == quants[k][1]) {
154154 same = 1;
155155 break;
156156 }
157157 }
158− if(same)
158+ if (same)
159159 continue;
160− for(k = 0; k < dim; k++)
160+ for (k = 0; k < dim; k++)
161161 curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k];
162162 curbits = ff_aac_spectral_bits[cb-1][curidx];
163163 vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
164164 #else
165165 mincost = INFINITY;
166166 vec = ff_aac_codebook_vectors[cb-1];
167− for(j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim){
167+ for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
168168 float rd = 0.0f;
169169 int curbits = ff_aac_spectral_bits[cb-1][j];
170170 #endif /* USE_REALLY_FULL_SEARCH */
171− if(IS_CODEBOOK_UNSIGNED(cb)){
172− for(k = 0; k < dim; k++){
171+ if (IS_CODEBOOK_UNSIGNED(cb)) {
172+ for (k = 0; k < dim; k++) {
173173 float t = fabsf(in[i+k]);
174174 float di;
175175 //do not code with escape sequence small values
176− if(vec[k] == 64.0f && t < 39.0f*IQ){
176+ if (vec[k] == 64.0f && t < 39.0f*IQ) {
177177 rd = INFINITY;
178178 break;
179179 }
180− if(vec[k] == 64.0f){//FIXME: slow
180+ if (vec[k] == 64.0f) {//FIXME: slow
181181 if (t >= CLIPPED_ESCAPE) {
182182 di = t - CLIPPED_ESCAPE;
183183 curbits += 21;
184− }else{
184+ } else {
185185 int c = av_clip(quant(t, Q), 0, 8191);
186186 di = t - c*cbrt(c)*IQ;
187187 curbits += av_log2(c)*2 - 4 + 1;
188188 }
189− }else{
189+ } else {
190190 di = t - vec[k]*IQ;
191191 }
192− if(vec[k] != 0.0f)
192+ if (vec[k] != 0.0f)
193193 curbits++;
194194 rd += di*di*lambda;
195195 }
196− }else{
197− for(k = 0; k < dim; k++){
196+ } else {
197+ for (k = 0; k < dim; k++) {
198198 float di = in[i+k] - vec[k]*IQ;
199199 rd += di*di*lambda;
200200 }
201201 }
202202 rd += curbits;
203− if(rd < mincost){
203+ if (rd < mincost) {
204204 mincost = rd;
205205 minidx = j;
206206 minbits = curbits;
@@ -208,11 +208,11 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, const · 1 unmodified line
208208 }
209209 cost += mincost;
210210 resbits += minbits;
211− if(cost >= uplim)
211+ if (cost >= uplim)
212212 return uplim;
213213 }
214214
215− if(bits)
215+ if (bits)
216216 *bits = resbits;
217217 return cost;
218218 }
@@ -234,17 +234,17 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 15 unmodified lines
234234 #endif /* USE_REALLY_FULL_SEARCH */
235235
236236 //START_TIMER
237− if(!cb)
237+ if (!cb)
238238 return;
239239
240240 #ifndef USE_REALLY_FULL_SEARCH
241241 offs[0] = 1;
242− for(i = 1; i < dim; i++)
242+ for (i = 1; i < dim; i++)
243243 offs[i] = offs[i-1]*range;
244244 abs_pow34_v(scaled, in, size);
245245 quantize_bands(s->qcoefs, in, scaled, size, Q34, !IS_CODEBOOK_UNSIGNED(cb), maxval);
246246 #endif /* USE_REALLY_FULL_SEARCH */
247− for(i = 0; i < size; i += dim){
247+ for (i = 0; i < size; i += dim) {
248248 float mincost;
249249 int minidx = 0;
250250 int minbits = 0;
@@ -252,83 +252,83 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 1 unmodified line
252252 #ifndef USE_REALLY_FULL_SEARCH
253253 int (*quants)[2] = &s->qcoefs[i];
254254 mincost = 0.0f;
255− for(j = 0; j < dim; j++){
255+ for (j = 0; j < dim; j++) {
256256 mincost += in[i+j]*in[i+j]*lambda;
257257 }
258258 minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
259259 minbits = ff_aac_spectral_bits[cb-1][minidx];
260260 mincost += minbits;
261− for(j = 0; j < (1<<dim); j++){
261+ for (j = 0; j < (1<<dim); j++) {
262262 float rd = 0.0f;
263263 int curbits;
264264 int curidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
265265 int same = 0;
266− for(k = 0; k < dim; k++){
267− if((j & (1 << k)) && quants[k][0] == quants[k][1]){
266+ for (k = 0; k < dim; k++) {
267+ if ((j & (1 << k)) && quants[k][0] == quants[k][1]) {
268268 same = 1;
269269 break;
270270 }
271271 }
272− if(same)
272+ if (same)
273273 continue;
274− for(k = 0; k < dim; k++)
274+ for (k = 0; k < dim; k++)
275275 curidx += quants[k][!!(j & (1 << k))] * offs[dim - 1 - k];
276276 curbits = ff_aac_spectral_bits[cb-1][curidx];
277277 vec = &ff_aac_codebook_vectors[cb-1][curidx*dim];
278278 #else
279279 vec = ff_aac_codebook_vectors[cb-1];
280280 mincost = INFINITY;
281− for(j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim){
281+ for (j = 0; j < ff_aac_spectral_sizes[cb-1]; j++, vec += dim) {
282282 float rd = 0.0f;
283283 int curbits = ff_aac_spectral_bits[cb-1][j];
284284 int curidx = j;
285285 #endif /* USE_REALLY_FULL_SEARCH */
286− if(IS_CODEBOOK_UNSIGNED(cb)){
287− for(k = 0; k < dim; k++){
286+ if (IS_CODEBOOK_UNSIGNED(cb)) {
287+ for (k = 0; k < dim; k++) {
288288 float t = fabsf(in[i+k]);
289289 float di;
290290 //do not code with escape sequence small values
291− if(vec[k] == 64.0f && t < 39.0f*IQ){
291+ if (vec[k] == 64.0f && t < 39.0f*IQ) {
292292 rd = INFINITY;
293293 break;
294294 }
295− if(vec[k] == 64.0f){//FIXME: slow
295+ if (vec[k] == 64.0f) {//FIXME: slow
296296 if (t >= CLIPPED_ESCAPE) {
297297 di = t - CLIPPED_ESCAPE;
298298 curbits += 21;
299− }else{
299+ } else {
300300 int c = av_clip(quant(t, Q), 0, 8191);
301301 di = t - c*cbrt(c)*IQ;
302302 curbits += av_log2(c)*2 - 4 + 1;
303303 }
304− }else{
304+ } else {
305305 di = t - vec[k]*IQ;
306306 }
307− if(vec[k] != 0.0f)
307+ if (vec[k] != 0.0f)
308308 curbits++;
309309 rd += di*di*lambda;
310310 }
311− }else{
312− for(k = 0; k < dim; k++){
311+ } else {
312+ for (k = 0; k < dim; k++) {
313313 float di = in[i+k] - vec[k]*IQ;
314314 rd += di*di*lambda;
315315 }
316316 }
317317 rd += curbits;
318− if(rd < mincost){
318+ if (rd < mincost) {
319319 mincost = rd;
320320 minidx = curidx;
321321 minbits = curbits;
322322 }
323323 }
324324 put_bits(pb, ff_aac_spectral_bits[cb-1][minidx], ff_aac_spectral_codes[cb-1][minidx]);
325− if(IS_CODEBOOK_UNSIGNED(cb))
326− for(j = 0; j < dim; j++)
327− if(ff_aac_codebook_vectors[cb-1][minidx*dim+j] != 0.0f)
325+ if (IS_CODEBOOK_UNSIGNED(cb))
326+ for (j = 0; j < dim; j++)
327+ if (ff_aac_codebook_vectors[cb-1][minidx*dim+j] != 0.0f)
328328 put_bits(pb, 1, in[i+j] < 0.0f);
329− if(cb == ESC_BT){
330− for(j = 0; j < 2; j++){
331− if(ff_aac_codebook_vectors[cb-1][minidx*2+j] == 64.0f){
329+ if (cb == ESC_BT) {
330+ for (j = 0; j < 2; j++) {
331+ if (ff_aac_codebook_vectors[cb-1][minidx*2+j] == 64.0f) {
332332 int coef = av_clip(quant(fabsf(in[i+j]), Q), 0, 8191);
333333 int len = av_log2(coef);
334334
@@ -370,29 +370,29 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 35 unmodified lines
370370
371371 abs_pow34_v(s->scoefs, sce->coeffs, 1024);
372372 start = win*128;
373− for(cb = 0; cb < 12; cb++){
373+ for (cb = 0; cb < 12; cb++) {
374374 path[0][cb].cost = 0.0f;
375375 path[0][cb].prev_idx = -1;
376376 path[0][cb].run = 0;
377377 }
378− for(swb = 0; swb < max_sfb; swb++){
378+ for (swb = 0; swb < max_sfb; swb++) {
379379 start2 = start;
380380 size = sce->ics.swb_sizes[swb];
381− if(sce->zeroes[win*16 + swb]){
382− for(cb = 0; cb < 12; cb++){
381+ if (sce->zeroes[win*16 + swb]) {
382+ for (cb = 0; cb < 12; cb++) {
383383 path[swb+1][cb].prev_idx = cb;
384384 path[swb+1][cb].cost = path[swb][cb].cost;
385385 path[swb+1][cb].run = path[swb][cb].run + 1;
386386 }
387− }else{
387+ } else {
388388 float minrd = next_minrd;
389389 int mincb = next_mincb;
390390 next_minrd = INFINITY;
391391 next_mincb = 0;
392− for(cb = 0; cb < 12; cb++){
392+ for (cb = 0; cb < 12; cb++) {
393393 float cost_stay_here, cost_get_here;
394394 float rd = 0.0f;
395− for(w = 0; w < group_len; w++){
395+ for (w = 0; w < group_len; w++) {
396396 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(win+w)*16+swb];
397397 rd += quantize_band_cost(s, sce->coeffs + start + w*128,
398398 s->scoefs + start + w*128, size,
@@ -401,7 +401,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 2 unmodified lines
401401 }
402402 cost_stay_here = path[swb][cb].cost + rd;
403403 cost_get_here = minrd + rd + run_bits + 4;
404− if( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
404+ if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
405405 != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1])
406406 cost_stay_here += run_bits;
407407 if (cost_get_here < cost_stay_here) {
@@ -425,12 +425,12 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 17 unmodified lines
425425 //convert resulting path from backward-linked list
426426 stack_len = 0;
427427 idx = 0;
428− for(cb = 1; cb < 12; cb++){
429− if(path[max_sfb][cb].cost < path[max_sfb][idx].cost)
428+ for (cb = 1; cb < 12; cb++) {
429+ if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
430430 idx = cb;
431431 }
432432 ppos = max_sfb;
433− while(ppos > 0){
433+ while(ppos > 0) {
434434 cb = idx;
435435 stackrun[stack_len] = path[ppos][cb].run;
436436 stackcb [stack_len] = cb;
@@ -440,16 +440,16 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 3 unmodified lines
440440 }
441441 //perform actual band info encoding
442442 start = 0;
443− for(i = stack_len - 1; i >= 0; i--){
443+ for (i = stack_len - 1; i >= 0; i--) {
444444 put_bits(&s->pb, 4, stackcb[i]);
445445 count = stackrun[i];
446446 memset(sce->zeroes + win*16 + start, !stackcb[i], count);
447447 //XXX: memset when band_type is also uint8_t
448− for(j = 0; j < count; j++){
448+ for (j = 0; j < count; j++) {
449449 sce->band_type[win*16 + start] = stackcb[i];
450450 start++;
451451 }
452− while(count >= run_esc){
452+ while(count >= run_esc) {
453453 put_bits(&s->pb, run_bits, run_esc);
454454 count -= run_esc;
455455 }
@@ -482,13 +482,13 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 26 unmodified lines
482482 int minq;
483483 float mincost;
484484
485− for(i = 0; i < 256; i++){
485+ for (i = 0; i < 256; i++) {
486486 paths[i].cost = 0.0f;
487487 paths[i].prev = -1;
488488 paths[i].min_val = i;
489489 paths[i].max_val = i;
490490 }
491− for(i = 256; i < 256*121; i++){
491+ for (i = 256; i < 256*121; i++) {
492492 paths[i].cost = INFINITY;
493493 paths[i].prev = -2;
494494 paths[i].min_val = INT_MAX;
@@ -496,9 +496,9 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 1 unmodified line
496496 }
497497 idx = 256;
498498 abs_pow34_v(s->scoefs, sce->coeffs, 1024);
499− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
499+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
500500 start = w*128;
501− for(g = 0; g < sce->ics.num_swb; g++){
501+ for (g = 0; g < sce->ics.num_swb; g++) {
502502 const float *coefs = sce->coeffs + start;
503503 float qmin, qmax;
504504 int nz = 0;
@@ -506,53 +506,53 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 1 unmodified line
506506 bandaddr[idx >> 8] = w*16+g;
507507 qmin = INT_MAX;
508508 qmax = 0.0f;
509− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
509+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
510510 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
511− if(band->energy <= band->threshold || band->threshold == 0.0f){
511+ if (band->energy <= band->threshold || band->threshold == 0.0f) {
512512 sce->zeroes[(w+w2)*16+g] = 1;
513513 continue;
514514 }
515515 sce->zeroes[(w+w2)*16+g] = 0;
516516 nz = 1;
517− for(i = 0; i < sce->ics.swb_sizes[g]; i++){
517+ for (i = 0; i < sce->ics.swb_sizes[g]; i++) {
518518 float t = fabsf(coefs[w2*128+i]);
519− if(t > 0.0f) qmin = fminf(qmin, t);
519+ if (t > 0.0f) qmin = fminf(qmin, t);
520520 qmax = fmaxf(qmax, t);
521521 }
522522 }
523− if(nz){
523+ if (nz) {
524524 int minscale, maxscale;
525525 float minrd = INFINITY;
526526 //minimum scalefactor index is when minimum nonzero coefficient after quantizing is not clipped
527527 minscale = av_clip_uint8(log2(qmin)*4 - 69 + SCALE_ONE_POS - SCALE_DIV_512);
528528 //maximum scalefactor index is when maximum coefficient after quantizing is still not zero
529529 maxscale = av_clip_uint8(log2(qmax)*4 + 6 + SCALE_ONE_POS - SCALE_DIV_512);
530− for(q = minscale; q < maxscale; q++){
530+ for (q = minscale; q < maxscale; q++) {
531531 float dists[12], dist;
532532 memset(dists, 0, sizeof(dists));
533− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
533+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
534534 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
535535 int cb;
536− for(cb = 0; cb <= ESC_BT; cb++){
536+ for (cb = 0; cb <= ESC_BT; cb++) {
537537 dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g],
538538 q, cb, lambda / band->threshold, INFINITY, NULL);
539539 }
540540 }
541541 dist = dists[0];
542− for(i = 1; i <= ESC_BT; i++)
542+ for (i = 1; i <= ESC_BT; i++)
543543 dist = fminf(dist, dists[i]);
544544 minrd = fminf(minrd, dist);
545545
546− for(i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++){
546+ for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++) {
547547 float cost;
548548 int minv, maxv;
549− if(isinf(paths[idx - 256 + i].cost))
549+ if (isinf(paths[idx - 256 + i].cost))
550550 continue;
551551 cost = paths[idx - 256 + i].cost + dist
552552 + ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO];
553553 minv = FFMIN(paths[idx - 256 + i].min_val, q);
554554 maxv = FFMAX(paths[idx - 256 + i].max_val, q);
555− if(cost < paths[idx + q].cost && maxv-minv < SCALE_MAX_DIFF){
555+ if (cost < paths[idx + q].cost && maxv-minv < SCALE_MAX_DIFF) {
556556 paths[idx + q].cost = cost;
557557 paths[idx + q].prev = idx - 256 + i;
558558 paths[idx + q].min_val = minv;
@@ -560,24 +560,24 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 1 unmodified line
560560 }
561561 }
562562 }
563− }else{
564− for(q = 0; q < 256; q++){
565− if(!isinf(paths[idx - 256 + q].cost)){
563+ } else {
564+ for (q = 0; q < 256; q++) {
565+ if (!isinf(paths[idx - 256 + q].cost)) {
566566 paths[idx + q].cost = paths[idx - 256 + q].cost + 1;
567567 paths[idx + q].prev = idx - 256 + q;
568568 paths[idx + q].min_val = FFMIN(paths[idx - 256 + q].min_val, q);
569569 paths[idx + q].max_val = FFMAX(paths[idx - 256 + q].max_val, q);
570570 continue;
571571 }
572− for(i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++){
572+ for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++) {
573573 float cost;
574574 int minv, maxv;
575− if(isinf(paths[idx - 256 + i].cost))
575+ if (isinf(paths[idx - 256 + i].cost))
576576 continue;
577577 cost = paths[idx - 256 + i].cost + ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO];
578578 minv = FFMIN(paths[idx - 256 + i].min_val, q);
579579 maxv = FFMAX(paths[idx - 256 + i].max_val, q);
580− if(cost < paths[idx + q].cost && maxv-minv < SCALE_MAX_DIFF){
580+ if (cost < paths[idx + q].cost && maxv-minv < SCALE_MAX_DIFF) {
581581 paths[idx + q].cost = cost;
582582 paths[idx + q].prev = idx - 256 + i;
583583 paths[idx + q].min_val = minv;
@@ -594,20 +594,20 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 10 unmodified lines
594594 idx -= 256;
595595 mincost = paths[idx].cost;
596596 minq = idx;
597− for(i = 1; i < 256; i++){
598− if(paths[idx + i].cost < mincost){
597+ for (i = 1; i < 256; i++) {
598+ if (paths[idx + i].cost < mincost) {
599599 mincost = paths[idx + i].cost;
600600 minq = idx + i;
601601 }
602602 }
603− while(minq >= 256){
603+ while(minq >= 256) {
604604 sce->sf_idx[bandaddr[minq>>8]] = minq & 0xFF;
605605 minq = paths[minq].prev;
606606 }
607607 //set the same quantizers inside window groups
608− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
609− for(g = 0; g < sce->ics.num_swb; g++)
610− for(w2 = 1; w2 < sce->ics.group_len[w]; w2++)
608+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
609+ for (g = 0; g < sce->ics.num_swb; g++)
610+ for (w2 = 1; w2 < sce->ics.group_len[w]; w2++)
611611 sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g];
612612 }
613613
@@ -628,14 +628,14 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 14 unmodified lines
628628 //XXX: some heuristic to determine initial quantizers will reduce search time
629629 memset(dists, 0, sizeof(dists));
630630 //determine zero bands and upper limits
631− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
632− for(g = 0; g < sce->ics.num_swb; g++){
631+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
632+ for (g = 0; g < sce->ics.num_swb; g++) {
633633 int nz = 0;
634634 float uplim = 0.0f;
635− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
635+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
636636 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
637637 uplim += band->threshold;
638− if(band->energy <= band->threshold || band->threshold == 0.0f){
638+ if (band->energy <= band->threshold || band->threshold == 0.0f) {
639639 sce->zeroes[(w+w2)*16+g] = 1;
640640 continue;
641641 }
@@ -643,14 +643,14 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 1 unmodified line
643643 }
644644 uplims[w*16+g] = uplim *512;
645645 sce->zeroes[w*16+g] = !nz;
646− if(nz)
646+ if (nz)
647647 minthr = fminf(minthr, uplim);
648648 allz = FFMAX(allz, nz);
649649 }
650650 }
651− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
652− for(g = 0; g < sce->ics.num_swb; g++){
653− if(sce->zeroes[w*16+g]){
651+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
652+ for (g = 0; g < sce->ics.num_swb; g++) {
653+ if (sce->zeroes[w*16+g]) {
654654 sce->sf_idx[w*16+g] = SCALE_ONE_POS;
655655 continue;
656656 }
@@ -658,7 +658,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 1 unmodified line
658658 }
659659 }
660660
661− if(!allz)
661+ if (!allz)
662662 return;
663663 abs_pow34_v(s->scoefs, sce->coeffs, 1024);
664664 //perform two-loop search
@@ -672,9 +672,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 7 unmodified lines
672672 int prev = -1;
673673 tbits = 0;
674674 fflag = 0;
675− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
675+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
676676 start = w*128;
677− for(g = 0; g < sce->ics.num_swb; g++){
677+ for (g = 0; g < sce->ics.num_swb; g++) {
678678 const float *coefs = sce->coeffs + start;
679679 const float *scaled = s->scoefs + start;
680680 int bits = 0;
@@ -682,13 +682,13 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 1 unmodified line
682682 float mindist = INFINITY;
683683 int minbits = 0;
684684
685− if(sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218)
685+ if (sce->zeroes[w*16+g] || sce->sf_idx[w*16+g] >= 218)
686686 continue;
687687 minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]);
688− for(cb = 0; cb <= ESC_BT; cb++){
688+ for (cb = 0; cb <= ESC_BT; cb++) {
689689 float dist = 0.0f;
690690 int bb = 0;
691− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
691+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
692692 int b;
693693 dist += quantize_band_cost(s, coefs + w2*128,
694694 scaled + w2*128,
@@ -700,14 +700,14 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 5 unmodified lines
700700 &b);
701701 bb += b;
702702 }
703− if(dist < mindist){
703+ if (dist < mindist) {
704704 mindist = dist;
705705 minbits = bb;
706706 }
707707 }
708708 dists[w*16+g] = mindist - minbits;
709709 bits = minbits;
710− if(prev != -1){
710+ if (prev != -1) {
711711 bits += ff_aac_scalefactor_bits[sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO];
712712 }
713713 tbits += bits;
@@ -715,36 +715,36 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, AACEncContext * · 1 unmodified line
715715 prev = sce->sf_idx[w*16+g];
716716 }
717717 }
718− if(tbits > destbits){
719− for(i = 0; i < 128; i++){
720− if(sce->sf_idx[i] < 218 - qstep){
718+ if (tbits > destbits) {
719+ for (i = 0; i < 128; i++) {
720+ if (sce->sf_idx[i] < 218 - qstep) {
721721 sce->sf_idx[i] += qstep;
722722 }
723723 }
724− }else{
725− for(i = 0; i < 128; i++){
726− if(sce->sf_idx[i] > 60 - qstep){
724+ } else {
725+ for (i = 0; i < 128; i++) {
726+ if (sce->sf_idx[i] > 60 - qstep) {
727727 sce->sf_idx[i] -= qstep;
728728 }
729729 }
730730 }
731731 qstep >>= 1;
732− if(!qstep && tbits > destbits*1.02)
732+ if (!qstep && tbits > destbits*1.02)
733733 qstep = 1;
734− if(sce->sf_idx[0] >= 217)break;
734+ if (sce->sf_idx[0] >= 217)break;
735735 }while(qstep);
736736
737737 fflag = 0;
738738 minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF);
739− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
739+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
740740 start = w*128;
741− for(g = 0; g < sce->ics.num_swb; g++){
741+ for (g = 0; g < sce->ics.num_swb; g++) {
742742 int prevsc = sce->sf_idx[w*16+g];
743− if(dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60)
743+ if (dists[w*16+g] > uplims[w*16+g] && sce->sf_idx[w*16+g] > 60)
744744 sce->sf_idx[w*16+g]--;
745745 sce->sf_idx[w*16+g] = av_clip(sce->sf_idx[w*16+g], minscaler, minscaler + SCALE_MAX_DIFF);
746746 sce->sf_idx[w*16+g] = FFMIN(sce->sf_idx[w*16+g], 219);
747− if(sce->sf_idx[w*16+g] != prevsc)
747+ if (sce->sf_idx[w*16+g] != prevsc)
748748 fflag = 1;
749749 }
750750 }
@@ -761,29 +761,29 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 10 unmodified lines
761761 float distfact = ((sce->ics.num_windows > 1) ? 85.80 : 147.84) / lambda;
762762 int last = 0, lastband = 0, curband = 0;
763763 float avg_energy = 0.0;
764− if(sce->ics.num_windows == 1){
764+ if (sce->ics.num_windows == 1) {
765765 start = 0;
766− for(i = 0; i < 1024; i++){
767− if(i - start >= sce->ics.swb_sizes[curband]){
766+ for (i = 0; i < 1024; i++) {
767+ if (i - start >= sce->ics.swb_sizes[curband]) {
768768 start += sce->ics.swb_sizes[curband];
769769 curband++;
770770 }
771− if(sce->coeffs[i]){
771+ if (sce->coeffs[i]) {
772772 avg_energy += sce->coeffs[i] * sce->coeffs[i];
773773 last = i;
774774 lastband = curband;
775775 }
776776 }
777− }else{
778− for(w = 0; w < 8; w++){
777+ } else {
778+ for (w = 0; w < 8; w++) {
779779 const float *coeffs = sce->coeffs + w*128;
780780 start = 0;
781− for(i = 0; i < 128; i++){
782− if(i - start >= sce->ics.swb_sizes[curband]){
781+ for (i = 0; i < 128; i++) {
782+ if (i - start >= sce->ics.swb_sizes[curband]) {
783783 start += sce->ics.swb_sizes[curband];
784784 curband++;
785785 }
786− if(coeffs[i]){
786+ if (coeffs[i]) {
787787 avg_energy += coeffs[i] * coeffs[i];
788788 last = FFMAX(last, i);
789789 lastband = FFMAX(lastband, curband);
@@ -793,41 +793,41 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 3 unmodified lines
793793 }
794794 last++;
795795 avg_energy /= last;
796− if(avg_energy == 0.0f){
797− for(i = 0; i < FF_ARRAY_ELEMS(sce->sf_idx); i++)
796+ if (avg_energy == 0.0f) {
797+ for (i = 0; i < FF_ARRAY_ELEMS(sce->sf_idx); i++)
798798 sce->sf_idx[i] = SCALE_ONE_POS;
799799 return;
800800 }
801− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
801+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
802802 start = w*128;
803− for(g = 0; g < sce->ics.num_swb; g++){
803+ for (g = 0; g < sce->ics.num_swb; g++) {
804804 float *coefs = sce->coeffs + start;
805805 const int size = sce->ics.swb_sizes[g];
806806 int start2 = start, end2 = start + size, peakpos = start;
807807 float maxval = -1, thr = 0.0f, t;
808808 maxq[w*16+g] = 0.0f;
809− if(g > lastband){
809+ if (g > lastband) {
810810 maxq[w*16+g] = 0.0f;
811811 start += size;
812− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++)
812+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++)
813813 memset(coefs + w2*128, 0, sizeof(coefs[0])*size);
814814 continue;
815815 }
816− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
817− for(i = 0; i < size; i++){
816+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
817+ for (i = 0; i < size; i++) {
818818 float t = coefs[w2*128+i]*coefs[w2*128+i];
819819 maxq[w*16+g] = fmaxf(maxq[w*16+g], fabsf(coefs[w2*128 + i]));
820820 thr += t;
821− if(sce->ics.num_windows == 1 && maxval < t){
821+ if (sce->ics.num_windows == 1 && maxval < t) {
822822 maxval = t;
823823 peakpos = start+i;
824824 }
825825 }
826826 }
827− if(sce->ics.num_windows == 1){
827+ if (sce->ics.num_windows == 1) {
828828 start2 = FFMAX(peakpos - 2, start2);
829829 end2 = FFMIN(peakpos + 3, end2);
830− }else{
830+ } else {
831831 start2 -= start;
832832 end2 -= start;
833833 }
@@ -839,16 +839,16 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 5 unmodified lines
839839 }
840840 memset(sce->sf_idx, 0, sizeof(sce->sf_idx));
841841 abs_pow34_v(s->scoefs, sce->coeffs, 1024);
842− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
842+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
843843 start = w*128;
844− for(g = 0; g < sce->ics.num_swb; g++){
844+ for (g = 0; g < sce->ics.num_swb; g++) {
845845 const float *coefs = sce->coeffs + start;
846846 const float *scaled = s->scoefs + start;
847847 const int size = sce->ics.swb_sizes[g];
848848 int scf, prev_scf, step;
849849 int min_scf = 0, max_scf = 255;
850850 float curdiff;
851− if(maxq[w*16+g] < 21.544){
851+ if (maxq[w*16+g] < 21.544) {
852852 sce->zeroes[w*16+g] = 1;
853853 start += size;
854854 continue;
@@ -856,11 +856,11 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 1 unmodified line
856856 sce->zeroes[w*16+g] = 0;
857857 scf = prev_scf = av_clip(SCALE_ONE_POS - SCALE_DIV_512 - log2(1/maxq[w*16+g])*16/3, 60, 218);
858858 step = 16;
859− for(;;){
859+ for (;;) {
860860 float dist = 0.0f;
861861 int quant_max;
862862
863− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
863+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
864864 int b;
865865 dist += quantize_band_cost(s, coefs + w2*128,
866866 scaled + w2*128,
@@ -874,24 +874,24 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 7 unmodified lines
874874 }
875875 dist *= 1.0f/512.0f;
876876 quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[200 - scf + SCALE_ONE_POS - SCALE_DIV_512]);
877− if(quant_max >= 8191){ // too much, return to the previous quantizer
877+ if (quant_max >= 8191) { // too much, return to the previous quantizer
878878 sce->sf_idx[w*16+g] = prev_scf;
879879 break;
880880 }
881881 prev_scf = scf;
882882 curdiff = fabsf(dist - uplim[w*16+g]);
883− if(curdiff == 0.0f)
883+ if (curdiff == 0.0f)
884884 step = 0;
885885 else
886886 step = fabsf(log2(curdiff));
887− if(dist > uplim[w*16+g])
887+ if (dist > uplim[w*16+g])
888888 step = -step;
889− if(FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)){
889+ if (FFABS(step) <= 1 || (step > 0 && scf >= max_scf) || (step < 0 && scf <= min_scf)) {
890890 sce->sf_idx[w*16+g] = scf;
891891 break;
892892 }
893893 scf += step;
894− if(step > 0)
894+ if (step > 0)
895895 min_scf = scf;
896896 else
897897 max_scf = scf;
@@ -900,17 +900,17 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 2 unmodified lines
900900 }
901901 }
902902 minq = sce->sf_idx[0] ? sce->sf_idx[0] : INT_MAX;
903− for(i = 1; i < 128; i++){
904− if(!sce->sf_idx[i])
903+ for (i = 1; i < 128; i++) {
904+ if (!sce->sf_idx[i])
905905 sce->sf_idx[i] = sce->sf_idx[i-1];
906906 else
907907 minq = FFMIN(minq, sce->sf_idx[i]);
908908 }
909− if(minq == INT_MAX) minq = 0;
909+ if (minq == INT_MAX) minq = 0;
910910 minq = FFMIN(minq, SCALE_MAX_POS);
911911 maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS);
912− for(i = 126; i >= 0; i--){
913− if(!sce->sf_idx[i])
912+ for (i = 126; i >= 0; i--) {
913+ if (!sce->sf_idx[i])
914914 sce->sf_idx[i] = sce->sf_idx[i+1];
915915 sce->sf_idx[i] = av_clip(sce->sf_idx[i], minq, maxsf);
916916 }
@@ -923,15 +923,15 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 6 unmodified lines
923923 int minq = 255;
924924
925925 memset(sce->sf_idx, 0, sizeof(sce->sf_idx));
926− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
926+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
927927 start = w*128;
928− for(g = 0; g < sce->ics.num_swb; g++){
929− for(w2 = 0; w2 < sce->ics.group_len[w]; w2++){
928+ for (g = 0; g < sce->ics.num_swb; g++) {
929+ for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
930930 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
931− if(band->energy <= band->threshold){
931+ if (band->energy <= band->threshold) {
932932 sce->sf_idx[(w+w2)*16+g] = 218;
933933 sce->zeroes[(w+w2)*16+g] = 1;
934− }else{
934+ } else {
935935 sce->sf_idx[(w+w2)*16+g] = av_clip(SCALE_ONE_POS - SCALE_DIV_512 + log2(band->threshold), 80, 218);
936936 sce->zeroes[(w+w2)*16+g] = 0;
937937 }
@@ -939,13 +939,13 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 1 unmodified line
939939 }
940940 }
941941 }
942− for(i = 0; i < 128; i++){
942+ for (i = 0; i < 128; i++) {
943943 sce->sf_idx[i] = 140;//av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1);
944944 }
945945 //set the same quantizers inside window groups
946− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
947− for(g = 0; g < sce->ics.num_swb; g++)
948− for(w2 = 1; w2 < sce->ics.group_len[w]; w2++)
946+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
947+ for (g = 0; g < sce->ics.num_swb; g++)
948+ for (w2 = 1; w2 < sce->ics.group_len[w]; w2++)
949949 sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g];
950950 }
951951
@@ -956,18 +956,18 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, const float lam · 4 unmodified lines
956956 float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3;
957957 SingleChannelElement *sce0 = &cpe->ch[0];
958958 SingleChannelElement *sce1 = &cpe->ch[1];
959− if(!cpe->common_window)
959+ if (!cpe->common_window)
960960 return;
961− for(w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]){
962− for(g = 0; g < sce0->ics.num_swb; g++){
963− if(!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]){
961+ for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {
962+ for (g = 0; g < sce0->ics.num_swb; g++) {
963+ if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) {
964964 float dist1 = 0.0f, dist2 = 0.0f;
965− for(w2 = 0; w2 < sce0->ics.group_len[w]; w2++){
965+ for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
966966 FFPsyBand *band0 = &s->psy.psy_bands[(s->cur_channel+0)*PSY_MAX_BANDS+(w+w2)*16+g];
967967 FFPsyBand *band1 = &s->psy.psy_bands[(s->cur_channel+1)*PSY_MAX_BANDS+(w+w2)*16+g];
968968 float minthr = fminf(band0->threshold, band1->threshold);
969969 float maxthr = fmaxf(band0->threshold, band1->threshold);
970− for(i = 0; i < sce0->ics.swb_sizes[g]; i++){
970+ for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
971971 M[i] = (sce0->coeffs[start+w2*128+i]
972972 + sce1->coeffs[start+w2*128+i])*0.5;
973973 S[i] = sce0->coeffs[start+w2*128+i]
libavcodec/aacenc.c+72−72
@@ -159,14 +159,14 @@ static av_cold int aac_encode_init(AVCodecContext *avctx) · 158 unmodified lines
159159
160160 avctx->frame_size = 1024;
161161
162− for(i = 0; i < 16; i++)
163− if(avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
162+ for (i = 0; i < 16; i++)
163+ if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i])
164164 break;
165− if(i == 16){
165+ if (i == 16) {
166166 av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate);
167167 return -1;
168168 }
169− if(avctx->channels > 6){
169+ if (avctx->channels > 6) {
170170 av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels);
171171 return -1;
172172 }
@@ -218,35 +218,35 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, · 45 unmodified lines
218218
219219 if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
220220 memcpy(s->output, sce->saved, sizeof(float)*1024);
221− if(sce->ics.window_sequence[0] == LONG_STOP_SEQUENCE){
221+ if (sce->ics.window_sequence[0] == LONG_STOP_SEQUENCE) {
222222 memset(s->output, 0, sizeof(s->output[0]) * 448);
223− for(i = 448; i < 576; i++)
223+ for (i = 448; i < 576; i++)
224224 s->output[i] = sce->saved[i] * pwindow[i - 448];
225− for(i = 576; i < 704; i++)
225+ for (i = 576; i < 704; i++)
226226 s->output[i] = sce->saved[i];
227227 }
228− if(sce->ics.window_sequence[0] != LONG_START_SEQUENCE){
228+ if (sce->ics.window_sequence[0] != LONG_START_SEQUENCE) {
229229 j = channel;
230− for (i = 0; i < 1024; i++, j += avctx->channels){
230+ for (i = 0; i < 1024; i++, j += avctx->channels) {
231231 s->output[i+1024] = audio[j] * lwindow[1024 - i - 1];
232232 sce->saved[i] = audio[j] * lwindow[i];
233233 }
234− }else{
234+ } else {
235235 j = channel;
236− for(i = 0; i < 448; i++, j += avctx->channels)
236+ for (i = 0; i < 448; i++, j += avctx->channels)
237237 s->output[i+1024] = audio[j];
238− for(i = 448; i < 576; i++, j += avctx->channels)
238+ for (i = 448; i < 576; i++, j += avctx->channels)
239239 s->output[i+1024] = audio[j] * swindow[576 - i - 1];
240240 memset(s->output+1024+576, 0, sizeof(s->output[0]) * 448);
241241 j = channel;
242− for(i = 0; i < 1024; i++, j += avctx->channels)
242+ for (i = 0; i < 1024; i++, j += avctx->channels)
243243 sce->saved[i] = audio[j];
244244 }
245245 ff_mdct_calc(&s->mdct1024, sce->coeffs, s->output);
246− }else{
246+ } else {
247247 j = channel;
248248 for (k = 0; k < 1024; k += 128) {
249− for(i = 448 + k; i < 448 + k + 256; i++)
249+ for (i = 448 + k; i < 448 + k + 256; i++)
250250 s->output[i - 448 - k] = (i < 1024)
251251 ? sce->saved[i]
252252 : audio[channel + (i-1024)*avctx->channels];
@@ -255,7 +255,7 @@ static void apply_window_and_mdct(AVCodecContext *avctx, AACEncContext *s, · 2 unmodified lines
255255 ff_mdct_calc(&s->mdct128, sce->coeffs + k, s->output);
256256 }
257257 j = channel;
258− for(i = 0; i < 1024; i++, j += avctx->channels)
258+ for (i = 0; i < 1024; i++, j += avctx->channels)
259259 sce->saved[i] = audio[j];
260260 }
261261 }
@@ -271,12 +271,12 @@ static void put_ics_info(AACEncContext *s, IndividualChannelStream *info) · 9 unmodified lines
271271 put_bits(&s->pb, 1, 0); // ics_reserved bit
272272 put_bits(&s->pb, 2, info->window_sequence[0]);
273273 put_bits(&s->pb, 1, info->use_kb_window[0]);
274− if(info->window_sequence[0] != EIGHT_SHORT_SEQUENCE){
274+ if (info->window_sequence[0] != EIGHT_SHORT_SEQUENCE) {
275275 put_bits(&s->pb, 6, info->max_sfb);
276276 put_bits(&s->pb, 1, 0); // no prediction
277− }else{
277+ } else {
278278 put_bits(&s->pb, 4, info->max_sfb);
279− for(w = 1; w < 8; w++){
279+ for (w = 1; w < 8; w++) {
280280 put_bits(&s->pb, 1, !info->group_len[w]);
281281 }
282282 }
@@ -291,9 +291,9 @@ static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe) · 8 unmodified lines
291291 int i, w;
292292
293293 put_bits(pb, 2, cpe->ms_mode);
294− if(cpe->ms_mode == 1){
295− for(w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w]){
296− for(i = 0; i < cpe->ch[0].ics.max_sfb; i++)
294+ if (cpe->ms_mode == 1) {
295+ for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w]) {
296+ for (i = 0; i < cpe->ch[0].ics.max_sfb; i++)
297297 put_bits(pb, 1, cpe->ms_mask[w*16 + i]);
298298 }
299299 }
@@ -307,34 +307,34 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in · 7 unmodified lines
307307 int i, w, w2, g, ch;
308308 int start, sum, maxsfb, cmaxsfb;
309309
310− for(ch = 0; ch < chans; ch++){
310+ for (ch = 0; ch < chans; ch++) {
311311 IndividualChannelStream *ics = &cpe->ch[ch].ics;
312312 start = 0;
313313 maxsfb = 0;
314314 cpe->ch[ch].pulse.num_pulse = 0;
315− for(w = 0; w < ics->num_windows*16; w += 16){
316− for(g = 0; g < ics->num_swb; g++){
315+ for (w = 0; w < ics->num_windows*16; w += 16) {
316+ for (g = 0; g < ics->num_swb; g++) {
317317 sum = 0;
318318 //apply M/S
319− if(!ch && cpe->ms_mask[w + g]){
320− for(i = 0; i < ics->swb_sizes[g]; i++){
319+ if (!ch && cpe->ms_mask[w + g]) {
320+ for (i = 0; i < ics->swb_sizes[g]; i++) {
321321 cpe->ch[0].coeffs[start+i] = (cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
322322 cpe->ch[1].coeffs[start+i] = cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
323323 }
324324 }
325325 start += ics->swb_sizes[g];
326326 }
327− for(cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--);
327+ for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--);
328328 maxsfb = FFMAX(maxsfb, cmaxsfb);
329329 }
330330 ics->max_sfb = maxsfb;
331331
332332 //adjust zero bands for window groups
333− for(w = 0; w < ics->num_windows; w += ics->group_len[w]){
334− for(g = 0; g < ics->max_sfb; g++){
333+ for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {
334+ for (g = 0; g < ics->max_sfb; g++) {
335335 i = 1;
336− for(w2 = w; w2 < w + ics->group_len[w]; w2++){
337− if(!cpe->ch[ch].zeroes[w2*16 + g]){
336+ for (w2 = w; w2 < w + ics->group_len[w]; w2++) {
337+ if (!cpe->ch[ch].zeroes[w2*16 + g]) {
338338 i = 0;
339339 break;
340340 }
@@ -344,16 +344,16 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in · 3 unmodified lines
344344 }
345345 }
346346
347− if(chans > 1 && cpe->common_window){
347+ if (chans > 1 && cpe->common_window) {
348348 IndividualChannelStream *ics0 = &cpe->ch[0].ics;
349349 IndividualChannelStream *ics1 = &cpe->ch[1].ics;
350350 int msc = 0;
351351 ics0->max_sfb = FFMAX(ics0->max_sfb, ics1->max_sfb);
352352 ics1->max_sfb = ics0->max_sfb;
353− for(w = 0; w < ics0->num_windows*16; w += 16)
354− for(i = 0; i < ics0->max_sfb; i++)
355− if(cpe->ms_mask[w+i]) msc++;
356− if(msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0;
353+ for (w = 0; w < ics0->num_windows*16; w += 16)
354+ for (i = 0; i < ics0->max_sfb; i++)
355+ if (cpe->ms_mask[w+i]) msc++;
356+ if (msc == 0 || ics0->max_sfb == 0) cpe->ms_mode = 0;
357357 else cpe->ms_mode = msc < ics0->max_sfb ? 1 : 2;
358358 }
359359 }
@@ -365,7 +365,7 @@ static void encode_band_info(AACEncContext *s, SingleChannelElement *sce) · 5 unmodified lines
365365 {
366366 int w;
367367
368− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
368+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
369369 s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda);
370370 }
371371 }
@@ -378,11 +378,11 @@ static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s, Single · 6 unmodified lines
378378 int off = sce->sf_idx[0], diff;
379379 int i, w;
380380
381− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
382− for(i = 0; i < sce->ics.max_sfb; i++){
383− if(!sce->zeroes[w*16 + i]){
381+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
382+ for (i = 0; i < sce->ics.max_sfb; i++) {
383+ if (!sce->zeroes[w*16 + i]) {
384384 diff = sce->sf_idx[w*16 + i] - off + SCALE_DIFF_ZERO;
385− if(diff < 0 || diff > 120) av_log(avctx, AV_LOG_ERROR, "Scalefactor difference is too big to be coded\n");
385+ if (diff < 0 || diff > 120) av_log(avctx, AV_LOG_ERROR, "Scalefactor difference is too big to be coded\n");
386386 off = sce->sf_idx[w*16 + i];
387387 put_bits(&s->pb, ff_aac_scalefactor_bits[diff], ff_aac_scalefactor_code[diff]);
388388 }
@@ -398,11 +398,11 @@ static void encode_pulses(AACEncContext *s, Pulse *pulse) · 9 unmodified lines
398398 int i;
399399
400400 put_bits(&s->pb, 1, !!pulse->num_pulse);
401− if(!pulse->num_pulse) return;
401+ if (!pulse->num_pulse) return;
402402
403403 put_bits(&s->pb, 2, pulse->num_pulse - 1);
404404 put_bits(&s->pb, 6, pulse->start);
405− for(i = 0; i < pulse->num_pulse; i++){
405+ for (i = 0; i < pulse->num_pulse; i++) {
406406 put_bits(&s->pb, 5, pulse->pos[i]);
407407 put_bits(&s->pb, 4, pulse->amp[i]);
408408 }
@@ -415,14 +415,14 @@ static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce) · 6 unmodified lines
415415 {
416416 int start, i, w, w2;
417417
418− for(w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]){
418+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
419419 start = 0;
420− for(i = 0; i < sce->ics.max_sfb; i++){
421− if(sce->zeroes[w*16 + i]){
420+ for (i = 0; i < sce->ics.max_sfb; i++) {
421+ if (sce->zeroes[w*16 + i]) {
422422 start += sce->ics.swb_sizes[i];
423423 continue;
424424 }
425− for(w2 = w; w2 < w + sce->ics.group_len[w]; w2++){
425+ for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) {
426426 s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128,
427427 sce->ics.swb_sizes[i],
428428 sce->sf_idx[w*16 + i],
@@ -440,7 +440,7 @@ static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce) · 11 unmodified lines
440440 static int encode_individual_channel(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, int common_window)
441441 {
442442 put_bits(&s->pb, 8, sce->sf_idx[0]);
443− if(!common_window) put_ics_info(s, &sce->ics);
443+ if (!common_window) put_ics_info(s, &sce->ics);
444444 encode_band_info(s, sce);
445445 encode_scale_factors(avctx, s, sce);
446446 encode_pulses(s, &sce->pulse);
@@ -460,12 +460,12 @@ static void put_bitstream_info(AVCodecContext *avctx, AACEncContext *s, const ch · 13 unmodified lines
460460 namelen = strlen(name) + 2;
461461 put_bits(&s->pb, 3, TYPE_FIL);
462462 put_bits(&s->pb, 4, FFMIN(namelen, 15));
463− if(namelen >= 15)
463+ if (namelen >= 15)
464464 put_bits(&s->pb, 8, namelen - 16);
465465 put_bits(&s->pb, 4, 0); //extension type - filler
466466 padbits = 8 - (put_bits_count(&s->pb) & 7);
467467 align_put_bits(&s->pb);
468− for(i = 0; i < namelen - 2; i++)
468+ for (i = 0; i < namelen - 2; i++)
469469 put_bits(&s->pb, 8, name[i]);
470470 put_bits(&s->pb, 12 - padbits, 0);
471471 }
@@ -480,15 +480,15 @@ static int aac_encode_frame(AVCodecContext *avctx, · 8 unmodified lines
480480 const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
481481 int chan_el_counter[4];
482482
483− if(s->last_frame)
483+ if (s->last_frame)
484484 return 0;
485− if(data){
486− if(!s->psypp){
485+ if (data) {
486+ if (!s->psypp) {
487487 memcpy(s->samples + 1024 * avctx->channels, data, 1024 * avctx->channels * sizeof(s->samples[0]));
488− }else{
488+ } else {
489489 start_ch = 0;
490490 samples2 = s->samples + 1024 * avctx->channels;
491− for(i = 0; i < chan_map[0]; i++){
491+ for (i = 0; i < chan_map[0]; i++) {
492492 tag = chan_map[i+1];
493493 chans = tag == TYPE_CPE ? 2 : 1;
494494 ff_psy_preprocess(s->psypp, (uint16_t*)data + start_ch, samples2 + start_ch, start_ch, chans);
@@ -496,26 +496,26 @@ static int aac_encode_frame(AVCodecContext *avctx, · 1 unmodified line
496496 }
497497 }
498498 }
499− if(!avctx->frame_number){
499+ if (!avctx->frame_number) {
500500 memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0]));
501501 return 0;
502502 }
503503
504504 init_put_bits(&s->pb, frame, buf_size*8);
505− if((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)){
505+ if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) {
506506 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
507507 }
508508 start_ch = 0;
509509 memset(chan_el_counter, 0, sizeof(chan_el_counter));
510− for(i = 0; i < chan_map[0]; i++){
510+ for (i = 0; i < chan_map[0]; i++) {
511511 FFPsyWindowInfo wi[2];
512512 tag = chan_map[i+1];
513513 chans = tag == TYPE_CPE ? 2 : 1;
514514 cpe = &s->cpe[i];
515515 samples2 = samples + start_ch;
516516 la = samples2 + 1024 * avctx->channels + start_ch;
517− if(!data) la = NULL;
518− for(j = 0; j < chans; j++){
517+ if (!data) la = NULL;
518+ for (j = 0; j < chans; j++) {
519519 IndividualChannelStream *ics = &cpe->ch[j].ics;
520520 int k;
521521 wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, start_ch + j, ics->window_sequence[0]);
@@ -526,7 +526,7 @@ static int aac_encode_frame(AVCodecContext *avctx, · 4 unmodified lines
526526 ics->num_windows = wi[j].num_windows;
527527 ics->swb_sizes = s->psy.bands [ics->num_windows == 8];
528528 ics->num_swb = s->psy.num_bands[ics->num_windows == 8];
529− for(k = 0; k < ics->num_windows; k++)
529+ for (k = 0; k < ics->num_windows; k++)
530530 ics->group_len[k] = wi[j].grouping[k];
531531
532532 s->cur_channel = start_ch + j;
@@ -534,31 +534,31 @@ static int aac_encode_frame(AVCodecContext *avctx, · 1 unmodified line
534534 s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
535535 }
536536 cpe->common_window = 0;
537− if(chans > 1
537+ if (chans > 1
538538 && wi[0].window_type[0] == wi[1].window_type[0]
539− && wi[0].window_shape == wi[1].window_shape){
539+ && wi[0].window_shape == wi[1].window_shape) {
540540
541541 cpe->common_window = 1;
542− for(j = 0; j < wi[0].num_windows; j++){
543− if(wi[0].grouping[j] != wi[1].grouping[j]){
542+ for (j = 0; j < wi[0].num_windows; j++) {
543+ if (wi[0].grouping[j] != wi[1].grouping[j]) {
544544 cpe->common_window = 0;
545545 break;
546546 }
547547 }
548548 }
549− if(cpe->common_window && s->coder->search_for_ms)
549+ if (cpe->common_window && s->coder->search_for_ms)
550550 s->coder->search_for_ms(s, cpe, s->lambda);
551551 adjust_frame_information(s, cpe, chans);
552552 put_bits(&s->pb, 3, tag);
553553 put_bits(&s->pb, 4, chan_el_counter[tag]++);
554− if(chans == 2){
554+ if (chans == 2) {
555555 put_bits(&s->pb, 1, cpe->common_window);
556− if(cpe->common_window){
556+ if (cpe->common_window) {
557557 put_ics_info(s, &cpe->ch[0].ics);
558558 encode_ms_info(&s->pb, cpe);
559559 }
560560 }
561− for(j = 0; j < chans; j++){
561+ for (j = 0; j < chans; j++) {
562562 s->cur_channel = start_ch + j;
563563 ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
564564 encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window);
@@ -571,7 +571,7 @@ static int aac_encode_frame(AVCodecContext *avctx, · 6 unmodified lines
571571 avctx->frame_bits = put_bits_count(&s->pb);
572572
573573 // rate control stuff
574− if(!(avctx->flags & CODEC_FLAG_QSCALE)){
574+ if (!(avctx->flags & CODEC_FLAG_QSCALE)) {
575575 float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits;
576576 s->lambda *= ratio;
577577 }
@@ -580,7 +580,7 @@ static int aac_encode_frame(AVCodecContext *avctx, · 2 unmodified lines
580580 av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n", avctx->frame_bits, 6144*avctx->channels);
581581 }
582582
583− if(!data)
583+ if (!data)
584584 s->last_frame = 1;
585585 memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0]));
586586 return put_bits_count(&s->pb)>>3;
libavcodec/aacenc.h+2−2
@@ -32,7 +32,7 @@ · 31 unmodified lines
3232
3333 struct AACEncContext;
3434
35−typedef struct AACCoefficientsEncoder{
35+typedef struct AACCoefficientsEncoder {
3636 void (*search_for_quantizers)(AVCodecContext *avctx, struct AACEncContext *s,
3737 SingleChannelElement *sce, const float lambda);
3838 void (*encode_window_bands_info)(struct AACEncContext *s, SingleChannelElement *sce,
@@ -40,7 +40,7 @@ typedef struct AACCoefficientsEncoder{ · 1 unmodified line
4040 void (*quantize_and_encode_band)(struct AACEncContext *s, PutBitContext *pb, const float *in, int size,
4141 int scale_idx, int cb, const float lambda);
4242 void (*search_for_ms)(struct AACEncContext *s, ChannelElement *cpe, const float lambda);
43−}AACCoefficientsEncoder;
43+} AACCoefficientsEncoder;
4444
4545 extern AACCoefficientsEncoder ff_aac_coders[];
4646
libavcodec/aacpsy.c+27−27
@@ -112,7 +112,7 @@ static av_cold float ath(float f, float add) · 111 unmodified lines
112112 + (0.6 + 0.04 * add) * 0.001 * f * f * f * f;
113113 }
114114
115−static av_cold int psy_3gpp_init(FFPsyContext *ctx){
115+static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
116116 Psy3gppContext *pctx;
117117 float barks[1024];
118118 int i, j, g, start;
@@ -121,26 +121,26 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx){ · 2 unmodified lines
121121 ctx->model_priv_data = av_mallocz(sizeof(Psy3gppContext));
122122 pctx = (Psy3gppContext*) ctx->model_priv_data;
123123
124− for(i = 0; i < 1024; i++)
124+ for (i = 0; i < 1024; i++)
125125 barks[i] = calc_bark(i * ctx->avctx->sample_rate / 2048.0);
126126 minath = ath(3410, ATH_ADD);
127− for(j = 0; j < 2; j++){
127+ for (j = 0; j < 2; j++) {
128128 Psy3gppCoeffs *coeffs = &pctx->psy_coef[j];
129129 i = 0;
130130 prev = 0.0;
131− for(g = 0; g < ctx->num_bands[j]; g++){
131+ for (g = 0; g < ctx->num_bands[j]; g++) {
132132 i += ctx->bands[j][g];
133133 coeffs->barks[g] = (barks[i - 1] + prev) / 2.0;
134134 prev = barks[i - 1];
135135 }
136− for(g = 0; g < ctx->num_bands[j] - 1; g++){
136+ for (g = 0; g < ctx->num_bands[j] - 1; g++) {
137137 coeffs->spread_low[g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_LOW);
138138 coeffs->spread_hi [g] = pow(10.0, -(coeffs->barks[g+1] - coeffs->barks[g]) * PSY_3GPP_SPREAD_HI);
139139 }
140140 start = 0;
141− for(g = 0; g < ctx->num_bands[j]; g++){
141+ for (g = 0; g < ctx->num_bands[j]; g++) {
142142 minscale = ath(ctx->avctx->sample_rate * start / 1024.0, ATH_ADD);
143− for(i = 1; i < ctx->bands[j][g]; i++){
143+ for (i = 1; i < ctx->bands[j][g]; i++) {
144144 minscale = fminf(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD));
145145 }
146146 coeffs->ath[g] = minscale - minath;
@@ -189,21 +189,21 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, · 42 unmodified lines
189189 FFPsyWindowInfo wi;
190190
191191 memset(&wi, 0, sizeof(wi));
192− if(la){
192+ if (la) {
193193 float s[8], v;
194194 int switch_to_eight = 0;
195195 float sum = 0.0, sum2 = 0.0;
196196 int attack_n = 0;
197− for(i = 0; i < 8; i++){
198− for(j = 0; j < 128; j++){
197+ for (i = 0; i < 8; i++) {
198+ for (j = 0; j < 128; j++) {
199199 v = iir_filter(audio[(i*128+j)*ctx->avctx->channels], pch->iir_state);
200200 sum += v*v;
201201 }
202202 s[i] = sum;
203203 sum2 += sum;
204204 }
205− for(i = 0; i < 8; i++){
206− if(s[i] > pch->win_energy * attack_ratio){
205+ for (i = 0; i < 8; i++) {
206+ if (s[i] > pch->win_energy * attack_ratio) {
207207 attack_n = i + 1;
208208 switch_to_eight = 1;
209209 break;
@@ -212,7 +212,7 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, · 2 unmodified lines
212212 pch->win_energy = pch->win_energy*7/8 + sum2/64;
213213
214214 wi.window_type[1] = prev_type;
215− switch(prev_type){
215+ switch (prev_type) {
216216 case ONLY_LONG_SEQUENCE:
217217 wi.window_type[0] = switch_to_eight ? LONG_START_SEQUENCE : ONLY_LONG_SEQUENCE;
218218 break;
@@ -229,21 +229,21 @@ static FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx, · 10 unmodified lines
229229 break;
230230 }
231231 pch->next_grouping = window_grouping[attack_n];
232− }else{
233− for(i = 0; i < 3; i++)
232+ } else {
233+ for (i = 0; i < 3; i++)
234234 wi.window_type[i] = prev_type;
235235 grouping = (prev_type == EIGHT_SHORT_SEQUENCE) ? window_grouping[0] : 0;
236236 }
237237
238238 wi.window_shape = 1;
239− if(wi.window_type[0] != EIGHT_SHORT_SEQUENCE){
239+ if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
240240 wi.num_windows = 1;
241241 wi.grouping[0] = 1;
242− }else{
242+ } else {
243243 int lastgrp = 0;
244244 wi.num_windows = 8;
245− for(i = 0; i < 8; i++){
246− if(!((grouping >> i) & 1))
245+ for (i = 0; i < 8; i++) {
246+ if (!((grouping >> i) & 1))
247247 lastgrp = i;
248248 wi.grouping[lastgrp]++;
249249 }
@@ -267,11 +267,11 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, const float *coefs, · 17 unmodified lines
267267 Psy3gppCoeffs *coeffs = &pctx->psy_coef[wi->num_windows == 8];
268268
269269 //calculate energies, initial thresholds and related values - 5.4.2 "Threshold Calculation"
270− for(w = 0; w < wi->num_windows*16; w += 16){
271− for(g = 0; g < num_bands; g++){
270+ for (w = 0; w < wi->num_windows*16; w += 16) {
271+ for (g = 0; g < num_bands; g++) {
272272 Psy3gppBand *band = &pch->band[w+g];
273273 band->energy = 0.0f;
274− for(i = 0; i < band_sizes[g]; i++)
274+ for (i = 0; i < band_sizes[g]; i++)
275275 band->energy += coefs[start+i] * coefs[start+i];
276276 band->energy *= 1.0f / (512*512);
277277 band->thr = band->energy * 0.001258925f;
@@ -281,17 +281,17 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, const float *coefs, · 3 unmodified lines
281281 }
282282 }
283283 //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"
284− for(w = 0; w < wi->num_windows*16; w += 16){
284+ for (w = 0; w < wi->num_windows*16; w += 16) {
285285 Psy3gppBand *band = &pch->band[w];
286− for(g = 1; g < num_bands; g++){
286+ for (g = 1; g < num_bands; g++) {
287287 band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]);
288288 }
289− for(g = num_bands - 2; g >= 0; g--){
289+ for (g = num_bands - 2; g >= 0; g--) {
290290 band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]);
291291 }
292− for(g = 0; g < num_bands; g++){
292+ for (g = 0; g < num_bands; g++) {
293293 band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]);
294− if(wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE){
294+ if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE) {
295295 band[g].thr_quiet = fmaxf(PSY_3GPP_RPEMIN*band[g].thr_quiet,
296296 fminf(band[g].thr_quiet,
297297 PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
libavcodec/psymodel.c+11−11
@@ -35,12 +35,12 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, · 34 unmodified lines
3535 ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens);
3636 memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens);
3737 memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens);
38− switch(ctx->avctx->codec_id){
38+ switch (ctx->avctx->codec_id) {
3939 case CODEC_ID_AAC:
4040 ctx->model = &ff_aac_psy_model;
4141 break;
4242 }
43− if(ctx->model->init)
43+ if (ctx->model->init)
4444 return ctx->model->init(ctx);
4545 return 0;
4646 }
@@ -60,7 +60,7 @@ void ff_psy_set_band_info(FFPsyContext *ctx, int channel, · 13 unmodified lines
6060
6161 av_cold void ff_psy_end(FFPsyContext *ctx)
6262 {
63− if(ctx->model->end)
63+ if (ctx->model->end)
6464 ctx->model->end(ctx);
6565 av_freep(&ctx->bands);
6666 av_freep(&ctx->num_bands);
@@ -84,16 +84,16 @@ av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *av · 17 unmodified lines
8484 ctx = av_mallocz(sizeof(FFPsyPreprocessContext));
8585 ctx->avctx = avctx;
8686
87− if(avctx->flags & CODEC_FLAG_QSCALE)
87+ if (avctx->flags & CODEC_FLAG_QSCALE)
8888 cutoff_coeff = 1.0f / av_clip(1 + avctx->global_quality / FF_QUALITY_SCALE, 1, 8);
8989 else
9090 cutoff_coeff = avctx->bit_rate / (4.0f * avctx->sample_rate * avctx->channels);
9191
9292 ctx->fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS,
9393 FILT_ORDER, cutoff_coeff, 0.0, 0.0);
94− if(ctx->fcoeffs){
94+ if (ctx->fcoeffs) {
9595 ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);
96− for(i = 0; i < avctx->channels; i++)
96+ for (i = 0; i < avctx->channels; i++)
9797 ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER);
9898 }
9999 return ctx;
@@ -104,15 +104,15 @@ void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, · 4 unmodified lines
104104 int tag, int channels)
105105 {
106106 int ch, i;
107− if(ctx->fstate){
108− for(ch = 0; ch < channels; ch++){
107+ if (ctx->fstate) {
108+ for (ch = 0; ch < channels; ch++) {
109109 ff_iir_filter(ctx->fcoeffs, ctx->fstate[tag+ch], ctx->avctx->frame_size,
110110 audio + ch, ctx->avctx->channels,
111111 dest + ch, ctx->avctx->channels);
112112 }
113− }else{
114− for(ch = 0; ch < channels; ch++){
115− for(i = 0; i < ctx->avctx->frame_size; i++)
113+ } else {
114+ for (ch = 0; ch < channels; ch++) {
115+ for (i = 0; i < ctx->avctx->frame_size; i++)
116116 dest[i*ctx->avctx->channels + ch] = audio[i*ctx->avctx->channels + ch];
117117 }
118118 }
libavcodec/psymodel.h+7−7
@@ -30,29 +30,29 @@ · 29 unmodified lines
3030 /**
3131 * single band psychoacoustic information
3232 */
33−typedef struct FFPsyBand{
33+typedef struct FFPsyBand {
3434 int bits;
3535 float energy;
3636 float threshold;
3737 float distortion;
3838 float perceptual_weight;
39−}FFPsyBand;
39+} FFPsyBand;
4040
4141 /**
4242 * windowing related information
4343 */
44−typedef struct FFPsyWindowInfo{
44+typedef struct FFPsyWindowInfo {
4545 int window_type[3]; ///< window type (short/long/transitional, etc.) - current, previous and next
4646 int window_shape; ///< window shape (sine/KBD/whatever)
4747 int num_windows; ///< number of windows in a frame
4848 int grouping[8]; ///< window grouping (for e.g. AAC)
4949 int *window_sizes; ///< sequence of window sizes inside one frame (for eg. WMA)
50−}FFPsyWindowInfo;
50+} FFPsyWindowInfo;
5151
5252 /**
5353 * context used by psychoacoustic model
5454 */
55−typedef struct FFPsyContext{
55+typedef struct FFPsyContext {
5656 AVCodecContext *avctx; ///< encoder context
5757 const struct FFPsyModel *model; ///< encoder-specific model functions
5858
@@ -63,7 +63,7 @@ typedef struct FFPsyContext{ · 4 unmodified lines
6363 int num_lens; ///< number of scalefactor band sets
6464
6565 void* model_priv_data; ///< psychoacoustic model implementation private data
66−}FFPsyContext;
66+} FFPsyContext;
6767
6868 /**
6969 * codec-specific psychoacoustic model implementation
@@ -74,7 +74,7 @@ typedef struct FFPsyModel { · 4 unmodified lines
7474 FFPsyWindowInfo (*window)(FFPsyContext *ctx, const int16_t *audio, const int16_t *la, int channel, int prev_type);
7575 void (*analyze)(FFPsyContext *ctx, int channel, const float *coeffs, FFPsyWindowInfo *wi);
7676 void (*end) (FFPsyContext *apc);
77−}FFPsyModel;
77+} FFPsyModel;
7878
7979 /**
8080 * Initialize psychoacoustic model.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t