1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

dolby_e: convert to lavu/tx

This commit is contained in:
Lynne 2022-10-29 23:20:52 +02:00
parent 1d810b650c
commit 2689038f08
No known key found for this signature in database
GPG Key ID: A2FEA5F03F034464
2 changed files with 24 additions and 17 deletions

1
configure vendored
View File

@ -2813,7 +2813,6 @@ dds_decoder_select="texturedsp"
dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc" dirac_decoder_select="dirac_parse dwt golomb videodsp mpegvideoenc"
dnxhd_decoder_select="blockdsp idctdsp" dnxhd_decoder_select="blockdsp idctdsp"
dnxhd_encoder_select="blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp videodsp" dnxhd_encoder_select="blockdsp fdctdsp idctdsp mpegvideoenc pixblockdsp videodsp"
dolby_e_decoder_select="mdct"
dvvideo_decoder_select="dvprofile idctdsp" dvvideo_decoder_select="dvprofile idctdsp"
dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp" dvvideo_encoder_select="dvprofile fdctdsp me_cmp pixblockdsp"
dxa_decoder_deps="zlib" dxa_decoder_deps="zlib"

View File

@ -24,13 +24,13 @@
#include "libavutil/mem.h" #include "libavutil/mem.h"
#include "libavutil/mem_internal.h" #include "libavutil/mem_internal.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "codec_internal.h" #include "codec_internal.h"
#include "decode.h" #include "decode.h"
#include "get_bits.h" #include "get_bits.h"
#include "dolby_e.h" #include "dolby_e.h"
#include "kbdwin.h" #include "kbdwin.h"
#include "fft.h"
#define MAX_SEGMENTS 2 #define MAX_SEGMENTS 2
@ -85,7 +85,8 @@ typedef struct DBEDecodeContext {
DECLARE_ALIGNED(32, float, history)[MAX_CHANNELS][256]; DECLARE_ALIGNED(32, float, history)[MAX_CHANNELS][256];
FFTContext imdct[3]; AVTXContext *imdct[2][3];
av_tx_fn imdct_fn[2][3];
AVFloatDSPContext *fdsp; AVFloatDSPContext *fdsp;
} DBEDecodeContext; } DBEDecodeContext;
@ -989,23 +990,23 @@ static int parse_meter(DBEDecodeContext *s1)
static void imdct_calc(DBEDecodeContext *s1, DBEGroup *g, float *result, float *values) static void imdct_calc(DBEDecodeContext *s1, DBEGroup *g, float *result, float *values)
{ {
FFTContext *imdct = &s1->imdct[g->imdct_idx]; AVTXContext *imdct = s1->imdct[g->imdct_phs == 1][g->imdct_idx];
av_tx_fn imdct_fn = s1->imdct_fn[g->imdct_phs == 1][g->imdct_idx];
int n = 1 << imdct_bits_tab[g->imdct_idx]; int n = 1 << imdct_bits_tab[g->imdct_idx];
int n2 = n >> 1; int n2 = n >> 1;
int i;
switch (g->imdct_phs) { switch (g->imdct_phs) {
case 0: case 0:
imdct->imdct_half(imdct, result, values); imdct_fn(imdct, result, values, sizeof(float));
for (i = 0; i < n2; i++) for (int i = 0; i < n2; i++)
result[n2 + i] = result[n2 - i - 1]; result[n2 + i] = result[n2 - i - 1];
break; break;
case 1: case 1:
imdct->imdct_calc(imdct, result, values); imdct_fn(imdct, result, values, sizeof(float));
break; break;
case 2: case 2:
imdct->imdct_half(imdct, result + n2, values); imdct_fn(imdct, result + n2, values, sizeof(float));
for (i = 0; i < n2; i++) for (int i = 0; i < n2; i++)
result[i] = -result[n - i - 1]; result[i] = -result[n - i - 1];
break; break;
default: default:
@ -1152,10 +1153,11 @@ static av_cold void dolby_e_flush(AVCodecContext *avctx)
static av_cold int dolby_e_close(AVCodecContext *avctx) static av_cold int dolby_e_close(AVCodecContext *avctx)
{ {
DBEDecodeContext *s = avctx->priv_data; DBEDecodeContext *s = avctx->priv_data;
int i;
for (i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
ff_mdct_end(&s->imdct[i]); av_tx_uninit(&s->imdct[0][i]);
av_tx_uninit(&s->imdct[1][i]);
}
av_freep(&s->fdsp); av_freep(&s->fdsp);
return 0; return 0;
@ -1252,14 +1254,20 @@ static av_cold int dolby_e_init(AVCodecContext *avctx)
{ {
static AVOnce init_once = AV_ONCE_INIT; static AVOnce init_once = AV_ONCE_INIT;
DBEDecodeContext *s = avctx->priv_data; DBEDecodeContext *s = avctx->priv_data;
int i; float scale = 2.0f;
int ret;
if (ff_thread_once(&init_once, init_tables)) if (ff_thread_once(&init_once, init_tables))
return AVERROR_UNKNOWN; return AVERROR_UNKNOWN;
for (i = 0; i < 3; i++) for (int i = 0; i < 3; i++) {
if (ff_mdct_init(&s->imdct[i], imdct_bits_tab[i], 1, 2.0) < 0) if ((ret = av_tx_init(&s->imdct[0][i], &s->imdct_fn[0][i], AV_TX_FLOAT_MDCT,
return AVERROR(ENOMEM); 1, 1 << imdct_bits_tab[i] - 1, &scale, 0)) < 0)
return ret;
if ((ret = av_tx_init(&s->imdct[1][i], &s->imdct_fn[1][i], AV_TX_FLOAT_MDCT,
1, 1 << imdct_bits_tab[i] - 1, &scale, AV_TX_FULL_IMDCT)) < 0)
return ret;
}
if (!(s->fdsp = avpriv_float_dsp_alloc(0))) if (!(s->fdsp = avpriv_float_dsp_alloc(0)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);