summaryrefslogtreecommitdiff
path: root/libavcodec/wmaenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-06-04 13:03:50 +0200
committerJames Almer <jamrial@gmail.com>2022-03-15 09:42:45 -0300
commit3c933af4934fa7e1119b8d684d361b85530bfe31 (patch)
tree15471681eda25ce664c942d3b57e12347d5e6fb8 /libavcodec/wmaenc.c
parent03ba5cf321e42e3a42c283ed717fc812b760e039 (diff)
wma: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/wmaenc.c')
-rw-r--r--libavcodec/wmaenc.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 66e3537cb0..4eeaefffba 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -38,10 +38,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->avctx = avctx;
- if (avctx->channels > MAX_CHANNELS) {
+ if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR,
"too many channels: got %i, need %i or fewer\n",
- avctx->channels, MAX_CHANNELS);
+ avctx->ch_layout.nb_channels, MAX_CHANNELS);
return AVERROR(EINVAL);
}
@@ -82,7 +82,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->use_exp_vlc = flags2 & 0x0001;
s->use_bit_reservoir = flags2 & 0x0002;
s->use_variable_block_len = flags2 & 0x0004;
- if (avctx->channels == 2)
+ if (avctx->ch_layout.nb_channels == 2)
s->ms_stereo = 1;
if ((ret = ff_wma_init(avctx, flags2)) < 0)
@@ -116,7 +116,7 @@ static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
int window_len = 1 << s->block_len_bits;
float n = 2.0 * 32768.0 / window_len;
- for (ch = 0; ch < avctx->channels; ch++) {
+ for (ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
memcpy(s->output, s->frame_out[ch], window_len * sizeof(*s->output));
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],
@@ -186,6 +186,7 @@ static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param)
static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
int total_gain)
{
+ int channels = s->avctx->ch_layout.nb_channels;
int v, bsize, ch, coef_nb_bits, parse_exponents;
float mdct_norm;
int nb_coefs[MAX_CHANNELS];
@@ -213,7 +214,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->avctx->channels; ch++)
+ for (ch = 0; ch < channels; ch++)
nb_coefs[ch] = v;
{
int n4 = s->block_len / 2;
@@ -222,17 +223,17 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
mdct_norm *= sqrt(n4);
}
- if (s->avctx->channels == 2)
+ if (channels == 2)
put_bits(&s->pb, 1, !!s->ms_stereo);
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < channels; ch++) {
// FIXME only set channel_coded when needed, instead of always
s->channel_coded[ch] = 1;
if (s->channel_coded[ch])
init_exp(s, ch, fixed_exp);
}
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < channels; ch++) {
if (s->channel_coded[ch]) {
WMACoef *coefs1;
float *coefs, *exponents, mult;
@@ -260,7 +261,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
}
v = 0;
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < channels; ch++) {
int a = s->channel_coded[ch];
put_bits(&s->pb, 1, a);
v |= a;
@@ -276,7 +277,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->avctx->channels; ch++) {
+ for (ch = 0; ch < channels; ch++) {
if (s->channel_coded[ch]) {
int i, n;
n = s->exponent_high_sizes[bsize];
@@ -294,7 +295,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
put_bits(&s->pb, 1, parse_exponents);
if (parse_exponents) {
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < channels; ch++) {
if (s->channel_coded[ch]) {
if (s->use_exp_vlc) {
encode_exp_vlc(s, ch, fixed_exp);
@@ -307,7 +308,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
} else
av_assert0(0); // FIXME not implemented
- for (ch = 0; ch < s->avctx->channels; ch++) {
+ for (ch = 0; ch < channels; ch++) {
if (s->channel_coded[ch]) {
int run, tindex;
WMACoef *ptr, *eptr;
@@ -346,7 +347,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1],
s->coef_vlcs[tindex]->huffcodes[1]);
}
- if (s->version == 1 && s->avctx->channels >= 2)
+ if (s->version == 1 && channels >= 2)
align_put_bits(&s->pb);
}
return 0;