dcaenc: convert to lavu/tx

The encoder is fixed point, and uses an MDCT only for analysis. Due
to the slightly different rounding, the encoder makes a different
decision, so the tests have to be adjusted as well.
pull/388/head
Lynne 2 years ago
parent 055413788f
commit b428003c1c
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
  1. 1
      configure
  2. 14
      libavcodec/dcaenc.c
  3. 2
      tests/fate/acodec.mak

1
configure vendored

@ -2807,7 +2807,6 @@ comfortnoise_encoder_select="lpc"
cook_decoder_select="audiodsp sinewin"
cri_decoder_select="mjpeg_decoder"
cscd_decoder_suggest="zlib"
dca_encoder_select="mdct"
dds_decoder_select="texturedsp"
dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc"
dnxhd_decoder_select="blockdsp idctdsp"

@ -21,8 +21,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#define FFT_FLOAT 0
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
@ -30,6 +28,7 @@
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libavutil/thread.h"
#include "libavutil/tx.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "dca.h"
@ -39,7 +38,6 @@
#include "dcadata.h"
#include "dcaenc.h"
#include "encode.h"
#include "fft.h"
#include "put_bits.h"
#define MAX_CHANNELS 6
@ -63,7 +61,8 @@ typedef struct DCAEncContext {
AVClass *class;
PutBitContext pb;
DCAADPCMEncContext adpcm_ctx;
FFTContext mdct;
AVTXContext *mdct;
av_tx_fn mdct_fn;
CompressionOptions options;
int frame_size;
int frame_bits;
@ -206,6 +205,7 @@ static int encode_init(AVCodecContext *avctx)
DCAEncContext *c = avctx->priv_data;
AVChannelLayout layout = avctx->ch_layout;
int i, j, k, min_frame_bits;
float scale = 1.0f;
int ret;
if ((ret = subband_bufer_alloc(c)) < 0)
@ -287,7 +287,7 @@ static int encode_init(AVCodecContext *avctx)
avctx->frame_size = 32 * SUBBAND_SAMPLES;
if ((ret = ff_mdct_init(&c->mdct, 9, 0, 1.0)) < 0)
if ((ret = av_tx_init(&c->mdct, &c->mdct_fn, AV_TX_INT32_MDCT, 0, 256, &scale, 0)) < 0)
return ret;
/* Init all tables */
@ -354,7 +354,7 @@ static int encode_init(AVCodecContext *avctx)
static av_cold int encode_close(AVCodecContext *avctx)
{
DCAEncContext *c = avctx->priv_data;
ff_mdct_end(&c->mdct);
av_tx_uninit(&c->mdct);
subband_bufer_free(c);
ff_dcaadpcm_free(&c->adpcm_ctx);
@ -506,7 +506,7 @@ static void calc_power(DCAEncContext *c,
for (i = 0; i < 512; i++)
data[i] = norm__(mul32(in[i], 0x3fffffff - (COS_T(4 * i + 2) >> 1)), 4);
c->mdct.mdct_calc(&c->mdct, coeff, data);
c->mdct_fn(c->mdct, coeff, data, sizeof(int32_t));
for (i = 0; i < 256; i++) {
const int32_t cb = get_cb(c, coeff[i]);
power[i] = add_cb(c, cb, cb);

@ -126,7 +126,7 @@ fate-acodec-dca2: CMD = enc_dec_pcm dts wav s16le $(SRC) -c:a dca -strict -2 -fl
fate-acodec-dca2: REF = $(SRC)
fate-acodec-dca2: CMP = stddev
fate-acodec-dca2: CMP_SHIFT = -2048
fate-acodec-dca2: CMP_TARGET = 535
fate-acodec-dca2: CMP_TARGET = 534
fate-acodec-dca2: SIZE_TOLERANCE = 1632
FATE_ACODEC-$(call ENCDEC, FLAC, FLAC) += fate-acodec-flac fate-acodec-flac-exact-rice

Loading…
Cancel
Save