[FFmpeg-cvslog] r19378 - in trunk/libavcodec: aaccoder.c aacenc.c aacpsy.c psymodel.c

diego subversion
Wed Jul 8 23:36:33 CEST 2009


Author: diego
Date: Wed Jul  8 23:36:33 2009
New Revision: 19378

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

Modified:
   trunk/libavcodec/aaccoder.c
   trunk/libavcodec/aacenc.c
   trunk/libavcodec/aacpsy.c
   trunk/libavcodec/psymodel.c

Modified: trunk/libavcodec/aaccoder.c
==============================================================================
--- trunk/libavcodec/aaccoder.c	Wed Jul  8 23:16:06 2009	(r19377)
+++ trunk/libavcodec/aaccoder.c	Wed Jul  8 23:36:33 2009	(r19378)
@@ -84,9 +84,8 @@ static void abs_pow34_v(float *out, cons
 {
 #ifndef USE_REALLY_FULL_SEARCH
     int i;
-    for (i = 0; i < size; i++) {
+    for (i = 0; i < size; i++)
         out[i] = pow(fabsf(in[i]), 0.75);
-    }
 #endif /* USE_REALLY_FULL_SEARCH */
 }
 
@@ -141,9 +140,8 @@ static float quantize_band_cost(struct A
 #ifndef USE_REALLY_FULL_SEARCH
         int (*quants)[2] = &s->qcoefs[i];
         mincost = 0.0f;
-        for (j = 0; j < dim; j++) {
+        for (j = 0; j < dim; j++)
             mincost += in[i+j]*in[i+j]*lambda;
-        }
         minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
         minbits = ff_aac_spectral_bits[cb-1][minidx];
         mincost += minbits;
@@ -256,9 +254,8 @@ static void quantize_and_encode_band(str
 #ifndef USE_REALLY_FULL_SEARCH
         int (*quants)[2] = &s->qcoefs[i];
         mincost = 0.0f;
-        for (j = 0; j < dim; j++) {
+        for (j = 0; j < dim; j++)
             mincost += in[i+j]*in[i+j]*lambda;
-        }
         minidx = IS_CODEBOOK_UNSIGNED(cb) ? 0 : 40;
         minbits = ff_aac_spectral_bits[cb-1][minidx];
         mincost += minbits;
@@ -429,10 +426,9 @@ static void encode_window_bands_info(AAC
     //convert resulting path from backward-linked list
     stack_len = 0;
     idx       = 0;
-    for (cb = 1; cb < 12; cb++) {
+    for (cb = 1; cb < 12; cb++)
         if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
             idx = cb;
-    }
     ppos = max_sfb;
     while (ppos > 0) {
         cb = idx;
@@ -523,7 +519,8 @@ static void search_for_quantizers_anmr(A
                 nz = 1;
                 for (i = 0; i < sce->ics.swb_sizes[g]; i++) {
                     float t = fabsf(coefs[w2*128+i]);
-                    if (t > 0.0f) qmin = fminf(qmin, t);
+                    if (t > 0.0f)
+                        qmin = fminf(qmin, t);
                     qmax = fmaxf(qmax, t);
                 }
             }
@@ -540,10 +537,9 @@ static void search_for_quantizers_anmr(A
                     for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
                         FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
                         int cb;
-                        for (cb = 0; cb <= ESC_BT; cb++) {
+                        for (cb = 0; cb <= ESC_BT; cb++)
                             dists[cb] += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g],
                                                             q, cb, lambda / band->threshold, INFINITY, NULL);
-                        }
                     }
                     dist = dists[0];
                     for (i = 1; i <= ESC_BT; i++)
@@ -725,22 +721,19 @@ static void search_for_quantizers_twoloo
                 }
             }
             if (tbits > destbits) {
-                for (i = 0; i < 128; i++) {
-                    if (sce->sf_idx[i] < 218 - qstep) {
+                for (i = 0; i < 128; i++)
+                    if (sce->sf_idx[i] < 218 - qstep)
                         sce->sf_idx[i] += qstep;
-                    }
-                }
             } else {
-                for (i = 0; i < 128; i++) {
-                    if (sce->sf_idx[i] > 60 - qstep) {
+                for (i = 0; i < 128; i++)
+                    if (sce->sf_idx[i] > 60 - qstep)
                         sce->sf_idx[i] -= qstep;
-                    }
-                }
             }
             qstep >>= 1;
             if (!qstep && tbits > destbits*1.02)
                 qstep = 1;
-            if (sce->sf_idx[0] >= 217)break;
+            if (sce->sf_idx[0] >= 217)
+                break;
         } while (qstep);
 
         fflag = 0;
@@ -916,7 +909,8 @@ static void search_for_quantizers_faac(A
         else
             minq = FFMIN(minq, sce->sf_idx[i]);
     }
-    if (minq == INT_MAX) minq = 0;
+    if (minq == INT_MAX)
+        minq = 0;
     minq = FFMIN(minq, SCALE_MAX_POS);
     maxsf = FFMIN(minq + SCALE_MAX_DIFF, SCALE_MAX_POS);
     for (i = 126; i >= 0; i--) {
@@ -951,7 +945,8 @@ static void search_for_quantizers_fast(A
         }
     }
     for (i = 0; i < 128; i++) {
-        sce->sf_idx[i] = 140;//av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1);
+        sce->sf_idx[i] = 140;
+        //av_clip(sce->sf_idx[i], minq, minq + SCALE_MAX_DIFF - 1);
     }
     //set the same quantizers inside window groups
     for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])

Modified: trunk/libavcodec/aacenc.c
==============================================================================
--- trunk/libavcodec/aacenc.c	Wed Jul  8 23:16:06 2009	(r19377)
+++ trunk/libavcodec/aacenc.c	Wed Jul  8 23:36:33 2009	(r19378)
@@ -276,9 +276,8 @@ static void put_ics_info(AACEncContext *
         put_bits(&s->pb, 1, 0);            // no prediction
     } else {
         put_bits(&s->pb, 4, info->max_sfb);
-        for (w = 1; w < 8; w++) {
+        for (w = 1; w < 8; w++)
             put_bits(&s->pb, 1, !info->group_len[w]);
-        }
     }
 }
 
@@ -291,12 +290,10 @@ static void encode_ms_info(PutBitContext
     int i, w;
 
     put_bits(pb, 2, cpe->ms_mode);
-    if (cpe->ms_mode == 1) {
-        for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w]) {
+    if (cpe->ms_mode == 1)
+        for (w = 0; w < cpe->ch[0].ics.num_windows; w += cpe->ch[0].ics.group_len[w])
             for (i = 0; i < cpe->ch[0].ics.max_sfb; i++)
                 put_bits(pb, 1, cpe->ms_mask[w*16 + i]);
-        }
-    }
 }
 
 /**
@@ -324,7 +321,8 @@ static void adjust_frame_information(AAC
                 }
                 start += ics->swb_sizes[g];
             }
-            for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--);
+            for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w+cmaxsfb-1]; cmaxsfb--)
+                ;
             maxsfb = FFMAX(maxsfb, cmaxsfb);
         }
         ics->max_sfb = maxsfb;
@@ -352,7 +350,8 @@ static void adjust_frame_information(AAC
         ics1->max_sfb = ics0->max_sfb;
         for (w = 0; w < ics0->num_windows*16; w += 16)
             for (i = 0; i < ics0->max_sfb; i++)
-                if (cpe->ms_mask[w+i]) msc++;
+                if (cpe->ms_mask[w+i])
+                    msc++;
         if (msc == 0 || ics0->max_sfb == 0)
             cpe->ms_mode = 0;
         else
@@ -367,9 +366,8 @@ static void encode_band_info(AACEncConte
 {
     int w;
 
-    for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
+    for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w])
         s->coder->encode_window_bands_info(s, sce, w, sce->ics.group_len[w], s->lambda);
-    }
 }
 
 /**
@@ -427,13 +425,12 @@ static void encode_spectral_coeffs(AACEn
                 start += sce->ics.swb_sizes[i];
                 continue;
             }
-            for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) {
+            for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++)
                 s->coder->quantize_and_encode_band(s, &s->pb, sce->coeffs + start + w2*128,
                                                    sce->ics.swb_sizes[i],
                                                    sce->sf_idx[w*16 + i],
                                                    sce->band_type[w*16 + i],
                                                    s->lambda);
-            }
             start += sce->ics.swb_sizes[i];
         }
     }
@@ -514,9 +511,8 @@ static int aac_encode_frame(AVCodecConte
     }
 
     init_put_bits(&s->pb, frame, buf_size*8);
-    if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) {
+    if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
         put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
-    }
     start_ch = 0;
     memset(chan_el_counter, 0, sizeof(chan_el_counter));
     for (i = 0; i < chan_map[0]; i++) {
@@ -526,7 +522,8 @@ static int aac_encode_frame(AVCodecConte
         cpe      = &s->cpe[i];
         samples2 = samples + start_ch;
         la       = samples2 + 1024 * avctx->channels + start_ch;
-        if (!data) la = NULL;
+        if (!data)
+            la = NULL;
         for (j = 0; j < chans; j++) {
             IndividualChannelStream *ics = &cpe->ch[j].ics;
             int k;
@@ -588,10 +585,9 @@ static int aac_encode_frame(AVCodecConte
         s->lambda *= ratio;
     }
 
-    if (avctx->frame_bits > 6144*avctx->channels) {
+    if (avctx->frame_bits > 6144*avctx->channels)
         av_log(avctx, AV_LOG_ERROR, "input buffer violation %d > %d.\n",
                avctx->frame_bits, 6144*avctx->channels);
-    }
 
     if (!data)
         s->last_frame = 1;

Modified: trunk/libavcodec/aacpsy.c
==============================================================================
--- trunk/libavcodec/aacpsy.c	Wed Jul  8 23:16:06 2009	(r19377)
+++ trunk/libavcodec/aacpsy.c	Wed Jul  8 23:36:33 2009	(r19378)
@@ -140,9 +140,8 @@ static av_cold int psy_3gpp_init(FFPsyCo
         start = 0;
         for (g = 0; g < ctx->num_bands[j]; g++) {
             minscale = ath(ctx->avctx->sample_rate * start / 1024.0, ATH_ADD);
-            for (i = 1; i < ctx->bands[j][g]; i++) {
+            for (i = 1; i < ctx->bands[j][g]; i++)
                 minscale = fminf(minscale, ath(ctx->avctx->sample_rate * (start + i) / 1024.0 / 2.0, ATH_ADD));
-            }
             coeffs->ath[g] = minscale - minath;
             start += ctx->bands[j][g];
         }
@@ -283,19 +282,16 @@ static void psy_3gpp_analyze(FFPsyContex
     //modify thresholds - spread, threshold in quiet - 5.4.3 "Spreaded Energy Calculation"
     for (w = 0; w < wi->num_windows*16; w += 16) {
         Psy3gppBand *band = &pch->band[w];
-        for (g = 1; g < num_bands; g++) {
+        for (g = 1; g < num_bands; g++)
             band[g].thr = FFMAX(band[g].thr, band[g-1].thr * coeffs->spread_low[g-1]);
-        }
-        for (g = num_bands - 2; g >= 0; g--) {
+        for (g = num_bands - 2; g >= 0; g--)
             band[g].thr = FFMAX(band[g].thr, band[g+1].thr * coeffs->spread_hi [g]);
-        }
         for (g = 0; g < num_bands; g++) {
             band[g].thr_quiet = FFMAX(band[g].thr, coeffs->ath[g]);
-            if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE) {
+            if (wi->num_windows != 8 && wi->window_type[1] != EIGHT_SHORT_SEQUENCE)
                 band[g].thr_quiet = fmaxf(PSY_3GPP_RPEMIN*band[g].thr_quiet,
                                           fminf(band[g].thr_quiet,
                                           PSY_3GPP_RPELEV*pch->prev_band[w+g].thr_quiet));
-            }
             band[g].thr = FFMAX(band[g].thr, band[g].thr_quiet * 0.25);
 
             ctx->psy_bands[channel*PSY_MAX_BANDS+w+g].threshold = band[g].thr;

Modified: trunk/libavcodec/psymodel.c
==============================================================================
--- trunk/libavcodec/psymodel.c	Wed Jul  8 23:16:06 2009	(r19377)
+++ trunk/libavcodec/psymodel.c	Wed Jul  8 23:36:33 2009	(r19378)
@@ -105,16 +105,14 @@ void ff_psy_preprocess(struct FFPsyPrepr
 {
     int ch, i;
     if (ctx->fstate) {
-        for (ch = 0; ch < channels; ch++) {
+        for (ch = 0; ch < channels; ch++)
             ff_iir_filter(ctx->fcoeffs, ctx->fstate[tag+ch], ctx->avctx->frame_size,
                           audio + ch, ctx->avctx->channels,
                           dest  + ch, ctx->avctx->channels);
-        }
     } else {
-        for (ch = 0; ch < channels; ch++) {
+        for (ch = 0; ch < channels; ch++)
             for (i = 0; i < ctx->avctx->frame_size; i++)
                 dest[i*ctx->avctx->channels + ch] = audio[i*ctx->avctx->channels + ch];
-        }
     }
 }
 



More information about the ffmpeg-cvslog mailing list