Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavcodec / atrac9dec.c
index 6c1f0d1..d24a8e3 100644 (file)
 #include "libavutil/thread.h"
 
 #include "codec_internal.h"
-#include "internal.h"
+#include "decode.h"
 #include "get_bits.h"
-#include "fft.h"
 #include "atrac9tab.h"
+#include "libavutil/tx.h"
 #include "libavutil/lfg.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mem_internal.h"
@@ -86,7 +86,8 @@ typedef struct ATRAC9BlockData {
 typedef struct ATRAC9Context {
     AVCodecContext *avctx;
     AVFloatDSPContext *fdsp;
-    FFTContext imdct;
+    AVTXContext *tx;
+    av_tx_fn tx_fn;
     ATRAC9BlockData block[5];
     AVLFG lfg;
 
@@ -101,7 +102,7 @@ typedef struct ATRAC9Context {
     uint8_t alloc_curve[48][48];
     DECLARE_ALIGNED(32, float, imdct_win)[256];
 
-    DECLARE_ALIGNED(32, float, temp)[256];
+    DECLARE_ALIGNED(32, float, temp)[2048];
 } ATRAC9Context;
 
 static VLC sf_vlc[2][8];            /* Signed/unsigned, length */
@@ -778,7 +779,7 @@ imdct:
         const ptrdiff_t offset = wsize*frame_idx*sizeof(float);
         float *dst = (float *)(frame->extended_data[dst_idx] + offset);
 
-        s->imdct.imdct_half(&s->imdct, s->temp, c->coeffs);
+        s->tx_fn(s->tx, s->temp, c->coeffs, sizeof(float));
         s->fdsp->vector_fmul_window(dst, c->prev_win, s->temp,
                                     s->imdct_win, wsize >> 1);
         memcpy(c->prev_win, s->temp + (wsize >> 1), sizeof(float)*wsize >> 1);
@@ -834,7 +835,7 @@ static av_cold int atrac9_decode_close(AVCodecContext *avctx)
 {
     ATRAC9Context *s = avctx->priv_data;
 
-    ff_mdct_end(&s->imdct);
+    av_tx_uninit(&s->tx);
     av_freep(&s->fdsp);
 
     return 0;
@@ -848,9 +849,9 @@ static av_cold void atrac9_init_vlc(VLC *vlc, int nb_bits, int nb_codes,
 
     vlc->table           = &vlc_buf[*buf_offset];
     vlc->table_allocated = FF_ARRAY_ELEMS(vlc_buf) - *buf_offset;
-    ff_init_vlc_from_lengths(vlc, nb_bits, nb_codes,
+    ff_vlc_init_from_lengths(vlc, nb_bits, nb_codes,
                              &(*tab)[0][1], 2, &(*tab)[0][0], 2, 1,
-                             offset, INIT_VLC_STATIC_OVERLONG, NULL);
+                             offset, VLC_INIT_STATIC_OVERLONG, NULL);
     *buf_offset += vlc->table_size;
     *tab        += nb_codes;
 }
@@ -896,10 +897,11 @@ static av_cold void atrac9_init_static(void)
 
 static av_cold int atrac9_decode_init(AVCodecContext *avctx)
 {
+    float scale;
     static AVOnce static_table_init = AV_ONCE_INIT;
     GetBitContext gb;
     ATRAC9Context *s = avctx->priv_data;
-    int version, block_config_idx, superframe_idx, alloc_c_len;
+    int err, version, block_config_idx, superframe_idx, alloc_c_len;
 
     s->avctx = avctx;
 
@@ -959,8 +961,11 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
     s->frame_count = 1 << superframe_idx;
     s->frame_log2  = at9_tab_sri_frame_log2[s->samplerate_idx];
 
-    if (ff_mdct_init(&s->imdct, s->frame_log2 + 1, 1, 1.0f / 32768.0f))
-        return AVERROR(ENOMEM);
+    scale = 1.0f / 32768.0;
+    err = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_MDCT, 1,
+                     1 << s->frame_log2, &scale, 0);
+    if (err < 0)
+        return err;
 
     s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!s->fdsp)
@@ -989,7 +994,7 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx)
 
 const FFCodec ff_atrac9_decoder = {
     .p.name         = "atrac9",
-    .p.long_name    = NULL_IF_CONFIG_SMALL("ATRAC9 (Adaptive TRansform Acoustic Coding 9)"),
+    CODEC_LONG_NAME("ATRAC9 (Adaptive TRansform Acoustic Coding 9)"),
     .p.type         = AVMEDIA_TYPE_AUDIO,
     .p.id           = AV_CODEC_ID_ATRAC9,
     .priv_data_size = sizeof(ATRAC9Context),
@@ -997,6 +1002,10 @@ const FFCodec ff_atrac9_decoder = {
     .close          = atrac9_decode_close,
     FF_CODEC_DECODE_CB(atrac9_decode_frame),
     .flush          = atrac9_decode_flush,
-    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
-    .p.capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
+    .p.capabilities =
+#if FF_API_SUBFRAMES
+                      AV_CODEC_CAP_SUBFRAMES |
+#endif
+                      AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
 };