wmaprodec: convert to lavu/tx

pull/388/head
Lynne 2 years ago
parent eb0e25f078
commit 5f1111e42e
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
  1. 2
      configure
  2. 24
      libavcodec/wmaprodec.c

2
configure vendored

@ -2995,7 +2995,7 @@ vp9_decoder_select="videodsp vp9_parser vp9_superframe_split_bsf"
wcmv_decoder_select="inflate_wrapper" wcmv_decoder_select="inflate_wrapper"
webp_decoder_select="vp8_decoder exif" webp_decoder_select="vp8_decoder exif"
wmalossless_decoder_select="llauddsp" wmalossless_decoder_select="llauddsp"
wmapro_decoder_select="mdct sinewin wma_freqs" wmapro_decoder_select="sinewin wma_freqs"
wmav1_decoder_select="mdct sinewin wma_freqs" wmav1_decoder_select="mdct sinewin wma_freqs"
wmav1_encoder_select="mdct sinewin wma_freqs" wmav1_encoder_select="mdct sinewin wma_freqs"
wmav2_decoder_select="mdct sinewin wma_freqs" wmav2_decoder_select="mdct sinewin wma_freqs"

@ -89,6 +89,7 @@
#include <inttypes.h> #include <inttypes.h>
#include "libavutil/audio_fifo.h" #include "libavutil/audio_fifo.h"
#include "libavutil/tx.h"
#include "libavutil/ffmath.h" #include "libavutil/ffmath.h"
#include "libavutil/float_dsp.h" #include "libavutil/float_dsp.h"
#include "libavutil/intfloat.h" #include "libavutil/intfloat.h"
@ -185,7 +186,8 @@ typedef struct WMAProDecodeCtx {
uint8_t frame_data[MAX_FRAMESIZE + uint8_t frame_data[MAX_FRAMESIZE +
AV_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data AV_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data
PutBitContext pb; ///< context for filling the frame_data buffer PutBitContext pb; ///< context for filling the frame_data buffer
FFTContext mdct_ctx[WMAPRO_BLOCK_SIZES]; ///< MDCT context per block size AVTXContext *tx[WMAPRO_BLOCK_SIZES]; ///< MDCT context per block size
av_tx_fn tx_fn[WMAPRO_BLOCK_SIZES];
DECLARE_ALIGNED(32, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer DECLARE_ALIGNED(32, float, tmp)[WMAPRO_BLOCK_MAX_SIZE]; ///< IMDCT output buffer
const float* windows[WMAPRO_BLOCK_SIZES]; ///< windows for the different block sizes const float* windows[WMAPRO_BLOCK_SIZES]; ///< windows for the different block sizes
@ -287,7 +289,7 @@ static av_cold int decode_end(WMAProDecodeCtx *s)
av_freep(&s->fdsp); av_freep(&s->fdsp);
for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) for (i = 0; i < WMAPRO_BLOCK_SIZES; i++)
ff_mdct_end(&s->mdct_ctx[i]); av_tx_uninit(&s->tx[i]);
return 0; return 0;
} }
@ -552,12 +554,13 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
/** init MDCT, FIXME: only init needed sizes */ /** init MDCT, FIXME: only init needed sizes */
for (int i = 0; i < WMAPRO_BLOCK_SIZES; i++) { for (i = 0; i < WMAPRO_BLOCK_SIZES; i++) {
ret = ff_mdct_init(&s->mdct_ctx[i], WMAPRO_BLOCK_MIN_BITS + 1 + i, 1, const float scale = 1.0 / (1 << (WMAPRO_BLOCK_MIN_BITS + i - 1))
1.0 / (1 << (WMAPRO_BLOCK_MIN_BITS + i - 1)) / (1ll << (s->bits_per_sample - 1));
/ (1ll << (s->bits_per_sample - 1))); int err = av_tx_init(&s->tx[i], &s->tx_fn[i], AV_TX_FLOAT_MDCT, 1,
if (ret < 0) 1 << (WMAPRO_BLOCK_MIN_BITS + i), &scale, 0);
return ret; if (err < 0)
return err;
} }
/** init MDCT windows: simple sine window */ /** init MDCT windows: simple sine window */
@ -1386,7 +1389,8 @@ static int decode_subframe(WMAProDecodeCtx *s)
get_bits_count(&s->gb) - s->subframe_offset); get_bits_count(&s->gb) - s->subframe_offset);
if (transmit_coeffs) { if (transmit_coeffs) {
FFTContext *mdct = &s->mdct_ctx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS]; AVTXContext *tx = s->tx[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS];
av_tx_fn tx_fn = s->tx_fn[av_log2(subframe_len) - WMAPRO_BLOCK_MIN_BITS];
/** reconstruct the per channel data */ /** reconstruct the per channel data */
inverse_channel_transform(s); inverse_channel_transform(s);
for (i = 0; i < s->channels_for_cur_subframe; i++) { for (i = 0; i < s->channels_for_cur_subframe; i++) {
@ -1412,7 +1416,7 @@ static int decode_subframe(WMAProDecodeCtx *s)
} }
/** apply imdct (imdct_half == DCTIV with reverse) */ /** apply imdct (imdct_half == DCTIV with reverse) */
mdct->imdct_half(mdct, s->channel[c].coeffs, s->tmp); tx_fn(tx, s->channel[c].coeffs, s->tmp, sizeof(float));
} }
} }

Loading…
Cancel
Save