38 #define SIN(s, n, x) (s->costab[(n) - (x)]) 41 #define COS(s, n, x) (s->costab[x]) 45 int n = 1 << ctx->
nbits;
49 for (i = 1; i < n / 2; i++) {
50 float tmp1 = data[
i ];
51 float tmp2 = data[n -
i];
52 float s =
SIN(ctx, n, 2 * i);
55 tmp1 = (tmp1 - tmp2) * 0.5
f;
57 data[n -
i] = s - tmp1;
65 for (i = 1; i < n - 2; i += 2) {
66 data[i + 1] += data[i - 1];
67 data[
i] = -data[i + 2];
75 int n = 1 << ctx->
nbits;
77 float next = -0.5f * (data[0] - data[n]);
79 for (i = 0; i < n / 2; i++) {
81 float tmp2 = data[n -
i];
82 float s =
SIN(ctx, n, 2 * i);
83 float c =
COS(ctx, n, 2 * i);
90 tmp1 = (tmp1 + tmp2) * 0.5
f;
92 data[n -
i] = tmp1 +
s;
99 for (i = 3; i <= n; i += 2)
100 data[i] = data[i - 2] - data[i];
105 int n = 1 << ctx->
nbits;
108 float next = data[n - 1];
109 float inv_n = 1.0f / n;
111 for (i = n - 2; i >= 2; i -= 2) {
112 float val1 = data[
i];
113 float val2 = data[i - 1] - data[i + 1];
114 float c =
COS(ctx, n, i);
115 float s =
SIN(ctx, n, i);
117 data[
i] = c * val1 + s * val2;
118 data[i + 1] = s * val1 - c * val2;
125 for (i = 0; i < n / 2; i++) {
126 float tmp1 = data[
i] * inv_n;
127 float tmp2 = data[n - i - 1] * inv_n;
128 float csc = ctx->
csc2[
i] * (tmp1 - tmp2);
131 data[
i] = tmp1 + csc;
132 data[n - i - 1] = tmp1 - csc;
138 int n = 1 << ctx->
nbits;
142 for (i = 0; i < n / 2; i++) {
143 float tmp1 = data[
i];
144 float tmp2 = data[n - i - 1];
145 float s =
SIN(ctx, n, 2 * i + 1);
148 tmp1 = (tmp1 + tmp2) * 0.5
f;
151 data[n-i-1] = tmp1 -
s;
156 next = data[1] * 0.5;
159 for (i = n - 2; i >= 0; i -= 2) {
160 float inr = data[
i ];
161 float ini = data[i + 1];
162 float c =
COS(ctx, n, i);
163 float s =
SIN(ctx, n, i);
165 data[
i] = c * inr + s * ini;
168 next += s * inr - c * ini;
174 ctx->
dct32(data, data);
183 memset(s, 0,
sizeof(*s));
188 if (inverse ==
DCT_II && nbits == 5) {
193 s->
costab = ff_cos_tabs[nbits + 2];
203 for (i = 0; i < n / 2; i++)
204 s->
csc2[i] = 0.5 / sin((
M_PI / (2 * n) * (2 * i + 1)));
av_cold void ff_rdft_end(RDFTContext *s)
static void dct32_func(DCTContext *ctx, FFTSample *data)
ptrdiff_t const GLvoid * data
static void dct_calc_I_c(DCTContext *ctx, FFTSample *data)
void ff_dct_init_x86(DCTContext *s)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void dct_calc_II_c(DCTContext *ctx, FFTSample *data)
void(* dct_calc)(struct DCTContext *s, FFTSample *data)
void(* rdft_calc)(struct RDFTContext *s, FFTSample *z)
void ff_dct32_float(float *dst, const float *src)
static void dct_calc_III_c(DCTContext *ctx, FFTSample *data)
av_cold int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType inverse)
Set up DCT.
void(* dct32)(FFTSample *out, const FFTSample *in)
#define ff_init_ff_cos_tabs
static void dst_calc_I_c(DCTContext *ctx, FFTSample *data)
av_cold void ff_dct_end(DCTContext *s)
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
#define av_malloc_array(a, b)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
Set up a real FFT.