Originally committed as revision 19378 to svn://svn.ffmpeg.org/ffmpeg/trunk
Unified · Split
| @@ -84,9 +84,8 @@ static void abs_pow34_v(float *out, const float *in, const int size) · 83 unmodified lines | ||
| 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, · 48 unmodified lines | ||
| 141 | 140 | #ifndef USE_REALLY_FULL_SEARCH |
| 142 | 141 | int (*quants)[2] = &s->qcoefs[i]; |
| 143 | 142 | mincost = 0.0f; |
| 144 | − for (j = 0; j < dim; j++) { | |
| 143 | + for (j = 0; j < dim; j++) | |
| 145 | 144 | mincost += in[i+j]*in[i+j]*lambda; |
| 146 | − } | |
| 147 | 145 | minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
| 148 | 146 | minbits = ff_aac_spectral_bits[cb-1][minidx]; |
| 149 | 147 | mincost += minbits; |
| @@ -256,9 +254,8 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 106 unmodified lines | ||
| 256 | 254 | #ifndef USE_REALLY_FULL_SEARCH |
| 257 | 255 | int (*quants)[2] = &s->qcoefs[i]; |
| 258 | 256 | mincost = 0.0f; |
| 259 | − for (j = 0; j < dim; j++) { | |
| 257 | + for (j = 0; j < dim; j++) | |
| 260 | 258 | mincost += in[i+j]*in[i+j]*lambda; |
| 261 | − } | |
| 262 | 259 | minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40; |
| 263 | 260 | minbits = ff_aac_spectral_bits[cb-1][minidx]; |
| 264 | 261 | mincost += minbits; |
| @@ -429,10 +426,9 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 164 unmodified lines | ||
| 429 | 426 | //convert resulting path from backward-linked list |
| 430 | 427 | stack_len = 0; |
| 431 | 428 | idx = 0; |
| 432 | − for (cb = 1; cb < 12; cb++) { | |
| 429 | + for (cb = 1; cb < 12; cb++) | |
| 433 | 430 | if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) |
| 434 | 431 | idx = cb; |
| 435 | − } | |
| 436 | 432 | ppos = max_sfb; |
| 437 | 433 | while (ppos > 0) { |
| 438 | 434 | cb = idx; |
| @@ -523,7 +519,8 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 84 unmodified lines | ||
| 523 | 519 | nz = 1; |
| 524 | 520 | for (i = 0; i < sce->ics.swb_sizes[g]; i++) { |
| 525 | 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 | 524 | qmax = fmaxf(qmax, t); |
| 528 | 525 | } |
| 529 | 526 | } |
| @@ -540,10 +537,9 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 10 unmodified lines | ||
| 540 | 537 | for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { |
| 541 | 538 | FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g]; |
| 542 | 539 | int cb; |
| 543 | − for (cb = 0; cb <= ESC_BT; cb++) { | |
| 540 | + for (cb = 0; cb <= ESC_BT; cb++) | |
| 544 | 541 | dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], |
| 545 | 542 | q, cb, lambda / band->threshold, INFINITY, NULL); |
| 546 | − } | |
| 547 | 543 | } |
| 548 | 544 | dist = dists[0]; |
| 549 | 545 | for (i = 1; i <= ESC_BT; i++) |
| @@ -725,22 +721,19 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 175 unmodified lines | ||
| 725 | 721 | } |
| 726 | 722 | } |
| 727 | 723 | if (tbits > destbits) { |
| 728 | − for (i = 0; i < 128; i++) { | |
| 729 | − if (sce->sf_idx[i] < 218 - qstep) { | |
| 724 | + for (i = 0; i < 128; i++) | |
| 725 | + if (sce->sf_idx[i] < 218 - qstep) | |
| 730 | 726 | sce->sf_idx[i] += qstep; |
| 731 | − } | |
| 732 | − } | |
| 733 | 727 | } else { |
| 734 | − for (i = 0; i < 128; i++) { | |
| 735 | − if (sce->sf_idx[i] > 60 - qstep) { | |
| 728 | + for (i = 0; i < 128; i++) | |
| 729 | + if (sce->sf_idx[i] > 60 - qstep) | |
| 736 | 730 | sce->sf_idx[i] -= qstep; |
| 737 | − } | |
| 738 | − } | |
| 739 | 731 | } |
| 740 | 732 | qstep >>= 1; |
| 741 | 733 | if (!qstep && tbits > destbits*1.02) |
| 742 | 734 | qstep = 1; |
| 743 | − if (sce->sf_idx[0] >= 217)break; | |
| 735 | + if (sce->sf_idx[0] >= 217) | |
| 736 | + break; | |
| 744 | 737 | } while (qstep); |
| 745 | 738 | |
| 746 | 739 | fflag = 0; |
| @@ -916,7 +909,8 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 169 unmodified lines | ||
| 916 | 909 | else |
| 917 | 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 | 914 | minq = FFMIN(minq, SCALE_MAX_POS); |
| 921 | 915 | maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS); |
| 922 | 916 | for (i = 126; i >= 0; i--) { |
| @@ -951,7 +945,8 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 28 unmodified lines | ||
| 951 | 945 | } |
| 952 | 946 | } |
| 953 | 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 | 951 | //set the same quantizers inside window groups |
| 957 | 952 | 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) · 275 unmodified lines | ||
| 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) · 6 unmodified lines | ||
| 291 | 290 | int i, w; |
| 292 | 291 | |
| 293 | 292 | 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]) { | |
| 293 | + if (cpe->ms_mode == 1) | |
| 294 | + for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w]) | |
| 296 | 295 | for (i = 0; i < cpe->ch[0].ics.max_sfb; i++) |
| 297 | 296 | put_bits(pb, 1, cpe->ms_mask[w*16 + i]); |
| 298 | − } | |
| 299 | − } | |
| 300 | 297 | } |
| 301 | 298 | |
| 302 | 299 | /** |
| @@ -324,7 +321,8 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in · 21 unmodified lines | ||
| 324 | 321 | } |
| 325 | 322 | start += ics->swb_sizes[g]; |
| 326 | 323 | } |
| 327 | − for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--); | |
| 324 | + for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--) | |
| 325 | + ; | |
| 328 | 326 | maxsfb = FFMAX(maxsfb, cmaxsfb); |
| 329 | 327 | } |
| 330 | 328 | ics->max_sfb = maxsfb; |
| @@ -352,7 +350,8 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in · 21 unmodified lines | ||
| 352 | 350 | ics1->max_sfb = ics0->max_sfb; |
| 353 | 351 | for (w = 0; w < ics0->num_windows*16; w += 16) |
| 354 | 352 | for (i = 0; i < ics0->max_sfb; i++) |
| 355 | − if (cpe->ms_mask[w+i]) msc++; | |
| 353 | + if (cpe->ms_mask[w+i]) | |
| 354 | + msc++; | |
| 356 | 355 | if (msc == 0 || ics0->max_sfb == 0) |
| 357 | 356 | cpe->ms_mode = 0; |
| 358 | 357 | else |
| @@ -367,9 +366,8 @@ static void encode_band_info(AACEncContext *s, SingleChannelElement *sce) · 8 unmodified lines | ||
| 367 | 366 | { |
| 368 | 367 | int w; |
| 369 | 368 | |
| 370 | − for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { | |
| 369 | + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) | |
| 371 | 370 | s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda); |
| 372 | − } | |
| 373 | 371 | } |
| 374 | 372 | |
| 375 | 373 | /** |
| @@ -427,13 +425,12 @@ static void encode_spectral_coeffs(AACEncContext *s, SingleChannelElement *sce) · 51 unmodified lines | ||
| 427 | 425 | start += sce->ics.swb_sizes[i]; |
| 428 | 426 | continue; |
| 429 | 427 | } |
| 430 | − for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) { | |
| 428 | + for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) | |
| 431 | 429 | s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128, |
| 432 | 430 | sce->ics.swb_sizes[i], |
| 433 | 431 | sce->sf_idx[w*16 + i], |
| 434 | 432 | sce->band_type[w*16 + i], |
| 435 | 433 | s->lambda); |
| 436 | − } | |
| 437 | 434 | start += sce->ics.swb_sizes[i]; |
| 438 | 435 | } |
| 439 | 436 | } |
| @@ -514,9 +511,8 @@ static int aac_encode_frame(AVCodecContext *avctx, · 74 unmodified lines | ||
| 514 | 511 | } |
| 515 | 512 | |
| 516 | 513 | init_put_bits(&s->pb, frame, buf_size*8); |
| 517 | − if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) { | |
| 514 | + if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) | |
| 518 | 515 | put_bitstream_info(avctx, s, LIBAVCODEC_IDENT); |
| 519 | − } | |
| 520 | 516 | start_ch = 0; |
| 521 | 517 | memset(chan_el_counter, 0, sizeof(chan_el_counter)); |
| 522 | 518 | for (i = 0; i < chan_map[0]; i++) { |
| @@ -526,7 +522,8 @@ static int aac_encode_frame(AVCodecContext *avctx, · 3 unmodified lines | ||
| 526 | 522 | cpe = &s->cpe[i]; |
| 527 | 523 | samples2 = samples + start_ch; |
| 528 | 524 | la = samples2 + 1024 * avctx->channels + start_ch; |
| 529 | − if (!data) la = NULL; | |
| 525 | + if (!data) | |
| 526 | + la = NULL; | |
| 530 | 527 | for (j = 0; j < chans; j++) { |
| 531 | 528 | IndividualChannelStream *ics = &cpe->ch[j].ics; |
| 532 | 529 | int k; |
| @@ -588,10 +585,9 @@ static int aac_encode_frame(AVCodecContext *avctx, · 55 unmodified lines | ||
| 588 | 585 | s->lambda *= ratio; |
| 589 | 586 | } |
| 590 | 587 | |
| 591 | − if (avctx->frame_bits > 6144*avctx->channels) { | |
| 588 | + if (avctx->frame_bits > 6144*avctx->channels) | |
| 592 | 589 | av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n", |
| 593 | 590 | avctx->frame_bits, 6144*avctx->channels); |
| 594 | − } | |
| 595 | 591 | |
| 596 | 592 | if (!data) |
| 597 | 593 | s->last_frame = 1; |
| @@ -140,9 +140,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { · 139 unmodified lines | ||
| 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, · 134 unmodified lines | ||
| 283 | 282 | //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation" |
| 284 | 283 | for (w = 0; w < wi->num_windows*16; w += 16) { |
| 285 | 284 | Psy3gppBand *band = &pch->band[w]; |
| 286 | − for (g = 1; g < num_bands; g++) { | |
| 285 | + for (g = 1; g < num_bands; g++) | |
| 287 | 286 | 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--) { | |
| 287 | + for (g = num_bands - 2; g >= 0; g--) | |
| 290 | 288 | band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]); |
| 291 | − } | |
| 292 | 289 | for (g = 0; g < num_bands; g++) { |
| 293 | 290 | band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]); |
| 294 | − if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE) { | |
| 291 | + if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE) | |
| 295 | 292 | band[g].thr_quiet = fmaxf(PSY_3GPP_RPEMIN*band[g].thr_quiet, |
| 296 | 293 | fminf(band[g].thr_quiet, |
| 297 | 294 | PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet)); |
| 298 | − } | |
| 299 | 295 | band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25); |
| 300 | 296 | |
| 301 | 297 | ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr; |
| @@ -105,16 +105,14 @@ void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, · 104 unmodified lines | ||
| 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 | |