History

cosmetics: Remove unnecessary {} around if/for blocks; move statements after if/for to the next line.

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

Diego Biurrun committed 17 years ago

Commit c8f47d81 parent 99d61d34 files · +36 −51Browse files

Unified · Split

4 files
  1. libavcodec/aaccoder.c +17 −22
  2. libavcodec/aacenc.c +13 −17
  3. libavcodec/aacpsy.c +4 −8
  4. libavcodec/psymodel.c +2 −4
libavcodec/aaccoder.c+17−22
@@ -84,9 +84,8 @@ static void abs_pow34_v(float *out, const float *in, const int size) · 83 unmodified lines
84{84{
85#ifndef USE_REALLY_FULL_SEARCH85#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
@@ -141,9 +140,8 @@ static float quantize_band_cost(struct AACEncContext *s, const float *in, · 48 unmodified lines
141#ifndef USE_REALLY_FULL_SEARCH140#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;
@@ -256,9 +254,8 @@ static void quantize_and_encode_band(struct AACEncContext *s, PutBitContext *pb, · 106 unmodified lines
256#ifndef USE_REALLY_FULL_SEARCH254#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;
@@ -429,10 +426,9 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce · 164 unmodified lines
429 //convert resulting path from backward-linked list426 //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;
@@ -523,7 +519,8 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 84 unmodified lines
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 }
@@ -540,10 +537,9 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, · 10 unmodified lines
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++)
@@ -725,22 +721,19 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 175 unmodified lines
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;
@@ -916,7 +909,8 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, · 169 unmodified lines
916 else909 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--) {
@@ -951,7 +945,8 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s, · 28 unmodified lines
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 groups951 //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])
libavcodec/aacenc.c+13−17
@@ -276,9 +276,8 @@ static void put_ics_info(AACEncContext *s, IndividualChannelStream *info) · 275 unmodified lines
276 put_bits(&s->pb, 1, 0); // no prediction276 put_bits(&s->pb, 1, 0); // no prediction
277 } else {277 } else {
278 put_bits(&s->pb, 4, info->max_sfb);278 put_bits(&s->pb, 4, info->max_sfb);
279 for (w = 1; w < 8; w++) {279 for (w = 1; w < 8; w++)
280 put_bits(&s->pb, 1, !info->group_len[w]);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 int i, w;290 int i, w;
292 291
293 put_bits(pb, 2, cpe->ms_mode);292 put_bits(pb, 2, cpe->ms_mode);
294 if (cpe->ms_mode == 1) {293 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 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++)295 for (i = 0; i < cpe->ch[0].ics.max_sfb; i++)
297 put_bits(pb, 1, cpe->ms_mask[w*16 + i]);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 start += ics->swb_sizes[g];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 maxsfb = FFMAX(maxsfb, cmaxsfb);326 maxsfb = FFMAX(maxsfb, cmaxsfb);
329 }327 }
330 ics->max_sfb = maxsfb;328 ics->max_sfb = maxsfb;
@@ -352,7 +350,8 @@ static void adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in · 21 unmodified lines
352 ics1->max_sfb = ics0->max_sfb;350 ics1->max_sfb = ics0->max_sfb;
353 for (w = 0; w < ics0->num_windows*16; w += 16)351 for (w = 0; w < ics0->num_windows*16; w += 16)
354 for (i = 0; i < ics0->max_sfb; i++)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 if (msc == 0 || ics0->max_sfb == 0)355 if (msc == 0 || ics0->max_sfb == 0)
357 cpe->ms_mode = 0;356 cpe->ms_mode = 0;
358 else357 else
@@ -367,9 +366,8 @@ static void encode_band_info(AACEncContext *s, SingleChannelElement *sce) · 8 unmodified lines
367{366{
368 int w;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 s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda);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 start += sce->ics.swb_sizes[i];425 start += sce->ics.swb_sizes[i];
428 continue;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 s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128,429 s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128,
432 sce->ics.swb_sizes[i],430 sce->ics.swb_sizes[i],
433 sce->sf_idx[w*16 + i],431 sce->sf_idx[w*16 + i],
434 sce->band_type[w*16 + i],432 sce->band_type[w*16 + i],
435 s->lambda);433 s->lambda);
436 }
437 start += sce->ics.swb_sizes[i];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 init_put_bits(&s->pb, frame, buf_size*8);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 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);515 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
519 }
520 start_ch = 0;516 start_ch = 0;
521 memset(chan_el_counter, 0, sizeof(chan_el_counter));517 memset(chan_el_counter, 0, sizeof(chan_el_counter));
522 for (i = 0; i < chan_map[0]; i++) {518 for (i = 0; i < chan_map[0]; i++) {
@@ -526,7 +522,8 @@ static int aac_encode_frame(AVCodecContext *avctx, · 3 unmodified lines
526 cpe = &s->cpe[i];522 cpe = &s->cpe[i];
527 samples2 = samples + start_ch;523 samples2 = samples + start_ch;
528 la = samples2 + 1024 * avctx->channels + start_ch;524 la = samples2 + 1024 * avctx->channels + start_ch;
529 if (!data) la = NULL;525 if (!data)
526 la = NULL;
530 for (j = 0; j < chans; j++) {527 for (j = 0; j < chans; j++) {
531 IndividualChannelStream *ics = &cpe->ch[j].ics;528 IndividualChannelStream *ics = &cpe->ch[j].ics;
532 int k;529 int k;
@@ -588,10 +585,9 @@ static int aac_encode_frame(AVCodecContext *avctx, · 55 unmodified lines
588 s->lambda *= ratio;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 av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n",589 av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n",
593 avctx->frame_bits, 6144*avctx->channels);590 avctx->frame_bits, 6144*avctx->channels);
594 }
595 591
596 if (!data)592 if (!data)
597 s->last_frame = 1;593 s->last_frame = 1;
libavcodec/aacpsy.c+4−8
@@ -140,9 +140,8 @@ static av_cold int psy_3gpp_init(FFPsyContext *ctx) { · 139 unmodified lines
140 start = 0;140 start = 0;
141 for (g = 0; g < ctx->num_bands[j]; g++) {141 for (g = 0; g < ctx->num_bands[j]; g++) {
142 minscale = ath(ctx->avctx->sample_rate * start / 1024.0, ATH_ADD);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 minscale = fminf(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD));144 minscale = fminf(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD));
145 }
146 coeffs->ath[g] = minscale - minath;145 coeffs->ath[g] = minscale - minath;
147 start += ctx->bands[j][g];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 //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"282 //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"
284 for (w = 0; w < wi->num_windows*16; w += 16) {283 for (w = 0; w < wi->num_windows*16; w += 16) {
285 Psy3gppBand *band = &pch->band[w];284 Psy3gppBand *band = &pch->band[w];
286 for (g = 1; g < num_bands; g++) {285 for (g = 1; g < num_bands; g++)
287 band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]);286 band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]);
288 }287 for (g = num_bands - 2; g >= 0; g--)
289 for (g = num_bands - 2; g >= 0; g--) {
290 band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]);288 band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]);
291 }
292 for (g = 0; g < num_bands; g++) {289 for (g = 0; g < num_bands; g++) {
293 band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]);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 band[g].thr_quiet = fmaxf(PSY_3GPP_RPEMIN*band[g].thr_quiet,292 band[g].thr_quiet = fmaxf(PSY_3GPP_RPEMIN*band[g].thr_quiet,
296 fminf(band[g].thr_quiet,293 fminf(band[g].thr_quiet,
297 PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));294 PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
298 }
299 band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25);295 band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25);
300 296
301 ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr;297 ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr;
libavcodec/psymodel.c+2−4
@@ -105,16 +105,14 @@ void ff_psy_preprocess(struct FFPsyPreprocessContext *ctx, · 104 unmodified lines
105{105{
106 int ch, i;106 int ch, i;
107 if (ctx->fstate) {107 if (ctx->fstate) {
108 for (ch = 0; ch < channels; ch++) {108 for (ch = 0; ch < channels; ch++)
109 ff_iir_filter(ctx->fcoeffs, ctx->fstate[tag+ch], ctx->avctx->frame_size,109 ff_iir_filter(ctx->fcoeffs, ctx->fstate[tag+ch], ctx->avctx->frame_size,
110 audio + ch, ctx->avctx->channels,110 audio + ch, ctx->avctx->channels,
111 dest + ch, ctx->avctx->channels);111 dest + ch, ctx->avctx->channels);
112 }
113 } else {112 } else {
114 for (ch = 0; ch < channels; ch++) {113 for (ch = 0; ch < channels; ch++)
115 for (i = 0; i < ctx->avctx->frame_size; i++)114 for (i = 0; i < ctx->avctx->frame_size; i++)
116 dest[i*ctx->avctx->channels + ch] = audio[i*ctx->avctx->channels + ch];115 dest[i*ctx->avctx->channels + ch] = audio[i*ctx->avctx->channels + ch];
117 }
118 }116 }
119}117}
120 118

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