5 // XXX philipd this might break things?
6 // these defines were placed after the machine-dependent
7 // checks below...i'm not sure why
9 #define COMPILER_IS_GCC 1
10 #define CPU_CLIPS_NEGATIVE 1
11 #define ENABLE_EXPERIMENTAL_CODE 0
12 #define GCC_MAJOR_VERSION 3
15 #define HAVE_DECL_S_IRGRP 1
16 #define HAVE_DLFCN_H 1
17 #define HAVE_FLEXIBLE_ARRAY 1
23 #define HAVE_FTRUNCATE 1
24 #define HAVE_GETPAGESIZE 1
26 #define HAVE_GMTIME_R 1
27 #define HAVE_INTTYPES_H 1
31 #define HAVE_MEMORY_H 1
35 #define HAVE_REALLOC 1
36 #define HAVE_SNPRINTF 1
37 #define HAVE_STDINT_H 1
38 #define HAVE_STDLIB_H 1
39 #define HAVE_STRINGS_H 1
40 #define HAVE_STRING_H 1
41 #define HAVE_SYS_STAT_H 1
42 #define HAVE_SYS_TYPES_H 1
43 #define HAVE_SYS_WAIT_H 1
44 #define HAVE_VSNPRINTF 1
46 #define PACKAGE "libsndfile"
47 #define PACKAGE_BUGREPORT "erikd@mega-nerd.com"
48 #define PACKAGE_NAME "libsndfile"
49 #define PACKAGE_STRING "libsndfile 1.0.10"
50 #define PACKAGE_TARNAME "libsndfile"
51 #define PACKAGE_VERSION "1.0.10"
53 #define SIZEOF_DOUBLE 8
54 #define SIZEOF_FLOAT 4
57 #define SIZEOF_OFF_T 8
58 #define SIZEOF_SF_COUNT_T 8
59 #define SIZEOF_SHORT 2
60 #define SIZEOF_SIZE_T 4
61 #define SIZEOF_SSIZE_T 4
62 #define SIZEOF_VOIDP 4
63 #define STDC_HEADERS 1
65 #define VERSION "1.0.10"
67 #ifdef __MACOSX_CORE__
68 #define CPU_CLIPS_POSITIVE 1
69 #define CPU_IS_BIG_ENDIAN 1
70 #define CPU_IS_LITTLE_ENDIAN 0
73 #define OS_IS_MACOSX 1
75 #define TYPEOF_SF_COUNT_T off_t
78 #if defined(__PLATFORM_WIN32__) //Dev Studio
79 #define CPU_CLIPS_POSITIVE 0
80 #define CPU_IS_BIG_ENDIAN 0
81 #define CPU_IS_LITTLE_ENDIAN 1
87 #undef HAVE_FLEXIBLE_ARRAY
88 #define OS_IS_MACOSX 0
90 #define TYPEOF_SF_COUNT_T off_t
93 #if defined (__WINDOWS_PTHREAD__) //Cygwin
94 #define CPU_CLIPS_POSITIVE 0
95 #define CPU_IS_BIG_ENDIAN 0
96 #define CPU_IS_LITTLE_ENDIAN 1
99 #define OS_IS_MACOSX 0
100 #define OS_IS_WIN32 0
101 #define TYPEOF_SF_COUNT_T off_t
104 #ifdef __LINUX_ALSA__
105 #define HAVE_ALSA_ASOUNDLIB_H
108 #if defined(__LINUX_ALSA__) || defined(__LINUX_OSS__) || defined(__LINUX_JACK__)
109 #define CPU_CLIPS_POSITIVE 0
110 #define CPU_IS_BIG_ENDIAN 0
111 #define CPU_IS_LITTLE_ENDIAN 1
113 #define HAVE_PWRITE 1
114 #define OS_IS_MACOSX 0
115 #define OS_IS_WIN32 0
116 #define SIZEOF_OFF64_T 0
117 #define SIZEOF_LOFF_T 8
118 #define TYPEOF_SF_COUNT_T loff_t
119 #define _FILE_OFFSET_BITS 64
120 #define HAVE_FDATASYNC 1
121 #define HAVE_ENDIAN_H 1
122 #define HAVE_LRINTF 1
128 // XXX 'inline' is necessary for C compilation
129 // in the microsoft vc6 compiler...
130 // and other ms win32 specialteez.
132 #ifdef __PLATFORM_WIN32__
134 #define C_INLINE __inline
135 #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFF
139 #define C_INLINE inline
140 #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
141 #define HAVE_UNISTD_H 1
142 #define HAVE_SSIZE_T 1
147 ** sndfile.h -- system-wide definitions
149 ** API documentation is in the doc/ directory of the source code tarball
150 ** and at http://www.mega-nerd.com/libsndfile/api.html.
156 /* This is the version 1.0.X header file. */
160 /* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */
162 #if (defined (__MWERKS__))
164 #include <sys/types.h>
169 #endif /* __cplusplus */
171 /* The following file types can be read and written.
172 ** A file type would consist of a major type (ie SF_FORMAT_WAV) bitwise
173 ** ORed with a minor type (ie SF_FORMAT_PCM). SF_FORMAT_TYPEMASK and
174 ** SF_FORMAT_SUBMASK can be used to separate the major and minor file
179 { /* Major formats. */
180 SF_FORMAT_WAV
= 0x010000, /* Microsoft WAV format (little endian). */
181 SF_FORMAT_AIFF
= 0x020000, /* Apple/SGI AIFF format (big endian). */
182 SF_FORMAT_AU
= 0x030000, /* Sun/NeXT AU format (big endian). */
183 SF_FORMAT_RAW
= 0x040000, /* RAW PCM data. */
184 SF_FORMAT_PAF
= 0x050000, /* Ensoniq PARIS file format. */
185 SF_FORMAT_SVX
= 0x060000, /* Amiga IFF / SVX8 / SV16 format. */
186 SF_FORMAT_NIST
= 0x070000, /* Sphere NIST format. */
187 SF_FORMAT_VOC
= 0x080000, /* VOC files. */
188 SF_FORMAT_IRCAM
= 0x0A0000, /* Berkeley/IRCAM/CARL */
189 SF_FORMAT_W64
= 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */
190 SF_FORMAT_MAT4
= 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */
191 SF_FORMAT_MAT5
= 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */
192 SF_FORMAT_PVF
= 0x0E0000, /* Portable Voice Format */
193 SF_FORMAT_XI
= 0x0F0000, /* Fasttracker 2 Extended Instrument */
194 SF_FORMAT_HTK
= 0x100000, /* HMM Tool Kit format */
195 SF_FORMAT_SDS
= 0x110000, /* Midi Sample Dump Standard */
196 SF_FORMAT_AVR
= 0x120000, /* Audio Visual Research */
197 SF_FORMAT_WAVEX
= 0x130000, /* MS WAVE with WAVEFORMATEX */
199 /* Subtypes from here on. */
201 SF_FORMAT_PCM_S8
= 0x0001, /* Signed 8 bit data */
202 SF_FORMAT_PCM_16
= 0x0002, /* Signed 16 bit data */
203 SF_FORMAT_PCM_24
= 0x0003, /* Signed 24 bit data */
204 SF_FORMAT_PCM_32
= 0x0004, /* Signed 32 bit data */
205 SF_FORMAT_PCM_U8
= 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */
206 SF_FORMAT_FLOAT
= 0x0006, /* 32 bit float data */
207 SF_FORMAT_DOUBLE
= 0x0007, /* 64 bit float data */
208 SF_FORMAT_ULAW
= 0x0010, /* U-Law encoded. */
209 SF_FORMAT_ALAW
= 0x0011, /* A-Law encoded. */
210 SF_FORMAT_IMA_ADPCM
= 0x0012, /* IMA ADPCM. */
211 SF_FORMAT_MS_ADPCM
= 0x0013, /* Microsoft ADPCM. */
212 SF_FORMAT_GSM610
= 0x0020, /* GSM 6.10 encoding. */
213 SF_FORMAT_VOX_ADPCM
= 0x0021, /* OKI / Dialogix ADPCM */
214 SF_FORMAT_G721_32
= 0x0030, /* 32kbs G721 ADPCM encoding. */
215 SF_FORMAT_G723_24
= 0x0031, /* 24kbs G723 ADPCM encoding. */
216 SF_FORMAT_G723_40
= 0x0032, /* 40kbs G723 ADPCM encoding. */
217 SF_FORMAT_DWVW_12
= 0x0040, /* 12 bit Delta Width Variable Word encoding. */
218 SF_FORMAT_DWVW_16
= 0x0041, /* 16 bit Delta Width Variable Word encoding. */
219 SF_FORMAT_DWVW_24
= 0x0042, /* 24 bit Delta Width Variable Word encoding. */
220 SF_FORMAT_DWVW_N
= 0x0043, /* N bit Delta Width Variable Word encoding. */
221 SF_FORMAT_DPCM_8
= 0x0050, /* 8 bit differential PCM (XI only) */
222 SF_FORMAT_DPCM_16
= 0x0051, /* 16 bit differential PCM (XI only) */
224 /* Endian-ness options. */
226 SF_ENDIAN_FILE
= 0x00000000, /* Default file endian-ness. */
227 SF_ENDIAN_LITTLE
= 0x10000000, /* Force little endian-ness. */
228 SF_ENDIAN_BIG
= 0x20000000, /* Force big endian-ness. */
229 SF_ENDIAN_CPU
= 0x30000000, /* Force CPU endian-ness. */
231 SF_FORMAT_SUBMASK
= 0x0000FFFF,
232 SF_FORMAT_TYPEMASK
= 0x0FFF0000,
233 SF_FORMAT_ENDMASK
= 0x30000000
239 ** The following are the valid command numbers for the sf_command()
240 ** interface. The use of these commands is documented in the file
241 ** command.html in the doc directory of the source code distribution.
247 { SFC_GET_LIB_VERSION
= 0x1000,
248 SFC_GET_LOG_INFO
= 0x1001,
249 SFC_GET_NORM_DOUBLE
= 0x1010,
250 SFC_GET_NORM_FLOAT
= 0x1011,
251 SFC_SET_NORM_DOUBLE
= 0x1012,
252 SFC_SET_NORM_FLOAT
= 0x1013,
253 SFC_GET_SIMPLE_FORMAT_COUNT
= 0x1020,
254 SFC_GET_SIMPLE_FORMAT
= 0x1021,
255 SFC_GET_FORMAT_INFO
= 0x1028,
256 SFC_GET_FORMAT_MAJOR_COUNT
= 0x1030,
257 SFC_GET_FORMAT_MAJOR
= 0x1031,
258 SFC_GET_FORMAT_SUBTYPE_COUNT
= 0x1032,
259 SFC_GET_FORMAT_SUBTYPE
= 0x1033,
260 SFC_CALC_SIGNAL_MAX
= 0x1040,
261 SFC_CALC_NORM_SIGNAL_MAX
= 0x1041,
262 SFC_CALC_MAX_ALL_CHANNELS
= 0x1042,
263 SFC_CALC_NORM_MAX_ALL_CHANNELS
= 0x1043,
264 SFC_SET_ADD_PEAK_CHUNK
= 0x1050,
265 SFC_UPDATE_HEADER_NOW
= 0x1060,
266 SFC_SET_UPDATE_HEADER_AUTO
= 0x1061,
267 SFC_FILE_TRUNCATE
= 0x1080,
268 SFC_SET_RAW_START_OFFSET
= 0x1090,
269 SFC_SET_DITHER_ON_WRITE
= 0x10A0,
270 SFC_SET_DITHER_ON_READ
= 0x10A1,
271 SFC_GET_DITHER_INFO_COUNT
= 0x10A2,
272 SFC_GET_DITHER_INFO
= 0x10A3,
273 SFC_GET_EMBED_FILE_INFO
= 0x10B0,
274 SFC_SET_CLIPPING
= 0x10C0,
275 SFC_GET_CLIPPING
= 0x10C1,
276 SFC_GET_INSTRUMENT
= 0x10D0,
277 SFC_SET_INSTRUMENT
= 0x10D1,
279 /* Following commands for testing only. */
280 SFC_TEST_IEEE_FLOAT_REPLACE
= 0x6001,
283 ** SFC_SET_ADD_* values are deprecated and will disappear at some
284 ** time in the future. They are guaranteed to be here up to and
285 ** including version 1.0.8 to avoid breakage of existng software.
286 ** They currently do nothing and will continue to do nothing.
289 SFC_SET_ADD_DITHER_ON_WRITE
= 0x1070,
290 SFC_SET_ADD_DITHER_ON_READ
= 0x1071
298 ** String types that can be set and read from files. Not all file types
299 ** support this and even the file types which support one, may not support
305 { SF_STR_TITLE
= 0x01,
306 SF_STR_COPYRIGHT
= 0x02,
307 SF_STR_SOFTWARE
= 0x03,
308 SF_STR_ARTIST
= 0x04,
309 SF_STR_COMMENT
= 0x05,
316 { /* True and false */
320 /* Modes for opening files. */
328 /* Pubic error values. These are guaranteed to remain unchanged for the duration
329 ** of the library major version number.
330 ** There are also a large number of private error numbers which are internal to
331 ** the library which can change at any time.
337 { SF_ERR_NO_ERROR
= 0,
338 SF_ERR_UNRECOGNISED_FORMAT
= 1,
344 /* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
346 typedef struct SNDFILE_tag SNDFILE
;
349 /* The following typedef is system specific and is defined when libsndfile is.
350 ** compiled. sf_count_t can be one of loff_t (Linux), off_t (*BSD),
351 ** off64_t (Solaris), __int64_t (Win32) etc.
354 typedef TYPEOF_SF_COUNT_T sf_count_t
;
356 //#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
358 /* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in.
359 ** On write, the SF_INFO structure is filled in by the user and passed into
364 { sf_count_t frames
; /* Used to be called samples. Changed to avoid confusion. */
372 typedef struct SF_INFO SF_INFO
;
374 /* The SF_FORMAT_INFO struct is used to retrieve information about the sound
375 ** file formats libsndfile supports using the sf_command () interface.
377 ** Using this interface will allow applications to support new file formats
378 ** and encoding types when libsndfile is upgraded, without requiring
379 ** re-compilation of the application.
381 ** Please consult the libsndfile documentation (particularly the information
382 ** on the sf_command () interface) for examples of its use.
388 const char *extension
;
392 ** Enums and typedefs for adding dither on read and write.
393 ** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE
394 ** and SFC_SET_DITHER_ON_READ.
398 { SFD_DEFAULT_LEVEL
= 0,
399 SFD_CUSTOM_LEVEL
= 0x40000000,
403 SFD_TRIANGULAR_PDF
= 502
412 /* Struct used to retrieve information about a file embedded within a
413 ** larger file. See SFC_GET_EMBED_FILE_INFO.
417 { sf_count_t offset
;
419 } SF_EMBED_FILE_INFO
;
421 /* Struct used to retrieve music sample information from a file.
428 int sustain_start
, sustain_end
;
430 int release_start
, reslease_end
;
433 /* sustain_mode and release_mode will be one of the following. */
436 { SF_LOOP_NONE
= 800,
441 /* Open the specified file for read, write or both. On error, this will
442 ** return a NULL pointer. To find the error number, pass a NULL SNDFILE
443 ** to sf_perror () or sf_error_str ().
444 ** All calls to sf_open() should be matched with a call to sf_close().
447 SNDFILE
* sf_open (const char *path
, int mode
, SF_INFO
*sfinfo
) ;
449 /* Use the existing file descriptor to create a SNDFILE object. If close_desc
450 ** is TRUE, the file descriptor will be closed when sf_close() is called. If
451 ** it is FALSE, the descritor will not be closed.
452 ** When passed a descriptor like this, the library will assume that the start
453 ** of file header is at the current file offset. This allows sound files within
454 ** larger container files to be read and/or written.
455 ** On error, this will return a NULL pointer. To find the error number, pass a
456 ** NULL SNDFILE to sf_perror () or sf_error_str ().
457 ** All calls to sf_open_fd() should be matched with a call to sf_close().
461 SNDFILE
* sf_open_fd (int fd
, int mode
, SF_INFO
*sfinfo
, int close_desc
) ;
463 /* sf_error () returns a error number which can be translated to a text
464 ** string using sf_error_number().
467 int sf_error (SNDFILE
*sndfile
) ;
469 /* sf_strerror () returns to the caller a pointer to the current error message for
470 ** the given SNDFILE.
473 const char* sf_strerror (SNDFILE
*sndfile
) ;
475 /* sf_error_number () allows the retrieval of the error string for each internal
480 const char* sf_error_number (int errnum
) ;
482 /* The following three error functions are deprecated but they will remain in the
483 ** library for the forseeable future. The function sf_strerror() should be used
487 int sf_perror (SNDFILE
*sndfile
) ;
488 int sf_error_str (SNDFILE
*sndfile
, char* str
, size_t len
) ;
491 /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
493 int sf_command (SNDFILE
*sndfile
, int command
, void *data
, int datasize
) ;
495 /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
497 int sf_format_check (const SF_INFO
*info
) ;
499 /* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses
500 ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as
501 ** stdio.h function fseek ().
502 ** An offset of zero with whence set to SEEK_SET will position the
503 ** read / write pointer to the first data sample.
504 ** On success sf_seek returns the current position in (multi-channel)
505 ** samples from the start of the file.
506 ** Please see the libsndfile documentation for moving the read pointer
507 ** separately from the write pointer on files open in mode SFM_RDWR.
508 ** On error all of these functions return -1.
511 sf_count_t
sf_seek (SNDFILE
*sndfile
, sf_count_t frames
, int whence
) ;
513 /* Functions for retrieving and setting string data within sound files.
514 ** Not all file types support this features; AIFF and WAV do. For both
515 ** functions, the str_type parameter must be one of the SF_STR_* values
517 ** On error, sf_set_string() returns non-zero while sf_get_string()
521 int sf_set_string (SNDFILE
*sndfile
, int str_type
, const char* str
) ;
523 const char* sf_get_string (SNDFILE
*sndfile
, int str_type
) ;
525 /* Functions for reading/writing the waveform data of a sound file.
528 sf_count_t
sf_read_raw (SNDFILE
*sndfile
, void *ptr
, sf_count_t bytes
) ;
529 sf_count_t
sf_write_raw (SNDFILE
*sndfile
, void *ptr
, sf_count_t bytes
) ;
531 /* Functions for reading and writing the data chunk in terms of frames.
532 ** The number of items actually read/written = frames * number of channels.
533 ** sf_xxxx_raw read/writes the raw data bytes from/to the file
534 ** sf_xxxx_short passes data in the native short format
535 ** sf_xxxx_int passes data in the native int format
536 ** sf_xxxx_float passes data in the native float format
537 ** sf_xxxx_double passes data in the native double format
538 ** All of these read/write function return number of frames read/written.
541 sf_count_t
sf_readf_short (SNDFILE
*sndfile
, short *ptr
, sf_count_t frames
) ;
542 sf_count_t
sf_writef_short (SNDFILE
*sndfile
, short *ptr
, sf_count_t frames
) ;
544 sf_count_t
sf_readf_int (SNDFILE
*sndfile
, int *ptr
, sf_count_t frames
) ;
545 sf_count_t
sf_writef_int (SNDFILE
*sndfile
, int *ptr
, sf_count_t frames
) ;
547 sf_count_t
sf_readf_float (SNDFILE
*sndfile
, float *ptr
, sf_count_t frames
) ;
548 sf_count_t
sf_writef_float (SNDFILE
*sndfile
, float *ptr
, sf_count_t frames
) ;
550 sf_count_t
sf_readf_double (SNDFILE
*sndfile
, double *ptr
, sf_count_t frames
) ;
551 sf_count_t
sf_writef_double (SNDFILE
*sndfile
, double *ptr
, sf_count_t frames
) ;
553 /* Functions for reading and writing the data chunk in terms of items.
554 ** Otherwise similar to above.
555 ** All of these read/write function return number of items read/written.
558 sf_count_t
sf_read_short (SNDFILE
*sndfile
, short *ptr
, sf_count_t items
) ;
559 sf_count_t
sf_write_short (SNDFILE
*sndfile
, short *ptr
, sf_count_t items
) ;
561 sf_count_t
sf_read_int (SNDFILE
*sndfile
, int *ptr
, sf_count_t items
) ;
562 sf_count_t
sf_write_int (SNDFILE
*sndfile
, int *ptr
, sf_count_t items
) ;
564 sf_count_t
sf_read_float (SNDFILE
*sndfile
, float *ptr
, sf_count_t items
) ;
565 sf_count_t
sf_write_float (SNDFILE
*sndfile
, float *ptr
, sf_count_t items
) ;
567 sf_count_t
sf_read_double (SNDFILE
*sndfile
, double *ptr
, sf_count_t items
) ;
568 sf_count_t
sf_write_double (SNDFILE
*sndfile
, double *ptr
, sf_count_t items
) ;
570 /* Close the SNDFILE and clean up all memory allocations associated with this
572 ** Returns 0 on success, or an error number.
575 int sf_close (SNDFILE
*sndfile
) ;
579 #endif /* __cplusplus */
581 #endif /* SNDFILE_H */
583 ** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
585 ** This program is free software; you can redistribute it and/or modify
586 ** it under the terms of the GNU Lesser General Public License as published by
587 ** the Free Software Foundation; either version 2.1 of the License, or
588 ** (at your option) any later version.
590 ** This program is distributed in the hope that it will be useful,
591 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
592 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
593 ** GNU Lesser General Public License for more details.
595 ** You should have received a copy of the GNU Lesser General Public License
596 ** along with this program; if not, write to the Free Software
597 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
600 #ifndef COMMON_H_INCLUDED
601 #define COMMON_H_INCLUDED
607 #define SF_BUFFER_LEN (8192*2)
608 #define SF_FILENAME_LEN (256)
609 #define SF_HEADER_LEN (4096)
610 #define SF_TEXT_LEN (1024)
611 #define SF_SYSERR_LEN (256)
612 #define SF_MAX_STRINGS (16)
614 #define SF_SEEK_ERROR ((sf_count_t) -1)
617 #define BITWIDTH2BYTES(x) (((x) + 7) / 8)
619 /* For some reason sizeof returns an unsigned value which causes
620 ** a warning when that value is added or subtracted from a signed
621 ** value. Use SIGNED_SIZEOF instead.
623 #define SIGNED_SIZEOF(x) ((int) sizeof (x))
625 #define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0])))
627 #define SF_MAX(a,b) ((a) > (b) ? (a) : (b))
628 #define SF_MIN(a,b) ((a) < (b) ? (a) : (b))
631 { /* PEAK chunk location. */
635 /* PEAK chunk location. */
639 /* str_flags values. */
640 SF_STR_ALLOW_START
= 0x0100,
641 SF_STR_ALLOW_END
= 0x0200,
643 /* Location of strings. */
644 SF_STR_LOCATE_START
= 0x0400,
645 SF_STR_LOCATE_END
= 0x0800,
647 SFD_TYPEMASK
= 0x0FFFFFFF
650 #define SFM_MASK (SFM_READ | SFM_WRITE | SFM_RDWR)
651 #define SFM_UNMASK (~SFM_MASK)
653 /*---------------------------------------------------------------------------------------
654 ** Formats that may be supported at some time in the future.
655 ** When support is finalised, these values move to src/sndfile.h.
659 { /* Work in progress. */
661 /* Formats supported read only. */
662 SF_FORMAT_WVE
= 0x4020000, /* Psion ALaw Sound File */
663 SF_FORMAT_TXW
= 0x4030000, /* Yamaha TX16 sampler file */
664 SF_FORMAT_DWD
= 0x4040000, /* DiamondWare Digirized */
666 /* Following are detected but not supported. */
667 SF_FORMAT_OGG
= 0x4090000,
669 SF_FORMAT_REX
= 0x40A0000, /* Propellorheads Rex/Rcy */
670 SF_FORMAT_SD2
= 0x40C0000, /* Sound Designer 2 */
671 SF_FORMAT_REX2
= 0x40D0000, /* Propellorheads Rex2 */
672 SF_FORMAT_KRZ
= 0x40E0000, /* Kurzweil sampler file */
673 SF_FORMAT_WMA
= 0x4100000, /* Windows Media Audio. */
674 SF_FORMAT_SHN
= 0x4110000, /* Shorten. */
675 SF_FORMAT_FLAC
= 0x4120000,
677 /* Unsupported encodings. */
678 SF_FORMAT_VORBIS
= 0x1001,
680 SF_FORMAT_SVX_FIB
= 0x1020, /* SVX Fibonacci Delta encoding. */
681 SF_FORMAT_SVX_EXP
= 0x1021, /* SVX Exponential Delta encoding. */
683 SF_FORMAT_PCM_N
= 0x1030
686 /*---------------------------------------------------------------------------------------
687 ** PEAK_CHUNK_OLD - This chunk type is common to both AIFF and WAVE files although their
688 ** endian encodings are different.
692 { float value
; /* signed value of peak */
693 unsigned int position
; /* the sample frame for the peak */
697 { unsigned int version
; /* version of the PEAK chunk */
698 unsigned int timestamp
; /* secs since 1/1/1970 */
699 #if HAVE_FLEXIBLE_ARRAY
700 PEAK_POS peaks
[] ; /* the per channel peak info */
702 PEAK_POS peaks
[1] ; /* the per channel peak info */
712 /*=======================================================================================
713 ** SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
714 ** sf_open_XXXX functions. The caller however has no knowledge of the struct's
718 typedef struct sf_private_tag
719 { /* Force the compiler to double align the start of buffer. */
720 double buffer
[SF_BUFFER_LEN
/ sizeof (double)] ;
721 char filename
[SF_FILENAME_LEN
] ;
723 char syserr
[SF_SYSERR_LEN
] ;
725 /* logbuffer and logindex should only be changed within the logging functions
728 char logbuffer
[SF_BUFFER_LEN
] ;
729 unsigned char header
[SF_HEADER_LEN
] ; /* Must be unsigned */
730 int rwf_endian
; /* Header endian-ness flag. */
732 /* Storage and housekeeping data for adding/reading strings from
735 STR_DATA strings
[SF_MAX_STRINGS
] ;
736 char str_storage
[SF_BUFFER_LEN
] ;
740 /* Guard value. If this changes the buffers above have overflowed. */
743 /* Index variables for maintaining logbuffer and header above. */
745 int headindex
, headend
;
747 int do_not_close_descriptor
;
754 int mode
; /* Open mode : SFM_READ, SFM_WRITE or SFM_RDWR. */
755 int endian
; /* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */
756 int float_endswap
; /* Need to endswap float32s? */
758 /* Vairables for handling pipes. */
759 int is_pipe
; /* True if file is a pipe. */
760 sf_count_t pipeoffset
; /* Number of bytes read from a pipe. */
762 /* True if clipping must be performed on float->int conversions. */
767 int have_written
; /* Has a single write been done to the file? */
768 int has_peak
; /* Has a PEAK chunk (AIFF and WAVE) been read? */
769 int peak_loc
; /* Write a PEAK chunk at the start or end of the file? */
772 sf_count_t filelength
; /* Overall length of (embedded) file. */
773 sf_count_t fileoffset
; /* Offset in number of bytes from beginning of file. */
775 sf_count_t dataoffset
; /* Offset in number of bytes from beginning of file. */
776 sf_count_t datalength
; /* Length in bytes of the audio data. */
777 sf_count_t dataend
; /* Offset to file tailer. */
779 int blockwidth
; /* Size in bytes of one set of interleaved samples. */
780 int bytewidth
; /* Size in bytes of one sample (one channel). */
785 int last_op
; /* Last operation; either SFM_READ or SFM_WRITE */
786 sf_count_t read_current
;
787 sf_count_t write_current
;
789 void *fdata
; /* This is a pointer to dynamically allocated file format
793 SF_DITHER_INFO write_dither
;
794 SF_DITHER_INFO read_dither
;
802 /* A set of file specific function pointers */
804 sf_count_t (*read_short
) (struct sf_private_tag
*, short *ptr
, sf_count_t len
) ;
805 sf_count_t (*read_int
) (struct sf_private_tag
*, int *ptr
, sf_count_t len
) ;
806 sf_count_t (*read_float
) (struct sf_private_tag
*, float *ptr
, sf_count_t len
) ;
807 sf_count_t (*read_double
) (struct sf_private_tag
*, double *ptr
, sf_count_t len
) ;
809 sf_count_t (*write_short
) (struct sf_private_tag
*, short *ptr
, sf_count_t len
) ;
810 sf_count_t (*write_int
) (struct sf_private_tag
*, int *ptr
, sf_count_t len
) ;
811 sf_count_t (*write_float
) (struct sf_private_tag
*, float *ptr
, sf_count_t len
) ;
812 sf_count_t (*write_double
) (struct sf_private_tag
*, double *ptr
, sf_count_t len
) ;
814 sf_count_t (*seek
) (struct sf_private_tag
*, int mode
, sf_count_t samples_from_start
) ;
815 int (*write_header
) (struct sf_private_tag
*, int calc_length
) ;
816 int (*command
) (struct sf_private_tag
*, int command
, void *data
, int datasize
) ;
817 int (*close
) (struct sf_private_tag
*) ;
825 { SFE_NO_ERROR
= SF_ERR_NO_ERROR
,
826 SFE_BAD_OPEN_FORMAT
= SF_ERR_UNRECOGNISED_FORMAT
,
827 SFE_SYSTEM
= SF_ERR_SYSTEM
,
834 SFE_BAD_SF_INCOMPLETE
,
848 SFE_NO_EMBED_SUPPORT
,
849 SFE_NO_EMBEDDED_RDWR
,
891 SFE_WAV_BAD_BLOCKALIGN
,
893 SFE_WAV_ADPCM_NOT4BIT
,
894 SFE_WAV_ADPCM_CHANNELS
,
895 SFE_WAV_GSM610_FORMAT
,
896 SFE_WAV_UNKNOWN_CHUNK
,
900 SFE_AIFF_AIFF_NO_FORM
,
901 SFE_AIFF_COMM_NO_FORM
,
902 SFE_AIFF_SSND_NO_COMM
,
903 SFE_AIFF_UNKNOWN_CHUNK
,
904 SFE_AIFF_COMM_CHUNK_SIZE
,
905 SFE_AIFF_BAD_COMM_CHUNK
,
906 SFE_AIFF_PEAK_B4_COMM
,
910 SFE_AIFF_RW_SSND_NOT_LAST
,
912 SFE_AU_UNKNOWN_FORMAT
,
914 SFE_AU_EMBED_BAD_LEN
,
916 SFE_RAW_READ_BAD_SPEC
,
917 SFE_RAW_BAD_BITWIDTH
,
922 SFE_PAF_UNKNOWN_FORMAT
,
923 SFE_PAF_SHORT_HEADER
,
929 SFE_SVX_BAD_NAME_LENGTH
,
932 SFE_NIST_CRLF_CONVERISON
,
933 SFE_NIST_BAD_ENCODING
,
939 SFE_VOC_BAD_SECTIONS
,
940 SFE_VOC_MULTI_SAMPLERATE
,
941 SFE_VOC_MULTI_SECTION
,
943 SFE_VOC_SECTION_COUNT
,
947 SFE_IRCAM_BAD_CHANNELS
,
948 SFE_IRCAM_UNKNOWN_FORMAT
,
957 SFE_W64_ADPCM_NOT4BIT
,
958 SFE_W64_ADPCM_CHANNELS
,
959 SFE_W64_GSM610_FORMAT
,
962 SFE_MAT4_NO_SAMPLERATE
,
963 SFE_MAT4_ZERO_CHANNELS
,
967 SFE_MAT5_SAMPLE_RATE
,
968 SFE_MAT5_ZERO_CHANNELS
,
972 SFE_PVF_BAD_BITWIDTH
,
974 SFE_DWVW_BAD_BITWIDTH
,
978 SFE_XI_EXCESS_SAMPLES
,
984 SFE_SDS_BAD_BIT_WIDTH
,
986 SFE_MAX_ERROR
/* This must be last in list. */
989 int subformat_to_bytewidth (int format
) ;
990 int s_bitwidth_to_subformat (int bits
) ;
991 int u_bitwidth_to_subformat (int bits
) ;
993 /* Functions for reading and writing floats and doubles on processors
994 ** with non-IEEE floats/doubles.
996 float float32_be_read (unsigned char *cptr
) ;
997 float float32_le_read (unsigned char *cptr
) ;
998 void float32_be_write (float in
, unsigned char *out
) ;
999 void float32_le_write (float in
, unsigned char *out
) ;
1001 double double64_be_read (unsigned char *cptr
) ;
1002 double double64_le_read (unsigned char *cptr
) ;
1003 void double64_be_write (double in
, unsigned char *out
) ;
1004 void double64_le_write (double in
, unsigned char *out
) ;
1006 /* Functions for writing to the internal logging buffer. */
1008 void psf_log_printf (SF_PRIVATE
*psf
, const char *format
, ...) ;
1009 void psf_log_SF_INFO (SF_PRIVATE
*psf
) ;
1011 void psf_hexdump (void *ptr
, int len
) ;
1013 /* Functions used when writing file headers. */
1015 int psf_binheader_writef (SF_PRIVATE
*psf
, const char *format
, ...) ;
1016 void psf_asciiheader_printf (SF_PRIVATE
*psf
, const char *format
, ...) ;
1018 /* Functions used when reading file headers. */
1020 int psf_binheader_readf (SF_PRIVATE
*psf
, char const *format
, ...) ;
1022 /* Functions used in the write function for updating the peak chunk. */
1024 void peak_update_short (SF_PRIVATE
*psf
, short *ptr
, size_t items
) ;
1025 void peak_update_int (SF_PRIVATE
*psf
, int *ptr
, size_t items
) ;
1026 void peak_update_double (SF_PRIVATE
*psf
, double *ptr
, size_t items
) ;
1028 /* Functions defined in command.c. */
1030 int psf_get_format_simple_count (void) ;
1031 int psf_get_format_simple (SF_FORMAT_INFO
*data
) ;
1033 int psf_get_format_info (SF_FORMAT_INFO
*data
) ;
1035 int psf_get_format_major_count (void) ;
1036 int psf_get_format_major (SF_FORMAT_INFO
*data
) ;
1038 int psf_get_format_subtype_count (void) ;
1039 int psf_get_format_subtype (SF_FORMAT_INFO
*data
) ;
1041 void psf_generate_format_desc (SF_PRIVATE
*psf
) ;
1043 double psf_calc_signal_max (SF_PRIVATE
*psf
, int normalize
) ;
1044 int psf_calc_max_all_channels (SF_PRIVATE
*psf
, double *peaks
, int normalize
) ;
1046 /* Functions in strings.c. */
1048 const char* psf_get_string (SF_PRIVATE
*psf
, int str_type
) ;
1049 int psf_store_string (SF_PRIVATE
*psf
, int str_type
, const char *str
) ;
1051 /* Default seek function. Use for PCM and float encoded data. */
1052 sf_count_t
psf_default_seek (SF_PRIVATE
*psf
, int mode
, sf_count_t samples_from_start
) ;
1054 /* Generate the currebt date as a string. */
1055 void psf_get_date_str (char *str
, int maxlen
) ;
1057 int macos_guess_file_type (SF_PRIVATE
*psf
, const char *filename
) ;
1059 /*------------------------------------------------------------------------------------
1060 ** File I/O functions which will allow access to large files (> 2 Gig) on
1061 ** some 32 bit OSes. Implementation in file_io.c.
1064 int psf_fopen (SF_PRIVATE
*psf
, const char *pathname
, int flags
) ;
1065 int psf_set_stdio (SF_PRIVATE
*psf
, int mode
) ;
1066 int psf_filedes_valid (SF_PRIVATE
*psf
) ;
1067 void psf_set_file (SF_PRIVATE
*psf
, int fd
) ;
1069 sf_count_t
psf_fseek (SF_PRIVATE
*psf
, sf_count_t offset
, int whence
) ;
1070 sf_count_t
psf_fread (void *ptr
, sf_count_t bytes
, sf_count_t count
, SF_PRIVATE
*psf
) ;
1071 sf_count_t
psf_fwrite (void *ptr
, sf_count_t bytes
, sf_count_t count
, SF_PRIVATE
*psf
) ;
1072 sf_count_t
psf_fgets (char *buffer
, sf_count_t bufsize
, SF_PRIVATE
*psf
) ;
1073 sf_count_t
psf_ftell (SF_PRIVATE
*psf
) ;
1074 sf_count_t
psf_get_filelen (SF_PRIVATE
*psf
) ;
1076 int psf_is_pipe (SF_PRIVATE
*psf
) ;
1078 int psf_ftruncate (SF_PRIVATE
*psf
, sf_count_t len
) ;
1079 int psf_fclose (SF_PRIVATE
*psf
) ;
1082 void psf_fclearerr (SF_PRIVATE *psf) ;
1083 int psf_ferror (SF_PRIVATE *psf) ;
1086 /*------------------------------------------------------------------------------------
1087 ** Functions for reading and writing different file formats.
1090 int aiff_open (SF_PRIVATE
*psf
) ;
1091 int au_open (SF_PRIVATE
*psf
) ;
1092 int au_nh_open (SF_PRIVATE
*psf
) ; /* Headerless version of AU. */
1093 int avr_open (SF_PRIVATE
*psf
) ;
1094 int htk_open (SF_PRIVATE
*psf
) ;
1095 int ircam_open (SF_PRIVATE
*psf
) ;
1096 int mat4_open (SF_PRIVATE
*psf
) ;
1097 int mat5_open (SF_PRIVATE
*psf
) ;
1098 int nist_open (SF_PRIVATE
*psf
) ;
1099 int paf_open (SF_PRIVATE
*psf
) ;
1100 int pvf_open (SF_PRIVATE
*psf
) ;
1101 int raw_open (SF_PRIVATE
*psf
) ;
1102 int sds_open (SF_PRIVATE
*psf
) ;
1103 int svx_open (SF_PRIVATE
*psf
) ;
1104 int voc_open (SF_PRIVATE
*psf
) ;
1105 int w64_open (SF_PRIVATE
*psf
) ;
1106 int wav_open (SF_PRIVATE
*psf
) ;
1107 int xi_open (SF_PRIVATE
*psf
) ;
1109 /* In progress. Do not currently work. */
1111 int ogg_open (SF_PRIVATE
*psf
) ;
1112 int rx2_open (SF_PRIVATE
*psf
) ;
1113 int sd2_open (SF_PRIVATE
*psf
) ;
1114 int txw_open (SF_PRIVATE
*psf
) ;
1115 int wve_open (SF_PRIVATE
*psf
) ;
1116 int dwd_open (SF_PRIVATE
*psf
) ;
1118 int macbinary3_open (SF_PRIVATE
*psf
) ;
1120 /*------------------------------------------------------------------------------------
1121 ** Init functions for a number of common data encodings.
1124 int pcm_init (SF_PRIVATE
*psf
) ;
1125 int ulaw_init (SF_PRIVATE
*psf
) ;
1126 int alaw_init (SF_PRIVATE
*psf
) ;
1127 int float32_init (SF_PRIVATE
*psf
) ;
1128 int double64_init (SF_PRIVATE
*psf
) ;
1129 int dwvw_init (SF_PRIVATE
*psf
, int bitwidth
) ;
1130 int gsm610_init (SF_PRIVATE
*psf
) ;
1131 int vox_adpcm_init (SF_PRIVATE
*psf
) ;
1133 int dither_init (SF_PRIVATE
*psf
, int mode
) ;
1135 int wav_w64_ima_init (SF_PRIVATE
*psf
, int blockalign
, int samplesperblock
) ;
1136 int wav_w64_msadpcm_init (SF_PRIVATE
*psf
, int blockalign
, int samplesperblock
) ;
1138 int aiff_ima_init (SF_PRIVATE
*psf
, int blockalign
, int samplesperblock
) ;
1140 int interleave_init (SF_PRIVATE
*psf
) ;
1142 /*------------------------------------------------------------------------------------
1143 ** Other helper functions.
1146 void *psf_memset (void *s
, int c
, sf_count_t n
) ;
1148 /*------------------------------------------------------------------------------------
1149 ** Here's how we fix systems which don't snprintf / vsnprintf.
1150 ** Systems without these functions should use the
1153 #if (defined (WIN32) || defined (_WIN32))
1154 #define LSF_SNPRINTF _snprintf
1156 #define snprintf _snprintf //XXX really?
1157 #elif (HAVE_SNPRINTF && ! FORCE_MISSING_SNPRINTF)
1158 #define LSF_SNPRINTF snprintf
1160 int missing_snprintf (char *str
, size_t n
, char const *fmt
, ...) ;
1161 #define LSF_SNPRINTF missing_snprintf
1164 #if (defined (WIN32) || defined (_WIN32))
1165 #define LSF_VSNPRINTF _vsnprintf
1166 #elif (HAVE_VSNPRINTF && ! FORCE_MISSING_SNPRINTF)
1167 #define LSF_VSNPRINTF vsnprintf
1169 int missing_vsnprintf (char *str
, size_t n
, const char *fmt
, ...) ;
1170 #define LSF_VSNPRINTF missing_vsnprintf
1173 #endif /* COMMON_H_INCLUDED */
1175 /*------------------------------------------------------------------------------------
1176 ** Extra commands for sf_command(). Not for public use yet.
1180 { SFC_TEST_AIFF_ADD_INST_CHUNK
= 0x2000,
1181 SFC_TEST_WAV_ADD_INFO_CHUNK
= 0x2010
1185 ** Maybe, one day, make these functions or something like them, public.
1187 ** Buffer to buffer dithering. Pointer in and out are allowed to point
1188 ** to the same buffer for in-place dithering.
1192 int sf_dither_short (const SF_DITHER_INFO
*dither
, const short *in
, short *out
, int count
) ;
1193 int sf_dither_int (const SF_DITHER_INFO
*dither
, const int *in
, int *out
, int count
) ;
1194 int sf_dither_float (const SF_DITHER_INFO
*dither
, const float *in
, float *out
, int count
) ;
1195 int sf_dither_double (const SF_DITHER_INFO
*dither
, const double *in
, double *out
, int count
) ;
1198 ** Do not edit or modify anything in this comment block.
1199 ** The arch-tag line is a file identity tag for the GNU Arch
1200 ** revision control system.
1202 ** arch-tag: 7b45c0ee-5835-4a18-a4ef-994e4cd95b67
1205 ** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@mega-nerd.com>
1207 ** This program is free software; you can redistribute it and/or modify
1208 ** it under the terms of the GNU Lesser General Public License as published by
1209 ** the Free Software Foundation; either version 2.1 of the License, or
1210 ** (at your option) any later version.
1212 ** This program is distributed in the hope that it will be useful,
1213 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1214 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1215 ** GNU Lesser General Public License for more details.
1217 ** You should have received a copy of the GNU Lesser General Public License
1218 ** along with this program; if not, write to the Free Software
1219 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1223 ** This file is not the same as the original file from Sun Microsystems. Nearly
1224 ** all the original definitions and function prototypes that were in the file
1225 ** of this name have been moved to private.h.
1228 #ifndef G72X_HEADER_FILE
1229 #define G72X_HEADER_FILE
1232 ** Number of samples per block to process.
1233 ** Must be a common multiple of possible bits per sample : 2, 3, 4, 5 and 8.
1235 #define G72x_BLOCK_SIZE (3*5*8)
1238 ** Identifiers for the differing kinds of G72x ADPCM codecs.
1239 ** The identifiers also define the number of encoded bits per sample.
1243 { G723_16_BITS_PER_SAMPLE
= 2,
1244 G723_24_BITS_PER_SAMPLE
= 3,
1245 G723_40_BITS_PER_SAMPLE
= 5,
1247 G721_32_BITS_PER_SAMPLE
= 4,
1248 G721_40_BITS_PER_SAMPLE
= 5,
1250 G723_16_SAMPLES_PER_BLOCK
= G72x_BLOCK_SIZE
,
1251 G723_24_SAMPLES_PER_BLOCK
= G723_24_BITS_PER_SAMPLE
* (G72x_BLOCK_SIZE
/ G723_24_BITS_PER_SAMPLE
),
1252 G723_40_SAMPLES_PER_BLOCK
= G723_40_BITS_PER_SAMPLE
* (G72x_BLOCK_SIZE
/ G723_40_BITS_PER_SAMPLE
),
1254 G721_32_SAMPLES_PER_BLOCK
= G72x_BLOCK_SIZE
,
1255 G721_40_SAMPLES_PER_BLOCK
= G721_40_BITS_PER_SAMPLE
* (G72x_BLOCK_SIZE
/ G721_40_BITS_PER_SAMPLE
),
1257 G723_16_BYTES_PER_BLOCK
= (G723_16_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1258 G723_24_BYTES_PER_BLOCK
= (G723_24_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1259 G723_40_BYTES_PER_BLOCK
= (G723_40_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1261 G721_32_BYTES_PER_BLOCK
= (G721_32_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1262 G721_40_BYTES_PER_BLOCK
= (G721_40_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8
1266 ** This is the public structure for passing data between the caller and
1267 ** the G72x encoder and decoder.
1268 ** The private array is used by the encoder and decoder for internal
1269 ** state information and should not be changed in any way by the caller.
1270 ** When decoding or encoding a stream, the same instance of this struct
1271 ** should be used for every call so that the decoder/encoder keeps the
1272 ** correct state data between calls.
1276 { /* Private data. Don't mess with it. */
1277 unsigned long sprivateo
[256 / sizeof (long)] ;
1279 /* Public data. Read only. */
1280 int blocksize
, max_bytes
, samplesperblock
, bytesperblock
;
1282 /* Public data. Read and write. */
1283 int blocks
, blockcount
, samplecount
;
1284 unsigned char block
[G72x_BLOCK_SIZE
] ;
1285 short samples
[G72x_BLOCK_SIZE
] ;
1288 /* External function definitions. */
1290 int g72x_reader_init (G72x_DATA
*data
, int codec
) ;
1291 int g72x_writer_init (G72x_DATA
*data
, int codec
) ;
1293 ** Initialize the ADPCM state table for the given codec.
1294 ** Return 0 on success, 1 on fail.
1297 int g72x_decode_block (G72x_DATA
*data
) ;
1299 ** The caller fills data->block with data->bytes bytes before calling the
1300 ** function. The value data->bytes must be an integer multiple of
1301 ** data->blocksize and be <= data->max_bytes.
1302 ** When it returns, the caller can read out data->samples samples.
1305 int g72x_encode_block (G72x_DATA
*data
) ;
1307 ** The caller fills state->samples some integer multiple data->samples_per_block
1308 ** (up to G72x_BLOCK_SIZE) samples before calling the function.
1309 ** When it returns, the caller can read out bytes encoded bytes.
1312 #endif /* !G72X_HEADER_FILE */
1314 ** Do not edit or modify anything in this comment block.
1315 ** The arch-tag line is a file identity tag for the GNU Arch
1316 ** revision control system.
1318 ** arch-tag: 6ca84e5f-f932-4ba1-87ee-37056d921621
1322 * This source code is a product of Sun Microsystems, Inc. and is provided
1323 * for unrestricted use. Users may copy or modify this source code without
1326 * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
1327 * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
1328 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
1330 * Sun source code is provided with no support and without any obligation on
1331 * the part of Sun Microsystems, Inc. to assist in its use, correction,
1332 * modification or enhancement.
1334 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
1335 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
1336 * OR ANY PART THEREOF.
1338 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
1339 * or profits or other special, indirect and consequential damages, even if
1340 * Sun has been advised of the possibility of such damages.
1342 * Sun Microsystems, Inc.
1343 * 2550 Garcia Avenue
1344 * Mountain View, California 94043
1347 #ifndef G72X_PRIVATE_H
1348 #define G72X_PRIVATE_H
1352 ** The following is the definition of the state structure used by the
1353 ** G.721/G.723 encoder and decoder to preserve their internal state
1354 ** between successive calls. The meanings of the majority of the state
1355 ** structure fields are explained in detail in the CCITT Recommendation
1356 ** G.721. The field names are essentially identical to variable names
1357 ** in the bit level description of the coding algorithm included in this
1361 typedef struct private_g72x
1362 { long yl
; /* Locked or steady state step size multiplier. */
1363 short yu
; /* Unlocked or non-steady state step size multiplier. */
1364 short dms
; /* Short term energy estimate. */
1365 short dml
; /* Long term energy estimate. */
1366 short ap
; /* Linear weighting coefficient of 'yl' and 'yu'. */
1368 short a
[2]; /* Coefficients of pole portion of prediction filter. */
1369 short b
[6]; /* Coefficients of zero portion of prediction filter. */
1371 ** Signs of previous two samples of a partially
1372 ** reconstructed signal.
1375 ** Previous 6 samples of the quantized difference
1376 ** signal represented in an internal floating point
1380 ** Previous 2 samples of the quantized difference
1381 ** signal represented in an internal floating point
1384 char td
; /* delayed tone detect, new in 1988 version */
1386 /* The following struct members were added for libsndfile. The original
1387 ** code worked by calling a set of functions on a sample by sample basis
1388 ** which is slow on architectures like Intel x86. For libsndfile, this
1389 ** was changed so that the encoding and decoding routines could work on
1390 ** a block of samples at a time to reduce the function call overhead.
1392 int (*encoder
) (int, struct private_g72x
* state
) ;
1393 int (*decoder
) (int, struct private_g72x
* state
) ;
1396 int byte_index
, sample_index
;
1402 int predictor_zero (G72x_STATE
*state_ptr
);
1404 int predictor_pole (G72x_STATE
*state_ptr
);
1406 int step_size (G72x_STATE
*state_ptr
);
1408 int quantize (int d
, int y
, short *table
, int size
);
1410 int reconstruct (int sign
, int dqln
, int y
);
1412 void update (int code_size
, int y
, int wi
, int fi
, int dq
, int sr
, int dqsez
, G72x_STATE
*state_ptr
);
1414 int g721_encoder (int sample
, G72x_STATE
*state_ptr
);
1415 int g721_decoder (int code
, G72x_STATE
*state_ptr
);
1417 int g723_16_encoder (int sample
, G72x_STATE
*state_ptr
);
1418 int g723_16_decoder (int code
, G72x_STATE
*state_ptr
);
1420 int g723_24_encoder (int sample
, G72x_STATE
*state_ptr
);
1421 int g723_24_decoder (int code
, G72x_STATE
*state_ptr
);
1423 int g723_40_encoder (int sample
, G72x_STATE
*state_ptr
);
1424 int g723_40_decoder (int code
, G72x_STATE
*state_ptr
);
1426 int unpack_bytes (G72x_DATA
*data
, int bits
) ;
1427 int pack_bytes (G72x_DATA
*data
, int bits
) ;
1429 void private_init_state (G72x_STATE
*state_ptr
) ;
1431 #endif /* G72X_PRIVATE_H */
1433 ** Do not edit or modify anything in this comment block.
1434 ** The arch-tag line is a file identity tag for the GNU Arch
1435 ** revision control system.
1437 ** arch-tag: d9ad4da7-0fa3-471d-8020-720b5cfb5e5b
1441 ** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
1443 ** This program is free software; you can redistribute it and/or modify
1444 ** it under the terms of the GNU Lesser General Public License as published by
1445 ** the Free Software Foundation; either version 2.1 of the License, or
1446 ** (at your option) any later version.
1448 ** This program is distributed in the hope that it will be useful,
1449 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1450 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1451 ** GNU Lesser General Public License for more details.
1453 ** You should have received a copy of the GNU Lesser General Public License
1454 ** along with this program; if not, write to the Free Software
1455 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1460 ** Many file types (ie WAV, AIFF) use sets of four consecutive bytes as a
1461 ** marker indicating different sections of the file.
1462 ** The following MAKE_MARKER macro allows th creation of integer constants
1463 ** for these markers.
1466 #if (CPU_IS_LITTLE_ENDIAN == 1)
1467 #define MAKE_MARKER(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24))
1468 #elif (CPU_IS_BIG_ENDIAN == 1)
1469 #define MAKE_MARKER(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
1471 #error "Target CPU endian-ness unknown. May need to hand edit src/config.h"
1474 /* wo standard endswap macros. */
1476 #define ENDSWAP_SHORT(x) ((((x)>>8)&0xFF)+(((x)&0xFF)<<8))
1477 #define ENDSWAP_INT(x) ((((x)>>24)&0xFF)+(((x)>>8)&0xFF00)+(((x)&0xFF00)<<8)+(((x)&0xFF)<<24))
1479 ** Macros to handle reading of data of a specific endian-ness into host endian
1480 ** shorts and ints. The single input is an unsigned char* pointer to the start
1481 ** of the object. There are two versions of each macro as we need to deal with
1482 ** both big and little endian CPUs.
1485 #if (CPU_IS_LITTLE_ENDIAN == 1)
1486 #define LES2H_SHORT(x) (x)
1487 #define LEI2H_INT(x) (x)
1489 #define BES2H_SHORT(x) ENDSWAP_SHORT(x)
1490 #define BEI2H_INT(x) ENDSWAP_INT(x)
1492 #elif (CPU_IS_BIG_ENDIAN == 1)
1493 #define LES2H_SHORT(x) ENDSWAP_SHORT(x)
1494 #define LEI2H_INT(x) ENDSWAP_INT(x)
1496 #define BES2H_SHORT(x) (x)
1497 #define BEI2H_INT(x) (x)
1500 #error "Target CPU endian-ness unknown. May need to hand edit src/config.h"
1503 #define LES2H_SHORT_PTR(x) ((x) [0] + ((x) [1] << 8))
1504 #define LES2H_INT_PTR(x) (((x) [0] << 16) + ((x) [1] << 24))
1506 #define LET2H_SHORT_PTR(x) ((x) [1] + ((x) [2] << 8))
1507 #define LET2H_INT_PTR(x) (((x) [0] << 8) + ((x) [1] << 16) + ((x) [2] << 24))
1509 #define LEI2H_SHORT_PTR(x) ((x) [2] + ((x) [3] << 8))
1510 #define LEI2H_INT_PTR(x) ((x) [0] + ((x) [1] << 8) + ((x) [2] << 16) + ((x) [3] << 24))
1512 #define BES2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1])
1513 #define BES2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16))
1515 #define BET2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1])
1516 #define BET2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8))
1518 #define BEI2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1])
1519 #define BEI2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8) + (x) [3])
1521 /* Endian swapping routines implemented in sfendian.c. */
1523 void endswap_short_array (short *ptr
, int len
) ;
1524 void endswap_int_array (int *ptr
, int len
) ;
1526 /* Always swaps 8 byte values whether sizeof (long) == 8 or not. */
1527 void endswap_long_array (long *ptr
, int len
) ;
1529 void endswap_short_copy (short *dest
, short *src
, int len
) ;
1530 void endswap_int_copy (int *dest
, int *src
, int len
) ;
1532 /* Always swaps 8 byte values whether sizeof (long) == 8 or not. */
1533 void endswap_long_copy (long *dest
, long *src
, int len
) ;
1536 ** Do not edit or modify anything in this comment block.
1537 ** The arch-tag line is a file identity tag for the GNU Arch
1538 ** revision control system.
1540 ** arch-tag: f0c5cd54-42d3-4237-90ec-11fe24995de7
1543 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
1544 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
1545 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
1556 typedef struct gsm_state
* gsm
;
1557 typedef short gsm_signal
; /* signed 16 bit */
1558 typedef unsigned char gsm_byte
;
1559 typedef gsm_byte gsm_frame
[33]; /* 33 * 8 bits */
1561 #define GSM_MAGIC 0xD /* 13 kbit/s RPE-LTP */
1563 #define GSM_PATCHLEVEL 10
1567 #define GSM_OPT_VERBOSE 1
1568 #define GSM_OPT_FAST 2
1569 #define GSM_OPT_LTP_CUT 3
1570 #define GSM_OPT_WAV49 4
1571 #define GSM_OPT_FRAME_INDEX 5
1572 #define GSM_OPT_FRAME_CHAIN 6
1574 gsm
gsm_create (void);
1576 /* Added for libsndfile : May 6, 2002 */
1577 void gsm_init (gsm
);
1579 void gsm_destroy (gsm
);
1581 int gsm_print (FILE *, gsm
, gsm_byte
*);
1582 int gsm_option (gsm
, int, int *);
1584 void gsm_encode (gsm
, gsm_signal
*, gsm_byte
*);
1585 int gsm_decode (gsm
, gsm_byte
*, gsm_signal
*);
1587 int gsm_explode (gsm
, gsm_byte
*, gsm_signal
*);
1588 void gsm_implode (gsm
, gsm_signal
*, gsm_byte
*);
1592 ** Do not edit or modify anything in this comment block.
1593 ** The arch-tag line is a file identity tag for the GNU Arch
1594 ** revision control system.
1596 ** arch-tag: 8cfc7698-5433-4b6f-aeca-967c6fda4dec
1600 ** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
1602 ** This program is free software; you can redistribute it and/or modify
1603 ** it under the terms of the GNU Lesser General Public License as published by
1604 ** the Free Software Foundation; either version 2.1 of the License, or
1605 ** (at your option) any later version.
1607 ** This program is distributed in the hope that it will be useful,
1608 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1609 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1610 ** GNU Lesser General Public License for more details.
1612 ** You should have received a copy of the GNU Lesser General Public License
1613 ** along with this program; if not, write to the Free Software
1614 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1617 #ifndef AU_HEADER_FILE
1618 #define AU_HEADER_FILE
1622 { AU_H_G721_32
= 200,
1627 int au_g72x_reader_init (SF_PRIVATE
*psf
, int codec
) ;
1628 int au_g72x_writer_init (SF_PRIVATE
*psf
, int codec
) ;
1630 #endif /* AU_HEADER_FILE */
1632 ** Do not edit or modify anything in this comment block.
1633 ** The arch-tag line is a file identity tag for the GNU Arch
1634 ** revision control system.
1636 ** arch-tag: 63affc81-e204-4468-9705-60abe4d10689
1639 ** Copyright (C) 1999-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
1641 ** This program is free software; you can redistribute it and/or modify
1642 ** it under the terms of the GNU Lesser General Public License as published by
1643 ** the Free Software Foundation; either version 2.1 of the License, or
1644 ** (at your option) any later version.
1646 ** This program is distributed in the hope that it will be useful,
1647 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1648 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1649 ** GNU Lesser General Public License for more details.
1651 ** You should have received a copy of the GNU Lesser General Public License
1652 ** along with this program; if not, write to the Free Software
1653 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1656 /* This file contains definitions commong to WAV and W64 files. */
1659 #ifndef WAV_W64_H_INCLUDED
1660 #define WAV_W64_H_INCLUDED
1662 /*------------------------------------------------------------------------------
1663 ** List of known WAV format tags
1668 /* keep sorted for wav_w64_format_str() */
1669 WAVE_FORMAT_UNKNOWN
= 0x0000, /* Microsoft Corporation */
1670 WAVE_FORMAT_PCM
= 0x0001, /* Microsoft PCM format */
1671 WAVE_FORMAT_MS_ADPCM
= 0x0002, /* Microsoft ADPCM */
1672 WAVE_FORMAT_IEEE_FLOAT
= 0x0003, /* Micrososft 32 bit float format */
1673 WAVE_FORMAT_VSELP
= 0x0004, /* Compaq Computer Corporation */
1674 WAVE_FORMAT_IBM_CVSD
= 0x0005, /* IBM Corporation */
1675 WAVE_FORMAT_ALAW
= 0x0006, /* Microsoft Corporation */
1676 WAVE_FORMAT_MULAW
= 0x0007, /* Microsoft Corporation */
1677 WAVE_FORMAT_OKI_ADPCM
= 0x0010, /* OKI */
1678 WAVE_FORMAT_IMA_ADPCM
= 0x0011, /* Intel Corporation */
1679 WAVE_FORMAT_MEDIASPACE_ADPCM
= 0x0012, /* Videologic */
1680 WAVE_FORMAT_SIERRA_ADPCM
= 0x0013, /* Sierra Semiconductor Corp */
1681 WAVE_FORMAT_G723_ADPCM
= 0x0014, /* Antex Electronics Corporation */
1682 WAVE_FORMAT_DIGISTD
= 0x0015, /* DSP Solutions, Inc. */
1683 WAVE_FORMAT_DIGIFIX
= 0x0016, /* DSP Solutions, Inc. */
1684 WAVE_FORMAT_DIALOGIC_OKI_ADPCM
= 0x0017, /* Dialogic Corporation */
1685 WAVE_FORMAT_MEDIAVISION_ADPCM
= 0x0018, /* Media Vision, Inc. */
1686 WAVE_FORMAT_CU_CODEC
= 0x0019, /* Hewlett-Packard Company */
1687 WAVE_FORMAT_YAMAHA_ADPCM
= 0x0020, /* Yamaha Corporation of America */
1688 WAVE_FORMAT_SONARC
= 0x0021, /* Speech Compression */
1689 WAVE_FORMAT_DSPGROUP_TRUESPEECH
= 0x0022, /* DSP Group, Inc */
1690 WAVE_FORMAT_ECHOSC1
= 0x0023, /* Echo Speech Corporation */
1691 WAVE_FORMAT_AUDIOFILE_AF36
= 0x0024, /* Audiofile, Inc. */
1692 WAVE_FORMAT_APTX
= 0x0025, /* Audio Processing Technology */
1693 WAVE_FORMAT_AUDIOFILE_AF10
= 0x0026, /* Audiofile, Inc. */
1694 WAVE_FORMAT_PROSODY_1612
= 0x0027, /* Aculab plc */
1695 WAVE_FORMAT_LRC
= 0x0028, /* Merging Technologies S.A. */
1696 WAVE_FORMAT_DOLBY_AC2
= 0x0030, /* Dolby Laboratories */
1697 WAVE_FORMAT_GSM610
= 0x0031, /* Microsoft Corporation */
1698 WAVE_FORMAT_MSNAUDIO
= 0x0032, /* Microsoft Corporation */
1699 WAVE_FORMAT_ANTEX_ADPCME
= 0x0033, /* Antex Electronics Corporation */
1700 WAVE_FORMAT_CONTROL_RES_VQLPC
= 0x0034, /* Control Resources Limited */
1701 WAVE_FORMAT_DIGIREAL
= 0x0035, /* DSP Solutions, Inc. */
1702 WAVE_FORMAT_DIGIADPCM
= 0x0036, /* DSP Solutions, Inc. */
1703 WAVE_FORMAT_CONTROL_RES_CR10
= 0x0037, /* Control Resources Limited */
1704 WAVE_FORMAT_NMS_VBXADPCM
= 0x0038, /* Natural MicroSystems */
1705 WAVE_FORMAT_ROLAND_RDAC
= 0x0039, /* Roland */
1706 WAVE_FORMAT_ECHOSC3
= 0x003A, /* Echo Speech Corporation */
1707 WAVE_FORMAT_ROCKWELL_ADPCM
= 0x003B, /* Rockwell International */
1708 WAVE_FORMAT_ROCKWELL_DIGITALK
= 0x003C, /* Rockwell International */
1709 WAVE_FORMAT_XEBEC
= 0x003D, /* Xebec Multimedia Solutions Limited */
1710 WAVE_FORMAT_G721_ADPCM
= 0x0040, /* Antex Electronics Corporation */
1711 WAVE_FORMAT_G728_CELP
= 0x0041, /* Antex Electronics Corporation */
1712 WAVE_FORMAT_MSG723
= 0x0042, /* Microsoft Corporation */
1713 WAVE_FORMAT_MPEG
= 0x0050, /* Microsoft Corporation */
1714 WAVE_FORMAT_RT24
= 0x0052, /* InSoft Inc. */
1715 WAVE_FORMAT_PAC
= 0x0053, /* InSoft Inc. */
1716 WAVE_FORMAT_MPEGLAYER3
= 0x0055, /* MPEG 3 Layer 1 */
1717 WAVE_FORMAT_LUCENT_G723
= 0x0059, /* Lucent Technologies */
1718 WAVE_FORMAT_CIRRUS
= 0x0060, /* Cirrus Logic */
1719 WAVE_FORMAT_ESPCM
= 0x0061, /* ESS Technology */
1720 WAVE_FORMAT_VOXWARE
= 0x0062, /* Voxware Inc */
1721 WAVE_FORMAT_CANOPUS_ATRAC
= 0x0063, /* Canopus, Co., Ltd. */
1722 WAVE_FORMAT_G726_ADPCM
= 0x0064, /* APICOM */
1723 WAVE_FORMAT_G722_ADPCM
= 0x0065, /* APICOM */
1724 WAVE_FORMAT_DSAT
= 0x0066, /* Microsoft Corporation */
1725 WAVE_FORMAT_DSAT_DISPLAY
= 0x0067, /* Microsoft Corporation */
1726 WAVE_FORMAT_VOXWARE_BYTE_ALIGNED
= 0x0069, /* Voxware Inc. */
1727 WAVE_FORMAT_VOXWARE_AC8
= 0x0070, /* Voxware Inc. */
1728 WAVE_FORMAT_VOXWARE_AC10
= 0x0071, /* Voxware Inc. */
1729 WAVE_FORMAT_VOXWARE_AC16
= 0x0072, /* Voxware Inc. */
1730 WAVE_FORMAT_VOXWARE_AC20
= 0x0073, /* Voxware Inc. */
1731 WAVE_FORMAT_VOXWARE_RT24
= 0x0074, /* Voxware Inc. */
1732 WAVE_FORMAT_VOXWARE_RT29
= 0x0075, /* Voxware Inc. */
1733 WAVE_FORMAT_VOXWARE_RT29HW
= 0x0076, /* Voxware Inc. */
1734 WAVE_FORMAT_VOXWARE_VR12
= 0x0077, /* Voxware Inc. */
1735 WAVE_FORMAT_VOXWARE_VR18
= 0x0078, /* Voxware Inc. */
1736 WAVE_FORMAT_VOXWARE_TQ40
= 0x0079, /* Voxware Inc. */
1737 WAVE_FORMAT_SOFTSOUND
= 0x0080, /* Softsound, Ltd. */
1738 WAVE_FORMAT_VOXARE_TQ60
= 0x0081, /* Voxware Inc. */
1739 WAVE_FORMAT_MSRT24
= 0x0082, /* Microsoft Corporation */
1740 WAVE_FORMAT_G729A
= 0x0083, /* AT&T Laboratories */
1741 WAVE_FORMAT_MVI_MV12
= 0x0084, /* Motion Pixels */
1742 WAVE_FORMAT_DF_G726
= 0x0085, /* DataFusion Systems (Pty) (Ltd) */
1743 WAVE_FORMAT_DF_GSM610
= 0x0086, /* DataFusion Systems (Pty) (Ltd) */
1744 /* removed because duplicate */
1745 /* WAVE_FORMAT_ISIAUDIO = 0x0088, */ /* Iterated Systems, Inc. */
1746 WAVE_FORMAT_ONLIVE
= 0x0089, /* OnLive! Technologies, Inc. */
1747 WAVE_FORMAT_SBC24
= 0x0091, /* Siemens Business Communications Systems */
1748 WAVE_FORMAT_DOLBY_AC3_SPDIF
= 0x0092, /* Sonic Foundry */
1749 WAVE_FORMAT_ZYXEL_ADPCM
= 0x0097, /* ZyXEL Communications, Inc. */
1750 WAVE_FORMAT_PHILIPS_LPCBB
= 0x0098, /* Philips Speech Processing */
1751 WAVE_FORMAT_PACKED
= 0x0099, /* Studer Professional Audio AG */
1752 WAVE_FORMAT_RHETOREX_ADPCM
= 0x0100, /* Rhetorex, Inc. */
1754 /* removed because of the following */
1755 /* WAVE_FORMAT_IRAT = 0x0101,*/ /* BeCubed Software Inc. */
1757 /* these three are unofficial */
1758 IBM_FORMAT_MULAW
= 0x0101, /* IBM mu-law format */
1759 IBM_FORMAT_ALAW
= 0x0102, /* IBM a-law format */
1760 IBM_FORMAT_ADPCM
= 0x0103, /* IBM AVC Adaptive Differential PCM format */
1762 WAVE_FORMAT_VIVO_G723
= 0x0111, /* Vivo Software */
1763 WAVE_FORMAT_VIVO_SIREN
= 0x0112, /* Vivo Software */
1764 WAVE_FORMAT_DIGITAL_G723
= 0x0123, /* Digital Equipment Corporation */
1765 WAVE_FORMAT_CREATIVE_ADPCM
= 0x0200, /* Creative Labs, Inc */
1766 WAVE_FORMAT_CREATIVE_FASTSPEECH8
= 0x0202, /* Creative Labs, Inc */
1767 WAVE_FORMAT_CREATIVE_FASTSPEECH10
= 0x0203, /* Creative Labs, Inc */
1768 WAVE_FORMAT_QUARTERDECK
= 0x0220, /* Quarterdeck Corporation */
1769 WAVE_FORMAT_FM_TOWNS_SND
= 0x0300, /* Fujitsu Corporation */
1770 WAVE_FORMAT_BZV_DIGITAL
= 0x0400, /* Brooktree Corporation */
1771 WAVE_FORMAT_VME_VMPCM
= 0x0680, /* AT&T Labs, Inc. */
1772 WAVE_FORMAT_OLIGSM
= 0x1000, /* Ing C. Olivetti & C., S.p.A. */
1773 WAVE_FORMAT_OLIADPCM
= 0x1001, /* Ing C. Olivetti & C., S.p.A. */
1774 WAVE_FORMAT_OLICELP
= 0x1002, /* Ing C. Olivetti & C., S.p.A. */
1775 WAVE_FORMAT_OLISBC
= 0x1003, /* Ing C. Olivetti & C., S.p.A. */
1776 WAVE_FORMAT_OLIOPR
= 0x1004, /* Ing C. Olivetti & C., S.p.A. */
1777 WAVE_FORMAT_LH_CODEC
= 0x1100, /* Lernout & Hauspie */
1778 WAVE_FORMAT_NORRIS
= 0x1400, /* Norris Communications, Inc. */
1779 /* removed because duplicate */
1780 /* WAVE_FORMAT_ISIAUDIO = 0x1401, */ /* AT&T Labs, Inc. */
1781 WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS
= 0x1500, /* AT&T Labs, Inc. */
1782 WAVE_FORMAT_DVM
= 0x2000, /* FAST Multimedia AG */
1783 WAVE_FORMAT_INTERWAV_VSC112
= 0x7150, /* ????? */
1784 WAVE_FORMAT_EXTENSIBLE
= 0xFFFE
1788 { unsigned short format
;
1789 unsigned short channels
;
1790 unsigned int samplerate
;
1791 unsigned int bytespersec
;
1792 unsigned short blockalign
;
1793 unsigned short bitwidth
;
1797 { unsigned short format
;
1798 unsigned short channels
;
1799 unsigned int samplerate
;
1800 unsigned int bytespersec
;
1801 unsigned short blockalign
;
1802 unsigned short bitwidth
;
1803 unsigned short extrabytes
;
1804 unsigned short dummy
;
1808 { unsigned short format
;
1809 unsigned short channels
;
1810 unsigned int samplerate
;
1811 unsigned int bytespersec
;
1812 unsigned short blockalign
;
1813 unsigned short bitwidth
;
1814 unsigned short extrabytes
;
1815 unsigned short samplesperblock
;
1816 unsigned short numcoeffs
;
1821 } MS_ADPCM_WAV_FMT
;
1824 { unsigned short format
;
1825 unsigned short channels
;
1826 unsigned int samplerate
;
1827 unsigned int bytespersec
;
1828 unsigned short blockalign
;
1829 unsigned short bitwidth
;
1830 unsigned short extrabytes
;
1831 unsigned short samplesperblock
;
1832 } IMA_ADPCM_WAV_FMT
;
1835 { unsigned short format
;
1836 unsigned short channels
;
1837 unsigned int samplerate
;
1838 unsigned int bytespersec
;
1839 unsigned short blockalign
;
1840 unsigned short bitwidth
;
1841 unsigned short extrabytes
;
1842 unsigned short auxblocksize
;
1843 } G72x_ADPCM_WAV_FMT
;
1847 { unsigned short format
;
1848 unsigned short channels
;
1849 unsigned int samplerate
;
1850 unsigned int bytespersec
;
1851 unsigned short blockalign
;
1852 unsigned short bitwidth
;
1853 unsigned short extrabytes
;
1854 unsigned short samplesperblock
;
1858 { unsigned int esf_field1
;
1859 unsigned short esf_field2
;
1860 unsigned short esf_field3
;
1861 char esf_field4
[8] ;
1865 { unsigned short format
;
1866 unsigned short channels
;
1867 unsigned int samplerate
;
1868 unsigned int bytespersec
;
1869 unsigned short blockalign
;
1870 unsigned short bitwidth
;
1871 unsigned short extrabytes
;
1872 unsigned short validbits
;
1873 unsigned int channelmask
;
1875 } EXTENSIBLE_WAV_FMT
;
1878 { unsigned short format
;
1880 IMA_ADPCM_WAV_FMT ima
;
1881 MS_ADPCM_WAV_FMT msadpcm
;
1882 G72x_ADPCM_WAV_FMT g72x
;
1883 EXTENSIBLE_WAV_FMT ext
;
1884 GSM610_WAV_FMT gsm610
;
1885 WAV_FMT_SIZE20 size20
;
1886 char padding
[512] ;
1893 #define WAV_W64_GSM610_BLOCKSIZE 65
1894 #define WAV_W64_GSM610_SAMPLES 320
1896 /*------------------------------------------------------------------------------------
1897 ** Functions defined in wav_ms_adpcm.c
1900 #define MSADPCM_ADAPT_COEFF_COUNT 7
1902 void msadpcm_write_adapt_coeffs (SF_PRIVATE
*psf
) ;
1904 /*------------------------------------------------------------------------------------
1905 ** Functions defined in wav_gsm610.c
1908 int wav_w64_srate2blocksize (int srate_chan_product
) ;
1909 char const* wav_w64_format_str (int k
) ;
1910 int wav_w64_read_fmt_chunk (SF_PRIVATE
*psf
, WAV_FMT
*wav_fmt
, int structsize
) ;
1914 ** Do not edit or modify anything in this comment block.
1915 ** The arch-tag line is a file identity tag for the GNU Arch
1916 ** revision control system.
1918 ** arch-tag: 877fde12-9be3-4a31-8a5a-fdae39958613
1921 ** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@mega-nerd.com>
1923 ** This program is free software; you can redistribute it and/or modify
1924 ** it under the terms of the GNU Lesser General Public License as published by
1925 ** the Free Software Foundation; either version 2.1 of the License, or
1926 ** (at your option) any later version.
1928 ** This program is distributed in the hope that it will be useful,
1929 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1930 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1931 ** GNU Lesser General Public License for more details.
1933 ** You should have received a copy of the GNU Lesser General Public License
1934 ** along with this program; if not, write to the Free Software
1935 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1939 ** This file is not the same as the original file from Sun Microsystems. Nearly
1940 ** all the original definitions and function prototypes that were in the file
1941 ** of this name have been moved to private.h.
1944 #ifndef G72X_HEADER_FILE
1945 #define G72X_HEADER_FILE
1948 ** Number of samples per block to process.
1949 ** Must be a common multiple of possible bits per sample : 2, 3, 4, 5 and 8.
1951 #define G72x_BLOCK_SIZE (3*5*8)
1954 ** Identifiers for the differing kinds of G72x ADPCM codecs.
1955 ** The identifiers also define the number of encoded bits per sample.
1959 { G723_16_BITS_PER_SAMPLE
= 2,
1960 G723_24_BITS_PER_SAMPLE
= 3,
1961 G723_40_BITS_PER_SAMPLE
= 5,
1963 G721_32_BITS_PER_SAMPLE
= 4,
1964 G721_40_BITS_PER_SAMPLE
= 5,
1966 G723_16_SAMPLES_PER_BLOCK
= G72x_BLOCK_SIZE
,
1967 G723_24_SAMPLES_PER_BLOCK
= G723_24_BITS_PER_SAMPLE
* (G72x_BLOCK_SIZE
/ G723_24_BITS_PER_SAMPLE
),
1968 G723_40_SAMPLES_PER_BLOCK
= G723_40_BITS_PER_SAMPLE
* (G72x_BLOCK_SIZE
/ G723_40_BITS_PER_SAMPLE
),
1970 G721_32_SAMPLES_PER_BLOCK
= G72x_BLOCK_SIZE
,
1971 G721_40_SAMPLES_PER_BLOCK
= G721_40_BITS_PER_SAMPLE
* (G72x_BLOCK_SIZE
/ G721_40_BITS_PER_SAMPLE
),
1973 G723_16_BYTES_PER_BLOCK
= (G723_16_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1974 G723_24_BYTES_PER_BLOCK
= (G723_24_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1975 G723_40_BYTES_PER_BLOCK
= (G723_40_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1977 G721_32_BYTES_PER_BLOCK
= (G721_32_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8,
1978 G721_40_BYTES_PER_BLOCK
= (G721_40_BITS_PER_SAMPLE
* G72x_BLOCK_SIZE
) / 8
1982 ** This is the public structure for passing data between the caller and
1983 ** the G72x encoder and decoder.
1984 ** The private array is used by the encoder and decoder for internal
1985 ** state information and should not be changed in any way by the caller.
1986 ** When decoding or encoding a stream, the same instance of this struct
1987 ** should be used for every call so that the decoder/encoder keeps the
1988 ** correct state data between calls.
1992 { /* Private data. Don't mess with it. */
1993 unsigned long sprivateo
[256 / sizeof (long)] ;
1995 /* Public data. Read only. */
1996 int blocksize
, max_bytes
, samplesperblock
, bytesperblock
;
1998 /* Public data. Read and write. */
1999 int blocks
, blockcount
, samplecount
;
2000 unsigned char block
[G72x_BLOCK_SIZE
] ;
2001 short samples
[G72x_BLOCK_SIZE
] ;
2004 /* External function definitions. */
2006 int g72x_reader_init (G72x_DATA
*data
, int codec
) ;
2007 int g72x_writer_init (G72x_DATA
*data
, int codec
) ;
2009 ** Initialize the ADPCM state table for the given codec.
2010 ** Return 0 on success, 1 on fail.
2013 int g72x_decode_block (G72x_DATA
*data
) ;
2015 ** The caller fills data->block with data->bytes bytes before calling the
2016 ** function. The value data->bytes must be an integer multiple of
2017 ** data->blocksize and be <= data->max_bytes.
2018 ** When it returns, the caller can read out data->samples samples.
2021 int g72x_encode_block (G72x_DATA
*data
) ;
2023 ** The caller fills state->samples some integer multiple data->samples_per_block
2024 ** (up to G72x_BLOCK_SIZE) samples before calling the function.
2025 ** When it returns, the caller can read out bytes encoded bytes.
2028 #endif /* !G72X_HEADER_FILE */
2030 ** Do not edit or modify anything in this comment block.
2031 ** The arch-tag line is a file identity tag for the GNU Arch
2032 ** revision control system.
2034 ** arch-tag: 6ca84e5f-f932-4ba1-87ee-37056d921621
2038 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
2039 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
2040 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
2046 /* Added by Erik de Castro Lopo */
2047 #define USE_FLOAT_MUL
2050 /* Added by Erik de Castro Lopo */
2054 typedef short word
; /* 16 bit signed int */
2055 typedef int longword
; /* 32 bit signed int */
2057 typedef unsigned short uword
; /* unsigned word */
2058 typedef unsigned int ulongword
; /* unsigned longword */
2063 word z1
; /* preprocessing.c, Offset_com. */
2064 longword L_z2
; /* Offset_com. */
2065 int mp
; /* Preemphasis */
2067 word u
[8] ; /* short_term_aly_filter.c */
2068 word LARpp
[2][8] ; /* */
2071 word ltp_cut
; /* long_term.c, LTP crosscorr. */
2072 word nrp
; /* 40 */ /* long_term.c, synthesis */
2073 word v
[9] ; /* short_term.c, synthesis */
2074 word msr
; /* decoder.c, Postprocessing */
2076 char verbose
; /* only used if !NDEBUG */
2077 char fast
; /* only used if FAST */
2079 char wav_fmt
; /* only used if WAV49 defined */
2080 unsigned char frame_index
; /* odd/even chaining */
2081 unsigned char frame_chain
; /* half-byte to carry forward */
2083 /* Moved here from code.c where it was defined as static */
2087 typedef struct gsm_state GSM_STATE
;
2089 #define MIN_WORD (-32767 - 1)
2090 #define MAX_WORD 32767
2092 #define MIN_LONGWORD (-2147483647 - 1)
2093 #define MAX_LONGWORD 2147483647
2095 /* Signed arithmetic shift right. */
2096 static C_INLINE word
2097 SASR_W (word x
, word by
)
2098 { return (x
>> by
) ;
2101 static C_INLINE longword
2102 SASR_L (longword x
, word by
)
2103 { return (x
>> by
) ;
2107 * Prototypes from add.c
2109 word
gsm_mult (word a
, word b
) ;
2110 longword
gsm_L_mult (word a
, word b
) ;
2111 word
gsm_mult_r (word a
, word b
) ;
2113 word
gsm_div (word num
, word denum
) ;
2115 word
gsm_add (word a
, word b
) ;
2116 longword
gsm_L_add (longword a
, longword b
) ;
2118 word
gsm_sub (word a
, word b
) ;
2119 longword
gsm_L_sub (longword a
, longword b
) ;
2121 word
gsm_abs (word a
) ;
2123 word
gsm_norm (longword a
) ;
2125 longword
gsm_L_asl (longword a
, int n
) ;
2126 word
gsm_asl (word a
, int n
) ;
2128 longword
gsm_L_asr (longword a
, int n
) ;
2129 word
gsm_asr (word a
, int n
) ;
2132 * Inlined functions from add.h
2135 static C_INLINE longword
2136 GSM_MULT_R (word a
, word b
)
2137 { return (((longword
) (a
)) * ((longword
) (b
)) + 16384) >> 15 ;
2140 static C_INLINE longword
2141 GSM_MULT (word a
, word b
)
2142 { return (((longword
) (a
)) * ((longword
) (b
))) >> 15 ;
2145 static C_INLINE longword
2146 GSM_L_MULT (word a
, word b
)
2147 { return ((longword
) (a
)) * ((longword
) (b
)) << 1 ;
2150 static C_INLINE longword
2151 GSM_L_ADD (longword a
, longword b
)
2155 { utmp
= (ulongword
)-((a
) + 1) + (ulongword
)-((b
) + 1) ;
2156 return (utmp
>= (ulongword
) MAX_LONGWORD
) ? MIN_LONGWORD
: -(longword
)utmp
-2 ;
2160 { utmp
= (ulongword
) a
+ (ulongword
) b
;
2161 return (utmp
>= (ulongword
) MAX_LONGWORD
) ? MAX_LONGWORD
: utmp
;
2167 static C_INLINE longword
2168 GSM_ADD (word a
, word b
)
2171 ltmp
= ((longword
) a
) + ((longword
) b
) ;
2173 if (ltmp
>= MAX_WORD
)
2175 if (ltmp
<= MIN_WORD
)
2181 static C_INLINE longword
2182 GSM_SUB (word a
, word b
)
2185 ltmp
= ((longword
) a
) - ((longword
) b
) ;
2187 if (ltmp
>= MAX_WORD
)
2189 else if (ltmp
<= MIN_WORD
)
2195 static C_INLINE word
2207 * More prototypes from implementations..
2210 struct gsm_state
* S
,
2211 word
* s
, /* [0..159] samples IN */
2212 word
* LARc
, /* [0..7] LAR coefficients OUT */
2213 word
* Nc
, /* [0..3] LTP lag OUT */
2214 word
* bc
, /* [0..3] coded LTP gain OUT */
2215 word
* Mc
, /* [0..3] RPE grid selection OUT */
2216 word
* xmaxc
,/* [0..3] Coded maximum amplitude OUT */
2217 word
* xMc
) ;/* [13*4] normalized RPE samples OUT */
2219 void Gsm_Long_Term_Predictor ( /* 4x for 160 samples */
2220 struct gsm_state
* S
,
2221 word
* d
, /* [0..39] residual signal IN */
2222 word
* dp
, /* [-120..-1] d' IN */
2223 word
* e
, /* [0..40] OUT */
2224 word
* dpp
, /* [0..40] OUT */
2225 word
* Nc
, /* correlation lag OUT */
2226 word
* bc
) ; /* gain factor OUT */
2228 void Gsm_LPC_Analysis (
2229 struct gsm_state
* S
,
2230 word
* s
, /* 0..159 signals IN/OUT */
2231 word
* LARc
) ; /* 0..7 LARc's OUT */
2233 void Gsm_Preprocess (
2234 struct gsm_state
* S
,
2235 word
* s
, word
* so
) ;
2238 struct gsm_state
* S
,
2245 void Gsm_Short_Term_Analysis_Filter (
2246 struct gsm_state
* S
,
2247 word
* LARc
, /* coded log area ratio [0..7] IN */
2248 word
* d
) ; /* st res. signal [0..159] IN/OUT */
2251 struct gsm_state
* S
,
2252 word
* LARcr
, /* [0..7] IN */
2253 word
* Ncr
, /* [0..3] IN */
2254 word
* bcr
, /* [0..3] IN */
2255 word
* Mcr
, /* [0..3] IN */
2256 word
* xmaxcr
, /* [0..3] IN */
2257 word
* xMcr
, /* [0..13*4] IN */
2258 word
* s
) ; /* [0..159] OUT */
2261 struct gsm_state
* S
,
2264 word
* xMcr
, /* [0..12] IN */
2265 word
* erp
) ; /* [0..39] OUT */
2267 void Gsm_Long_Term_Synthesis_Filtering (
2268 struct gsm_state
* S
,
2271 word
* erp
, /* [0..39] IN */
2272 word
* drp
) ; /* [-120..-1] IN, [0..40] OUT */
2274 void Gsm_RPE_Decoding (
2275 /*-struct gsm_state *S,-*/
2278 word
* xMcr
, /* [0..12], 3 bits IN */
2279 word
* erp
) ; /* [0..39] OUT */
2281 void Gsm_RPE_Encoding (
2282 /*-struct gsm_state * S,-*/
2283 word
* e
, /* -5..-1][0..39][40..44 IN/OUT */
2284 word
* xmaxc
, /* OUT */
2285 word
* Mc
, /* OUT */
2286 word
* xMc
) ; /* [0..12] OUT */
2288 void Gsm_Short_Term_Synthesis_Filter (
2289 struct gsm_state
* S
,
2290 word
* LARcr
, /* log area ratios [0..7] IN */
2291 word
* drp
, /* received d [0...39] IN */
2292 word
* s
) ; /* signal s [0..159] OUT */
2294 void Gsm_Update_of_reconstructed_short_time_residual_signal (
2295 word
* dpp
, /* [0...39] IN */
2296 word
* ep
, /* [0...39] IN */
2297 word
* dp
) ; /* [-120...-1] IN/OUT */
2300 * Tables from table.c
2304 extern word gsm_A
[8], gsm_B
[8], gsm_MIC
[8], gsm_MAC
[8] ;
2305 extern word gsm_INVA
[8] ;
2306 extern word gsm_DLB
[4], gsm_QLB
[4] ;
2307 extern word gsm_H
[11] ;
2308 extern word gsm_NRFAC
[8] ;
2309 extern word gsm_FAC
[8] ;
2311 #endif /* GSM_TABLE_C */
2318 # define gsm_debug_words(a, b, c, d) /* nil */
2319 # define gsm_debug_longwords(a, b, c, d) /* nil */
2320 # define gsm_debug_word(a, b) /* nil */
2321 # define gsm_debug_longword(a, b) /* nil */
2323 #else /* !NDEBUG => DEBUG */
2325 void gsm_debug_words (char * name
, int, int, word
*) ;
2326 void gsm_debug_longwords (char * name
, int, int, longword
*) ;
2327 void gsm_debug_longword (char * name
, longword
) ;
2328 void gsm_debug_word (char * name
, word
) ;
2330 #endif /* !NDEBUG */
2332 #endif /* PRIVATE_H */
2334 ** Do not edit or modify anything in this comment block.
2335 ** The arch-tag line is a file identity tag for the GNU Arch
2336 ** revision control system.
2338 ** arch-tag: 8bc5fdf2-e8c8-4686-9bd7-a30b512bef0c
2342 ** Copyright (C) 2001-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
2344 ** This program is free software; you can redistribute it and/or modify
2345 ** it under the terms of the GNU Lesser General Public License as published by
2346 ** the Free Software Foundation; either version 2.1 of the License, or
2347 ** (at your option) any later version.
2349 ** This program is distributed in the hope that it will be useful,
2350 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
2351 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2352 ** GNU Lesser General Public License for more details.
2354 ** You should have received a copy of the GNU Lesser General Public License
2355 ** along with this program; if not, write to the Free Software
2356 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2362 /*============================================================================
2363 ** On Intel Pentium processors (especially PIII and probably P4), converting
2364 ** from float to int is very slow. To meet the C specs, the code produced by
2365 ** most C compilers targeting Pentium needs to change the FPU rounding mode
2366 ** before the float to int conversion is performed.
2368 ** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It
2369 ** is this flushing of the pipeline which is so slow.
2371 ** Fortunately the ISO C99 specifications define the functions lrint, lrintf,
2372 ** llrint and llrintf which fix this problem as a side effect.
2374 ** On Unix-like systems, the configure process should have detected the
2375 ** presence of these functions. If they weren't found we have to replace them
2376 ** here with a standard C cast.
2380 ** The C99 prototypes for lrint and lrintf are as follows:
2382 ** long int lrintf (float x) ;
2383 ** long int lrint (double x) ;
2388 ** The presence of the required functions are detected during the configure
2389 ** process and the values HAVE_LRINT and HAVE_LRINTF are set accordingly in
2390 ** the config.h file.
2393 #define HAVE_LRINT_REPLACEMENT 0
2395 #if (HAVE_LRINT && HAVE_LRINTF)
2398 ** These defines enable functionality introduced with the 1999 ISO C
2399 ** standard. They must be defined before the inclusion of math.h to
2400 ** engage them. If optimisation is enabled, these functions will be
2401 ** inlined. With optimisation switched off, you have to link in the
2402 ** maths library using -lm.
2405 #define _ISOC9X_SOURCE 1
2406 #define _ISOC99_SOURCE 1
2408 #define __USE_ISOC9X 1
2409 #define __USE_ISOC99 1
2412 #elif ( defined (WIN32) || defined (_WIN32) || defined(__PLATFORM_WIN32__) )
2414 #undef HAVE_LRINT_REPLACEMENT
2415 #define HAVE_LRINT_REPLACEMENT 1
2418 ** Win32 doesn't seem to have these functions.
2419 ** Therefore implement inline versions of these functions here.
2446 #elif (defined (__MWERKS__) && defined (macintosh))
2448 /* This MacOS 9 solution was provided by Stephane Letz */
2450 #undef HAVE_LRINT_REPLACEMENT
2451 #define HAVE_LRINT_REPLACEMENT 1
2456 #define lrint double2int
2457 #define lrintf float2int
2460 float2int (register float in
)
2471 double2int (register double in
)
2481 #elif (defined (__MACH__) && defined (__APPLE__))
2483 /* For Apple MacOSX. */
2485 #undef HAVE_LRINT_REPLACEMENT
2486 #define HAVE_LRINT_REPLACEMENT 1
2491 #define lrint double2int
2492 #define lrintf float2int
2494 inline static long int
2495 float2int (register float in
)
2498 __asm__ __volatile__
2499 ( "fctiw %1, %1\n\t"
2501 : "=m" (res
) /* Output */
2502 : "f" (in
) /* Input */
2509 inline static long int
2510 double2int (register double in
)
2513 __asm__ __volatile__
2514 ( "fctiw %1, %1\n\t"
2516 : "=m" (res
) /* Output */
2517 : "f" (in
) /* Input */
2526 // #warning "Don't have the functions lrint() and lrintf()."
2527 // #warning "Replacing these functions with a standard C cast."
2531 #define lrint(dbl) ((long) (dbl))
2532 #define lrintf(flt) ((long) (flt))
2539 ** Do not edit or modify anything in this comment block.
2540 ** The arch-tag line is a file identity tag for the GNU Arch
2541 ** revision control system.
2543 ** arch-tag: 42db1693-ff61-4051-bac1-e4d24c4e30b7
2546 ** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com>
2548 ** This program is free software; you can redistribute it and/or modify
2549 ** it under the terms of the GNU Lesser General Public License as published by
2550 ** the Free Software Foundation; either version 2.1 of the License, or
2551 ** (at your option) any later version.
2553 ** This program is distributed in the hope that it will be useful,
2554 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
2555 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2556 ** GNU Lesser General Public License for more details.
2558 ** You should have received a copy of the GNU Lesser General Public License
2559 ** along with this program; if not, write to the Free Software
2560 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2563 /* Some defines that microsoft 'forgot' to implement. */
2566 #define S_IRWXU 0000700 /* rwx, owner */
2570 #define S_IRUSR 0000400 /* read permission, owner */
2574 #define S_IWUSR 0000200 /* write permission, owner */
2578 #define S_IXUSR 0000100 /* execute/search permission, owner */
2582 #define S_IRWXG 0000070 /* rwx, group */
2586 #define S_IRGRP 0000040 /* read permission, group */
2590 #define S_IWGRP 0000020 /* write permission, grougroup */
2594 #define S_IXGRP 0000010 /* execute/search permission, group */
2598 #define S_IRWXO 0000007 /* rwx, other */
2602 #define S_IROTH 0000004 /* read permission, other */
2606 #define S_IWOTH 0000002 /* write permission, other */
2610 #define S_IXOTH 0000001 /* execute/search permission, other */
2614 #define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO)
2618 #define S_ISREG(mode) (((mode) & _S_IFREG) == _S_IFREG)
2622 ** Don't know if these are still needed.
2624 ** #define _IFMT _S_IFMT
2625 ** #define _IFREG _S_IFREG
2628 ** Do not edit or modify anything in this comment block.
2629 ** The arch-tag line is a file identity tag for the GNU Arch
2630 ** revision control system.
2632 ** arch-tag: 253aea6d-6299-46fd-8d06-bc5f6224c8fe