X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fra288.c;h=05f322c40a8361e100db41871b5ce02f35240ed9;hb=a247ac640df3da573cd661065bf53f37863e2b46;hp=f1b3c8eab55f63923ae17fb5a1496eda3f65d2a6;hpb=e645d7a6d452df83cedcbb1d6708429ceea156da;p=ffmpeg diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index f1b3c8eab55..05f322c40a8 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -22,6 +22,7 @@ #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" @@ -39,7 +40,8 @@ #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) @@ -60,31 +62,25 @@ typedef struct RA288Context { 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; } @@ -158,7 +154,7 @@ static void do_hybrid_window(RA288Context *ractx, 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); @@ -185,7 +181,7 @@ static void backward_filter(RA288Context *ractx, 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)); } @@ -241,7 +237,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data, 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, @@ -249,6 +245,5 @@ AVCodec ff_ra_288_decoder = { .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, };