History

qdm2: convert to lavu/tx

Lynne committed 4 years ago

Commit 1aeedd21 parent e6afa612 files · +27 −21Browse files

Unified · Split

2 files
  1. configure +1 −1
  2. libavcodec/qdm2.c +26 −20
configure+1−1
@@ -2920,7 +2920,7 @@ prores_encoder_select="fdctdsp" · 2919 unmodified lines
29202920 prores_aw_encoder_select="fdctdsp"
29212921 prores_ks_encoder_select="fdctdsp"
29222922 qcelp_decoder_select="lsp"
2923−qdm2_decoder_select="rdft mpegaudiodsp"
2923+qdm2_decoder_select="mpegaudiodsp"
29242924 ra_144_decoder_select="audiodsp"
29252925 ra_144_encoder_select="audio_frame_queue lpc audiodsp"
29262926 ralf_decoder_select="golomb"
libavcodec/qdm2.c+26−20
@@ -37,6 +37,7 @@ · 36 unmodified lines
3737 #include "libavutil/channel_layout.h"
3838 #include "libavutil/mem_internal.h"
3939 #include "libavutil/thread.h"
40+#include "libavutil/tx.h"
4041
4142 #define BITSTREAM_READER_LE
4243 #include "avcodec.h"
@@ -46,7 +47,6 @@ · 3 unmodified lines
4647 #include "decode.h"
4748 #include "mpegaudio.h"
4849 #include "mpegaudiodsp.h"
49−#include "rdft.h"
5050
5151 #include "qdm2_tablegen.h"
5252
@@ -96,14 +96,9 @@ typedef struct QDM2SubPNode { · 43 unmodified lines
9696 struct QDM2SubPNode *next; ///< pointer to next packet in the list, NULL if leaf node
9797 } QDM2SubPNode;
9898
99−typedef struct QDM2Complex {
100− float re;
101− float im;
102−} QDM2Complex;
103−
10499 typedef struct FFTTone {
105100 float level;
106− QDM2Complex *complex;
101+ AVComplexFloat *complex;
107102 const float *table;
108103 int phase;
109104 int phase_shift;
@@ -121,7 +116,8 @@ typedef struct FFTCoefficient { · 11 unmodified lines
121116 } FFTCoefficient;
122117
123118 typedef struct QDM2FFT {
124− DECLARE_ALIGNED(32, QDM2Complex, complex)[MPA_MAX_CHANNELS][256];
119+ DECLARE_ALIGNED(32, AVComplexFloat, complex)[MPA_MAX_CHANNELS][256 + 1];
120+ DECLARE_ALIGNED(32, AVComplexFloat, temp)[MPA_MAX_CHANNELS][256];
125121 } QDM2FFT;
126122
127123 /**
@@ -161,7 +157,8 @@ typedef struct QDM2Context { · 33 unmodified lines
161157 int fft_coefs_min_index[5];
162158 int fft_coefs_max_index[5];
163159 int fft_level_exp[6];
164− RDFTContext rdft_ctx;
160+ AVTXContext *rdft_ctx;
161+ av_tx_fn rdft_fn;
165162 QDM2FFT fft;
166163
167164 /// I/O data
@@ -1428,7 +1425,7 @@ static void qdm2_fft_generate_tone(QDM2Context *q, FFTTone *tone) · 1260 unmodified lines
14281425 {
14291426 float level, f[6];
14301427 int i;
1431− QDM2Complex c;
1428+ AVComplexFloat c;
14321429 const double iscale = 2.0 * M_PI / 512.0;
14331430
14341431 tone->phase += tone->phase_shift;
@@ -1476,7 +1473,7 @@ static void qdm2_fft_tone_synthesizer(QDM2Context *q, int sub_packet) · 41 unmodified lines
14761473 const double iscale = 0.25 * M_PI;
14771474
14781475 for (ch = 0; ch < q->channels; ch++) {
1479− memset(q->fft.complex[ch], 0, q->fft_size * sizeof(QDM2Complex));
1476+ memset(q->fft.complex[ch], 0, q->fft_size * sizeof(AVComplexFloat));
14801477 }
14811478
14821479
@@ -1484,7 +1481,7 @@ static void qdm2_fft_tone_synthesizer(QDM2Context *q, int sub_packet) · 1 unmodified line
14841481 if (q->fft_coefs_min_index[4] >= 0)
14851482 for (i = q->fft_coefs_min_index[4]; i < q->fft_coefs_max_index[4]; i++) {
14861483 float level;
1487− QDM2Complex c;
1484+ AVComplexFloat c;
14881485
14891486 if (q->fft_coefs[i].sub_packet != sub_packet)
14901487 break;
@@ -1545,14 +1542,19 @@ static void qdm2_calculate_fft(QDM2Context *q, int channel, int sub_packet) · 54 unmodified lines
15451542 {
15461543 const float gain = (q->channels == 1 && q->nb_channels == 2) ? 0.5f : 1.0f;
15471544 float *out = q->output_buffer + channel;
1548− int i;
1545+
15491546 q->fft.complex[channel][0].re *= 2.0f;
15501547 q->fft.complex[channel][0].im = 0.0f;
1551− q->rdft_ctx.rdft_calc(&q->rdft_ctx, (FFTSample *)q->fft.complex[channel]);
1548+ q->fft.complex[channel][q->fft_size].re = 0.0f;
1549+ q->fft.complex[channel][q->fft_size].im = 0.0f;
1550+
1551+ q->rdft_fn(q->rdft_ctx, q->fft.temp[channel], q->fft.complex[channel],
1552+ sizeof(AVComplexFloat));
1553+
15521554 /* add samples to output buffer */
1553− for (i = 0; i < FFALIGN(q->fft_size, 8); i++) {
1554− out[0] += q->fft.complex[channel][i].re * gain;
1555− out[q->channels] += q->fft.complex[channel][i].im * gain;
1555+ for (int i = 0; i < FFALIGN(q->fft_size, 8); i++) {
1556+ out[0] += q->fft.temp[channel][i].re * gain;
1557+ out[q->channels] += q->fft.temp[channel][i].im * gain;
15561558 out += 2 * q->channels;
15571559 }
15581560 }
@@ -1613,7 +1615,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) · 54 unmodified lines
16131615 {
16141616 static AVOnce init_static_once = AV_ONCE_INIT;
16151617 QDM2Context *s = avctx->priv_data;
1616− int tmp_val, tmp, size;
1618+ int ret, tmp_val, tmp, size;
1619+ float scale = 1.0f / 2.0f;
16171620 GetByteContext gb;
16181621
16191622 /* extradata parsing
@@ -1756,7 +1759,10 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx) · 136 unmodified lines
17561759 return AVERROR_INVALIDDATA;
17571760 }
17581761
1759− ff_rdft_init(&s->rdft_ctx, s->fft_order, IDFT_C2R);
1762+ ret = av_tx_init(&s->rdft_ctx, &s->rdft_fn, AV_TX_FLOAT_RDFT, 1, 2*s->fft_size, &scale, 0);
1763+ if (ret < 0)
1764+ return ret;
1765+
17601766 ff_mpadsp_init(&s->mpadsp);
17611767
17621768 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
@@ -1770,7 +1776,7 @@ static av_cold int qdm2_decode_close(AVCodecContext *avctx) · 7 unmodified lines
17701776 {
17711777 QDM2Context *s = avctx->priv_data;
17721778
1773− ff_rdft_end(&s->rdft_ctx);
1779+ av_tx_uninit(&s->rdft_ctx);
17741780
17751781 return 0;
17761782 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t