FFmpeg
tx_priv.h
Go to the documentation of this file.
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 AVUTIL_TX_PRIV_H
20 #define AVUTIL_TX_PRIV_H
21 
22 #include "tx.h"
23 #include <stddef.h>
24 #include "thread.h"
25 #include "mem.h"
26 #include "avassert.h"
27 #include "attributes.h"
28 
29 #ifdef TX_FLOAT
30 #define TX_NAME(x) x ## _float
31 typedef float FFTSample;
33 #elif defined(TX_DOUBLE)
34 #define TX_NAME(x) x ## _double
35 typedef double FFTSample;
37 #else
38 typedef void FFTComplex;
39 #endif
40 
41 #if defined(TX_FLOAT) || defined(TX_DOUBLE)
42 #define BF(x, y, a, b) do { \
43  x = (a) - (b); \
44  y = (a) + (b); \
45  } while (0)
46 
47 #define CMUL(dre, dim, are, aim, bre, bim) do { \
48  (dre) = (are) * (bre) - (aim) * (bim); \
49  (dim) = (are) * (bim) + (aim) * (bre); \
50  } while (0)
51 #endif
52 
53 #define CMUL3(c, a, b) \
54  CMUL((c).re, (c).im, (a).re, (a).im, (b).re, (b).im)
55 
56 #define COSTABLE(size) \
57  DECLARE_ALIGNED(32, FFTSample, TX_NAME(ff_cos_##size))[size/2]
58 
59 /* Used by asm, reorder with care */
60 struct AVTXContext {
61  int n; /* Nptwo part */
62  int m; /* Ptwo part */
63  int inv; /* Is inverted */
64  int type; /* Type */
65 
66  FFTComplex *exptab; /* MDCT exptab */
67  FFTComplex *tmp; /* Temporary buffer needed for all compound transforms */
68  int *pfatab; /* Input/Output mapping for compound transforms */
69  int *revtab; /* Input mapping for power of two transforms */
70 };
71 
72 /* Shared functions */
75 
76 /* Also used by SIMD init */
77 static inline int split_radix_permutation(int i, int n, int inverse)
78 {
79  int m;
80  if (n <= 2)
81  return i & 1;
82  m = n >> 1;
83  if (!(i & m))
84  return split_radix_permutation(i, m, inverse)*2;
85  m >>= 1;
86  if (inverse == !(i & m))
87  return split_radix_permutation(i, m, inverse)*4 + 1;
88  else
89  return split_radix_permutation(i, m, inverse)*4 - 1;
90 }
91 
92 /* Templated functions */
94  enum AVTXType type, int inv, int len,
95  const void *scale, uint64_t flags);
97  enum AVTXType type, int inv, int len,
98  const void *scale, uint64_t flags);
99 
100 typedef struct CosTabsInitOnce {
101  void (*func)(void);
102  AVOnce control;
104 
105 #endif /* AVUTIL_TX_PRIV_H */
int inv
Definition: tx_priv.h:63
Memory handling functions.
GLint GLenum type
Definition: opengl_enc.c:104
void FFTComplex
Definition: tx_priv.h:38
Macro definitions for various function/variable attributes.
int ff_tx_gen_ptwo_revtab(AVTXContext *s)
Definition: tx.c:83
int ff_tx_gen_compound_mapping(AVTXContext *s)
Definition: tx.c:32
#define AVOnce
Definition: thread.h:159
int ff_tx_init_mdct_fft_float(AVTXContext *s, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:68
AVTXType
Definition: tx.h:35
simple assert() macros that are a bit more flexible than ISO C assert().
float FFTSample
Definition: avfft.h:35
FFTComplex * exptab
Definition: tx_priv.h:66
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
int * revtab
Definition: tx_priv.h:69
#define s(width, name)
Definition: cbs_vp9.c:257
int * pfatab
Definition: tx_priv.h:68
FFTComplex * tmp
Definition: tx_priv.h:67
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67
int type
Definition: tx_priv.h:64
#define flags(name, subs,...)
Definition: cbs_av1.c:561
int ff_tx_init_mdct_fft_double(AVTXContext *s, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
int len
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
Definition: asfcrypt.c:35
static int split_radix_permutation(int i, int n, int inverse)
Definition: tx_priv.h:77