summaryrefslogtreecommitdiff
path: root/libavcodec/wmaenc.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/wmaenc.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/wmaenc.c')
-rw-r--r--libavcodec/wmaenc.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 8abb55bbd4..13d8a1cfbf 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -29,7 +29,7 @@
static int encode_init(AVCodecContext * avctx){
WMACodecContext *s = avctx->priv_data;
- int i, flags1, flags2;
+ int i, flags1, flags2, block_align;
uint8_t *extradata;
s->avctx = avctx;
@@ -80,10 +80,10 @@ static int encode_init(AVCodecContext * avctx){
for(i = 0; i < s->nb_block_sizes; i++)
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0);
- s->block_align = avctx->bit_rate * (int64_t)s->frame_len /
+ block_align = avctx->bit_rate * (int64_t)s->frame_len /
(avctx->sample_rate * 8);
- s->block_align = FFMIN(s->block_align, MAX_CODED_SUPERFRAME_SIZE);
- avctx->block_align = s->block_align;
+ block_align = FFMIN(block_align, MAX_CODED_SUPERFRAME_SIZE);
+ avctx->block_align = block_align;
avctx->bit_rate = avctx->block_align * 8LL * avctx->sample_rate /
s->frame_len;
avctx->frame_size = avctx->delay = s->frame_len;
@@ -188,7 +188,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
//FIXME factor
v = s->coefs_end[bsize] - s->coefs_start;
- for(ch = 0; ch < s->nb_channels; ch++)
+ for (ch = 0; ch < s->avctx->channels; ch++)
nb_coefs[ch] = v;
{
int n4 = s->block_len / 2;
@@ -198,18 +198,18 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
}
}
- if (s->nb_channels == 2) {
+ if (s->avctx->channels == 2) {
put_bits(&s->pb, 1, !!s->ms_stereo);
}
- for(ch = 0; ch < s->nb_channels; ch++) {
+ for (ch = 0; ch < s->avctx->channels; ch++) {
s->channel_coded[ch] = 1; //FIXME only set channel_coded when needed, instead of always
if (s->channel_coded[ch]) {
init_exp(s, ch, fixed_exp);
}
}
- for(ch = 0; ch < s->nb_channels; ch++) {
+ for (ch = 0; ch < s->avctx->channels; ch++) {
if (s->channel_coded[ch]) {
WMACoef *coefs1;
float *coefs, *exponents, mult;
@@ -237,7 +237,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
}
v = 0;
- for(ch = 0; ch < s->nb_channels; ch++) {
+ for (ch = 0; ch < s->avctx->channels; ch++) {
int a = s->channel_coded[ch];
put_bits(&s->pb, 1, a);
v |= a;
@@ -253,7 +253,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
coef_nb_bits= ff_wma_total_gain_to_bits(total_gain);
if (s->use_noise_coding) {
- for(ch = 0; ch < s->nb_channels; ch++) {
+ for (ch = 0; ch < s->avctx->channels; ch++) {
if (s->channel_coded[ch]) {
int i, n;
n = s->exponent_high_sizes[bsize];
@@ -272,7 +272,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
}
if (parse_exponents) {
- for(ch = 0; ch < s->nb_channels; ch++) {
+ for (ch = 0; ch < s->avctx->channels; ch++) {
if (s->channel_coded[ch]) {
if (s->use_exp_vlc) {
encode_exp_vlc(s, ch, fixed_exp);
@@ -286,7 +286,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
assert(0); //FIXME not implemented
}
- for(ch = 0; ch < s->nb_channels; ch++) {
+ for (ch = 0; ch < s->avctx->channels; ch++) {
if (s->channel_coded[ch]) {
int run, tindex;
WMACoef *ptr, *eptr;
@@ -324,7 +324,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
if(run)
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]);
}
- if (s->version == 1 && s->nb_channels >= 2) {
+ if (s->version == 1 && s->avctx->channels >= 2) {
avpriv_align_put_bits(&s->pb);
}
}
@@ -343,7 +343,7 @@ static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
avpriv_align_put_bits(&s->pb);
- return put_bits_count(&s->pb)/8 - s->block_align;
+ return put_bits_count(&s->pb) / 8 - s->avctx->block_align;
}
static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
@@ -413,7 +413,7 @@ static int encode_superframe(AVCodecContext *avctx, AVPacket *avpkt,
if (frame->pts != AV_NOPTS_VALUE)
avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->delay);
- avpkt->size = s->block_align;
+ avpkt->size = avctx->block_align;
*got_packet_ptr = 1;
return 0;
}