mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-21 15:00:27 +00:00
wma: convert to lavu/tx
Converts both the decoder and encoders.
This commit is contained in:
parent
6ba0aa1770
commit
978963a77b
8
configure
vendored
8
configure
vendored
@ -2992,10 +2992,10 @@ wcmv_decoder_select="inflate_wrapper"
|
||||
webp_decoder_select="vp8_decoder exif"
|
||||
wmalossless_decoder_select="llauddsp"
|
||||
wmapro_decoder_select="sinewin wma_freqs"
|
||||
wmav1_decoder_select="mdct sinewin wma_freqs"
|
||||
wmav1_encoder_select="mdct sinewin wma_freqs"
|
||||
wmav2_decoder_select="mdct sinewin wma_freqs"
|
||||
wmav2_encoder_select="mdct sinewin wma_freqs"
|
||||
wmav1_decoder_select="sinewin wma_freqs"
|
||||
wmav1_encoder_select="sinewin wma_freqs"
|
||||
wmav2_decoder_select="sinewin wma_freqs"
|
||||
wmav2_encoder_select="sinewin wma_freqs"
|
||||
wmavoice_decoder_select="lsp rdft dct sinewin"
|
||||
wmv1_decoder_select="msmpeg4dec"
|
||||
wmv1_encoder_select="msmpeg4enc"
|
||||
|
@ -369,7 +369,7 @@ int ff_wma_end(AVCodecContext *avctx)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < s->nb_block_sizes; i++)
|
||||
ff_mdct_end(&s->mdct_ctx[i]);
|
||||
av_tx_uninit(&s->mdct_ctx[i]);
|
||||
|
||||
if (s->use_exp_vlc)
|
||||
ff_free_vlc(&s->exp_vlc);
|
||||
|
@ -24,9 +24,9 @@
|
||||
|
||||
#include "libavutil/float_dsp.h"
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/tx.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "fft.h"
|
||||
#include "get_bits.h"
|
||||
#include "put_bits.h"
|
||||
|
||||
@ -115,8 +115,9 @@ typedef struct WMACodecContext {
|
||||
float max_exponent[MAX_CHANNELS];
|
||||
WMACoef coefs1[MAX_CHANNELS][BLOCK_MAX_SIZE];
|
||||
DECLARE_ALIGNED(32, float, coefs)[MAX_CHANNELS][BLOCK_MAX_SIZE];
|
||||
DECLARE_ALIGNED(32, FFTSample, output)[BLOCK_MAX_SIZE * 2];
|
||||
FFTContext mdct_ctx[BLOCK_NB_SIZES];
|
||||
DECLARE_ALIGNED(32, float, output)[BLOCK_MAX_SIZE * 2];
|
||||
AVTXContext *mdct_ctx[BLOCK_NB_SIZES];
|
||||
av_tx_fn mdct_fn[BLOCK_NB_SIZES];
|
||||
const float *windows[BLOCK_NB_SIZES];
|
||||
/* output buffer for one frame and the last for IMDCT windowing */
|
||||
DECLARE_ALIGNED(32, float, frame_out)[MAX_CHANNELS][BLOCK_MAX_SIZE * 2];
|
||||
|
@ -111,8 +111,9 @@ static av_cold int wma_decode_init(AVCodecContext *avctx)
|
||||
|
||||
/* init MDCT */
|
||||
for (i = 0; i < s->nb_block_sizes; i++) {
|
||||
ret = ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1,
|
||||
1, 1.0 / 32768.0);
|
||||
float scale = 1.0 / 32768.0;
|
||||
ret = av_tx_init(&s->mdct_ctx[i], &s->mdct_fn[i], AV_TX_FLOAT_MDCT,
|
||||
1, 1 << (s->frame_len_bits - i), &scale, AV_TX_FULL_IMDCT);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@ -448,7 +449,8 @@ static int wma_decode_block(WMACodecContext *s)
|
||||
int coef_nb_bits, total_gain;
|
||||
int nb_coefs[MAX_CHANNELS];
|
||||
float mdct_norm;
|
||||
FFTContext *mdct;
|
||||
AVTXContext *mdct;
|
||||
av_tx_fn mdct_fn;
|
||||
|
||||
#ifdef TRACE
|
||||
ff_tlog(s->avctx, "***decode_block: %d:%d\n",
|
||||
@ -757,14 +759,15 @@ static int wma_decode_block(WMACodecContext *s)
|
||||
}
|
||||
|
||||
next:
|
||||
mdct = &s->mdct_ctx[bsize];
|
||||
mdct = s->mdct_ctx[bsize];
|
||||
mdct_fn = s->mdct_fn[bsize];
|
||||
|
||||
for (ch = 0; ch < channels; ch++) {
|
||||
int n4, index;
|
||||
|
||||
n4 = s->block_len / 2;
|
||||
if (s->channel_coded[ch])
|
||||
mdct->imdct_calc(mdct, s->output, s->coefs[ch]);
|
||||
mdct_fn(mdct, s->output, s->coefs[ch], sizeof(float));
|
||||
else if (!(s->ms_stereo && ch == 1))
|
||||
memset(s->output, 0, sizeof(s->output));
|
||||
|
||||
|
@ -92,7 +92,9 @@ static av_cold int encode_init(AVCodecContext *avctx)
|
||||
|
||||
/* init MDCT */
|
||||
for (i = 0; i < s->nb_block_sizes; i++) {
|
||||
ret = ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0);
|
||||
float scale = 1.0f;
|
||||
ret = av_tx_init(&s->mdct_ctx[i], &s->mdct_fn[i], AV_TX_FLOAT_MDCT,
|
||||
0, 1 << (s->frame_len_bits - i), &scale, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
@ -112,7 +114,8 @@ static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
|
||||
const float *const *audio = (const float *const *) frame->extended_data;
|
||||
int len = frame->nb_samples;
|
||||
int window_index = s->frame_len_bits - s->block_len_bits;
|
||||
FFTContext *mdct = &s->mdct_ctx[window_index];
|
||||
AVTXContext *mdct = s->mdct_ctx[window_index];
|
||||
av_tx_fn mdct_fn = s->mdct_fn[window_index];
|
||||
int ch;
|
||||
const float *win = s->windows[window_index];
|
||||
int window_len = 1 << s->block_len_bits;
|
||||
@ -124,7 +127,7 @@ static int apply_window_and_mdct(AVCodecContext *avctx, const AVFrame *frame)
|
||||
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);
|
||||
mdct_fn(mdct, s->coefs[ch], s->output, sizeof(float));
|
||||
if (!isfinite(s->coefs[ch][0])) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Input contains NaN/+-Inf\n");
|
||||
return AVERROR(EINVAL);
|
||||
|
Loading…
Reference in New Issue
Block a user