Originally committed as revision 19378 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -84,9 +84,8 @@ static void abs_pow34_v(float *out, const float *in, const int size) |
| 84 | 84 |
{
|
| 85 | 85 |
#ifndef USE_REALLY_FULL_SEARCH |
| 86 | 86 |
int i; |
| 87 |
- for (i = 0; i < size; i++) {
|
|
| 87 |
+ for (i = 0; i < size; i++) |
|
| 88 | 88 |
out[i] = pow(fabsf(in[i]), 0.75); |
| 89 |
- } |
|
| 90 | 89 |
#endif /* USE_REALLY_FULL_SEARCH */ |
| 91 | 90 |
} |
| 92 | 91 |
|
| ... | ... |
@@ -141,9 +140,8 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, |
| 141 | 141 |
#ifndef USE_REALLY_FULL_SEARCH |
| 142 | 142 |
int (*quants)[2] = &s->qcoefs[i]; |
| 143 | 143 |
mincost = 0.0f; |
| 144 |
- for (j = 0; j < dim; j++) {
|
|
| 144 |
+ for (j = 0; j < dim; j++) |
|
| 145 | 145 |
mincost += in[i+j]*in[i+j]*lambda; |
| 146 |
- } |
|
| 147 | 146 |
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
| 148 | 147 |
minbits = ff_aac_spectral_bits[cb-1][minidx]; |
| 149 | 148 |
mincost += minbits; |
| ... | ... |
@@ -256,9 +254,8 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, |
| 256 | 256 |
#ifndef USE_REALLY_FULL_SEARCH |
| 257 | 257 |
int (*quants)[2] = &s->qcoefs[i]; |
| 258 | 258 |
mincost = 0.0f; |
| 259 |
- for (j = 0; j < dim; j++) {
|
|
| 259 |
+ for (j = 0; j < dim; j++) |
|
| 260 | 260 |
mincost += in[i+j]*in[i+j]*lambda; |
| 261 |
- } |
|
| 262 | 261 |
minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
| 263 | 262 |
minbits = ff_aac_spectral_bits[cb-1][minidx]; |
| 264 | 263 |
mincost += minbits; |
| ... | ... |
@@ -429,10 +426,9 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce |
| 429 | 429 |
//convert resulting path from backward-linked list |
| 430 | 430 |
stack_len = 0; |
| 431 | 431 |
idx = 0; |
| 432 |
- for (cb = 1; cb < 12; cb++) {
|
|
| 432 |
+ for (cb = 1; cb < 12; cb++) |
|
| 433 | 433 |
if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) |
| 434 | 434 |
idx = cb; |
| 435 |
- } |
|
| 436 | 435 |
ppos = max_sfb; |
| 437 | 436 |
while (ppos > 0) {
|
| 438 | 437 |
cb = idx; |
| ... | ... |
@@ -523,7 +519,8 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, |
| 523 | 523 |
nz = 1; |
| 524 | 524 |
for (i = 0; i < sce->ics.swb_sizes[g]; i++) {
|
| 525 | 525 |
float t = fabsf(coefs[w2*128+i]); |
| 526 |
- if (t > 0.0f) qmin = fminf(qmin, t); |
|
| 526 |
+ if (t > 0.0f) |
|
| 527 |
+ qmin = fminf(qmin, t); |
|
| 527 | 528 |
qmax = fmaxf(qmax, t); |
| 528 | 529 |
} |
| 529 | 530 |
} |
| ... | ... |
@@ -540,10 +537,9 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, |
| 540 | 540 |
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
|
| 541 | 541 |
FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; |
| 542 | 542 |
int cb; |
| 543 |
- for (cb = 0; cb <= ESC_BT; cb++) {
|
|
| 543 |
+ for (cb = 0; cb <= ESC_BT; cb++) |
|
| 544 | 544 |
dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], |
| 545 | 545 |
q, cb, lambda / band->threshold, INFINITY, NULL); |
| 546 |
- } |
|
| 547 | 546 |
} |
| 548 | 547 |
dist = dists[0]; |
| 549 | 548 |
for (i = 1; i <= ESC_BT; i++) |
| ... | ... |
@@ -725,22 +721,19 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, |
| 725 | 725 |
} |
| 726 | 726 |
} |
| 727 | 727 |
if (tbits > destbits) {
|
| 728 |
- for (i = 0; i < 128; i++) {
|
|
| 729 |
- if (sce->sf_idx[i] < 218 - qstep) {
|
|
| 728 |
+ for (i = 0; i < 128; i++) |
|
| 729 |
+ if (sce->sf_idx[i] < 218 - qstep) |
|
| 730 | 730 |
sce->sf_idx[i] += qstep; |
| 731 |
- } |
|
| 732 |
- } |
|
| 733 | 731 |
} else {
|
| 734 |
- for (i = 0; i < 128; i++) {
|
|
| 735 |
- if (sce->sf_idx[i] > 60 - qstep) {
|
|
| 732 |
+ for (i = 0; i < 128; i++) |
|
| 733 |
+ if (sce->sf_idx[i] > 60 - qstep) |
|
| 736 | 734 |
sce->sf_idx[i] -= qstep; |
| 737 |
- } |
|
| 738 |
- } |
|
| 739 | 735 |
} |
| 740 | 736 |
qstep >>= 1; |
| 741 | 737 |
if (!qstep && tbits > destbits*1.02) |
| 742 | 738 |
qstep = 1; |
| 743 |
- if (sce->sf_idx[0] >= 217)break; |
|
| 739 |
+ if (sce->sf_idx[0] >= 217) |
|
| 740 |
+ break; |
|
| 744 | 741 |
} while (qstep); |
| 745 | 742 |
|
| 746 | 743 |
fflag = 0; |
| ... | ... |
@@ -916,7 +909,8 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, |
| 916 | 916 |
else |
| 917 | 917 |
minq = FFMIN(minq, sce->sf_idx[i]); |
| 918 | 918 |
} |
| 919 |
- if (minq == INT_MAX) minq = 0; |
|
| 919 |
+ if (minq == INT_MAX) |
|
| 920 |
+ minq = 0; |
|
| 920 | 921 |
minq = FFMIN(minq, SCALE_MAX_POS); |
| 921 | 922 |
maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); |
| 922 | 923 |
for (i = 126; i >= 0; i--) {
|
| ... | ... |
@@ -951,7 +945,8 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, |
| 951 | 951 |
} |
| 952 | 952 |
} |
| 953 | 953 |
for (i = 0; i < 128; i++) {
|
| 954 |
- sce->sf_idx[i] = 140;//av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1); |
|
| 954 |
+ sce->sf_idx[i] = 140; |
|
| 955 |
+ //av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1); |
|
| 955 | 956 |
} |
| 956 | 957 |
//set the same quantizers inside window groups |
| 957 | 958 |
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) |
| ... | ... |
@@ -276,9 +276,8 @@ static void put_ics_info(AACEncContext *s, IndividualChannelStream *info) |
| 276 | 276 |
put_bits(&s->pb, 1, 0); // no prediction |
| 277 | 277 |
} else {
|
| 278 | 278 |
put_bits(&s->pb, 4, info->max_sfb); |
| 279 |
- for (w = 1; w < 8; w++) {
|
|
| 279 |
+ for (w = 1; w < 8; w++) |
|
| 280 | 280 |
put_bits(&s->pb, 1, !info->group_len[w]); |
| 281 |
- } |
|
| 282 | 281 |
} |
| 283 | 282 |
} |
| 284 | 283 |
|
| ... | ... |
@@ -291,12 +290,10 @@ static void encode_ms_info(PutBitContext *pb, ChannelElement *cpe) |
| 291 | 291 |
int i, w; |
| 292 | 292 |
|
| 293 | 293 |
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]) {
|
|
| 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 | 296 |
for (i = 0; i < cpe->ch[0].ics.max_sfb; i++) |
| 297 | 297 |
put_bits(pb, 1, cpe->ms_mask[w*16 + i]); |
| 298 |
- } |
|
| 299 |
- } |
|
| 300 | 298 |
} |
| 301 | 299 |
|
| 302 | 300 |
/** |
| ... | ... |
@@ -324,7 +321,8 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in |
| 324 | 324 |
} |
| 325 | 325 |
start += ics->swb_sizes[g]; |
| 326 | 326 |
} |
| 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--) |
|
| 328 |
+ ; |
|
| 328 | 329 |
maxsfb = FFMAX(maxsfb, cmaxsfb); |
| 329 | 330 |
} |
| 330 | 331 |
ics->max_sfb = maxsfb; |
| ... | ... |
@@ -352,7 +350,8 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in |
| 352 | 352 |
ics1->max_sfb = ics0->max_sfb; |
| 353 | 353 |
for (w = 0; w < ics0->num_windows*16; w += 16) |
| 354 | 354 |
for (i = 0; i < ics0->max_sfb; i++) |
| 355 |
- if (cpe->ms_mask[w+i]) msc++; |
|
| 355 |
+ if (cpe->ms_mask[w+i]) |
|
| 356 |
+ msc++; |
|
| 356 | 357 |
if (msc == 0 || ics0->max_sfb == 0) |
| 357 | 358 |
cpe->ms_mode = 0; |
| 358 | 359 |
else |
| ... | ... |
@@ -367,9 +366,8 @@ static void encode_band_info(AACEncContext *s, SingleChannelElement *sce) |
| 367 | 367 |
{
|
| 368 | 368 |
int w; |
| 369 | 369 |
|
| 370 |
- for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
|
| 370 |
+ for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) |
|
| 371 | 371 |
s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda); |
| 372 |
- } |
|
| 373 | 372 |
} |
| 374 | 373 |
|
| 375 | 374 |
/** |
| ... | ... |
@@ -427,13 +425,12 @@ static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce) |
| 427 | 427 |
start += sce->ics.swb_sizes[i]; |
| 428 | 428 |
continue; |
| 429 | 429 |
} |
| 430 |
- for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) {
|
|
| 430 |
+ for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) |
|
| 431 | 431 |
s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128, |
| 432 | 432 |
sce->ics.swb_sizes[i], |
| 433 | 433 |
sce->sf_idx[w*16 + i], |
| 434 | 434 |
sce->band_type[w*16 + i], |
| 435 | 435 |
s->lambda); |
| 436 |
- } |
|
| 437 | 436 |
start += sce->ics.swb_sizes[i]; |
| 438 | 437 |
} |
| 439 | 438 |
} |
| ... | ... |
@@ -514,9 +511,8 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 514 | 514 |
} |
| 515 | 515 |
|
| 516 | 516 |
init_put_bits(&s->pb, frame, buf_size*8); |
| 517 |
- if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) {
|
|
| 517 |
+ if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) |
|
| 518 | 518 |
put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); |
| 519 |
- } |
|
| 520 | 519 |
start_ch = 0; |
| 521 | 520 |
memset(chan_el_counter, 0, sizeof(chan_el_counter)); |
| 522 | 521 |
for (i = 0; i < chan_map[0]; i++) {
|
| ... | ... |
@@ -526,7 +522,8 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 526 | 526 |
cpe = &s->cpe[i]; |
| 527 | 527 |
samples2 = samples + start_ch; |
| 528 | 528 |
la = samples2 + 1024 * avctx->channels + start_ch; |
| 529 |
- if (!data) la = NULL; |
|
| 529 |
+ if (!data) |
|
| 530 |
+ la = NULL; |
|
| 530 | 531 |
for (j = 0; j < chans; j++) {
|
| 531 | 532 |
IndividualChannelStream *ics = &cpe->ch[j].ics; |
| 532 | 533 |
int k; |
| ... | ... |
@@ -588,10 +585,9 @@ static int aac_encode_frame(AVCodecContext *avctx, |
| 588 | 588 |
s->lambda *= ratio; |
| 589 | 589 |
} |
| 590 | 590 |
|
| 591 |
- if (avctx->frame_bits > 6144*avctx->channels) {
|
|
| 591 |
+ if (avctx->frame_bits > 6144*avctx->channels) |
|
| 592 | 592 |
av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n", |
| 593 | 593 |
avctx->frame_bits, 6144*avctx->channels); |
| 594 |
- } |
|
| 595 | 594 |
|
| 596 | 595 |
if (!data) |
| 597 | 596 |
s->last_frame = 1; |
| ... | ... |
@@ -140,9 +140,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) {
|
| 140 | 140 |
start = 0; |
| 141 | 141 |
for (g = 0; g < ctx->num_bands[j]; g++) {
|
| 142 | 142 |
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++) |
|
| 144 | 144 |
minscale = fminf(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD)); |
| 145 |
- } |
|
| 146 | 145 |
coeffs->ath[g] = minscale - minath; |
| 147 | 146 |
start += ctx->bands[j][g]; |
| 148 | 147 |
} |
| ... | ... |
@@ -283,19 +282,16 @@ static void psy_3gpp_analyze(FFPsyContext *ctx, int channel, |
| 283 | 283 |
//modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation" |
| 284 | 284 |
for (w = 0; w < wi->num_windows*16; w += 16) {
|
| 285 | 285 |
Psy3gppBand *band = &pch->band[w]; |
| 286 |
- for (g = 1; g < num_bands; g++) {
|
|
| 286 |
+ for (g = 1; g < num_bands; g++) |
|
| 287 | 287 |
band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]); |
| 288 |
- } |
|
| 289 |
- for (g = num_bands - 2; g >= 0; g--) {
|
|
| 288 |
+ for (g = num_bands - 2; g >= 0; g--) |
|
| 290 | 289 |
band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]); |
| 291 |
- } |
|
| 292 | 290 |
for (g = 0; g < num_bands; g++) {
|
| 293 | 291 |
band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]); |
| 294 |
- if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE) {
|
|
| 292 |
+ if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE) |
|
| 295 | 293 |
band[g].thr_quiet = fmaxf(PSY_3GPP_RPEMIN*band[g].thr_quiet, |
| 296 | 294 |
fminf(band[g].thr_quiet, |
| 297 | 295 |
PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet)); |
| 298 |
- } |
|
| 299 | 296 |
band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25); |
| 300 | 297 |
|
| 301 | 298 |
ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr; |
| ... | ... |
@@ -105,16 +105,14 @@ void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, |
| 105 | 105 |
{
|
| 106 | 106 |
int ch, i; |
| 107 | 107 |
if (ctx->fstate) {
|
| 108 |
- for (ch = 0; ch < channels; ch++) {
|
|
| 108 |
+ for (ch = 0; ch < channels; ch++) |
|
| 109 | 109 |
ff_iir_filter(ctx->fcoeffs, ctx->fstate[tag+ch], ctx->avctx->frame_size, |
| 110 | 110 |
audio + ch, ctx->avctx->channels, |
| 111 | 111 |
dest + ch, ctx->avctx->channels); |
| 112 |
- } |
|
| 113 | 112 |
} else {
|
| 114 |
- for (ch = 0; ch < channels; ch++) {
|
|
| 113 |
+ for (ch = 0; ch < channels; ch++) |
|
| 115 | 114 |
for (i = 0; i < ctx->avctx->frame_size; i++) |
| 116 | 115 |
dest[i*ctx->avctx->channels + ch] = audio[i*ctx->avctx->channels + ch]; |
| 117 |
- } |
|
| 118 | 116 |
} |
| 119 | 117 |
} |
| 120 | 118 |
|