faudio: Import upstream release 24.02.
[wine.git] / libs / faudio / src / FAPOFX_masteringlimiter.c
blob2a8bb92dda4ee6eb506da15adbbf9043904d6dd1
1 /* FAudio - XAudio Reimplementation for FNA
3 * Copyright (c) 2011-2024 Ethan Lee, Luigi Auriemma, and the MonoGame Team
5 * This software is provided 'as-is', without any express or implied warranty.
6 * In no event will the authors be held liable for any damages arising from
7 * the use of this software.
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software in a
15 * product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
21 * 3. This notice may not be removed or altered from any source distribution.
23 * Ethan "flibitijibibo" Lee <flibitijibibo@flibitijibibo.com>
27 #include "FAPOFX.h"
28 #include "FAudio_internal.h"
30 /* FXMasteringLimiter FAPO Implementation */
32 const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter =
34 0xC4137916,
35 0x2BE1,
36 0x46FD,
38 0x85,
39 0x99,
40 0x44,
41 0x15,
42 0x36,
43 0xF4,
44 0x98,
45 0x56
49 static FAPORegistrationProperties FXMasteringLimiterProperties =
51 /* .clsid = */ {0},
52 /* .FriendlyName = */
54 'F', 'X', 'M', 'a', 's', 't', 'e', 'r', 'i', 'n', 'g', 'L', 'i', 'm', 'i', 't', 'e', 'r', '\0'
56 /*.CopyrightInfo = */
58 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
59 'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
61 /*.MajorVersion = */ 0,
62 /*.MinorVersion = */ 0,
63 /*.Flags = */(
64 FAPO_FLAG_FRAMERATE_MUST_MATCH |
65 FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
66 FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
67 FAPO_FLAG_INPLACE_SUPPORTED |
68 FAPO_FLAG_INPLACE_REQUIRED
70 /*.MinInputBufferCount = */ 1,
71 /*.MaxInputBufferCount = */ 1,
72 /*.MinOutputBufferCount = */ 1,
73 /*.MaxOutputBufferCount =*/ 1
76 const FAudioGUID FAPOFX_CLSID_FXMasteringLimiter_LEGACY =
78 0xA90BC001,
79 0xE897,
80 0xE897,
82 0x74,
83 0x39,
84 0x43,
85 0x55,
86 0x00,
87 0x00,
88 0x00,
89 0x01
93 static FAPORegistrationProperties FXMasteringLimiterProperties_LEGACY =
95 /* .clsid = */ {0},
96 /* .FriendlyName = */
98 'F', 'X', 'M', 'a', 's', 't', 'e', 'r', 'i', 'n', 'g', 'L', 'i', 'm', 'i', 't', 'e', 'r', '\0'
100 /*.CopyrightInfo = */
102 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'c', ')',
103 'E', 't', 'h', 'a', 'n', ' ', 'L', 'e', 'e', '\0'
105 /*.MajorVersion = */ 0,
106 /*.MinorVersion = */ 0,
107 /*.Flags = */(
108 FAPO_FLAG_FRAMERATE_MUST_MATCH |
109 FAPO_FLAG_BITSPERSAMPLE_MUST_MATCH |
110 FAPO_FLAG_BUFFERCOUNT_MUST_MATCH |
111 FAPO_FLAG_INPLACE_SUPPORTED |
112 FAPO_FLAG_INPLACE_REQUIRED
114 /*.MinInputBufferCount = */ 1,
115 /*.MaxInputBufferCount = */ 1,
116 /*.MinOutputBufferCount = */ 1,
117 /*.MaxOutputBufferCount =*/ 1
120 typedef struct FAPOFXMasteringLimiter
122 FAPOBase base;
124 /* TODO */
125 } FAPOFXMasteringLimiter;
127 uint32_t FAPOFXMasteringLimiter_Initialize(
128 FAPOFXMasteringLimiter *fapo,
129 const void* pData,
130 uint32_t DataByteSize
132 #define INITPARAMS(offset) \
133 FAudio_memcpy( \
134 fapo->base.m_pParameterBlocks + DataByteSize * offset, \
135 pData, \
136 DataByteSize \
138 INITPARAMS(0)
139 INITPARAMS(1)
140 INITPARAMS(2)
141 #undef INITPARAMS
142 return 0;
145 void FAPOFXMasteringLimiter_Process(
146 FAPOFXMasteringLimiter *fapo,
147 uint32_t InputProcessParameterCount,
148 const FAPOProcessBufferParameters* pInputProcessParameters,
149 uint32_t OutputProcessParameterCount,
150 FAPOProcessBufferParameters* pOutputProcessParameters,
151 int32_t IsEnabled
153 FAPOBase_BeginProcess(&fapo->base);
155 /* TODO */
157 FAPOBase_EndProcess(&fapo->base);
160 void FAPOFXMasteringLimiter_Free(void* fapo)
162 FAPOFXMasteringLimiter *limiter = (FAPOFXMasteringLimiter*) fapo;
163 limiter->base.pFree(limiter->base.m_pParameterBlocks);
164 limiter->base.pFree(fapo);
167 /* Public API */
169 uint32_t FAPOFXCreateMasteringLimiter(
170 FAPO **pEffect,
171 const void *pInitData,
172 uint32_t InitDataByteSize,
173 FAudioMallocFunc customMalloc,
174 FAudioFreeFunc customFree,
175 FAudioReallocFunc customRealloc,
176 uint8_t legacy
178 const FAPOFXMasteringLimiterParameters fxdefault =
180 FAPOFXMASTERINGLIMITER_DEFAULT_RELEASE,
181 FAPOFXMASTERINGLIMITER_DEFAULT_LOUDNESS
184 /* Allocate... */
185 FAPOFXMasteringLimiter *result = (FAPOFXMasteringLimiter*) customMalloc(
186 sizeof(FAPOFXMasteringLimiter)
188 uint8_t *params = (uint8_t*) customMalloc(
189 sizeof(FAPOFXMasteringLimiterParameters) * 3
191 if (pInitData == NULL)
193 FAudio_zero(params, sizeof(FAPOFXMasteringLimiterParameters) * 3);
194 #define INITPARAMS(offset) \
195 FAudio_memcpy( \
196 params + sizeof(FAPOFXMasteringLimiterParameters) * offset, \
197 &fxdefault, \
198 sizeof(FAPOFXMasteringLimiterParameters) \
200 INITPARAMS(0)
201 INITPARAMS(1)
202 INITPARAMS(2)
203 #undef INITPARAMS
205 else
207 FAudio_assert(InitDataByteSize == sizeof(FAPOFXMasteringLimiterParameters));
208 FAudio_memcpy(params, pInitData, InitDataByteSize);
209 FAudio_memcpy(params + InitDataByteSize, pInitData, InitDataByteSize);
210 FAudio_memcpy(params + (InitDataByteSize * 2), pInitData, InitDataByteSize);
213 /* Initialize... */
214 FAudio_memcpy(
215 &FXMasteringLimiterProperties_LEGACY.clsid,
216 &FAPOFX_CLSID_FXMasteringLimiter_LEGACY,
217 sizeof(FAudioGUID)
219 FAudio_memcpy(
220 &FXMasteringLimiterProperties.clsid,
221 &FAPOFX_CLSID_FXMasteringLimiter,
222 sizeof(FAudioGUID)
224 CreateFAPOBaseWithCustomAllocatorEXT(
225 &result->base,
226 legacy ? &FXMasteringLimiterProperties_LEGACY : &FXMasteringLimiterProperties,
227 params,
228 sizeof(FAPOFXMasteringLimiterParameters),
230 customMalloc,
231 customFree,
232 customRealloc
235 /* Function table... */
236 result->base.base.Initialize = (InitializeFunc)
237 FAPOFXMasteringLimiter_Initialize;
238 result->base.base.Process = (ProcessFunc)
239 FAPOFXMasteringLimiter_Process;
240 result->base.Destructor = FAPOFXMasteringLimiter_Free;
242 /* Finally. */
243 *pEffect = &result->base.base;
244 return 0;
247 /* vim: set noexpandtab shiftwidth=8 tabstop=8: */