History

avcodec: remove deprecated FF_API_AVFFT

Deprecated since 2023-09-01.

James Almer committed 1 year ago

Commit 84c64e01 parent 58286244 files · +0 −420Browse files

Unified · Split

4 files
  1. libavcodec/Makefile +0 −2
  2. libavcodec/avfft.c +0 −268
  3. libavcodec/avfft.h +0 −149
  4. libavcodec/version_major.h +0 −1
libavcodec/Makefile+0−2
@@ -5,7 +5,6 @@ HEADERS = ac3_parser.h \ · 4 unmodified lines
55 adts_parser.h \
66 avcodec.h \
77 avdct.h \
8− avfft.h \
98 bsf.h \
109 codec.h \
1110 codec_desc.h \
@@ -31,7 +30,6 @@ OBJS = ac3_parser.o \ · 19 unmodified lines
3130 allcodecs.o \
3231 avcodec.o \
3332 avdct.o \
34− avfft.o \
3533 packet.o \
3634 bitstream.o \
3735 bitstream_filters.o \
libavcodec/avfft.c+0−268
@@ -1,268 +0,0 @@
1−/*
2− * This file is part of FFmpeg.
3− *
4− * FFmpeg is free software; you can redistribute it and/or
5− * modify it under the terms of the GNU Lesser General Public
6− * License as published by the Free Software Foundation; either
7− * version 2.1 of the License, or (at your option) any later version.
8− *
9− * FFmpeg is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12− * Lesser General Public License for more details.
13− *
14− * You should have received a copy of the GNU Lesser General Public
15− * License along with FFmpeg; if not, write to the Free Software
16− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17− */
18−
19−#include <stddef.h>
20−#include <string.h>
21−
22−#include "libavutil/attributes.h"
23−#include "libavutil/macros.h"
24−#include "libavutil/mem.h"
25−#include "libavutil/tx.h"
26−#include "avfft.h"
27−
28−typedef struct AVTXWrapper {
29− AVTXContext *ctx;
30− av_tx_fn fn;
31−
32− AVTXContext *ctx2;
33− av_tx_fn fn2;
34−
35− ptrdiff_t stride;
36− int len;
37− int inv;
38−
39− float *tmp;
40− int out_of_place;
41−} AVTXWrapper;
42−
43−/* FFT */
44−
45−FFTContext *av_fft_init(int nbits, int inverse)
46−{
47− int ret;
48− float scale = 1.0f;
49− AVTXWrapper *s = av_mallocz(sizeof(*s));
50− if (!s)
51− return NULL;
52−
53− ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_FFT, inverse, 1 << nbits,
54− &scale, AV_TX_INPLACE);
55− if (ret < 0) {
56− av_free(s);
57− return NULL;
58− }
59−
60− return (FFTContext *)s;
61−}
62−
63−void av_fft_permute(FFTContext *s, FFTComplex *z)
64−{
65− /* Empty */
66−}
67−
68−void av_fft_calc(FFTContext *s, FFTComplex *z)
69−{
70− AVTXWrapper *w = (AVTXWrapper *)s;
71− w->fn(w->ctx, z, (void *)z, sizeof(AVComplexFloat));
72−}
73−
74−av_cold void av_fft_end(FFTContext *s)
75−{
76− if (s) {
77− AVTXWrapper *w = (AVTXWrapper *)s;
78− av_tx_uninit(&w->ctx);
79− av_tx_uninit(&w->ctx2);
80− av_free(w);
81− }
82−}
83−
84−FFTContext *av_mdct_init(int nbits, int inverse, double scale)
85−{
86− int ret;
87− float scale_f = scale;
88− AVTXWrapper *s = av_mallocz(sizeof(*s));
89− if (!s)
90− return NULL;
91−
92− ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_MDCT, inverse, 1 << (nbits - 1), &scale_f, 0);
93− if (ret < 0) {
94− av_free(s);
95− return NULL;
96− }
97−
98− if (inverse) {
99− ret = av_tx_init(&s->ctx2, &s->fn2, AV_TX_FLOAT_MDCT, inverse, 1 << (nbits - 1),
100− &scale_f, AV_TX_FULL_IMDCT);
101− if (ret < 0) {
102− av_tx_uninit(&s->ctx);
103− av_free(s);
104− return NULL;
105− }
106− }
107−
108− return (FFTContext *)s;
109−}
110−
111−void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
112−{
113− AVTXWrapper *w = (AVTXWrapper *)s;
114− w->fn2(w->ctx2, output, (void *)input, sizeof(float));
115−}
116−
117−void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
118−{
119− AVTXWrapper *w = (AVTXWrapper *)s;
120− w->fn(w->ctx, output, (void *)input, sizeof(float));
121−}
122−
123−void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
124−{
125− AVTXWrapper *w = (AVTXWrapper *)s;
126− w->fn(w->ctx, output, (void *)input, sizeof(float));
127−}
128−
129−av_cold void av_mdct_end(FFTContext *s)
130−{
131− if (s) {
132− AVTXWrapper *w = (AVTXWrapper *)s;
133− av_tx_uninit(&w->ctx2);
134− av_tx_uninit(&w->ctx);
135− av_free(w);
136− }
137−}
138−
139−RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans)
140−{
141− int ret;
142− float scale = trans == IDFT_C2R ? 0.5f : 1.0f;
143− AVTXWrapper *s;
144−
145− /* The other 2 modes are unconventional, do not form an orthogonal
146− * transform, have never been useful, and so they're not implemented. */
147− if (trans != IDFT_C2R && trans != DFT_R2C)
148− return NULL;
149−
150− s = av_mallocz(sizeof(*s));
151− if (!s)
152− return NULL;
153−
154− ret = av_tx_init(&s->ctx, &s->fn, AV_TX_FLOAT_RDFT, trans == IDFT_C2R,
155− 1 << nbits, &scale, 0x0);
156− if (ret < 0) {
157− av_free(s);
158− return NULL;
159− }
160−
161− s->stride = (trans == DFT_C2R) ? sizeof(AVComplexFloat) : sizeof(float);
162− s->len = 1 << nbits;
163− s->inv = trans == IDFT_C2R;
164−
165− s->tmp = av_malloc((s->len + 2)*sizeof(float));
166− if (!s->tmp) {
167− av_tx_uninit(&s->ctx);
168− av_free(s);
169− return NULL;
170− }
171−
172− return (RDFTContext *)s;
173−}
174−
175−void av_rdft_calc(RDFTContext *s, FFTSample *data)
176−{
177− AVTXWrapper *w = (AVTXWrapper *)s;
178− float *src = w->inv ? w->tmp : (float *)data;
179− float *dst = w->inv ? (float *)data : w->tmp;
180−
181− if (w->inv) {
182− memcpy(src, data, w->len*sizeof(float));
183−
184− src[w->len] = src[1];
185− src[1] = 0.0f;
186− }
187−
188− w->fn(w->ctx, dst, (void *)src, w->stride);
189−
190− if (!w->inv) {
191− dst[1] = dst[w->len];
192− memcpy(data, dst, w->len*sizeof(float));
193− }
194−}
195−
196−av_cold void av_rdft_end(RDFTContext *s)
197−{
198− if (s) {
199− AVTXWrapper *w = (AVTXWrapper *)s;
200− av_tx_uninit(&w->ctx);
201− av_free(w->tmp);
202− av_free(w);
203− }
204−}
205−
206−DCTContext *av_dct_init(int nbits, enum DCTTransformType inverse)
207−{
208− int ret;
209− const float scale_map[] = {
210− [DCT_II] = 0.5f,
211− [DCT_III] = 1.0f / (1 << nbits),
212− [DCT_I] = 0.5f,
213− [DST_I] = 2.0f,
214− };
215− static const enum AVTXType type_map[] = {
216− [DCT_II] = AV_TX_FLOAT_DCT,
217− [DCT_III] = AV_TX_FLOAT_DCT,
218− [DCT_I] = AV_TX_FLOAT_DCT_I,
219− [DST_I] = AV_TX_FLOAT_DST_I,
220− };
221−
222− AVTXWrapper *s = av_mallocz(sizeof(*s));
223− if (!s)
224− return NULL;
225−
226− s->len = (1 << nbits);
227− s->out_of_place = (inverse == DCT_I) || (inverse == DST_I);
228−
229− ret = av_tx_init(&s->ctx, &s->fn, type_map[inverse],
230− (inverse == DCT_III), 1 << (nbits - (inverse == DCT_III)),
231− &scale_map[inverse], s->out_of_place ? 0 : AV_TX_INPLACE);
232− if (ret < 0) {
233− av_free(s);
234− return NULL;
235− }
236−
237− if (s->out_of_place) {
238− s->tmp = av_malloc((1 << (nbits + 1))*sizeof(float));
239− if (!s->tmp) {
240− av_tx_uninit(&s->ctx);
241− av_free(s);
242− return NULL;
243− }
244− }
245−
246− return (DCTContext *)s;
247−}
248−
249−void av_dct_calc(DCTContext *s, FFTSample *data)
250−{
251− AVTXWrapper *w = (AVTXWrapper *)s;
252− if (w->out_of_place) {
253− memcpy(w->tmp, data, w->len*sizeof(float));
254− w->fn(w->ctx, (void *)data, w->tmp, sizeof(float));
255− } else {
256− w->fn(w->ctx, data, (void *)data, sizeof(float));
257− }
258−}
259−
260−av_cold void av_dct_end(DCTContext *s)
261−{
262− if (s) {
263− AVTXWrapper *w = (AVTXWrapper *)s;
264− av_tx_uninit(&w->ctx);
265− av_free(w->tmp);
266− av_free(w);
267− }
268−}
libavcodec/avfft.h+0−149
@@ -1,149 +0,0 @@
1−/*
2− * This file is part of FFmpeg.
3− *
4− * FFmpeg is free software; you can redistribute it and/or
5− * modify it under the terms of the GNU Lesser General Public
6− * License as published by the Free Software Foundation; either
7− * version 2.1 of the License, or (at your option) any later version.
8− *
9− * FFmpeg is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12− * Lesser General Public License for more details.
13− *
14− * You should have received a copy of the GNU Lesser General Public
15− * License along with FFmpeg; if not, write to the Free Software
16− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17− */
18−
19−#ifndef AVCODEC_AVFFT_H
20−#define AVCODEC_AVFFT_H
21−
22−#include "libavutil/attributes.h"
23−#include "version_major.h"
24−#if FF_API_AVFFT
25−
26−/**
27− * @file
28− * @ingroup lavc_fft
29− * FFT functions
30− */
31−
32−/**
33− * @defgroup lavc_fft FFT functions
34− * @ingroup lavc_misc
35− *
36− * @{
37− */
38−
39−typedef float FFTSample;
40−
41−typedef struct FFTComplex {
42− FFTSample re, im;
43−} FFTComplex;
44−
45−typedef struct FFTContext FFTContext;
46−
47−/**
48− * Set up a complex FFT.
49− * @param nbits log2 of the length of the input array
50− * @param inverse if 0 perform the forward transform, if 1 perform the inverse
51− * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_FFT
52− */
53−attribute_deprecated
54−FFTContext *av_fft_init(int nbits, int inverse);
55−
56−/**
57− * Do the permutation needed BEFORE calling ff_fft_calc().
58− * @deprecated without replacement
59− */
60−attribute_deprecated
61−void av_fft_permute(FFTContext *s, FFTComplex *z);
62−
63−/**
64− * Do a complex FFT with the parameters defined in av_fft_init(). The
65− * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
66− * @deprecated use the av_tx_fn value returned by av_tx_init, which also does permutation
67− */
68−attribute_deprecated
69−void av_fft_calc(FFTContext *s, FFTComplex *z);
70−
71−attribute_deprecated
72−void av_fft_end(FFTContext *s);
73−
74−/**
75− * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_MDCT,
76− * with a flag of AV_TX_FULL_IMDCT for a replacement to av_imdct_calc.
77− */
78−attribute_deprecated
79−FFTContext *av_mdct_init(int nbits, int inverse, double scale);
80−attribute_deprecated
81−void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
82−attribute_deprecated
83−void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
84−attribute_deprecated
85−void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
86−attribute_deprecated
87−void av_mdct_end(FFTContext *s);
88−
89−/* Real Discrete Fourier Transform */
90−
91−enum RDFTransformType {
92− DFT_R2C,
93− IDFT_C2R,
94− IDFT_R2C,
95− DFT_C2R,
96−};
97−
98−typedef struct RDFTContext RDFTContext;
99−
100−/**
101− * Set up a real FFT.
102− * @param nbits log2 of the length of the input array
103− * @param trans the type of transform
104− *
105− * @deprecated use av_tx_init from libavutil/tx.h with a type of AV_TX_FLOAT_RDFT
106− */
107−attribute_deprecated
108−RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
109−attribute_deprecated
110−void av_rdft_calc(RDFTContext *s, FFTSample *data);
111−attribute_deprecated
112−void av_rdft_end(RDFTContext *s);
113−
114−/* Discrete Cosine Transform */
115−
116−typedef struct DCTContext DCTContext;
117−
118−enum DCTTransformType {
119− DCT_II = 0,
120− DCT_III,
121− DCT_I,
122− DST_I,
123−};
124−
125−/**
126− * Set up DCT.
127− *
128− * @param nbits size of the input array:
129− * (1 << nbits) for DCT-II, DCT-III and DST-I
130− * (1 << nbits) + 1 for DCT-I
131− * @param type the type of transform
132− *
133− * @note the first element of the input of DST-I is ignored
134− *
135− * @deprecated use av_tx_init from libavutil/tx.h with an appropriate type of AV_TX_FLOAT_DCT
136− */
137−attribute_deprecated
138−DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
139−attribute_deprecated
140−void av_dct_calc(DCTContext *s, FFTSample *data);
141−attribute_deprecated
142−void av_dct_end (DCTContext *s);
143−
144−/**
145− * @}
146− */
147−
148−#endif /* FF_API_AVFFT */
149−#endif /* AVCODEC_AVFFT_H */
libavcodec/version_major.h+0−1
@@ -39,7 +39,6 @@ · 38 unmodified lines
3939
4040 #define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 62)
4141
42−#define FF_API_AVFFT (LIBAVCODEC_VERSION_MAJOR < 62)
4342 #define FF_API_FF_PROFILE_LEVEL (LIBAVCODEC_VERSION_MAJOR < 62)
4443 #define FF_API_AVCODEC_CLOSE (LIBAVCODEC_VERSION_MAJOR < 62)
4544 #define FF_API_BUFFER_MIN_SIZE (LIBAVCODEC_VERSION_MAJOR < 62)

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