summaryrefslogtreecommitdiff
path: root/libavcodec/wma.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-10-23 16:30:59 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-11-01 11:29:19 -0400
commit2ed40608e9499de7ed6bd4bd61cc50645ec6d8a4 (patch)
treecc3cbabc728fac54c8966dc1db97039ebc267280 /libavcodec/wma.c
parent50a65e7a540ce6747f81d6dbf6a602ad35be77ff (diff)
wma: do not keep private copies of some AVCodecContext fields
channels, sample_rate, bit_rate, and block_align can be used directly from the AVCodecContext
Diffstat (limited to 'libavcodec/wma.c')
-rw-r--r--libavcodec/wma.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/libavcodec/wma.c b/libavcodec/wma.c
index f9ba9c3855..9808a16a26 100644
--- a/libavcodec/wma.c
+++ b/libavcodec/wma.c
@@ -82,11 +82,6 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
|| avctx->bit_rate <= 0)
return -1;
- s->sample_rate = avctx->sample_rate;
- s->nb_channels = avctx->channels;
- s->bit_rate = avctx->bit_rate;
- s->block_align = avctx->block_align;
-
ff_dsputil_init(&s->dsp, avctx);
ff_fmt_convert_init(&s->fmt_conv, avctx);
avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
@@ -98,7 +93,8 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
}
/* compute MDCT block size */
- s->frame_len_bits = ff_wma_get_frame_len_bits(s->sample_rate, s->version, 0);
+ s->frame_len_bits = ff_wma_get_frame_len_bits(avctx->sample_rate,
+ s->version, 0);
s->next_block_len_bits = s->frame_len_bits;
s->prev_block_len_bits = s->frame_len_bits;
s->block_len_bits = s->frame_len_bits;
@@ -107,7 +103,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
if (s->use_variable_block_len) {
int nb_max, nb;
nb = ((flags2 >> 3) & 3) + 1;
- if ((s->bit_rate / s->nb_channels) >= 32000)
+ if ((avctx->bit_rate / avctx->channels) >= 32000)
nb += 2;
nb_max = s->frame_len_bits - BLOCK_MIN_BITS;
if (nb > nb_max)
@@ -119,10 +115,10 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
/* init rate dependent parameters */
s->use_noise_coding = 1;
- high_freq = s->sample_rate * 0.5;
+ high_freq = avctx->sample_rate * 0.5;
/* if version 2, then the rates are normalized */
- sample_rate1 = s->sample_rate;
+ sample_rate1 = avctx->sample_rate;
if (s->version == 2) {
if (sample_rate1 >= 44100) {
sample_rate1 = 44100;
@@ -137,13 +133,13 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
}
}
- bps = (float)s->bit_rate / (float)(s->nb_channels * s->sample_rate);
+ bps = (float)avctx->bit_rate / (float)(avctx->channels * avctx->sample_rate);
s->byte_offset_bits = av_log2((int)(bps * s->frame_len / 8.0 + 0.5)) + 2;
/* compute high frequency value and choose if noise coding should
be activated */
bps1 = bps;
- if (s->nb_channels == 2)
+ if (avctx->channels == 2)
bps1 = bps * 1.6;
if (sample_rate1 == 44100) {
if (bps1 >= 0.61) {
@@ -186,8 +182,8 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
}
av_dlog(s->avctx, "flags2=0x%x\n", flags2);
av_dlog(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, avctx->channels, avctx->sample_rate, avctx->bit_rate,
+ avctx->block_align);
av_dlog(s->avctx, "bps=%f bps1=%f high_freq=%f bitoffset=%d\n",
bps, bps1, high_freq, s->byte_offset_bits);
av_dlog(s->avctx, "use_noise_coding=%d use_exp_vlc=%d nb_block_sizes=%d\n",
@@ -210,7 +206,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
- b = s->sample_rate;
+ b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b >> 1)) / b;
if (pos > block_len)
pos = block_len;
@@ -227,11 +223,11 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
table = NULL;
a = s->frame_len_bits - BLOCK_MIN_BITS - k;
if (a < 3) {
- if (s->sample_rate >= 44100) {
+ if (avctx->sample_rate >= 44100) {
table = exponent_band_44100[a];
- } else if (s->sample_rate >= 32000) {
+ } else if (avctx->sample_rate >= 32000) {
table = exponent_band_32000[a];
- } else if (s->sample_rate >= 22050) {
+ } else if (avctx->sample_rate >= 22050) {
table = exponent_band_22050[a];
}
}
@@ -245,7 +241,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
lpos = 0;
for (i = 0; i < 25; i++) {
a = ff_wma_critical_freqs[i];
- b = s->sample_rate;
+ b = avctx->sample_rate;
pos = ((block_len * 2 * a) + (b << 1)) / (4 * b);
pos <<= 2;
if (pos > block_len)
@@ -264,7 +260,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
s->coefs_end[k] = (s->frame_len - ((s->frame_len * 9) / 100)) >> k;
/* high freq computation */
s->high_band_start[k] = (int)((block_len * 2 * high_freq) /
- s->sample_rate + 0.5);
+ avctx->sample_rate + 0.5);
n = s->exponent_sizes[k];
j = 0;
pos = 0;
@@ -344,7 +340,7 @@ int ff_wma_init(AVCodecContext *avctx, int flags2)
/* choose the VLC tables for the coefficients */
coef_vlc_table = 2;
- if (s->sample_rate >= 32000) {
+ if (avctx->sample_rate >= 32000) {
if (bps1 < 0.72) {
coef_vlc_table = 0;
} else if (bps1 < 1.16) {