* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/attributes.h"
#include "avcodec.h"
#include "internal.h"
#include "wma.h"
#include <assert.h>
-static int encode_init(AVCodecContext * avctx){
+static av_cold 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;
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;
-#if FF_API_OLD_ENCODE_AUDIO
- avctx->coded_frame = &s->frame;
- avcodec_get_frame_defaults(avctx->coded_frame);
-#endif
-
return 0;
}
for (ch = 0; ch < avctx->channels; ch++) {
memcpy(s->output, s->frame_out[ch], window_len * sizeof(*s->output));
- s->dsp.vector_fmul_scalar(s->frame_out[ch], audio[ch], n, len);
- s->dsp.vector_fmul_reverse(&s->output[window_len], s->frame_out[ch], win, len);
+ s->fdsp.vector_fmul_scalar(s->frame_out[ch], audio[ch], n, len);
+ s->fdsp.vector_fmul_reverse(&s->output[window_len], s->frame_out[ch], win, len);
s->fdsp.vector_fmul(s->frame_out[ch], s->frame_out[ch], win, len);
mdct->mdct_calc(mdct, s->coefs[ch], s->output);
}
//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;
}
}
- 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;
}
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;
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];
}
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);
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;
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);
}
}
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,
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;
}
AVCodec ff_wmav1_encoder = {
.name = "wmav1",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_WMAV1,
.priv_data_size = sizeof(WMACodecContext),
.close = ff_wma_end,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"),
};
AVCodec ff_wmav2_encoder = {
.name = "wmav2",
+ .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_WMAV2,
.priv_data_size = sizeof(WMACodecContext),
.close = ff_wma_end,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"),
};