DEADSOFTWARE

game: remove d_player (unused command)
[d2df-sdl.git] / src / lib / opus / opus.pas
1 unit opus;
3 {$MODE OBJFPC}{$H+}
4 {$PACKRECORDS C}
5 {$MINENUMSIZE 4}
7 interface
9 uses
10 CTypes, SysUtils, ogg;
12 {$IF DEFINED(WINDOWS)}
13 {$IFDEF OPUS_WINDOZE_STATIC}
14 {$LINKLIB libopusfile.a}
15 {$LINKLIB libopus.a}
16 {$ELSE}
17 {$DEFINE OPUS_DYNAMIC}
18 const opuslib = 'libopus-0.dll';
19 const opusfilelib = 'libopusfile-0.dll';
20 {$ENDIF}
21 {$ELSEIF DEFINED(UNIX)}
22 {$DEFINE OPUS_DYNAMIC}
23 {$LINKLIB libopus}
24 {$LINKLIB libopusfile}
25 const opuslib = 'libopus.so';
26 const opusfilelib = 'libopusfile.so';
27 {$ELSE}
28 {$ERROR libopus not supported on this platform. Fix it!}
29 {$ENDIF}
31 const
32 OP_FALSE = -1;
33 OP_HOLE = -3;
34 OP_EREAD = -128;
35 OP_EFAULT = -129;
36 OP_EIMPL = -130;
37 OP_EINVAL = -131;
38 OP_ENOTVORBIS = -132;
39 OP_EBADHEADER = -133;
40 OP_EVERSION = -134;
41 OP_ENOTAUDIO = -135;
42 OP_EBADPACKET = -136;
43 OP_EBADLINK = -137;
44 OP_ENOSEEK = -138;
45 OP_EBADTIMESTAMP = -139;
47 const
48 OPUS_OK = 0;
49 OPUS_BAD_ARG = -1;
50 OPUS_BUFFER_TOO_SMALL = -2;
51 OPUS_INTERNAL_ERROR = -3;
52 OPUS_INVALID_PACKET = -4;
53 OPUS_UNIMPLEMENTED = -5;
54 OPUS_INVALID_STATE = -6;
55 OPUS_ALLOC_FAIL = -7;
57 OPUS_APPLICATION_VOIP = 2048;
58 OPUS_APPLICATION_AUDIO = 2049;
59 OPUS_APPLICATION_RESTRICTED_LOWDELAY = 2051;
61 OPUS_SIGNAL_VOICE = 3001; // Signal being encoded is voice
62 OPUS_SIGNAL_MUSIC = 3002; // Signal being encoded is music
64 OPUS_BANDWIDTH_NARROWBAND = 1101; // 4 kHz bandpass @hideinitializer
65 OPUS_BANDWIDTH_MEDIUMBAND = 1102; // 6 kHz bandpass @hideinitializer
66 OPUS_BANDWIDTH_WIDEBAND = 1103; // 8 kHz bandpass @hideinitializer
67 OPUS_BANDWIDTH_SUPERWIDEBAND = 1104; // 12 kHz bandpass @hideinitializer
68 OPUS_BANDWIDTH_FULLBAND = 1105; // 20 kHz bandpass @hideinitializer
70 OPUS_FRAMESIZE_ARG = 5000; // Select frame size from the argument (default)
71 OPUS_FRAMESIZE_2_5_MS = 5001; // Use 2.5 ms frames
72 OPUS_FRAMESIZE_5_MS = 5002; // Use 5 ms frames
73 OPUS_FRAMESIZE_10_MS = 5003; // Use 10 ms frames
74 OPUS_FRAMESIZE_20_MS = 5004; // Use 20 ms frames
75 OPUS_FRAMESIZE_40_MS = 5005; // Use 40 ms frames
76 OPUS_FRAMESIZE_60_MS = 5006; // Use 60 ms frames
78 OPUS_CHANNEL_COUNT_MAX = 255;
80 const
81 OPUS_SET_APPLICATION_REQUEST = 4000;
82 OPUS_GET_APPLICATION_REQUEST = 4001;
83 OPUS_SET_BITRATE_REQUEST = 4002;
84 OPUS_GET_BITRATE_REQUEST = 4003;
85 OPUS_SET_MAX_BANDWIDTH_REQUEST = 4004;
86 OPUS_GET_MAX_BANDWIDTH_REQUEST = 4005;
87 OPUS_SET_VBR_REQUEST = 4006;
88 OPUS_GET_VBR_REQUEST = 4007;
89 OPUS_SET_BANDWIDTH_REQUEST = 4008;
90 OPUS_GET_BANDWIDTH_REQUEST = 4009;
91 OPUS_SET_COMPLEXITY_REQUEST = 4010;
92 OPUS_GET_COMPLEXITY_REQUEST = 4011;
93 OPUS_SET_INBAND_FEC_REQUEST = 4012;
94 OPUS_GET_INBAND_FEC_REQUEST = 4013;
95 OPUS_SET_PACKET_LOSS_PERC_REQUEST = 4014;
96 OPUS_GET_PACKET_LOSS_PERC_REQUEST = 4015;
97 OPUS_SET_DTX_REQUEST = 4016;
98 OPUS_GET_DTX_REQUEST = 4017;
99 OPUS_SET_VBR_CONSTRAINT_REQUEST = 4020;
100 OPUS_GET_VBR_CONSTRAINT_REQUEST = 4021;
101 OPUS_SET_FORCE_CHANNELS_REQUEST = 4022;
102 OPUS_GET_FORCE_CHANNELS_REQUEST = 4023;
103 OPUS_SET_SIGNAL_REQUEST = 4024;
104 OPUS_GET_SIGNAL_REQUEST = 4025;
105 OPUS_GET_LOOKAHEAD_REQUEST = 4027;
106 OPUS_RESET_STATE_REQUEST = 4028;
107 OPUS_GET_SAMPLE_RATE_REQUEST = 4029;
108 OPUS_GET_FINAL_RANGE_REQUEST = 4031;
109 OPUS_GET_PITCH_REQUEST = 4033;
110 OPUS_SET_GAIN_REQUEST = 4034;
111 OPUS_GET_GAIN_REQUEST = 4045;
112 OPUS_SET_LSB_DEPTH_REQUEST = 4036;
113 OPUS_GET_LSB_DEPTH_REQUEST = 4037;
114 OPUS_GET_LAST_PACKET_DURATION_REQUEST = 4039;
115 OPUS_SET_EXPERT_FRAME_DURATION_REQUEST = 4040;
116 OPUS_GET_EXPERT_FRAME_DURATION_REQUEST = 4041;
117 OPUS_SET_PREDICTION_DISABLED_REQUEST = 4042;
118 OPUS_GET_PREDICTION_DISABLED_REQUEST = 4043;
119 OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST = 5120;
120 OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST = 5122;
122 type
123 OpusHead = record
124 version: cint;
125 channel_count: cint;
126 pre_skip: cuint;
127 input_sample_rate: cuint32;
128 output_gain: cint;
129 mapping_family: cint;
130 stream_count: cint;
131 coupled_count: cint;
132 mapping: array [0..OPUS_CHANNEL_COUNT_MAX-1] of byte;
133 end;
134 POpusHead = ^OpusHead;
136 type
137 OggOpusFile = record end;
138 POggOpusFile = ^OggOpusFile;
140 type
141 op_read_func = function (stream: Pointer; buffer: pointer; nbytes: cint): cint; cdecl;
142 op_seek_func = function (stream: Pointer; offset: Int64; whence: cint): cint; cdecl;
143 op_tell_func = function (stream: Pointer): Int64; cdecl;
144 op_close_func = function (stream: Pointer): cint; cdecl;
146 OpusFileCallbacks = record
147 read: op_read_func;
148 seek: op_seek_func;
149 tell: op_tell_func;
150 close: op_close_func;
151 end;
153 function opus_get_version_string(): PAnsiChar; cdecl; external {$IFDEF OPUS_DYNAMIC}opuslib{$ENDIF};
154 function opus_strerror(error: cint): PAnsiChar; cdecl; external {$IFDEF OPUS_DYNAMIC}opuslib{$ENDIF};
156 function op_open_file(path: pchar; err: pcint): POggOpusFile; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
157 function op_open_memory(data: pointer; size: csize_t; err: pcint): POggOpusFile; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
159 function op_test_file(path: pchar; err: pcint): POggOpusFile; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
160 function op_test_memory(data: pointer; size: csize_t; err: pcint): POggOpusFile; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
162 procedure op_free(opf: POggOpusFile); cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
164 function op_seekable(opf: POggOpusFile): cint; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
165 function op_channel_count(opf: POggOpusFile): cuint32; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
166 function op_head(opf: POggOpusFile; li: cint): POpusHead; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
167 function op_pcm_tell(opf: POggOpusFile): cint64; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
168 function op_pcm_total(opf: POggOpusFile; li: cint): cint64; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
170 function op_read(opf: POggOpusFile; pcm: pcint16; bufsiz: cint; li: cint): cint; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
171 function op_read_stereo(opf: POggOpusFile; pcm: pcint16; bufsiz: cint): cint; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
172 function op_pcm_seek(opf: POggOpusFile; pos: cint64): cint; cdecl; external {$IFDEF OPUS_DYNAMIC}opusfilelib{$ENDIF};
174 implementation
176 end.