#include "libavutil/channel_layout.h"
#include "libavutil/float_dsp.h"
#include "libavutil/internal.h"
+#include "libavutil/mem_internal.h"
#define BITSTREAM_READER_LE
#include "avcodec.h"
#define RA288_BLOCKS_PER_FRAME 32
typedef struct RA288Context {
- AVFloatDSPContext *fdsp;
+ void (*vector_fmul)(float *dst, const float *src0, const float *src1,
+ int len);
DECLARE_ALIGNED(32, float, sp_lpc)[FFALIGN(36, 16)]; ///< LPC coefficients for speech data (spec: A)
DECLARE_ALIGNED(32, float, gain_lpc)[FFALIGN(10, 16)]; ///< LPC coefficients for gain (spec: GB)
float gain_rec[11];
} RA288Context;
-static av_cold int ra288_decode_close(AVCodecContext *avctx)
-{
- RA288Context *ractx = avctx->priv_data;
-
- av_freep(&ractx->fdsp);
-
- return 0;
-}
-
static av_cold int ra288_decode_init(AVCodecContext *avctx)
{
RA288Context *ractx = avctx->priv_data;
+ AVFloatDSPContext *fdsp;
avctx->channels = 1;
avctx->channel_layout = AV_CH_LAYOUT_MONO;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
- if (avctx->block_align <= 0) {
+ if (avctx->block_align != 38) {
av_log(avctx, AV_LOG_ERROR, "unsupported block align\n");
return AVERROR_PATCHWELCOME;
}
- ractx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
- if (!ractx->fdsp)
+ fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+ if (!fdsp)
return AVERROR(ENOMEM);
+ ractx->vector_fmul = fdsp->vector_fmul;
+ av_free(fdsp);
return 0;
}
av_assert2(order>=0);
- ractx->fdsp->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
+ ractx->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
convolve(buffer1, work + order , n , order);
convolve(buffer2, work + order + n, non_rec, order);
do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window);
if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1))
- ractx->fdsp->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
+ ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
memmove(hist, hist + n, move_size*sizeof(*hist));
}
return avctx->block_align;
}
-AVCodec ff_ra_288_decoder = {
+const AVCodec ff_ra_288_decoder = {
.name = "real_288",
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 2.0 (28.8K)"),
.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(RA288Context),
.init = ra288_decode_init,
.decode = ra288_decode_frame,
- .close = ra288_decode_close,
- .capabilities = AV_CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
};