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 module ffmpeg.libavutil.tx; 19 20 import ffmpeg.libavutil; 21 22 extern (C) @nogc nothrow: 23 24 struct AVTXContext; 25 26 struct AVComplexFloat 27 { 28 float re; 29 float im; 30 } 31 32 struct AVComplexDouble 33 { 34 double re; 35 double im; 36 } 37 38 struct AVComplexInt32 39 { 40 int re; 41 int im; 42 } 43 44 enum AVTXType 45 { 46 /** 47 * Standard complex to complex FFT with sample data type AVComplexFloat. 48 * Output is not 1/len normalized. Scaling currently unsupported. 49 * The stride parameter is ignored. 50 */ 51 AV_TX_FLOAT_FFT = 0, 52 53 /** 54 * Standard MDCT with sample data type of float and a scale type of 55 * float. Length is the frame size, not the window size (which is 2x frame) 56 * For forward transforms, the stride specifies the spacing between each 57 * sample in the output array in bytes. The input must be a flat array. 58 * For inverse transforms, the stride specifies the spacing between each 59 * sample in the input array in bytes. The output will be a flat array. 60 * Stride must be a non-zero multiple of sizeof(float). 61 * NOTE: the inverse transform is half-length, meaning the output will not 62 * contain redundant data. This is what most codecs work with. 63 */ 64 AV_TX_FLOAT_MDCT = 1, 65 66 /** 67 * Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble. 68 */ 69 AV_TX_DOUBLE_FFT = 2, 70 71 /** 72 * Same as AV_TX_FLOAT_MDCT with data and scale type of double. 73 * Stride must be a non-zero multiple of sizeof(double). 74 */ 75 AV_TX_DOUBLE_MDCT = 3, 76 77 /** 78 * Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32. 79 */ 80 AV_TX_INT32_FFT = 4, 81 82 /** 83 * Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of float. 84 * Only scale values less than or equal to 1.0 are supported. 85 * Stride must be a non-zero multiple of sizeof(int32_t). 86 */ 87 AV_TX_INT32_MDCT = 5 88 } 89 90 /** 91 * Function pointer to a function to perform the transform. 92 * 93 * @note Using a different context than the one allocated during av_tx_init() 94 * is not allowed. 95 * 96 * @param s the transform context 97 * @param out the output array 98 * @param in the input array 99 * @param stride the input or output stride in bytes 100 * 101 * The out and in arrays must be aligned to the maximum required by the CPU 102 * architecture. 103 * The stride must follow the constraints the transform type has specified. 104 */ 105 alias av_tx_fn = void function (AVTXContext* s, void* out_, void* in_, ptrdiff_t stride); 106 107 /** 108 * Flags for av_tx_init() 109 */ 110 enum AVTXFlags 111 { 112 /** 113 * Performs an in-place transformation on the input. The output argument 114 * of av_tn_fn() MUST match the input. May be unsupported or slower for some 115 * transform types. 116 */ 117 AV_TX_INPLACE = 1UL << 0 118 } 119 120 /** 121 * Initialize a transform context with the given configuration 122 * (i)MDCTs with an odd length are currently not supported. 123 * 124 * @param ctx the context to allocate, will be NULL on error 125 * @param tx pointer to the transform function pointer to set 126 * @param type type the type of transform 127 * @param inv whether to do an inverse or a forward transform 128 * @param len the size of the transform in samples 129 * @param scale pointer to the value to scale the output if supported by type 130 * @param flags a bitmask of AVTXFlags or 0 131 * 132 * @return 0 on success, negative error code on failure 133 */ 134 int av_tx_init ( 135 AVTXContext** ctx, 136 av_tx_fn* tx, 137 AVTXType type, 138 int inv, 139 int len, 140 const(void)* scale, 141 ulong flags); 142 143 /** 144 * Frees a context and sets ctx to NULL, does nothing when ctx == NULL 145 */ 146 void av_tx_uninit (AVTXContext** ctx); 147 148 /* AVUTIL_TX_H */