aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/wma.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2009-06-12 13:12:13 +0000
committerDiego Biurrun <diego@biurrun.de>2009-06-12 13:12:13 +0000
commitae1374ce106d079f3f55085ffb1de1bb5677c979 (patch)
tree8528da7cb422e4314a2836a63efc609ef65c652f /libavcodec/wma.c
parent761c8c923ea918c15fc503269a370d040f0d884d (diff)
downloadffmpeg-ae1374ce106d079f3f55085ffb1de1bb5677c979.tar.gz
cosmetics: Prettyprint and reformat wma.c closer to K&R style.
Originally committed as revision 19165 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/wma.c')
-rw-r--r--libavcodec/wma.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/libavcodec/wma.c b/libavcodec/wma.c
index ff01f49b5c..053be0a3ff 100644
--- a/libavcodec/wma.c
+++ b/libavcodec/wma.c
@@ -28,41 +28,41 @@
/* XXX: use same run/length optimization as mpeg decoders */
//FIXME maybe split decode / encode or pass flag
-static void init_coef_vlc(VLC *vlc,
- uint16_t **prun_table, uint16_t **plevel_table, uint16_t **pint_table,
+static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
+ uint16_t **plevel_table, uint16_t **pint_table,
const CoefVLCTable *vlc_table)
{
int n = vlc_table->n;
- const uint8_t *table_bits = vlc_table->huffbits;
- const uint32_t *table_codes = vlc_table->huffcodes;
+ const uint8_t *table_bits = vlc_table->huffbits;
+ const uint32_t *table_codes = vlc_table->huffcodes;
const uint16_t *levels_table = vlc_table->levels;
uint16_t *run_table, *level_table, *int_table;
int i, l, j, k, level;
init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, 0);
- run_table = av_malloc(n * sizeof(uint16_t));
+ run_table = av_malloc(n * sizeof(uint16_t));
level_table = av_malloc(n * sizeof(uint16_t));
- int_table = av_malloc(n * sizeof(uint16_t));
+ int_table = av_malloc(n * sizeof(uint16_t));
i = 2;
level = 1;
k = 0;
while (i < n) {
- int_table[k]= i;
+ int_table[k] = i;
l = levels_table[k++];
- for(j=0;j<l;j++) {
- run_table[i] = j;
+ for (j = 0; j < l; j++) {
+ run_table[i] = j;
level_table[i] = level;
i++;
}
level++;
}
- *prun_table = run_table;
+ *prun_table = run_table;
*plevel_table = level_table;
- *pint_table= int_table;
+ *pint_table = int_table;
}
-int ff_wma_init(AVCodecContext * avctx, int flags2)
+int ff_wma_init(AVCodecContext *avctx, int flags2)
{
WMACodecContext *s = avctx->priv_data;
int i;
@@ -71,14 +71,14 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
int sample_rate1;
int coef_vlc_table;
- if( avctx->sample_rate<=0 || avctx->sample_rate>50000
- || avctx->channels<=0 || avctx->channels>8
- || avctx->bit_rate<=0)
+ if ( avctx->sample_rate <= 0 || avctx->sample_rate > 50000
+ || avctx->channels <= 0 || avctx->channels > 8
+ || avctx->bit_rate <= 0)
return -1;
s->sample_rate = avctx->sample_rate;
s->nb_channels = avctx->channels;
- s->bit_rate = avctx->bit_rate;
+ s->bit_rate = avctx->bit_rate;
s->block_align = avctx->block_align;
dsputil_init(&s->dsp, avctx);
@@ -92,7 +92,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
/* compute MDCT block size */
if (s->sample_rate <= 16000) {
s->frame_len_bits = 9;
- } else if (s->sample_rate <= 22050 ||
+ } else if ( s->sample_rate <= 22050 ||
(s->sample_rate <= 32000 && s->version == 1)) {
s->frame_len_bits = 10;
} else {
@@ -177,12 +177,12 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
}
dprintf(s->avctx, "flags2=0x%x\n", flags2);
dprintf(s->avctx, "version=%d channels=%d sample_rate=%d bitrate=%d block_align=%d\n",
- s->version, s->nb_channels, s->sample_rate, s->bit_rate,
- s->block_align);
+ s->version, s->nb_channels, s->sample_rate, s->bit_rate,
+ s->block_align);
dprintf(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
- bps, bps1, high_freq, s->byte_offset_bits);
+ bps, bps1, high_freq, s->byte_offset_bits);
dprintf(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
- s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
+ s->use_noise_coding, s->use_exp_vlc, s->nb_block_sizes);
/* compute the scale factor band sizes for each MDCT block size */
{
@@ -194,15 +194,15 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
} else {
s->coefs_start = 0;
}
- for(k = 0; k < s->nb_block_sizes; k++) {
+ for (k = 0; k < s->nb_block_sizes; k++) {
block_len = s->frame_len >> k;
if (s->version == 1) {
lpos = 0;
- for(i=0;i<25;i++) {
+ for (i = 0; i < 25; i++) {
a = wma_critical_freqs[i];
b = s->sample_rate;
- pos = ((block_len * 2 * a) + (b >> 1)) / b;
+ pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
s->exponent_bands[0][i] = pos - lpos;
@@ -227,16 +227,16 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
}
if (table) {
n = *table++;
- for(i=0;i<n;i++)
+ for (i = 0; i < n; i++)
s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n;
} else {
j = 0;
lpos = 0;
- for(i=0;i<25;i++) {
+ for (i = 0; i < 25; i++) {
a = wma_critical_freqs[i];
b = s->sample_rate;
- pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
+ pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
pos = block_len;
@@ -258,7 +258,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
n = s->exponent_sizes[k];
j = 0;
pos = 0;
- for(i=0;i<n;i++) {
+ for (i = 0; i < n; i++) {
int start, end;
start = pos;
pos += s->exponent_bands[k][i];
@@ -273,11 +273,11 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
s->exponent_high_sizes[k] = j;
#if 0
tprintf(s->avctx, "%5d: coefs_end=%d high_band_start=%d nb_high_bands=%d: ",
- s->frame_len >> k,
- s->coefs_end[k],
- s->high_band_start[k],
- s->exponent_high_sizes[k]);
- for(j=0;j<s->exponent_high_sizes[k];j++)
+ s->frame_len >> k,
+ s->coefs_end[k],
+ s->high_band_start[k],
+ s->exponent_high_sizes[k]);
+ for (j = 0; j < s->exponent_high_sizes[k]; j++)
tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
tprintf(s->avctx, "\n");
#endif
@@ -287,11 +287,11 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
#ifdef TRACE
{
int i, j;
- for(i = 0; i < s->nb_block_sizes; i++) {
+ for (i = 0; i < s->nb_block_sizes; i++) {
tprintf(s->avctx, "%5d: n=%2d:",
- s->frame_len >> i,
- s->exponent_sizes[i]);
- for(j=0;j<s->exponent_sizes[i];j++)
+ s->frame_len >> i,
+ s->exponent_sizes[i]);
+ for (j = 0; j < s->exponent_sizes[i]; j++)
tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
tprintf(s->avctx, "\n");
}
@@ -299,7 +299,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
#endif
/* init MDCT windows : simple sinus window */
- for(i = 0; i < s->nb_block_sizes; i++) {
+ for (i = 0; i < s->nb_block_sizes; i++) {
int n;
n = 1 << (s->frame_len_bits - i);
ff_sine_window_init(ff_sine_windows[s->frame_len_bits - i - 7], n);
@@ -317,7 +317,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
s->noise_mult = 0.04;
#ifdef TRACE
- for(i=0;i<NOISE_TAB_SIZE;i++)
+ for (i = 0; i < NOISE_TAB_SIZE; i++)
s->noise_table[i] = 1.0 * s->noise_mult;
#else
{
@@ -325,7 +325,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
float norm;
seed = 1;
norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult;
- for(i=0;i<NOISE_TAB_SIZE;i++) {
+ for (i = 0; i < NOISE_TAB_SIZE; i++) {
seed = seed * 314159 + 1;
s->noise_table[i] = (float)((int)seed) * norm;
}
@@ -351,7 +351,8 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
return 0;
}
-int ff_wma_total_gain_to_bits(int total_gain){
+int ff_wma_total_gain_to_bits(int total_gain)
+{
if (total_gain < 15) return 13;
else if (total_gain < 32) return 12;
else if (total_gain < 40) return 11;
@@ -364,7 +365,7 @@ int ff_wma_end(AVCodecContext *avctx)
WMACodecContext *s = avctx->priv_data;
int i;
- for(i = 0; i < s->nb_block_sizes; i++)
+ for (i = 0; i < s->nb_block_sizes; i++)
ff_mdct_end(&s->mdct_ctx[i]);
if (s->use_exp_vlc) {
@@ -373,7 +374,7 @@ int ff_wma_end(AVCodecContext *avctx)
if (s->use_noise_coding) {
free_vlc(&s->hgain_vlc);
}
- for(i = 0;i < 2; i++) {
+ for (i = 0; i < 2; i++) {
free_vlc(&s->coef_vlc[i]);
av_free(s->run_table[i]);
av_free(s->level_table[i]);