Commit ef897dcd authored by diego's avatar diego

cosmetics: Prettyprint and reformat wma.c closer to K&R style.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@19165 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 782b4407
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
/* XXX: use same run/length optimization as mpeg decoders */ /* XXX: use same run/length optimization as mpeg decoders */
//FIXME maybe split decode / encode or pass flag //FIXME maybe split decode / encode or pass flag
static void init_coef_vlc(VLC *vlc, static void init_coef_vlc(VLC *vlc, uint16_t **prun_table,
uint16_t **prun_table, uint16_t **plevel_table, uint16_t **pint_table, uint16_t **plevel_table, uint16_t **pint_table,
const CoefVLCTable *vlc_table) const CoefVLCTable *vlc_table)
{ {
int n = vlc_table->n; int n = vlc_table->n;
...@@ -48,9 +48,9 @@ static void init_coef_vlc(VLC *vlc, ...@@ -48,9 +48,9 @@ static void init_coef_vlc(VLC *vlc,
level = 1; level = 1;
k = 0; k = 0;
while (i < n) { while (i < n) {
int_table[k]= i; int_table[k] = i;
l = levels_table[k++]; l = levels_table[k++];
for(j=0;j<l;j++) { for (j = 0; j < l; j++) {
run_table[i] = j; run_table[i] = j;
level_table[i] = level; level_table[i] = level;
i++; i++;
...@@ -59,10 +59,10 @@ static void init_coef_vlc(VLC *vlc, ...@@ -59,10 +59,10 @@ static void init_coef_vlc(VLC *vlc,
} }
*prun_table = run_table; *prun_table = run_table;
*plevel_table = level_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; WMACodecContext *s = avctx->priv_data;
int i; int i;
...@@ -71,9 +71,9 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -71,9 +71,9 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
int sample_rate1; int sample_rate1;
int coef_vlc_table; int coef_vlc_table;
if( avctx->sample_rate<=0 || avctx->sample_rate>50000 if ( avctx->sample_rate <= 0 || avctx->sample_rate > 50000
|| avctx->channels<=0 || avctx->channels>8 || avctx->channels <= 0 || avctx->channels > 8
|| avctx->bit_rate<=0) || avctx->bit_rate <= 0)
return -1; return -1;
s->sample_rate = avctx->sample_rate; s->sample_rate = avctx->sample_rate;
...@@ -92,7 +92,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -92,7 +92,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
/* compute MDCT block size */ /* compute MDCT block size */
if (s->sample_rate <= 16000) { if (s->sample_rate <= 16000) {
s->frame_len_bits = 9; 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->sample_rate <= 32000 && s->version == 1)) {
s->frame_len_bits = 10; s->frame_len_bits = 10;
} else { } else {
...@@ -194,12 +194,12 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -194,12 +194,12 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
} else { } else {
s->coefs_start = 0; 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; block_len = s->frame_len >> k;
if (s->version == 1) { if (s->version == 1) {
lpos = 0; lpos = 0;
for(i=0;i<25;i++) { for (i = 0; i < 25; i++) {
a = wma_critical_freqs[i]; a = wma_critical_freqs[i];
b = s->sample_rate; b = s->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b; pos = ((block_len * 2 * a) + (b >> 1)) / b;
...@@ -227,13 +227,13 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -227,13 +227,13 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
} }
if (table) { if (table) {
n = *table++; n = *table++;
for(i=0;i<n;i++) for (i = 0; i < n; i++)
s->exponent_bands[k][i] = table[i]; s->exponent_bands[k][i] = table[i];
s->exponent_sizes[k] = n; s->exponent_sizes[k] = n;
} else { } else {
j = 0; j = 0;
lpos = 0; lpos = 0;
for(i=0;i<25;i++) { for (i = 0; i < 25; i++) {
a = wma_critical_freqs[i]; a = wma_critical_freqs[i];
b = s->sample_rate; b = s->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b); pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
...@@ -258,7 +258,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -258,7 +258,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
n = s->exponent_sizes[k]; n = s->exponent_sizes[k];
j = 0; j = 0;
pos = 0; pos = 0;
for(i=0;i<n;i++) { for (i = 0; i < n; i++) {
int start, end; int start, end;
start = pos; start = pos;
pos += s->exponent_bands[k][i]; pos += s->exponent_bands[k][i];
...@@ -277,7 +277,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -277,7 +277,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
s->coefs_end[k], s->coefs_end[k],
s->high_band_start[k], s->high_band_start[k],
s->exponent_high_sizes[k]); s->exponent_high_sizes[k]);
for(j=0;j<s->exponent_high_sizes[k];j++) for (j = 0; j < s->exponent_high_sizes[k]; j++)
tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]); tprintf(s->avctx, " %d", s->exponent_high_bands[k][j]);
tprintf(s->avctx, "\n"); tprintf(s->avctx, "\n");
#endif #endif
...@@ -287,11 +287,11 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -287,11 +287,11 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
#ifdef TRACE #ifdef TRACE
{ {
int i, j; 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:", tprintf(s->avctx, "%5d: n=%2d:",
s->frame_len >> i, s->frame_len >> i,
s->exponent_sizes[i]); s->exponent_sizes[i]);
for(j=0;j<s->exponent_sizes[i];j++) for (j = 0; j < s->exponent_sizes[i]; j++)
tprintf(s->avctx, " %d", s->exponent_bands[i][j]); tprintf(s->avctx, " %d", s->exponent_bands[i][j]);
tprintf(s->avctx, "\n"); tprintf(s->avctx, "\n");
} }
...@@ -299,7 +299,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -299,7 +299,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
#endif #endif
/* init MDCT windows : simple sinus window */ /* 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; int n;
n = 1 << (s->frame_len_bits - i); n = 1 << (s->frame_len_bits - i);
ff_sine_window_init(ff_sine_windows[s->frame_len_bits - i - 7], n); 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) ...@@ -317,7 +317,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
s->noise_mult = 0.04; s->noise_mult = 0.04;
#ifdef TRACE #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; s->noise_table[i] = 1.0 * s->noise_mult;
#else #else
{ {
...@@ -325,7 +325,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -325,7 +325,7 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
float norm; float norm;
seed = 1; seed = 1;
norm = (1.0 / (float)(1LL << 31)) * sqrt(3) * s->noise_mult; 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; seed = seed * 314159 + 1;
s->noise_table[i] = (float)((int)seed) * norm; s->noise_table[i] = (float)((int)seed) * norm;
} }
...@@ -351,7 +351,8 @@ int ff_wma_init(AVCodecContext * avctx, int flags2) ...@@ -351,7 +351,8 @@ int ff_wma_init(AVCodecContext * avctx, int flags2)
return 0; 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; if (total_gain < 15) return 13;
else if (total_gain < 32) return 12; else if (total_gain < 32) return 12;
else if (total_gain < 40) return 11; else if (total_gain < 40) return 11;
...@@ -364,7 +365,7 @@ int ff_wma_end(AVCodecContext *avctx) ...@@ -364,7 +365,7 @@ int ff_wma_end(AVCodecContext *avctx)
WMACodecContext *s = avctx->priv_data; WMACodecContext *s = avctx->priv_data;
int i; 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]); ff_mdct_end(&s->mdct_ctx[i]);
if (s->use_exp_vlc) { if (s->use_exp_vlc) {
...@@ -373,7 +374,7 @@ int ff_wma_end(AVCodecContext *avctx) ...@@ -373,7 +374,7 @@ int ff_wma_end(AVCodecContext *avctx)
if (s->use_noise_coding) { if (s->use_noise_coding) {
free_vlc(&s->hgain_vlc); free_vlc(&s->hgain_vlc);
} }
for(i = 0;i < 2; i++) { for (i = 0; i < 2; i++) {
free_vlc(&s->coef_vlc[i]); free_vlc(&s->coef_vlc[i]);
av_free(s->run_table[i]); av_free(s->run_table[i]);
av_free(s->level_table[i]); av_free(s->level_table[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment