---
libavcodec/ac3enc.c | 58 ++++++++++++++++++++------------------------------
1 files changed, 23 insertions(+), 35 deletions(-)
diff --git libavcodec/ac3enc.c libavcodec/ac3enc.c
index 0ac0f94..e1af91d 100644
--- libavcodec/ac3enc.c
+++ libavcodec/ac3enc.c
@@ -101,7 +101,7 @@ static av_cold void fft_init(int ln)
n = 1 << ln;
- for (i = 0; i < (n/2); i++) {
+ for (i = 0; i < n/2; i++) {
alpha = 2 * M_PI * (float)i / (float)n;
costab[i] = FIX15(cos(alpha));
sintab[i] = FIX15(sin(alpha));
@@ -161,12 +161,12 @@ static void fft(IComplex *z, int ln)
/* pass 0 */
p = &z[0];
- j = (np >> 1);
+ j = np >> 1;
do {
BF(p[0].re, p[0].im, p[1].re, p[1].im,
p[0].re, p[0].im, p[1].re, p[1].im);
- p+=2;
- } while (--j != 0);
+ p += 2;
+ } while (j--);
/* pass 1 */
@@ -178,7 +178,7 @@ static void fft(IComplex *z, int ln)
BF(p[1].re, p[1].im, p[3].re, p[3].im,
p[1].re, p[1].im, p[3].im, -p[3].re);
p += 4;
- } while (--j != 0);
+ } while (j--);
/* pass 2 .. ln-1 */
@@ -188,8 +188,7 @@ static void fft(IComplex *z, int ln)
do {
p = z;
q = z + nloops;
- for (j = 0; j < nblocks; ++j) {
-
+ for (j = 0; j < nblocks; j++) {
BF(p->re, p->im, q->re, q->im,
p->re, p->im, q->re, q->im);
@@ -220,7 +219,7 @@ static void mdct512(int32_t *out, int16_t *in)
/* shift to simplify computations */
for (i = 0; i < MDCT_SAMPLES/4; i++)
rot[i] = -in[i + 3*MDCT_SAMPLES/4];
- for (i = MDCT_SAMPLES/4; i < MDCT_SAMPLES; i++)
+ for (; i < MDCT_SAMPLES; i++)
rot[i] = in[i - MDCT_SAMPLES/4];
/* pre rotation */
@@ -247,9 +246,8 @@ static int calc_exp_diff(uint8_t *exp1, uint8_t *exp2, int n)
{
int sum, i;
sum = 0;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++)
sum += abs(exp1[i] - exp2[i]);
- }
return sum;
}
@@ -359,18 +357,16 @@ static int encode_exp(uint8_t encoded_exp[AC3_MAX_COEFS],
encoded_exp[0] = exp1[0];
k = 1;
for (i = 1; i <= nb_groups; i++) {
- for (j = 0; j < group_size; j++) {
+ for (j = 0; j < group_size; j++)
encoded_exp[k+j] = exp1[i];
- }
k += group_size;
}
#ifdef DEBUG
dprintf(NULL, "exponents: strategy=%s\n",
exp_strategy==EXP_D15?"D15":exp_strategy==EXP_D25?"D25":"D45");
- for (i = 0; i <= nb_groups * group_size; i++) {
+ for (i = 0; i <= nb_groups * group_size; i++)
dprintf(NULL, "%d ", encoded_exp[i]);
- }
dprintf(NULL, "\n");
#endif
@@ -607,9 +603,8 @@ static int compute_bit_allocation(AC3EncodeContext *s,
for (blk = 0; blk < AC3_MAX_BLOCKS; i++) {
for (ch = 0; ch < s->channels; ch++) {
dprintf(s->avctx, "bap[blk=%d][ch=%d]=", blk, ch);
- for (i = 0; i < s->nb_coefs[ch]; i++) {
+ for (i = 0; i < s->nb_coefs[ch]; i++)
dprintf(s->avctx, "%d ",bap[blk][ch][i]);
- }
dprintf(s->avctx, "\n");
}
}
@@ -633,10 +628,10 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
if (avcodec_channel_layout_num_channels(ch_layout) != channels)
return -1;
- s->lfe_on = !!(ch_layout & CH_LOW_FREQUENCY);
- s->channels = channels;
+ s->lfe_on = !!(ch_layout & CH_LOW_FREQUENCY);
+ s->channels = channels;
s->fbw_channels = channels - s->lfe_on;
- s->lfe_ch = s->lfe_on ? s->fbw_channels : -1;
+ s->lfe_ch = s->lfe_on ? s->fbw_channels : -1;
if (s->lfe_on)
ch_layout -= CH_LOW_FREQUENCY;
@@ -654,7 +649,7 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
return -1;
}
- s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe_on];
+ s->channel_map = ff_ac3_enc_channel_map[s->channel_mode][s->lfe_on];
*channel_layout = ch_layout;
if (s->lfe_on)
*channel_layout |= CH_LOW_FREQUENCY;
@@ -859,13 +854,11 @@ static void output_audio_block(AC3EncodeContext *s,
}
/* exponent strategy */
- for (ch = 0; ch < s->fbw_channels; ch++) {
+ for (ch = 0; ch < s->fbw_channels; ch++)
put_bits(&s->pb, 2, exp_strategy[ch]);
- }
- if (s->lfe_on) {
+ if (s->lfe_on)
put_bits(&s->pb, 1, exp_strategy[s->lfe_ch]);
- }
for (ch = 0; ch < s->fbw_channels; ch++) {
if (exp_strategy[ch] != EXP_REUSE)
@@ -1097,9 +1090,8 @@ static int log2_tab(int16_t *tab, int n)
int i, v;
v = 0;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++)
v |= abs(tab[i]);
- }
return av_log2(v);
}
@@ -1108,14 +1100,12 @@ static void lshift_tab(int16_t *tab, int n, int lshift)
int i;
if (lshift > 0) {
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++)
tab[i] <<= lshift;
- }
} else if (lshift < 0) {
lshift = -lshift;
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++)
tab[i] >>= lshift;
- }
}
}
@@ -1196,8 +1186,7 @@ static int AC3_encode_frame(AVCodecContext *avctx,
ff_ac3_window[j]) >> 15;
}
- /* Normalize the samples to use the maximum available
- precision */
+ /* Normalize the samples to use the maximum available precision */
v = 14 - log2_tab(input_samples, AC3_BLOCK_SIZE*2);
if (v < 0)
v = 0;
@@ -1207,8 +1196,7 @@ static int AC3_encode_frame(AVCodecContext *avctx,
/* do the MDCT */
mdct512(mdct_coef[i][ch], input_samples);
- /* compute "exponents". We take into account the
- normalization there */
+ /* compute "exponents". We take into account the normalization there */
for (j = 0; j < AC3_MAX_COEFS; j++) {
int e;
v = abs(mdct_coef[i][ch][j]);
@@ -1262,7 +1250,7 @@ static int AC3_encode_frame(AVCodecContext *avctx,
/* everything is known... let's output the frame */
output_frame_header(s, frame);
- for( i = 0; i < AC3_MAX_BLOCKS; i++) {
+ for (i = 0; i < AC3_MAX_BLOCKS; i++) {
output_audio_block(s, exp_strategy[i], encoded_exp[i], bap[i],
mdct_coef[i], exp_samples[i], i);
}
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc