Mercurial > libavcodec.hg
comparison aaccoder.c @ 9938:6c1ac45b3097 libavcodec
cosmetics: Remove unnecessary {} around if/for blocks;
move statements after if/for to the next line.
author | diego |
---|---|
date | Wed, 08 Jul 2009 21:36:33 +0000 |
parents | 3e39dbd2d9eb |
children | 6c5a58b34997 |
comparison
equal
deleted
inserted
replaced
9937:3e39dbd2d9eb | 9938:6c1ac45b3097 |
---|---|
82 | 82 |
83 static void abs_pow34_v(float *out, const float *in, const int size) | 83 static void abs_pow34_v(float *out, const float *in, const int size) |
84 { | 84 { |
85 #ifndef USE_REALLY_FULL_SEARCH | 85 #ifndef USE_REALLY_FULL_SEARCH |
86 int i; | 86 int i; |
87 for (i = 0; i < size; i++) { | 87 for (i = 0; i < size; i++) |
88 out[i] = pow(fabsf(in[i]), 0.75); | 88 out[i] = pow(fabsf(in[i]), 0.75); |
89 } | |
90 #endif /* USE_REALLY_FULL_SEARCH */ | 89 #endif /* USE_REALLY_FULL_SEARCH */ |
91 } | 90 } |
92 | 91 |
93 static av_always_inline int quant2(float coef, const float Q) | 92 static av_always_inline int quant2(float coef, const float Q) |
94 { | 93 { |
139 int minbits = 0; | 138 int minbits = 0; |
140 const float *vec; | 139 const float *vec; |
141 #ifndef USE_REALLY_FULL_SEARCH | 140 #ifndef USE_REALLY_FULL_SEARCH |
142 int (*quants)[2] = &s->qcoefs[i]; | 141 int (*quants)[2] = &s->qcoefs[i]; |
143 mincost = 0.0f; | 142 mincost = 0.0f; |
144 for (j = 0; j < dim; j++) { | 143 for (j = 0; j < dim; j++) |
145 mincost += in[i+j]*in[i+j]*lambda; | 144 mincost += in[i+j]*in[i+j]*lambda; |
146 } | |
147 minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; | 145 minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
148 minbits = ff_aac_spectral_bits[cb-1][minidx]; | 146 minbits = ff_aac_spectral_bits[cb-1][minidx]; |
149 mincost += minbits; | 147 mincost += minbits; |
150 for (j = 0; j < (1<<dim); j++) { | 148 for (j = 0; j < (1<<dim); j++) { |
151 float rd = 0.0f; | 149 float rd = 0.0f; |
254 int minbits = 0; | 252 int minbits = 0; |
255 const float *vec; | 253 const float *vec; |
256 #ifndef USE_REALLY_FULL_SEARCH | 254 #ifndef USE_REALLY_FULL_SEARCH |
257 int (*quants)[2] = &s->qcoefs[i]; | 255 int (*quants)[2] = &s->qcoefs[i]; |
258 mincost = 0.0f; | 256 mincost = 0.0f; |
259 for (j = 0; j < dim; j++) { | 257 for (j = 0; j < dim; j++) |
260 mincost += in[i+j]*in[i+j]*lambda; | 258 mincost += in[i+j]*in[i+j]*lambda; |
261 } | |
262 minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; | 259 minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
263 minbits = ff_aac_spectral_bits[cb-1][minidx]; | 260 minbits = ff_aac_spectral_bits[cb-1][minidx]; |
264 mincost += minbits; | 261 mincost += minbits; |
265 for (j = 0; j < (1<<dim); j++) { | 262 for (j = 0; j < (1<<dim); j++) { |
266 float rd = 0.0f; | 263 float rd = 0.0f; |
427 } | 424 } |
428 | 425 |
429 //convert resulting path from backward-linked list | 426 //convert resulting path from backward-linked list |
430 stack_len = 0; | 427 stack_len = 0; |
431 idx = 0; | 428 idx = 0; |
432 for (cb = 1; cb < 12; cb++) { | 429 for (cb = 1; cb < 12; cb++) |
433 if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) | 430 if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) |
434 idx = cb; | 431 idx = cb; |
435 } | |
436 ppos = max_sfb; | 432 ppos = max_sfb; |
437 while (ppos > 0) { | 433 while (ppos > 0) { |
438 cb = idx; | 434 cb = idx; |
439 stackrun[stack_len] = path[ppos][cb].run; | 435 stackrun[stack_len] = path[ppos][cb].run; |
440 stackcb [stack_len] = cb; | 436 stackcb [stack_len] = cb; |
521 } | 517 } |
522 sce->zeroes[(w+w2)*16+g] = 0; | 518 sce->zeroes[(w+w2)*16+g] = 0; |
523 nz = 1; | 519 nz = 1; |
524 for (i = 0; i < sce->ics.swb_sizes[g]; i++) { | 520 for (i = 0; i < sce->ics.swb_sizes[g]; i++) { |
525 float t = fabsf(coefs[w2*128+i]); | 521 float t = fabsf(coefs[w2*128+i]); |
526 if (t > 0.0f) qmin = fminf(qmin, t); | 522 if (t > 0.0f) |
523 qmin = fminf(qmin, t); | |
527 qmax = fmaxf(qmax, t); | 524 qmax = fmaxf(qmax, t); |
528 } | 525 } |
529 } | 526 } |
530 if (nz) { | 527 if (nz) { |
531 int minscale, maxscale; | 528 int minscale, maxscale; |
538 float dists[12], dist; | 535 float dists[12], dist; |
539 memset(dists, 0, sizeof(dists)); | 536 memset(dists, 0, sizeof(dists)); |
540 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { | 537 for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
541 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; | 538 FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; |
542 int cb; | 539 int cb; |
543 for (cb = 0; cb <= ESC_BT; cb++) { | 540 for (cb = 0; cb <= ESC_BT; cb++) |
544 dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], | 541 dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], |
545 q, cb, lambda / band->threshold, INFINITY, NULL); | 542 q, cb, lambda / band->threshold, INFINITY, NULL); |
546 } | |
547 } | 543 } |
548 dist = dists[0]; | 544 dist = dists[0]; |
549 for (i = 1; i <= ESC_BT; i++) | 545 for (i = 1; i <= ESC_BT; i++) |
550 dist = fminf(dist, dists[i]); | 546 dist = fminf(dist, dists[i]); |
551 minrd = fminf(minrd, dist); | 547 minrd = fminf(minrd, dist); |
723 start += sce->ics.swb_sizes[g]; | 719 start += sce->ics.swb_sizes[g]; |
724 prev = sce->sf_idx[w*16+g]; | 720 prev = sce->sf_idx[w*16+g]; |
725 } | 721 } |
726 } | 722 } |
727 if (tbits > destbits) { | 723 if (tbits > destbits) { |
728 for (i = 0; i < 128; i++) { | 724 for (i = 0; i < 128; i++) |
729 if (sce->sf_idx[i] < 218 - qstep) { | 725 if (sce->sf_idx[i] < 218 - qstep) |
730 sce->sf_idx[i] += qstep; | 726 sce->sf_idx[i] += qstep; |
731 } | |
732 } | |
733 } else { | 727 } else { |
734 for (i = 0; i < 128; i++) { | 728 for (i = 0; i < 128; i++) |
735 if (sce->sf_idx[i] > 60 - qstep) { | 729 if (sce->sf_idx[i] > 60 - qstep) |
736 sce->sf_idx[i] -= qstep; | 730 sce->sf_idx[i] -= qstep; |
737 } | |
738 } | |
739 } | 731 } |
740 qstep >>= 1; | 732 qstep >>= 1; |
741 if (!qstep && tbits > destbits*1.02) | 733 if (!qstep && tbits > destbits*1.02) |
742 qstep = 1; | 734 qstep = 1; |
743 if (sce->sf_idx[0] >= 217)break; | 735 if (sce->sf_idx[0] >= 217) |
736 break; | |
744 } while (qstep); | 737 } while (qstep); |
745 | 738 |
746 fflag = 0; | 739 fflag = 0; |
747 minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); | 740 minscaler = av_clip(minscaler, 60, 255 - SCALE_MAX_DIFF); |
748 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { | 741 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { |
914 if (!sce->sf_idx[i]) | 907 if (!sce->sf_idx[i]) |
915 sce->sf_idx[i] = sce->sf_idx[i-1]; | 908 sce->sf_idx[i] = sce->sf_idx[i-1]; |
916 else | 909 else |
917 minq = FFMIN(minq, sce->sf_idx[i]); | 910 minq = FFMIN(minq, sce->sf_idx[i]); |
918 } | 911 } |
919 if (minq == INT_MAX) minq = 0; | 912 if (minq == INT_MAX) |
913 minq = 0; | |
920 minq = FFMIN(minq, SCALE_MAX_POS); | 914 minq = FFMIN(minq, SCALE_MAX_POS); |
921 maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); | 915 maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); |
922 for (i = 126; i >= 0; i--) { | 916 for (i = 126; i >= 0; i--) { |
923 if (!sce->sf_idx[i]) | 917 if (!sce->sf_idx[i]) |
924 sce->sf_idx[i] = sce->sf_idx[i+1]; | 918 sce->sf_idx[i] = sce->sf_idx[i+1]; |
949 minq = FFMIN(minq, sce->sf_idx[(w+w2)*16+g]); | 943 minq = FFMIN(minq, sce->sf_idx[(w+w2)*16+g]); |
950 } | 944 } |
951 } | 945 } |
952 } | 946 } |
953 for (i = 0; i < 128; i++) { | 947 for (i = 0; i < 128; i++) { |
954 sce->sf_idx[i] = 140;//av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1); | 948 sce->sf_idx[i] = 140; |
949 //av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1); | |
955 } | 950 } |
956 //set the same quantizers inside window groups | 951 //set the same quantizers inside window groups |
957 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) | 952 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) |
958 for (g = 0; g < sce->ics.num_swb; g++) | 953 for (g = 0; g < sce->ics.num_swb; g++) |
959 for (w2 = 1; w2 < sce->ics.group_len[w]; w2++) | 954 for (w2 = 1; w2 < sce->ics.group_len[w]; w2++) |