source: trunk/Packages/uos/uos_fdkaacdecoder.pas

Last change on this file was 664, checked in by chronos, 3 days ago
  • Added: Ability to play music in background in start screen and in-game. Used uos as audio library.
File size: 69.1 KB
Line 
1{This unit is part of United Openlibraries of Sound (uos)}
2
3{This is the Pascal Wrapper + Dynamic loading of fdk_aacdecoder library.
4 Load library with ad_load() and release with ad_unload().
5 License : modified LGPL.
6 Fred van Stappen / fiens@hotmail.com / 2024}
7
8unit uos_fdkaacdecoder;
9
10{$mode objfpc}{$H+}
11{$PACKRECORDS C}
12{$MINENUMSIZE 4}
13
14interface
15
16uses
17 dynlibs,
18 SysUtils;
19
20type
21 FDK_MODULE_ID = (
22 FDK_NONE = 0,
23 FDK_TOOLS = 1,
24 FDK_SYSLIB = 2,
25 FDK_AACDEC = 3,
26 FDK_AACENC = 4,
27 FDK_SBRDEC = 5,
28 FDK_SBRENC = 6,
29 FDK_TPDEC = 7,
30 FDK_TPENC = 8,
31 FDK_MPSDEC = 9,
32 FDK_MPEGFILEREAD = 10,
33 FDK_MPEGFILEWRITE = 11,
34 FDK_PCMDMX = 31,
35 FDK_MPSENC = 34,
36 FDK_TDLIMIT = 35,
37 FDK_UNIDRCDEC = 38,
38
39 FDK_MODULE_LAST
40 );
41
42type
43(**
44 * Library information.
45 *)
46 PPLIB_INFO = ^PLIB_INFO;
47 PLIB_INFO = ^LIB_INFO;
48
49 LIB_INFO = record
50 title: MarshaledAString;
51 build_date: MarshaledAString;
52 build_time: MarshaledAString;
53 module_id: FDK_MODULE_ID;
54 version: integer;
55 flags: cardinal;
56 versionStr: array[0..31] of AnsiChar;
57 end;
58
59const
60 _PU = '';
61 {$IF Defined(MSWINDOWS)}
62 {$IFDEF CPUX64}
63 libfdk_aac = 'libfdk-aac-2.dll';
64 {$ENDIF}
65 {$IFDEF CPUX86}
66 libfdk_aac = 'libfdk-aac-2.dll';
67 {$ENDIF}
68 {$ELSEIF Defined(DARWIN) or Defined(MACOS)}
69 libfdk_aac = '@executable_path/../Frameworks/libfdk-aac-2.dylib';
70 {$ELSEIF Defined(UNIX)}
71 libfdk_aac = 'libfdk-aac-2.so';
72 {$IFEND}
73
74type
75 (**
76 * File format identifiers.
77 *)
78 FILE_FORMAT = (
79 FF_UNKNOWN = -1, (**< Unknown format. *)
80 FF_RAW = 0, (**< No container, bit stream data conveyed "as is". *)
81
82 FF_MP4_3GPP = 3, (**< 3GPP file format. *)
83 FF_MP4_MP4F = 4, (**< MPEG-4 File format. *)
84
85 FF_RAWPACKETS = 5 (**< Proprietary raw packet file. *)
86 );
87
88 (**
89 * Transport type identifiers.
90 *)
91 TRANSPORT_TYPE = (
92 TT_UNKNOWN = -1, (**< Unknown format. *)
93 TT_MP4_RAW = 0, (**< "as is" access units (packet based since there is
94 obviously no sync layer) *)
95 TT_MP4_ADIF = 1, (**< ADIF bitstream format. *)
96 TT_MP4_ADTS = 2, (**< ADTS bitstream format. *)
97
98 TT_MP4_LATM_MCP1 = 6, (**< Audio Mux Elements with muxConfigPresent = 1 *)
99 TT_MP4_LATM_MCP0 = 7, (**< Audio Mux Elements with muxConfigPresent = 0, out
100 of band StreamMuxConfig *)
101
102 TT_MP4_LOAS = 10, (**< Audio Sync Stream. *)
103
104 TT_DRM = 12 (**< Digital Radio Mondial (DRM30/DRM+) bitstream format. *)
105 );
106
107 //TT_IS_PACKET(x) \
108 // (((x) == TT_MP4_RAW) || ((x) == TT_DRM) || ((x) == TT_MP4_LATM_MCP0) || \
109 // ((x) == TT_MP4_LATM_MCP1))
110function TT_IS_PACKET(x: TRANSPORT_TYPE): Boolean;
111
112type
113 (**
114 * Audio Object Type definitions.
115 *)
116 AUDIO_OBJECT_TYPE = (
117 AOT_NONE = -1,
118 AOT_NULL_OBJECT = 0,
119 AOT_AAC_MAIN = 1, (**< Main profile *)
120 AOT_AAC_LC = 2, (**< Low Complexity object *)
121 AOT_AAC_SSR = 3,
122 AOT_AAC_LTP = 4,
123 AOT_SBR = 5,
124 AOT_AAC_SCAL = 6,
125 AOT_TWIN_VQ = 7,
126 AOT_CELP = 8,
127 AOT_HVXC = 9,
128 AOT_RSVD_10 = 10, (**< (reserved) *)
129 AOT_RSVD_11 = 11, (**< (reserved) *)
130 AOT_TTSI = 12, (**< TTSI Object *)
131 AOT_MAIN_SYNTH = 13, (**< Main Synthetic object *)
132 AOT_WAV_TAB_SYNTH = 14, (**< Wavetable Synthesis object *)
133 AOT_GEN_MIDI = 15, (**< General MIDI object *)
134 AOT_ALG_SYNTH_AUD_FX = 16, (**< Algorithmic Synthesis and Audio FX object *)
135 AOT_ER_AAC_LC = 17, (**< Error Resilient(ER) AAC Low Complexity *)
136 AOT_RSVD_18 = 18, (**< (reserved) *)
137 AOT_ER_AAC_LTP = 19, (**< Error Resilient(ER) AAC LTP object *)
138 AOT_ER_AAC_SCAL = 20, (**< Error Resilient(ER) AAC Scalable object *)
139 AOT_ER_TWIN_VQ = 21, (**< Error Resilient(ER) TwinVQ object *)
140 AOT_ER_BSAC = 22, (**< Error Resilient(ER) BSAC object *)
141 AOT_ER_AAC_LD = 23, (**< Error Resilient(ER) AAC LowDelay object *)
142 AOT_ER_CELP = 24, (**< Error Resilient(ER) CELP object *)
143 AOT_ER_HVXC = 25, (**< Error Resilient(ER) HVXC object *)
144 AOT_ER_HILN = 26, (**< Error Resilient(ER) HILN object *)
145 AOT_ER_PARA = 27, (**< Error Resilient(ER) Parametric object *)
146 AOT_RSVD_28 = 28, (**< might become SSC *)
147 AOT_PS = 29, (**< PS, Parametric Stereo (includes SBR) *)
148 AOT_MPEGS = 30, (**< MPEG Surround *)
149
150 AOT_ESCAPE = 31, (**< Signal AOT uses more than 5 bits *)
151
152 AOT_MP3ONMP4_L1 = 32, (**< MPEG-Layer1 in mp4 *)
153 AOT_MP3ONMP4_L2 = 33, (**< MPEG-Layer2 in mp4 *)
154 AOT_MP3ONMP4_L3 = 34, (**< MPEG-Layer3 in mp4 *)
155 AOT_RSVD_35 = 35, (**< might become DST *)
156 AOT_RSVD_36 = 36, (**< might become ALS *)
157 AOT_AAC_SLS = 37, (**< AAC + SLS *)
158 AOT_SLS = 38, (**< SLS *)
159 AOT_ER_AAC_ELD = 39, (**< AAC Enhanced Low Delay *)
160
161 AOT_USAC = 42, (**< USAC *)
162 AOT_SAOC = 43, (**< SAOC *)
163 AOT_LD_MPEGS = 44, (**< Low Delay MPEG Surround *)
164
165 (* Pseudo AOTs *)
166 AOT_MP2_AAC_LC = 129, (**< Virtual AOT MP2 Low Complexity profile *)
167 AOT_MP2_SBR = 132, (**< Virtual AOT MP2 Low Complexity Profile with SBR *)
168
169 AOT_DRM_AAC = 143, (**< Virtual AOT for DRM (ER-AAC-SCAL without SBR) *)
170 AOT_DRM_SBR = 144, (**< Virtual AOT for DRM (ER-AAC-SCAL with SBR) *)
171 AOT_DRM_MPEG_PS =
172 145, (**< Virtual AOT for DRM (ER-AAC-SCAL with SBR and MPEG-PS) *)
173 AOT_DRM_SURROUND =
174 146, (**< Virtual AOT for DRM Surround (ER-AAC-SCAL (+SBR) +MPS) *)
175 AOT_DRM_USAC = 147 (**< Virtual AOT for DRM with USAC *)
176 );
177
178 //CAN_DO_PS(aot) \
179 // ((aot) == AOT_AAC_LC || (aot) == AOT_SBR || (aot) == AOT_PS || \
180 // (aot) == AOT_ER_BSAC || (aot) == AOT_DRM_AAC)
181function CAN_DO_PS(aot: AUDIO_OBJECT_TYPE): Boolean;
182
183 //IS_USAC(aot) ((aot) == AOT_USAC)
184function IS_USAC(aot: AUDIO_OBJECT_TYPE): Boolean;
185
186 //IS_LOWDELAY(aot) ((aot) == AOT_ER_AAC_LD || (aot) == AOT_ER_AAC_ELD)
187function IS_LOWDELAY(aot: AUDIO_OBJECT_TYPE): Boolean;
188
189type
190 (** Channel Mode ( 1-7 equals MPEG channel configurations, others are
191 * arbitrary). *)
192 CHANNEL_MODE = (
193 MODE_INVALID = -1,
194 MODE_UNKNOWN = 0,
195 MODE_1 = 1, (**< C *)
196 MODE_2 = 2, (**< L+R *)
197 MODE_1_2 = 3, (**< C, L+R *)
198 MODE_1_2_1 = 4, (**< C, L+R, Rear *)
199 MODE_1_2_2 = 5, (**< C, L+R, LS+RS *)
200 MODE_1_2_2_1 = 6, (**< C, L+R, LS+RS, LFE *)
201 MODE_1_2_2_2_1 = 7, (**< C, LC+RC, L+R, LS+RS, LFE *)
202
203 MODE_6_1 = 11, (**< C, L+R, LS+RS, Crear, LFE *)
204 MODE_7_1_BACK = 12, (**< C, L+R, LS+RS, Lrear+Rrear, LFE *)
205 MODE_7_1_TOP_FRONT = 14, (**< C, L+R, LS+RS, LFE, Ltop+Rtop *)
206
207 MODE_7_1_REAR_SURROUND = 33, (**< C, L+R, LS+RS, Lrear+Rrear, LFE *)
208 MODE_7_1_FRONT_CENTER = 34, (**< C, LC+RC, L+R, LS+RS, LFE *)
209
210 MODE_212 = 128 (**< 212 configuration, used in ELDv2 *)
211 );
212
213 (**
214 * Speaker description tags.
215 * Do not change the enumeration values unless it keeps the following
216 * segmentation:
217 * - Bit 0-3: Horizontal postion (0: none, 1: front, 2: side, 3: back, 4: lfe)
218 * - Bit 4-7: Vertical position (0: normal, 1: top, 2: bottom)
219 *)
220 AUDIO_CHANNEL_TYPE = (
221 ACT_NONE = $00,
222 ACT_FRONT = $01, (*!< Front speaker position (at normal height) *)
223 ACT_SIDE = $02, (*!< Side speaker position (at normal height) *)
224 ACT_BACK = $03, (*!< Back speaker position (at normal height) *)
225 ACT_LFE = $04, (*!< Low frequency effect speaker postion (front) *)
226
227 ACT_TOP = $10, (*!< Top speaker area (for combination with speaker positions) *)
228 ACT_FRONT_TOP = $11, (*!< Top front speaker = (ACT_FRONT|ACT_TOP) *)
229 ACT_SIDE_TOP = $12, (*!< Top side speaker = (ACT_SIDE |ACT_TOP) *)
230 ACT_BACK_TOP = $13, (*!< Top back speaker = (ACT_BACK |ACT_TOP) *)
231
232 ACT_BOTTOM = $20, (*!< Bottom speaker area (for combination with speaker positions) *)
233 ACT_FRONT_BOTTOM = $21, (*!< Bottom front speaker = (ACT_FRONT|ACT_BOTTOM) *)
234 ACT_SIDE_BOTTOM = $22, (*!< Bottom side speaker = (ACT_SIDE |ACT_BOTTOM) *)
235 ACT_BACK_BOTTOM = $23 (*!< Bottom back speaker = (ACT_BACK |ACT_BOTTOM) *)
236 );
237
238 SBR_PS_SIGNALING = (
239 SIG_UNKNOWN = -1,
240 SIG_IMPLICIT = 0,
241 SIG_EXPLICIT_BW_COMPATIBLE = 1,
242 SIG_EXPLICIT_HIERARCHICAL = 2
243 );
244
245const
246 (**
247 * Audio Codec flags.
248 *)
249 AC_ER_VCB11 = $000001; (*!< aacSectionDataResilienceFlag flag (from ASC): 1 means use
250 virtual codebooks *)
251 AC_ER_RVLC = $000002; (*!< aacSpectralDataResilienceFlag flag (from ASC): 1 means use
252 huffman codeword reordering *)
253 AC_ER_HCR = $000004; (*!< aacSectionDataResilienceFlag flag (from ASC): 1 means use
254 virtual codebooks *)
255 AC_SCALABLE = $000008; (*!< AAC Scalable*)
256 AC_ELD = $000010; (*!< AAC-ELD *)
257 AC_LD = $000020; (*!< AAC-LD *)
258 AC_ER = $000040; (*!< ER syntax *)
259 AC_BSAC = $000080; (*!< BSAC *)
260 AC_USAC = $000100; (*!< USAC *)
261 AC_RSV603DA = $000200; (*!< RSVD60 3D audio *)
262 AC_HDAAC = $000400; (*!< HD-AAC *)
263 AC_RSVD50 = $004000; (*!< Rsvd50 *)
264 AC_SBR_PRESENT = $008000; (*!< SBR present flag (from ASC) *)
265 AC_SBRCRC = $010000; (*!< SBR CRC present flag. Only relevant for AAC-ELD for now. *)
266 AC_PS_PRESENT = $020000; (*!< PS present flag (from ASC or implicit) *)
267 AC_MPS_PRESENT = $040000; (*!< MPS present flag (from ASC or implicit)
268 *)
269 AC_DRM = $080000; (*!< DRM bit stream syntax *)
270 AC_INDEP = $100000; (*!< Independency flag *)
271 AC_MPEGD_RES = $200000; (*!< MPEG-D residual individual channel data. *)
272 AC_SAOC_PRESENT = $400000; (*!< SAOC Present Flag *)
273 AC_DAB = $800000; (*!< DAB bit stream syntax *)
274 AC_ELD_DOWNSCALE = $1000000; (*!< ELD Downscaled playout *)
275 AC_LD_MPS = $2000000; (*!< Low Delay MPS. *)
276 AC_DRC_PRESENT = $4000000; (*!< Dynamic Range Control (DRC) data found.
277 *)
278 AC_USAC_SCFGI3 = $8000000; (*!< USAC flag: If stereoConfigIndex is 3 the flag is set. *)
279 (**
280 * Audio Codec flags (reconfiguration).
281 *)
282 AC_CM_DET_CFG_CHANGE = $000001; (*!< Config mode signalizes the callback to work in config change
283 detection mode *)
284 AC_CM_ALLOC_MEM = $000002; (*!< Config mode signalizes the callback to work in memory
285 allocation mode *)
286
287 (**
288 * Audio Codec flags (element specific).
289 *)
290 AC_EL_USAC_TW = $000001; (*!< USAC time warped filter bank is active *)
291 AC_EL_USAC_NOISE = $000002; (*!< USAC noise filling is active *)
292 AC_EL_USAC_ITES = $000004; (*!< USAC SBR inter-TES tool is active *)
293 AC_EL_USAC_PVC = $000008; (*!< USAC SBR predictive vector coding tool is active *)
294 AC_EL_USAC_MPS212 = $000010; (*!< USAC MPS212 tool is active *)
295 AC_EL_USAC_LFE = $000020; (*!< USAC element is LFE *)
296 AC_EL_USAC_CP_POSSIBLE = $000040; (*!< USAC may use Complex Stereo Prediction in this channel element
297 *)
298 AC_EL_ENHANCED_NOISE = $000080; (*!< Enhanced noise filling*)
299 AC_EL_IGF_AFTER_TNS = $000100; (*!< IGF after TNS *)
300 AC_EL_IGF_INDEP_TILING = $000200; (*!< IGF independent tiling *)
301 AC_EL_IGF_USE_ENF = $000400; (*!< IGF use enhanced noise filling *)
302 AC_EL_FULLBANDLPD = $000800; (*!< enable fullband LPD tools *)
303 AC_EL_LPDSTEREOIDX = $001000; (*!< LPD-stereo-tool stereo index *)
304 AC_EL_LFE = $002000; (*!< The element is of type LFE. *)
305
306 (* CODER_CONFIG::flags *)
307 CC_MPEG_ID = $00100000;
308 CC_IS_BASELAYER = $00200000;
309 CC_PROTECTION = $00400000;
310 CC_SBR = $00800000;
311 CC_SBRCRC = $00010000;
312 CC_SAC = $00020000;
313 CC_RVLC = $01000000;
314 CC_VCB11 = $02000000;
315 CC_HCR = $04000000;
316 CC_PSEUDO_SURROUND = $08000000;
317 CC_USAC_NOISE = $10000000;
318 CC_USAC_TW = $20000000;
319 CC_USAC_HBE = $40000000;
320
321type
322 (** Generic audio coder configuration structure. *)
323 TCODER_CONFIG = record
324 aot: AUDIO_OBJECT_TYPE; (**< Audio Object Type (AOT). *)
325 extAOT: AUDIO_OBJECT_TYPE; (**< Extension Audio Object Type (SBR). *)
326 channelMode: CHANNEL_MODE; (**< Channel mode. *)
327 channelConfigZero: byte; (**< Use channel config zero + pce although a
328 standard channel config could be signaled. *)
329 samplingRate: integer; (**< Sampling rate. *)
330 extSamplingRate: integer; (**< Extended samplerate (SBR). *)
331 downscaleSamplingRate: integer; (**< Downscale sampling rate (ELD downscaled mode)
332 *)
333 bitRate: integer; (**< Average bitrate. *)
334 samplesPerFrame: integer; (**< Number of PCM samples per codec frame and audio
335 channel. *)
336 noChannels: integer; (**< Number of audio channels. *)
337 bitsFrame: integer;
338 nSubFrames: integer; (**< Amount of encoder subframes. 1 means no subframing. *)
339 BSACnumOfSubFrame: integer; (**< The number of the sub-frames which are grouped and
340 transmitted in a super-frame (BSAC). *)
341 BSAClayerLength: integer; (**< The average length of the large-step layers in bytes
342 (BSAC). *)
343 flags: cardinal; (**< flags *)
344 matrixMixdownA: byte; (**< Matrix mixdown index to put into PCE. Default value
345 0 means no mixdown coefficient, valid values are 1-4
346 which correspond to matrix_mixdown_idx 0-3. *)
347 headerPeriod: byte; (**< Frame period for sending in band configuration
348 buffers in the transport layer. *)
349
350 stereoConfigIndex: byte; (**< USAC MPS stereo mode *)
351 sbrMode: byte; (**< USAC SBR mode *)
352 sbrSignaling: SBR_PS_SIGNALING; (**< 0: implicit signaling, 1: backwards
353 compatible explicit signaling, 2:
354 hierarcical explicit signaling *)
355
356 rawConfig: array[0..63] of byte; (**< raw codec specific config as bit stream *)
357 rawConfigBits: integer; (**< Size of rawConfig in bits *)
358
359 sbrPresent: byte;
360 psPresent: byte;
361 end;
362
363const
364 USAC_ID_BIT = 16; (** USAC element IDs start at USAC_ID_BIT *)
365
366type
367 (** MP4 Element IDs. *)
368 MP4_ELEMENT_ID = (
369 (* mp4 element IDs *)
370 ID_NONE = -1, (**< Invalid Element helper ID. *)
371 ID_SCE = 0, (**< Single Channel Element. *)
372 ID_CPE = 1, (**< Channel Pair Element. *)
373 ID_CCE = 2, (**< Coupling Channel Element. *)
374 ID_LFE = 3, (**< LFE Channel Element. *)
375 ID_DSE = 4, (**< Currently one Data Stream Element for ancillary data is
376 supported. *)
377 ID_PCE = 5, (**< Program Config Element. *)
378 ID_FIL = 6, (**< Fill Element. *)
379 ID_END = 7, (**< Arnie (End Element = Terminator). *)
380 ID_EXT = 8, (**< Extension Payload (ER only). *)
381 ID_SCAL = 9, (**< AAC scalable element (ER only). *)
382 (* USAC element IDs *)
383 ID_USAC_SCE = 0 + USAC_ID_BIT, (**< Single Channel Element. *)
384 ID_USAC_CPE = 1 + USAC_ID_BIT, (**< Channel Pair Element. *)
385 ID_USAC_LFE = 2 + USAC_ID_BIT, (**< LFE Channel Element. *)
386 ID_USAC_EXT = 3 + USAC_ID_BIT, (**< Extension Element. *)
387 ID_USAC_END = 4 + USAC_ID_BIT, (**< Arnie (End Element = Terminator). *)
388 ID_LAST
389 );
390
391 (* usacConfigExtType q.v. ISO/IEC DIS 23008-3 Table 52 and ISO/IEC FDIS
392 * 23003-3:2011(E) Table 74*)
393 CONFIG_EXT_ID = (
394 (* USAC and RSVD60 3DA *)
395 ID_CONFIG_EXT_FILL = 0,
396 (* RSVD60 3DA *)
397 ID_CONFIG_EXT_DOWNMIX = 1,
398 ID_CONFIG_EXT_LOUDNESS_INFO = 2,
399 ID_CONFIG_EXT_AUDIOSCENE_INFO = 3,
400 ID_CONFIG_EXT_HOA_MATRIX = 4,
401 ID_CONFIG_EXT_SIG_GROUP_INFO = 6
402 (* 5-127 => reserved for ISO use *)
403 (* > 128 => reserved for use outside of ISO scope *)
404 );
405
406 //IS_CHANNEL_ELEMENT(elementId) \
407 // ((elementId) == ID_SCE || (elementId) == ID_CPE || (elementId) == ID_LFE || \
408 // (elementId) == ID_USAC_SCE || (elementId) == ID_USAC_CPE || \
409 // (elementId) == ID_USAC_LFE)
410function IS_CHANNEL_ELEMENT(elementId: MP4_ELEMENT_ID): Boolean;
411
412 //IS_MP4_CHANNEL_ELEMENT(elementId) \
413 // ((elementId) == ID_SCE || (elementId) == ID_CPE || (elementId) == ID_LFE)
414function IS_MP4_CHANNEL_ELEMENT(elementId: MP4_ELEMENT_ID): Boolean;
415
416const
417 EXT_ID_BITS = 4; (**< Size in bits of extension payload type tags. *)
418
419type
420 (** Extension payload types. *)
421 EXT_PAYLOAD_TYPE = (
422 EXT_FIL = $00,
423 EXT_FILL_DATA = $01,
424 EXT_DATA_ELEMENT = $02,
425 EXT_DATA_LENGTH = $03,
426 EXT_UNI_DRC = $04,
427 EXT_LDSAC_DATA = $09,
428 EXT_SAOC_DATA = $0a,
429 EXT_DYNAMIC_RANGE = $0b,
430 EXT_SAC_DATA = $0c,
431 EXT_SBR_DATA = $0d,
432 EXT_SBR_DATA_CRC = $0e
433 );
434
435 //IS_USAC_CHANNEL_ELEMENT(elementId) \
436 // ((elementId) == ID_USAC_SCE || (elementId) == ID_USAC_CPE || \
437 // (elementId) == ID_USAC_LFE)
438function IS_USAC_CHANNEL_ELEMENT(elementId: MP4_ELEMENT_ID): Boolean;
439
440type
441 (** MPEG-D USAC & RSVD60 3D audio Extension Element Types. *)
442 USAC_EXT_ELEMENT_TYPE = (
443 (* usac *)
444 ID_EXT_ELE_FILL = $00,
445 ID_EXT_ELE_MPEGS = $01,
446 ID_EXT_ELE_SAOC = $02,
447 ID_EXT_ELE_AUDIOPREROLL = $03,
448 ID_EXT_ELE_UNI_DRC = $04,
449 (* rsv603da *)
450 ID_EXT_ELE_OBJ_METADATA = $05,
451 ID_EXT_ELE_SAOC_3D = $06,
452 ID_EXT_ELE_HOA = $07,
453 ID_EXT_ELE_FMT_CNVRTR = $08,
454 ID_EXT_ELE_MCT = $09,
455 ID_EXT_ELE_ENHANCED_OBJ_METADATA = $0d,
456 (* reserved for use outside of ISO scope *)
457 ID_EXT_ELE_VR_METADATA = $81,
458 ID_EXT_ELE_UNKNOWN = $FF
459 );
460
461 (**
462 * Proprietary raw packet file configuration data type identifier.
463 *)
464 TP_CONFIG_TYPE = (
465 TC_NOTHING = 0, (* No configuration available -> in-band configuration. *)
466 TC_RAW_ADTS = 2, (* Transfer type is ADTS. *)
467 TC_RAW_LATM_MCP1 = 6, (* Transfer type is LATM with SMC present. *)
468 TC_RAW_SDC = 21 (* Configuration data field is Drm SDC. *)
469
470 );
471
472const
473 (* AAC capability flags *)
474 CAPF_AAC_LC = $00000001; (**< Support flag for AAC Low Complexity. *)
475 CAPF_ER_AAC_LD = $00000002; (**< Support flag for AAC Low Delay with Error Resilience tools.
476 *)
477 CAPF_ER_AAC_SCAL = $00000004; (**< Support flag for AAC Scalable. *)
478 CAPF_ER_AAC_LC = $00000008; (**< Support flag for AAC Low Complexity with Error Resilience
479 tools. *)
480 CAPF_AAC_480 = $00000010; (**< Support flag for AAC with 480 framelength. *)
481 CAPF_AAC_512 = $00000020; (**< Support flag for AAC with 512 framelength. *)
482 CAPF_AAC_960 = $00000040; (**< Support flag for AAC with 960 framelength. *)
483 CAPF_AAC_1024 = $00000080; (**< Support flag for AAC with 1024 framelength. *)
484 CAPF_AAC_HCR = $00000100; (**< Support flag for AAC with Huffman Codeword Reordering. *)
485 CAPF_AAC_VCB11 = $00000200; (**< Support flag for AAC Virtual Codebook 11. *)
486 CAPF_AAC_RVLC = $00000400; (**< Support flag for AAC Reversible Variable Length Coding. *)
487 CAPF_AAC_MPEG4 = $00000800; (**< Support flag for MPEG file format. *)
488 CAPF_AAC_DRC = $00001000; (**< Support flag for AAC Dynamic Range Control. *)
489 CAPF_AAC_CONCEALMENT = $00002000; (**< Support flag for AAC concealment. *)
490 CAPF_AAC_DRM_BSFORMAT = $00004000; (**< Support flag for AAC DRM bistream format. *)
491 CAPF_ER_AAC_ELD = $00008000; (**< Support flag for AAC Enhanced Low Delay with Error
492 Resilience tools. *)
493 CAPF_ER_AAC_BSAC = $00010000; (**< Support flag for AAC BSAC. *)
494 CAPF_AAC_ELD_DOWNSCALE = $00040000; (**< Support flag for AAC-ELD Downscaling *)
495 CAPF_AAC_USAC_LP = $00100000; (**< Support flag for USAC low power mode. *)
496 CAPF_AAC_USAC = $00200000; (**< Support flag for Unified Speech and Audio Coding (USAC). *)
497 CAPF_ER_AAC_ELDV2 = $00800000; (**< Support flag for AAC Enhanced Low Delay with MPS 212. *)
498 CAPF_AAC_UNIDRC = $01000000; (**< Support flag for MPEG-D Dynamic Range Control (uniDrc). *)
499
500 (* Transport capability flags *)
501 CAPF_ADTS = $00000001; (**< Support flag for ADTS transport format. *)
502 CAPF_ADIF = $00000002; (**< Support flag for ADIF transport format. *)
503 CAPF_LATM = $00000004; (**< Support flag for LATM transport format. *)
504 CAPF_LOAS = $00000008; (**< Support flag for LOAS transport format. *)
505 CAPF_RAWPACKETS = $00000010; (**< Support flag for RAW PACKETS transport format. *)
506 CAPF_DRM = $00000020; (**< Support flag for DRM/DRM+ transport format. *)
507 CAPF_RSVD50 = $00000040; (**< Support flag for RSVD50 transport format *)
508
509 (* SBR capability flags *)
510 CAPF_SBR_LP = $00000001; (**< Support flag for SBR Low Power mode. *)
511 CAPF_SBR_HQ = $00000002; (**< Support flag for SBR High Quality mode. *)
512 CAPF_SBR_DRM_BS = $00000004; (**< Support flag for *)
513 CAPF_SBR_CONCEALMENT = $00000008; (**< Support flag for SBR concealment. *)
514 CAPF_SBR_DRC = $00000010; (**< Support flag for SBR Dynamic Range Control. *)
515 CAPF_SBR_PS_MPEG = $00000020; (**< Support flag for MPEG Parametric Stereo. *)
516 CAPF_SBR_PS_DRM = $00000040; (**< Support flag for DRM Parametric Stereo. *)
517 CAPF_SBR_ELD_DOWNSCALE = $00000080; (**< Support flag for ELD reduced delay mode *)
518 CAPF_SBR_HBEHQ = $00000100; (**< Support flag for HQ HBE *)
519
520 (* PCM utils capability flags *)
521 CAPF_DMX_BLIND = $00000001; (**< Support flag for blind downmixing. *)
522 CAPF_DMX_PCE = $00000002; (**< Support flag for guided downmix with data from MPEG-2/4
523 Program Config Elements (PCE). *)
524 CAPF_DMX_ARIB = $00000004; (**< Support flag for PCE guided downmix with slightly different
525 equations and levels to fulfill ARIB standard. *)
526 CAPF_DMX_DVB = $00000008; (**< Support flag for guided downmix with data from DVB ancillary
527 data fields. *)
528 CAPF_DMX_CH_EXP = $00000010; (**< Support flag for simple upmixing by dublicating channels or
529 adding zero channels. *)
530 CAPF_DMX_6_CH = $00000020; (**< Support flag for 5.1 channel configuration (input and
531 output). *)
532 CAPF_DMX_8_CH = $00000040; (**< Support flag for 6 and 7.1 channel configurations (input and
533 output). *)
534 CAPF_DMX_24_CH = $00000080; (**< Support flag for 22.2 channel configuration (input and
535 output). *)
536 CAPF_LIMITER = $00002000; (**< Support flag for signal level limiting.
537 *)
538
539 (* MPEG Surround capability flags *)
540 CAPF_MPS_STD = $00000001; (**< Support flag for MPEG Surround. *)
541 CAPF_MPS_LD = $00000002; (**< Support flag for Low Delay MPEG Surround.
542 *)
543 CAPF_MPS_USAC = $00000004; (**< Support flag for USAC MPEG Surround. *)
544 CAPF_MPS_HQ = $00000010; (**< Support flag indicating if high quality processing is
545 supported *)
546 CAPF_MPS_LP = $00000020; (**< Support flag indicating if partially complex (low power)
547 processing is supported *)
548 CAPF_MPS_BLIND = $00000040; (**< Support flag indicating if blind processing is supported *)
549 CAPF_MPS_BINAURAL = $00000080; (**< Support flag indicating if binaural output is possible *)
550 CAPF_MPS_2CH_OUT = $00000100; (**< Support flag indicating if 2ch output is possible *)
551 CAPF_MPS_6CH_OUT = $00000200; (**< Support flag indicating if 6ch output is possible *)
552 CAPF_MPS_8CH_OUT = $00000400; (**< Support flag indicating if 8ch output is possible *)
553 CAPF_MPS_1CH_IN = $00001000; (**< Support flag indicating if 1ch dmx input is possible *)
554 CAPF_MPS_2CH_IN = $00002000; (**< Support flag indicating if 2ch dmx input is possible *)
555 CAPF_MPS_6CH_IN = $00004000; (**< Support flag indicating if 5ch dmx input is possible *)
556
557 (* \endcond *)
558
559
560 (*
561 * ##############################################################################################
562 * Library versioning
563 * ##############################################################################################
564 *)
565
566 (**
567 * Convert each member of version numbers to one single numeric version
568 * representation.
569 * \param lev0 1st level of version number.
570 * \param lev1 2nd level of version number.
571 * \param lev2 3rd level of version number.
572 *)
573 //LIB_VERSION(lev0, lev1, lev2) \
574 // ((lev0 << 24 & = $ff000000) | (lev1 << 16 & = $00ff0000) | \
575 // (lev2 << 8 & = $0000ff00))
576
577function LIB_VERSION(lev0: byte; lev1: byte; lev2: byte): integer;
578
579 (**
580 * Build text string of version.
581 *)
582 //LIB_VERSION_STRING(info) \
583 // FDKsprintf((info)->versionStr, "%d.%d.%d", (((info)->version >> 24) & = $ff), \
584 // (((info)->version >> 16) & = $ff), \
585 // (((info)->version >> 8) & = $ff))
586function LIB_VERSION_STRING(info: LIB_INFO): string;
587
588
589 (** Initialize library info. *)
590 //static FDK_AUDIO_INLINE void FDKinitLibInfo(LIB_INFO* info) {
591 // int i;
592
593 // for (i = 0; i < FDK_MODULE_LAST; i++) {
594 // info[i].module_id = FDK_NONE;
595 // }
596 //}
597procedure FDKinitLibInfo(var info: array of LIB_INFO);
598
599
600 (** Aquire supported features of library. *)
601 //static FDK_AUDIO_INLINE UINT
602 //FDKlibInfo_getCapabilities(const LIB_INFO* info, FDK_MODULE_ID module_id) {
603 // int i;
604
605 // for (i = 0; i < FDK_MODULE_LAST; i++) {
606 // if (info[i].module_id == module_id) {
607 // return info[i].flags;
608 // }
609 // }
610 // return 0;
611 //}
612function FDKlibInfo_getCapabilities(const info: array of LIB_INFO; module_id: FDK_MODULE_ID): cardinal;
613
614
615 (** Search for next free tab. *)
616 //static FDK_AUDIO_INLINE INT FDKlibInfo_lookup(const LIB_INFO* info,
617 // FDK_MODULE_ID module_id) {
618 // int i = -1;
619
620 // for (i = 0; i < FDK_MODULE_LAST; i++) {
621 // if (info[i].module_id == module_id) return -1;
622 // if (info[i].module_id == FDK_NONE) break;
623 // }
624 // if (i == FDK_MODULE_LAST) return -1;
625
626 // return i;
627 //}
628function FDKlibInfo_lookup(const info: array of LIB_INFO; module_id: FDK_MODULE_ID): integer;
629
630type
631 (*
632 * ##############################################################################################
633 * Buffer description
634 * ##############################################################################################
635 *)
636
637 (**
638 * I/O buffer descriptor.
639 *)
640 FDK_bufDescr = record
641 ppBase: Pointer; (*!< Pointer to an array containing buffer base addresses.
642 Set to NULL for buffer requirement info. *)
643 pBufSize: PCardinal; (*!< Pointer to an array containing the number of elements
644 that can be placed in the specific buffer. *)
645 pEleSize: PCardinal; (*!< Pointer to an array containing the element size for each
646 buffer in bytes. That is mostly the number returned by the
647 sizeof() operator for the data type used for the specific
648 buffer. *)
649 pBufType: PCardinal; (*!< Pointer to an array of bit fields containing a description
650 for each buffer. See XXX below for more details. *)
651 numBufs: cardinal; (*!< Total number of buffers. *)
652 end;
653
654(**
655 * Buffer type description field.
656 *)
657const
658 FDK_BUF_TYPE_MASK_IO = (cardinal($03) shl 30);
659 FDK_BUF_TYPE_MASK_DESCR = (cardinal($3F) shl 16);
660 FDK_BUF_TYPE_MASK_ID = cardinal($FF);
661
662 FDK_BUF_TYPE_INPUT = (cardinal($1) shl 30);
663 FDK_BUF_TYPE_OUTPUT = (cardinal($2) shl 30);
664
665 FDK_BUF_TYPE_PCM_DATA = (cardinal($1) shl 16);
666 FDK_BUF_TYPE_ANC_DATA = (cardinal($2) shl 16);
667 FDK_BUF_TYPE_BS_DATA = (cardinal($4) shl 16);
668
669const
670 AACDECODER_LIB_VL0 = 3;
671 AACDECODER_LIB_VL1 = 2;
672 AACDECODER_LIB_VL2 = 0;
673
674
675(**
676 * \brief AAC decoder error codes.
677 *)
678type
679 AAC_DECODER_ERROR = (
680 AAC_DEC_OK =
681 $0000, (*!< No error occurred. Output buffer is valid and error free. *)
682 AAC_DEC_OUT_OF_MEMORY =
683 $0002, (*!< Heap returned NULL pointer. Output buffer is invalid. *)
684 AAC_DEC_UNKNOWN =
685 $0005, (*!< Error condition is of unknown reason, or from a another
686 module. Output buffer is invalid. *)
687
688 (* Synchronization errors. Output buffer is invalid. *)
689 aac_dec_sync_error_start = $1000,
690 AAC_DEC_TRANSPORT_SYNC_ERROR = $1001, (*!< The transport decoder had
691 synchronization problems. Do not
692 exit decoding. Just feed new
693 bitstream data. *)
694 AAC_DEC_NOT_ENOUGH_BITS = $1002, (*!< The input buffer ran out of bits. *)
695 aac_dec_sync_error_end = $1FFF,
696
697 (* Initialization errors. Output buffer is invalid. *)
698 aac_dec_init_error_start = $2000,
699 AAC_DEC_INVALID_HANDLE =
700 $2001, (*!< The handle passed to the function call was invalid (NULL). *)
701 AAC_DEC_UNSUPPORTED_AOT =
702 $2002, (*!< The AOT found in the configuration is not supported. *)
703 AAC_DEC_UNSUPPORTED_FORMAT =
704 $2003, (*!< The bitstream format is not supported. *)
705 AAC_DEC_UNSUPPORTED_ER_FORMAT =
706 $2004, (*!< The error resilience tool format is not supported. *)
707 AAC_DEC_UNSUPPORTED_EPCONFIG =
708 $2005, (*!< The error protection format is not supported. *)
709 AAC_DEC_UNSUPPORTED_MULTILAYER =
710 $2006, (*!< More than one layer for AAC scalable is not supported. *)
711 AAC_DEC_UNSUPPORTED_CHANNELCONFIG =
712 $2007, (*!< The channel configuration (either number or arrangement) is
713 not supported. *)
714 AAC_DEC_UNSUPPORTED_SAMPLINGRATE = $2008, (*!< The sample rate specified in
715 the configuration is not
716 supported. *)
717 AAC_DEC_INVALID_SBR_CONFIG =
718 $2009, (*!< The SBR configuration is not supported. *)
719 AAC_DEC_SET_PARAM_FAIL = $200A, (*!< The parameter could not be set. Either
720 the value was out of range or the
721 parameter does not exist. *)
722 AAC_DEC_NEED_TO_RESTART = $200B, (*!< The decoder needs to be restarted,
723 since the required configuration change
724 cannot be performed. *)
725 AAC_DEC_OUTPUT_BUFFER_TOO_SMALL =
726 $200C, (*!< The provided output buffer is too small. *)
727 aac_dec_init_error_end = $2FFF,
728
729 (* Decode errors. Output buffer is valid but concealed. *)
730 aac_dec_decode_error_start = $4000,
731 AAC_DEC_TRANSPORT_ERROR =
732 $4001, (*!< The transport decoder encountered an unexpected error. *)
733 AAC_DEC_PARSE_ERROR = $4002, (*!< Error while parsing the bitstream. Most
734 probably it is corrupted, or the system
735 crashed. *)
736 AAC_DEC_UNSUPPORTED_EXTENSION_PAYLOAD =
737 $4003, (*!< Error while parsing the extension payload of the bitstream.
738 The extension payload type found is not supported. *)
739 AAC_DEC_DECODE_FRAME_ERROR = $4004, (*!< The parsed bitstream value is out of
740 range. Most probably the bitstream is
741 corrupt, or the system crashed. *)
742 AAC_DEC_CRC_ERROR = $4005, (*!< The embedded CRC did not match. *)
743 AAC_DEC_INVALID_CODE_BOOK = $4006, (*!< An invalid codebook was signaled.
744 Most probably the bitstream is corrupt,
745 or the system crashed. *)
746 AAC_DEC_UNSUPPORTED_PREDICTION =
747 $4007, (*!< Predictor found, but not supported in the AAC Low Complexity
748 profile. Most probably the bitstream is corrupt, or has a wrong
749 format. *)
750 AAC_DEC_UNSUPPORTED_CCE = $4008, (*!< A CCE element was found which is not
751 supported. Most probably the bitstream is
752 corrupt, or has a wrong format. *)
753 AAC_DEC_UNSUPPORTED_LFE = $4009, (*!< A LFE element was found which is not
754 supported. Most probably the bitstream is
755 corrupt, or has a wrong format. *)
756 AAC_DEC_UNSUPPORTED_GAIN_CONTROL_DATA =
757 $400A, (*!< Gain control data found but not supported. Most probably the
758 bitstream is corrupt, or has a wrong format. *)
759 AAC_DEC_UNSUPPORTED_SBA =
760 $400B, (*!< SBA found, but currently not supported in the BSAC profile.
761 *)
762 AAC_DEC_TNS_READ_ERROR = $400C, (*!< Error while reading TNS data. Most
763 probably the bitstream is corrupt or the
764 system crashed. *)
765 AAC_DEC_RVLC_ERROR =
766 $400D, (*!< Error while decoding error resilient data. *)
767 aac_dec_decode_error_end = $4FFF,
768 (* Ancillary data errors. Output buffer is valid. *)
769 aac_dec_anc_data_error_start = $8000,
770 AAC_DEC_ANC_DATA_ERROR =
771 $8001, (*!< Non severe error concerning the ancillary data handling. *)
772 AAC_DEC_TOO_SMALL_ANC_BUFFER = $8002, (*!< The registered ancillary data
773 buffer is too small to receive the
774 parsed data. *)
775 AAC_DEC_TOO_MANY_ANC_ELEMENTS = $8003, (*!< More than the allowed number of
776 ancillary data elements should be
777 written to buffer. *)
778 aac_dec_anc_data_error_end = $8FFF
779
780 );
781
782 (** Macro to identify initialization errors. Output buffer is invalid. *)
783 //#define IS_INIT_ERROR(err) \
784 // ((((err) >= aac_dec_init_error_start) && ((err) <= aac_dec_init_error_end)) \
785 // ? 1 \
786 // : 0)
787 (** Macro to identify decode errors. Output buffer is valid but concealed. *)
788 //#define IS_DECODE_ERROR(err) \
789 // ((((err) >= aac_dec_decode_error_start) && \
790 // ((err) <= aac_dec_decode_error_end)) \
791 // ? 1 \
792 // : 0)
793(**
794 * Macro to identify if the audio output buffer contains valid samples after
795 * calling aacDecoder_DecodeFrame(). Output buffer is valid but can be
796 * concealed.
797 *)
798 //#define IS_OUTPUT_VALID(err) (((err) == AAC_DEC_OK) || IS_DECODE_ERROR(err))
799
800(*! \enum AAC_MD_PROFILE
801 * \brief The available metadata profiles which are mostly related to downmixing. The values define the arguments
802 * for the use with parameter ::AAC_METADATA_PROFILE.
803 *)
804 AAC_MD_PROFILE = (
805 AAC_MD_PROFILE_MPEG_STANDARD =
806 0, (*!< The standard profile creates a mixdown signal based on the
807 advanced downmix metadata (from a DSE). The equations and default
808 values are defined in ISO/IEC 14496:3 Ammendment 4. Any other
809 (legacy) downmix metadata will be ignored. No other parameter will
810 be modified. *)
811 AAC_MD_PROFILE_MPEG_LEGACY =
812 1, (*!< This profile behaves identical to the standard profile if advanced
813 downmix metadata (from a DSE) is available. If not, the
814 matrix_mixdown information embedded in the program configuration
815 element (PCE) will be applied. If neither is the case, the module
816 creates a mixdown using the default coefficients as defined in
817 ISO/IEC 14496:3 AMD 4. The profile can be used to support legacy
818 digital TV (e.g. DVB) streams. *)
819 AAC_MD_PROFILE_MPEG_LEGACY_PRIO =
820 2, (*!< Similar to the ::AAC_MD_PROFILE_MPEG_LEGACY profile but if both
821 the advanced (ISO/IEC 14496:3 AMD 4) and the legacy (PCE) MPEG
822 downmix metadata are available the latter will be applied.
823 *)
824 AAC_MD_PROFILE_ARIB_JAPAN =
825 3 (*!< Downmix creation as described in ABNT NBR 15602-2. But if advanced
826 downmix metadata (ISO/IEC 14496:3 AMD 4) is available it will be
827 preferred because of the higher resolutions. In addition the
828 metadata expiry time will be set to the value defined in the ARIB
829 standard (see ::AAC_METADATA_EXPIRY_TIME).
830 *)
831 );
832
833(*! \enum AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS
834 * \brief Options for handling of DRC parameters, if presentation mode is not indicated in bitstream
835 *)
836 AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS = (
837 AAC_DRC_PARAMETER_HANDLING_DISABLED = -1, (*!< DRC parameter handling
838 disabled, all parameters are
839 applied as requested. *)
840 AAC_DRC_PARAMETER_HANDLING_ENABLED =
841 0, (*!< Apply changes to requested DRC parameters to prevent clipping. *)
842 AAC_DRC_PRESENTATION_MODE_1_DEFAULT =
843 1, (*!< Use DRC presentation mode 1 as default (e.g. for Nordig) *)
844 AAC_DRC_PRESENTATION_MODE_2_DEFAULT =
845 2 (*!< Use DRC presentation mode 2 as default (e.g. for DTG DBook) *)
846 );
847
848(**
849 * \brief AAC decoder setting parameters
850 *)
851 AACDEC_PARAM = (
852 AAC_PCM_DUAL_CHANNEL_OUTPUT_MODE =
853 $0002, (*!< Defines how the decoder processes two channel signals: \n
854 0: Leave both signals as they are (default). \n
855 1: Create a dual mono output signal from channel 1. \n
856 2: Create a dual mono output signal from channel 2. \n
857 3: Create a dual mono output signal by mixing both channels
858 (L' = R' = 0.5*Ch1 + 0.5*Ch2). *)
859 AAC_PCM_OUTPUT_CHANNEL_MAPPING =
860 $0003, (*!< Output buffer channel ordering. 0: MPEG PCE style order, 1:
861 WAV file channel order (default). *)
862 AAC_PCM_LIMITER_ENABLE =
863 $0004, (*!< Enable signal level limiting. \n
864 -1: Auto-config. Enable limiter for all
865 non-lowdelay configurations by default. \n
866 0: Disable limiter in general. \n
867 1: Enable limiter always.
868 It is recommended to call the decoder
869 with a AACDEC_CLRHIST flag to reset all
870 states when the limiter switch is changed
871 explicitly. *)
872 AAC_PCM_LIMITER_ATTACK_TIME = $0005, (*!< Signal level limiting attack time
873 in ms. Default configuration is 15
874 ms. Adjustable range from 1 ms to 15
875 ms. *)
876 AAC_PCM_LIMITER_RELEAS_TIME = $0006, (*!< Signal level limiting release time
877 in ms. Default configuration is 50
878 ms. Adjustable time must be larger
879 than 0 ms. *)
880 AAC_PCM_MIN_OUTPUT_CHANNELS =
881 $0011, (*!< Minimum number of PCM output channels. If higher than the
882 number of encoded audio channels, a simple channel extension is
883 applied (see note 4 for exceptions). \n -1, 0: Disable channel
884 extension feature. The decoder output contains the same number
885 of channels as the encoded bitstream. \n 1: This value is
886 currently needed only together with the mix-down feature. See
887 ::AAC_PCM_MAX_OUTPUT_CHANNELS and note 2 below. \n
888 2: Encoded mono signals will be duplicated to achieve a
889 2/0/0.0 channel output configuration. \n 6: The decoder
890 tries to reorder encoded signals with less than six channels to
891 achieve a 3/0/2.1 channel output signal. Missing channels will
892 be filled with a zero signal. If reordering is not possible the
893 empty channels will simply be appended. Only available if
894 instance is configured to support multichannel output. \n 8:
895 The decoder tries to reorder encoded signals with less than
896 eight channels to achieve a 3/0/4.1 channel output signal.
897 Missing channels will be filled with a zero signal. If
898 reordering is not possible the empty channels will simply be
899 appended. Only available if instance is configured to
900 support multichannel output.\n NOTE: \n
901 1. The channel signaling (CStreamInfo::pChannelType and
902 CStreamInfo::pChannelIndices) will not be modified. Added empty
903 channels will be signaled with channel type
904 AUDIO_CHANNEL_TYPE::ACT_NONE. \n
905 2. If the parameter value is greater than that of
906 ::AAC_PCM_MAX_OUTPUT_CHANNELS both will be set to the same
907 value. \n
908 3. This parameter will be ignored if the number of encoded
909 audio channels is greater than 8. *)
910 AAC_PCM_MAX_OUTPUT_CHANNELS =
911 $0012, (*!< Maximum number of PCM output channels. If lower than the
912 number of encoded audio channels, downmixing is applied
913 accordingly (see note 5 for exceptions). If dedicated metadata
914 is available in the stream it will be used to achieve better
915 mixing results. \n -1, 0: Disable downmixing feature. The
916 decoder output contains the same number of channels as the
917 encoded bitstream. \n 1: All encoded audio configurations
918 with more than one channel will be mixed down to one mono
919 output signal. \n 2: The decoder performs a stereo mix-down
920 if the number encoded audio channels is greater than two. \n 6:
921 If the number of encoded audio channels is greater than six the
922 decoder performs a mix-down to meet the target output
923 configuration of 3/0/2.1 channels. Only available if instance
924 is configured to support multichannel output. \n 8: This
925 value is currently needed only together with the channel
926 extension feature. See ::AAC_PCM_MIN_OUTPUT_CHANNELS and note 2
927 below. Only available if instance is configured to support
928 multichannel output. \n NOTE: \n
929 1. Down-mixing of any seven or eight channel configuration
930 not defined in ISO/IEC 14496-3 PDAM 4 is not supported by this
931 software version. \n
932 2. If the parameter value is greater than zero but smaller
933 than ::AAC_PCM_MIN_OUTPUT_CHANNELS both will be set to same
934 value. \n
935 3. This parameter will be ignored if the number of encoded
936 audio channels is greater than 8. *)
937 AAC_METADATA_PROFILE =
938 $0020, (*!< See ::AAC_MD_PROFILE for all available values. *)
939 AAC_METADATA_EXPIRY_TIME = $0021, (*!< Defines the time in ms after which all
940 the bitstream associated meta-data (DRC,
941 downmix coefficients, ...) will be reset
942 to default if no update has been
943 received. Negative values disable the
944 feature. *)
945
946 AAC_CONCEAL_METHOD = $0100, (*!< Error concealment: Processing method. \n
947 0: Spectral muting. \n
948 1: Noise substitution (see ::CONCEAL_NOISE).
949 \n 2: Energy interpolation (adds additional
950 signal delay of one frame, see
951 ::CONCEAL_INTER. only some AOTs are
952 supported). \n *)
953 AAC_DRC_BOOST_FACTOR =
954 $0200, (*!< MPEG-4 / MPEG-D Dynamic Range Control (DRC): Scaling factor
955 for boosting gain values. Defines how the boosting DRC factors
956 (conveyed in the bitstream) will be applied to the decoded
957 signal. The valid values range from 0 (don't apply boost
958 factors) to 127 (fully apply boost factors). Default value is 0
959 for MPEG-4 DRC and 127 for MPEG-D DRC. *)
960 AAC_DRC_ATTENUATION_FACTOR = $0201, (*!< MPEG-4 / MPEG-D DRC: Scaling factor
961 for attenuating gain values. Same as
962 ::AAC_DRC_BOOST_FACTOR but for
963 attenuating DRC factors. *)
964 AAC_DRC_REFERENCE_LEVEL =
965 $0202, (*!< MPEG-4 / MPEG-D DRC: Target reference level / decoder target
966 loudness.\n Defines the level below full-scale (quantized in
967 steps of 0.25dB) to which the output audio signal will be
968 normalized to by the DRC module.\n The parameter controls
969 loudness normalization for both MPEG-4 DRC and MPEG-D DRC. The
970 valid values range from 40 (-10 dBFS) to 127 (-31.75 dBFS).\n
971 Example values:\n
972 124 (-31 dBFS) for audio/video receivers (AVR) or other
973 devices allowing audio playback with high dynamic range,\n 96
974 (-24 dBFS) for TV sets or equivalent devices (default),\n 64
975 (-16 dBFS) for mobile devices where the dynamic range of audio
976 playback is restricted.\n Any value smaller than 0 switches off
977 loudness normalization and MPEG-4 DRC. *)
978 AAC_DRC_HEAVY_COMPRESSION =
979 $0203, (*!< MPEG-4 DRC: En-/Disable DVB specific heavy compression (aka
980 RF mode). If set to 1, the decoder will apply the compression
981 values from the DVB specific ancillary data field. At the same
982 time the MPEG-4 Dynamic Range Control tool will be disabled. By
983 default, heavy compression is disabled. *)
984 AAC_DRC_DEFAULT_PRESENTATION_MODE =
985 $0204, (*!< MPEG-4 DRC: Default presentation mode (DRC parameter
986 handling). \n Defines the handling of the DRC parameters boost
987 factor, attenuation factor and heavy compression, if no
988 presentation mode is indicated in the bitstream.\n For options,
989 see ::AAC_DRC_DEFAULT_PRESENTATION_MODE_OPTIONS.\n Default:
990 ::AAC_DRC_PARAMETER_HANDLING_DISABLED *)
991 AAC_DRC_ENC_TARGET_LEVEL =
992 $0205, (*!< MPEG-4 DRC: Encoder target level for light (i.e. not heavy)
993 compression.\n If known, this declares the target reference
994 level that was assumed at the encoder for calculation of
995 limiting gains. The valid values range from 0 (full-scale) to
996 127 (31.75 dB below full-scale). This parameter is used only
997 with ::AAC_DRC_PARAMETER_HANDLING_ENABLED and ignored
998 otherwise.\n Default: 127 (worst-case assumption).\n *)
999 AAC_UNIDRC_SET_EFFECT = $0206, (*!< MPEG-D DRC: Request a DRC effect type for
1000 selection of a DRC set.\n Supported indices
1001 are:\n -1: DRC off. Completely disables
1002 MPEG-D DRC.\n 0: None (default). Disables
1003 MPEG-D DRC, but automatically enables DRC
1004 if necessary to prevent clipping.\n 1: Late
1005 night\n 2: Noisy environment\n 3: Limited
1006 playback range\n 4: Low playback level\n 5:
1007 Dialog enhancement\n 6: General
1008 compression. Used for generally enabling
1009 MPEG-D DRC without particular request.\n *)
1010 AAC_UNIDRC_ALBUM_MODE =
1011 $0207, (*!< MPEG-D DRC: Enable album mode. 0: Disabled (default), 1:
1012 Enabled.\n Disabled album mode leads to application of gain
1013 sequences for fading in and out, if provided in the
1014 bitstream.\n Enabled album mode makes use of dedicated album
1015 loudness information, if provided in the bitstream.\n *)
1016 AAC_QMF_LOWPOWER =
1017 $0300, (*!< Quadrature Mirror Filter (QMF) Bank processing mode. \n
1018 -1: Use internal default. \n
1019 0: Use complex QMF data mode. \n
1020 1: Use real (low power) QMF data mode. \n *)
1021 AAC_TPDEC_CLEAR_BUFFER =
1022 $0603 (*!< Clear internal bit stream buffer of transport layers. The
1023 decoder will start decoding at new data passed after this event
1024 and any previous data is discarded. *)
1025
1026 );
1027
1028(**
1029 * \brief This structure gives information about the currently decoded audio
1030 * data. All fields are read-only.
1031 *)
1032 PCStreamInfo = ^TCStreamInfo;
1033
1034 TCStreamInfo = record
1035 (* These five members are the only really relevant ones for the user. *)
1036 sampleRate: integer; (*!< The sample rate in Hz of the decoded PCM audio signal. *)
1037 frameSize: integer; (*!< The frame size of the decoded PCM audio signal. \n
1038 Typically this is: \n
1039 1024 or 960 for AAC-LC \n
1040 2048 or 1920 for HE-AAC (v2) \n
1041 512 or 480 for AAC-LD and AAC-ELD \n
1042 768, 1024, 2048 or 4096 for USAC *)
1043 numChannels: integer; (*!< The number of output audio channels before the rendering
1044 module, i.e. the original channel configuration. *)
1045 pChannelType: array of AUDIO_CHANNEL_TYPE; (*!< Audio channel type of each output audio channel. *)
1046 pChannelIndices: array of byte; (*!< Audio channel index for each output audio
1047 channel. See ISO/IEC 13818-7:2005(E), 8.5.3.2
1048 Explicit channel mapping using a
1049 program_config_element() *)
1050 (* Decoder internal members. *)
1051 aacSampleRate: integer; (*!< Sampling rate in Hz without SBR (from configuration
1052 info) divided by a (ELD) downscale factor if present. *)
1053 profile: integer; (*!< MPEG-2 profile (from file header) (-1: not applicable (e. g.
1054 MPEG-4)). *)
1055 aot: AUDIO_OBJECT_TYPE; (*!< Audio Object Type (from ASC): is set to the appropriate value
1056 for MPEG-2 bitstreams (e. g. 2 for AAC-LC). *)
1057 channelConfig: integer; (*!< Channel configuration (0: PCE defined, 1: mono, 2:
1058 stereo, ... *)
1059 bitRate: integer; (*!< Instantaneous bit rate. *)
1060 aacSamplesPerFrame: integer; (*!< Samples per frame for the AAC core (from ASC)
1061 divided by a (ELD) downscale factor if present. \n
1062 Typically this is (with a downscale factor of 1):
1063 \n 1024 or 960 for AAC-LC \n 512 or 480 for
1064 AAC-LD and AAC-ELD *)
1065 aacNumChannels: integer; (*!< The number of audio channels after AAC core
1066 processing (before PS or MPS processing). CAUTION: This
1067 are not the final number of output channels! *)
1068 extAot: AUDIO_OBJECT_TYPE; (*!< Extension Audio Object Type (from ASC) *)
1069 extSamplingRate: integer; (*!< Extension sampling rate in Hz (from ASC) divided by
1070 a (ELD) downscale factor if present. *)
1071
1072 outputDelay: cardinal; (*!< The number of samples the output is additionally
1073 delayed by.the decoder. *)
1074 flags: cardinal; (*!< Copy of internal flags. Only to be written by the decoder,
1075 and only to be read externally. *)
1076
1077 epConfig: shortint; (*!< epConfig level (from ASC): only level 0 supported, -1
1078 means no ER (e. g. AOT=2, MPEG-2 AAC, etc.) *)
1079 (* Statistics *)
1080 numLostAccessUnits: integer; (*!< This integer will reflect the estimated amount of
1081 lost access units in case aacDecoder_DecodeFrame()
1082 returns AAC_DEC_TRANSPORT_SYNC_ERROR. It will be
1083 < 0 if the estimation failed. *)
1084
1085 numTotalBytes: int64; (*!< This is the number of total bytes that have passed
1086 through the decoder. *)
1087 numBadBytes: int64; (*!< This is the number of total bytes that were considered
1088 with errors from numTotalBytes. *)
1089 numTotalAccessUnits: int64; (*!< This is the number of total access units that
1090 have passed through the decoder. *)
1091 numBadAccessUnits: int64; (*!< This is the number of total access units that
1092 were considered with errors from numTotalBytes. *)
1093
1094 (* Metadata *)
1095 drcProgRefLev: shortint; (*!< DRC program reference level. Defines the reference
1096 level below full-scale. It is quantized in steps of
1097 0.25dB. The valid values range from 0 (0 dBFS) to 127
1098 (-31.75 dBFS). It is used to reflect the average
1099 loudness of the audio in LKFS according to ITU-R BS
1100 1770. If no level has been found in the bitstream the
1101 value is -1. *)
1102 drcPresMode: shortint; (*!< DRC presentation mode. According to ETSI TS 101 154,
1103 this field indicates whether light (MPEG-4 Dynamic Range
1104 Control tool) or heavy compression (DVB heavy
1105 compression) dynamic range control shall take priority
1106 on the outputs. For details, see ETSI TS 101 154, table
1107 C.33. Possible values are: \n -1: No corresponding
1108 metadata found in the bitstream \n 0: DRC presentation
1109 mode not indicated \n 1: DRC presentation mode 1 \n 2:
1110 DRC presentation mode 2 \n 3: Reserved *)
1111 outputLoudness: integer; (*!< Audio output loudness in steps of -0.25 dB. Range: 0
1112 (0 dBFS) to 231 (-57.75 dBFS).\n A value of -1
1113 indicates that no loudness metadata is present.\n If
1114 loudness normalization is active, the value corresponds
1115 to the target loudness value set with
1116 ::AAC_DRC_REFERENCE_LEVEL.\n If loudness normalization
1117 is not active, the output loudness value corresponds to
1118 the loudness metadata given in the bitstream.\n
1119 Loudness metadata can originate from MPEG-4 DRC or
1120 MPEG-D DRC. *)
1121
1122 end;
1123
1124 HANDLE_AACDECODER = ^AAC_DECODER_INSTANCE;
1125
1126 AAC_DECODER_INSTANCE = record
1127 HANDLE_AACDECODER: Pointer; (*!< Pointer to a AAC decoder instance. *)
1128 end;
1129
1130 (**
1131 * \brief Initialize ancillary data buffer.
1132 *
1133 * \param self AAC decoder handle.
1134 * \param buffer Pointer to (external) ancillary data buffer.
1135 * \param size Size of the buffer pointed to by buffer.
1136 * \return Error code.
1137 *)
1138var
1139
1140 aacDecoder_AncDataInit: function(self: HANDLE_AACDECODER; buffer: PByte; size: integer): AAC_DECODER_ERROR;
1141 cdecl;
1142
1143(**
1144 * \brief Get one ancillary data element.
1145 *
1146 * \param self AAC decoder handle.
1147 * \param index Index of the ancillary data element to get.
1148 * \param ptr Pointer to a buffer receiving a pointer to the requested
1149 * ancillary data element.
1150 * \param size Pointer to a buffer receiving the length of the requested
1151 * ancillary data element.
1152 * \return Error code.
1153 *)
1154 aacDecoder_AncDataGet: function(self: HANDLE_AACDECODER; index: integer; var ptr: PByte; var size: integer): AAC_DECODER_ERROR;
1155 cdecl;
1156
1157(**
1158 * \brief Set one single decoder parameter.
1159 *
1160 * \param self AAC decoder handle.
1161 * \param param Parameter to be set.
1162 * \param value Parameter value.
1163 * \return Error code.
1164 *)
1165 aacDecoder_SetParam: function(const self: HANDLE_AACDECODER; const param: AACDEC_PARAM; const Value: integer): AAC_DECODER_ERROR;
1166 cdecl;
1167
1168(**
1169 * \brief Get free bytes inside decoder internal buffer.
1170 * \param self Handle of AAC decoder instance.
1171 * \param pFreeBytes Pointer to variable receiving amount of free bytes inside
1172 * decoder internal buffer.
1173 * \return Error code.
1174 *)
1175 aacDecoder_GetFreeBytes: function(const self: HANDLE_AACDECODER; var pFreeBytes: cardinal): AAC_DECODER_ERROR;
1176 cdecl;
1177
1178(**
1179 * \brief Open an AAC decoder instance.
1180 * \param transportFmt The transport type to be used.
1181 * \param nrOfLayers Number of transport layers.
1182 * \return AAC decoder handle.
1183 *)
1184 aacDecoder_Open: function(transportFmt: TRANSPORT_TYPE; nrOfLayers: cardinal): HANDLE_AACDECODER;
1185 cdecl;
1186
1187(**
1188 * \brief Explicitly configure the decoder by passing a raw AudioSpecificConfig
1189 * (ASC) or a StreamMuxConfig (SMC), contained in a binary buffer. This is
1190 * required for MPEG-4 and Raw Packets file format bitstreams as well as for
1191 * LATM bitstreams with no in-band SMC. If the transport format is LATM with or
1192 * without LOAS, configuration is assumed to be an SMC, for all other file
1193 * formats an ASC.
1194 *
1195 * \param self AAC decoder handle.
1196 * \param conf Pointer to an unsigned char buffer containing the binary
1197 * configuration buffer (either ASC or SMC).
1198 * \param length Length of the configuration buffer in bytes.
1199 * \return Error code.
1200 *)
1201 aacDecoder_ConfigRaw: function(self: HANDLE_AACDECODER; conf: Pointer; const length: PCardinal): AAC_DECODER_ERROR;
1202 cdecl;
1203
1204(**
1205 * \brief Submit raw ISO base media file format boxes to decoder for parsing
1206 * (only some box types are recognized).
1207 *
1208 * \param self AAC decoder handle.
1209 * \param buffer Pointer to an unsigned char buffer containing the binary box
1210 * data (including size and type, can be a sequence of multiple boxes).
1211 * \param length Length of the data in bytes.
1212 * \return Error code.
1213 *)
1214 aacDecoder_RawISOBMFFData: function(self: HANDLE_AACDECODER; buffer: PByte; length: cardinal): AAC_DECODER_ERROR;
1215 cdecl;
1216
1217(**
1218 * \brief Fill AAC decoder's internal input buffer with bitstream data from the
1219 * external input buffer. The function only copies such data as long as the
1220 * decoder-internal input buffer is not full. So it grabs whatever it can from
1221 * pBuffer and returns information (bytesValid) so that at a subsequent call of
1222 * %aacDecoder_Fill(), the right position in pBuffer can be determined to grab
1223 * the next data.
1224 *
1225 * \param self AAC decoder handle.
1226 * \param pBuffer Pointer to external input buffer.
1227 * \param bufferSize Size of external input buffer. This argument is required
1228 * because decoder-internally we need the information to calculate the offset to
1229 * pBuffer, where the next available data is, which is then
1230 * fed into the decoder-internal buffer (as much as
1231 * possible). Our example framework implementation fills the
1232 * buffer at pBuffer again, once it contains no available valid bytes anymore
1233 * (meaning bytesValid equal 0).
1234 * \param bytesValid Number of bitstream bytes in the external bitstream buffer
1235 * that have not yet been copied into the decoder's internal bitstream buffer by
1236 * calling this function. The value is updated according to
1237 * the amount of newly copied bytes.
1238 * \return Error code.
1239 *)
1240 aacDecoder_Fill: function(self: HANDLE_AACDECODER; pBuffer: PByte; var bufferSize: cardinal;
1241 var bytesValid: cardinal): AAC_DECODER_ERROR;
1242 cdecl;
1243
1244const
1245 (** Flag for aacDecoder_DecodeFrame(): Trigger the built-in error concealment
1246 * module to generate a substitute signal for one lost frame. New input data
1247 * will not be considered.
1248 *)
1249 AACDEC_CONCEAL = 1;
1250 (** Flag for aacDecoder_DecodeFrame(): Flush all filterbanks to get all delayed
1251 * audio without having new input data. Thus new input data will not be
1252 * considered.
1253 *)
1254 AACDEC_FLUSH = 2;
1255 (** Flag for aacDecoder_DecodeFrame(): Signal an input bit stream data
1256 * discontinuity. Resync any internals as necessary.
1257 *)
1258 AACDEC_INTR = 4;
1259 (** Flag for aacDecoder_DecodeFrame(): Clear all signal delay lines and history
1260 * buffers. CAUTION: This can cause discontinuities in the output signal.
1261 *)
1262 AACDEC_CLRHIST = 8;
1263
1264(**
1265 * \brief Decode one audio frame
1266 *
1267 * \param self AAC decoder handle.
1268 * \param pTimeData Pointer to external output buffer where the decoded PCM
1269 * samples will be stored into.
1270 * \param timeDataSize Size of external output buffer.
1271 * \param flags Bit field with flags for the decoder: \n
1272 * (flags & AACDEC_CONCEAL) == 1: Do concealment. \n
1273 * (flags & AACDEC_FLUSH) == 2: Discard input data. Flush
1274 * filter banks (output delayed audio). \n (flags & AACDEC_INTR) == 4: Input
1275 * data is discontinuous. Resynchronize any internals as
1276 * necessary. \n (flags & AACDEC_CLRHIST) == 8: Clear all signal delay lines and
1277 * history buffers.
1278 * \return Error code.
1279 *)
1280var
1281
1282 aacDecoder_DecodeFrame: function(self: HANDLE_AACDECODER; pTimeData: PSmallInt; const timeDataSize: integer;
1283 const flags: cardinal): AAC_DECODER_ERROR;
1284 cdecl;
1285
1286(**
1287 * \brief De-allocate all resources of an AAC decoder instance.
1288 *
1289 * \param self AAC decoder handle.
1290 * \return void.
1291 *)
1292 aacDecoder_Close: procedure(self: HANDLE_AACDECODER);
1293 cdecl;
1294
1295(**
1296 * \brief Get CStreamInfo handle from decoder.
1297 *
1298 * \param self AAC decoder handle.
1299 * \return Reference to requested CStreamInfo.
1300 *)
1301 aacDecoder_GetStreamInfo: function(self: HANDLE_AACDECODER): PCStreamInfo;
1302 cdecl;
1303
1304(**
1305 * \brief Get decoder library info.
1306 *
1307 * \param info Pointer to an allocated LIB_INFO structure.
1308 * \return 0 on success.
1309 *)
1310 aacDecoder_GetLibInfo: function(var info: array of LIB_INFO): integer;
1311 cdecl;
1312
1313var
1314 ad_Handle: TLibHandle = dynlibs.NilHandle;
1315 {$if defined(cpu32) and defined(windows)} // try load dependency if not in /windows/system32/
1316 gc_Handle :TLibHandle=dynlibs.NilHandle;
1317 {$endif}
1318
1319var
1320 ReferenceCounter: cardinal = 0;
1321
1322function ad_IsLoaded: Boolean; inline;
1323
1324function ad_Load(const libfilename: string): Boolean;
1325
1326procedure ad_Unload();
1327
1328
1329implementation
1330
1331function ad_IsLoaded: Boolean;
1332begin
1333 Result := (ad_Handle <> dynlibs.NilHandle);
1334end;
1335
1336procedure ad_Unload;
1337begin
1338 // < Reference counting
1339 if ReferenceCounter > 0 then
1340 Dec(ReferenceCounter);
1341 if ReferenceCounter > 0 then
1342 Exit;
1343 // >
1344 if ad_IsLoaded then
1345 begin
1346 DynLibs.UnloadLibrary(ad_Handle);
1347 ad_Handle := DynLibs.NilHandle;
1348 {$if defined(cpu32) and defined(windows)}
1349 if gc_Handle <> DynLibs.NilHandle then begin
1350 DynLibs.UnloadLibrary(gc_Handle);
1351 gc_Handle:=DynLibs.NilHandle;
1352 end;
1353 {$endif}
1354 end;
1355end;
1356
1357function ad_Load(const libfilename: string): Boolean;
1358var
1359 thelib, thelibgcc: string;
1360begin
1361 Result := False;
1362 if ad_Handle <> 0 then
1363 begin
1364 Inc(ReferenceCounter);
1365 Result := True; {is it already there ?}
1366 end
1367 else
1368 begin
1369 {$if defined(cpu32) and defined(windows)}
1370 if Length(libfilename) = 0 then thelibgcc := 'libgcc_s_dw2-1.dll' else
1371 thelibgcc := IncludeTrailingBackslash(ExtractFilePath(libfilename)) + 'libgcc_s_dw2-1.dll';
1372 gc_Handle:= DynLibs.SafeLoadLibrary(thelibgcc);
1373 {$endif}
1374 {go & load the library}
1375 if Length(libfilename) = 0 then
1376 thelib := libfdk_aac
1377 else
1378 thelib := libfilename;
1379 ad_Handle := DynLibs.SafeLoadLibrary(thelib); // obtain the handle we want
1380 if ad_Handle <> DynLibs.NilHandle then
1381 begin {now we tie the functions to the VARs from above}
1382
1383 Pointer(aacDecoder_Fill) := DynLibs.GetProcedureAddress(ad_Handle, PChar('aacDecoder_Fill'));
1384 Pointer(aacDecoder_DecodeFrame) := DynLibs.GetProcedureAddress(ad_Handle, PChar('aacDecoder_DecodeFrame'));
1385 Pointer(aacDecoder_GetStreamInfo) := DynLibs.GetProcedureAddress(ad_Handle, PChar('aacDecoder_GetStreamInfo'));
1386 Pointer(aacDecoder_Open) := DynLibs.GetProcedureAddress(ad_Handle, PChar('aacDecoder_Open'));
1387 Pointer(aacDecoder_SetParam) := DynLibs.GetProcedureAddress(ad_Handle, PChar('aacDecoder_SetParam'));
1388 Pointer(aacDecoder_Close) := DynLibs.GetProcedureAddress(ad_Handle, PChar('aacDecoder_Close'));
1389
1390 end;
1391 Result := ad_IsLoaded;
1392 ReferenceCounter := 1;
1393 end;
1394
1395end;
1396
1397function TT_IS_PACKET(x: TRANSPORT_TYPE): Boolean;
1398begin
1399 Result := ((x = TRANSPORT_TYPE.TT_MP4_RAW) or (x = TRANSPORT_TYPE.TT_DRM) or (x = TRANSPORT_TYPE.TT_MP4_LATM_MCP0) or (x = TRANSPORT_TYPE.TT_MP4_LATM_MCP1));
1400end;
1401
1402function CAN_DO_PS(aot: AUDIO_OBJECT_TYPE): Boolean;
1403begin
1404 Result := ((aot = AUDIO_OBJECT_TYPE.AOT_AAC_LC) or (aot = AUDIO_OBJECT_TYPE.AOT_SBR) or (aot = AUDIO_OBJECT_TYPE.AOT_PS) or (aot = AUDIO_OBJECT_TYPE.AOT_ER_BSAC) or (aot = AUDIO_OBJECT_TYPE.AOT_DRM_AAC));
1405end;
1406
1407function IS_USAC(aot: AUDIO_OBJECT_TYPE): Boolean;
1408begin
1409 Result := aot = AUDIO_OBJECT_TYPE.AOT_USAC;
1410end;
1411
1412function IS_LOWDELAY(aot: AUDIO_OBJECT_TYPE): Boolean;
1413begin
1414 Result := (aot = AUDIO_OBJECT_TYPE.AOT_ER_AAC_LD) or (aot = AUDIO_OBJECT_TYPE.AOT_ER_AAC_ELD);
1415end;
1416
1417function IS_CHANNEL_ELEMENT(elementId: MP4_ELEMENT_ID): Boolean;
1418begin
1419 Result := (elementId = MP4_ELEMENT_ID.ID_SCE) or (elementId = MP4_ELEMENT_ID.ID_CPE) or (elementId = MP4_ELEMENT_ID.ID_LFE) or (elementId = MP4_ELEMENT_ID.ID_USAC_SCE) or
1420 (elementId = MP4_ELEMENT_ID.ID_USAC_CPE) or (elementId = MP4_ELEMENT_ID.ID_USAC_LFE);
1421end;
1422
1423function IS_MP4_CHANNEL_ELEMENT(elementId: MP4_ELEMENT_ID): Boolean;
1424begin
1425 Result := (elementId = MP4_ELEMENT_ID.ID_SCE) or (elementId = MP4_ELEMENT_ID.ID_CPE) or (elementId = MP4_ELEMENT_ID.ID_LFE);
1426end;
1427
1428function IS_USAC_CHANNEL_ELEMENT(elementId: MP4_ELEMENT_ID): Boolean;
1429begin
1430 Result := (elementId = MP4_ELEMENT_ID.ID_USAC_SCE) or (elementId = MP4_ELEMENT_ID.ID_USAC_CPE) or (elementId = MP4_ELEMENT_ID.ID_USAC_LFE);
1431end;
1432
1433function LIB_VERSION(lev0: byte; lev1: byte; lev2: byte): integer;
1434begin
1435 Result := (lev0 shl 24) or (lev1 shl 16) or (lev2 shl 8);
1436end;
1437
1438function LIB_VERSION_STRING(info: LIB_INFO): string;
1439begin
1440 Result := string(info.versionStr);
1441 if info.versionStr = '' then
1442 Result := Format('%d.%d.%d', [(info.versionStr), ((info.version shr 24) and $ff), ((info.version shr 16) and $ff), ((info.version shr 8) and $ff)]);
1443end;
1444
1445(** Initialize library info. *)
1446procedure FDKinitLibInfo(var info: array of LIB_INFO);
1447var
1448 i: integer;
1449begin
1450 for i := 0 to integer(FDK_MODULE_ID.FDK_MODULE_LAST) - 1 do
1451 info[i].module_id := FDK_MODULE_ID.FDK_NONE;
1452end;
1453
1454(** Aquire supported features of library. *)
1455function FDKlibInfo_getCapabilities(const info: array of LIB_INFO; module_id: FDK_MODULE_ID): cardinal;
1456var
1457 i: integer;
1458begin
1459 Result := 0;
1460 for i := 0 to integer(FDK_MODULE_ID.FDK_MODULE_LAST) - 1 do
1461 if Info[i].module_id = module_id then
1462 begin
1463 Result := Info[i].flags;
1464 break;
1465 end;
1466end;
1467
1468
1469function FDKlibInfo_lookup(const info: array of LIB_INFO; module_id: FDK_MODULE_ID): integer;
1470var
1471 i: integer;
1472begin
1473 Result := -1;
1474 for i := 0 to integer(FDK_MODULE_ID.FDK_MODULE_LAST) - 1 do
1475 if Info[i].module_id = module_id then
1476 begin
1477 Result := -1;
1478 Exit;
1479 end
1480 else if Info[i].module_id = FDK_MODULE_ID.FDK_NONE then
1481 begin
1482 Result := i;
1483 Exit;
1484 end
1485 else if i = integer(FDK_MODULE_ID.FDK_MODULE_LAST) then
1486 begin
1487 Result := -1;
1488 Exit;
1489 end;
1490end;
1491
1492
1493end.
1494
Note: See TracBrowser for help on using the repository browser.