| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
#ifndef __UTIL_SNDFILE_H__ |
| 54 |
#define __UTIL_SNDFILE_H__ |
| 55 |
|
| 56 |
#if defined(__CHUNREAL_ENGINE__) |
| 57 |
#pragma warning(disable : 4668) // -Wundef |
| 58 |
#ifdef __clang__ |
| 59 |
#pragma clang diagnostic ignored "-Wundef" |
| 60 |
#endif |
| 61 |
#endif |
| 62 |
|
| 63 |
#include <stdio.h> |
| 64 |
#include <stdlib.h> |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
#define COMPILER_IS_GCC 1 |
| 71 |
#define CPU_CLIPS_NEGATIVE 1 |
| 72 |
#define ENABLE_EXPERIMENTAL_CODE 0 |
| 73 |
#define GCC_MAJOR_VERSION 3 |
| 74 |
#define HAVE_CALLOC 1 |
| 75 |
#define HAVE_CEIL 1 |
| 76 |
#define HAVE_DECL_S_IRGRP 1 |
| 77 |
#define HAVE_DLFCN_H 1 |
| 78 |
#define HAVE_FLEXIBLE_ARRAY 1 |
| 79 |
#define HAVE_FLOOR 1 |
| 80 |
#define HAVE_FMOD 1 |
| 81 |
#define HAVE_FREE 1 |
| 82 |
#define HAVE_FSTAT 1 |
| 83 |
#define HAVE_FSYNC 1 |
| 84 |
#define HAVE_FTRUNCATE 1 |
| 85 |
#define HAVE_GETPAGESIZE 1 |
| 86 |
#define HAVE_GMTIME 1 |
| 87 |
#define HAVE_GMTIME_R 1 |
| 88 |
#define HAVE_INTTYPES_H 1 |
| 89 |
#define HAVE_LIBM 1 |
| 90 |
#define HAVE_LSEEK 1 |
| 91 |
#define HAVE_MALLOC 1 |
| 92 |
#define HAVE_MEMORY_H 1 |
| 93 |
#define HAVE_MMAP 1 |
| 94 |
#define HAVE_OPEN 1 |
| 95 |
#define HAVE_READ 1 |
| 96 |
#define HAVE_REALLOC 1 |
| 97 |
#define HAVE_SNPRINTF 1 |
| 98 |
#define HAVE_STDINT_H 1 |
| 99 |
#define HAVE_STDLIB_H 1 |
| 100 |
#define HAVE_STRINGS_H 1 |
| 101 |
#define HAVE_STRING_H 1 |
| 102 |
#define HAVE_SYS_STAT_H 1 |
| 103 |
#define HAVE_SYS_TYPES_H 1 |
| 104 |
#define HAVE_SYS_WAIT_H 1 |
| 105 |
#define HAVE_VSNPRINTF 1 |
| 106 |
#define HAVE_WRITE 1 |
| 107 |
#define PACKAGE "libsndfile" |
| 108 |
#define PACKAGE_BUGREPORT "[email protected]" |
| 109 |
#define PACKAGE_NAME "libsndfile" |
| 110 |
#define PACKAGE_STRING "libsndfile 1.0.10" |
| 111 |
#define PACKAGE_TARNAME "libsndfile" |
| 112 |
#define PACKAGE_VERSION "1.0.10" |
| 113 |
|
| 114 |
#define SIZEOF_DOUBLE 8 |
| 115 |
#define SIZEOF_FLOAT 4 |
| 116 |
#define SIZEOF_INT 4 |
| 117 |
#define SIZEOF_LONG 4 |
| 118 |
#define SIZEOF_OFF_T 8 |
| 119 |
#define SIZEOF_SF_COUNT_T 8 |
| 120 |
#define SIZEOF_SHORT 2 |
| 121 |
#define SIZEOF_SIZE_T 4 |
| 122 |
#define SIZEOF_SSIZE_T 4 |
| 123 |
#define SIZEOF_VOIDP 4 |
| 124 |
#define STDC_HEADERS 1 |
| 125 |
|
| 126 |
#define VERSION "1.0.10" |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
#if defined(__APPLE__) |
| 132 |
#define CPU_CLIPS_POSITIVE 1 |
| 133 |
#ifdef __LITTLE_ENDIAN__ |
| 134 |
#define CPU_IS_BIG_ENDIAN 0 |
| 135 |
#define CPU_IS_LITTLE_ENDIAN 1 |
| 136 |
#define HAVE_LRINTF 1 |
| 137 |
#define HAVE_LRINT 1 |
| 138 |
#else |
| 139 |
#define CPU_IS_BIG_ENDIAN 1 |
| 140 |
#define CPU_IS_LITTLE_ENDIAN 0 |
| 141 |
#endif |
| 142 |
#define HAVE_PREAD 1 |
| 143 |
#define HAVE_PWRITE 1 |
| 144 |
#define OS_IS_MACOSX 1 |
| 145 |
#define OS_IS_WIN32 0 |
| 146 |
#define TYPEOF_SF_COUNT_T off_t |
| 147 |
#endif |
| 148 |
|
| 149 |
#if defined(_WIN32) |
| 150 |
#define CPU_CLIPS_POSITIVE 0 |
| 151 |
#define CPU_IS_BIG_ENDIAN 0 |
| 152 |
#define CPU_IS_LITTLE_ENDIAN 1 |
| 153 |
#define HAVE_LRINTF 0 |
| 154 |
#define HAVE_LRINT 0 |
| 155 |
#undef HAVE_GMTIME_R |
| 156 |
#undef HAVE_GMTIME |
| 157 |
#undef HAVE_SNPRINTF |
| 158 |
#undef HAVE_FLEXIBLE_ARRAY |
| 159 |
#define OS_IS_MACOSX 0 |
| 160 |
#define OS_IS_WIN32 1 |
| 161 |
#define TYPEOF_SF_COUNT_T off_t |
| 162 |
#endif |
| 163 |
|
| 164 |
#if defined (__CYGWIN__) |
| 165 |
#define CPU_CLIPS_POSITIVE 0 |
| 166 |
#define CPU_IS_BIG_ENDIAN 0 |
| 167 |
#define CPU_IS_LITTLE_ENDIAN 1 |
| 168 |
#define HAVE_LRINTF 0 |
| 169 |
#define HAVE_LRINT 0 |
| 170 |
#define OS_IS_MACOSX 0 |
| 171 |
#define OS_IS_WIN32 0 |
| 172 |
#define TYPEOF_SF_COUNT_T off_t |
| 173 |
#endif |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
#if defined(__linux__) || defined(__FreeBSD__) |
| 181 |
#define CPU_CLIPS_POSITIVE 0 |
| 182 |
#define CPU_IS_BIG_ENDIAN 0 |
| 183 |
#define CPU_IS_LITTLE_ENDIAN 1 |
| 184 |
#define HAVE_PREAD 1 |
| 185 |
#define HAVE_PWRITE 1 |
| 186 |
#define OS_IS_MACOSX 0 |
| 187 |
#define OS_IS_WIN32 0 |
| 188 |
#define SIZEOF_OFF64_T 0 |
| 189 |
#define SIZEOF_LOFF_T 8 |
| 190 |
#define TYPEOF_SF_COUNT_T loff_t |
| 191 |
#define _FILE_OFFSET_BITS 64 |
| 192 |
#define HAVE_FDATASYNC 1 |
| 193 |
#define HAVE_ENDIAN_H 1 |
| 194 |
#define HAVE_LRINTF 1 |
| 195 |
#define HAVE_LRINT 1 |
| 196 |
#endif |
| 197 |
|
| 198 |
#ifdef __EMSCRIPTEN__ |
| 199 |
#define CPU_CLIPS_POSITIVE 1 |
| 200 |
#define CPU_IS_BIG_ENDIAN 0 |
| 201 |
#define CPU_IS_LITTLE_ENDIAN 1 |
| 202 |
#define HAVE_LRINTF 1 |
| 203 |
#define HAVE_LRINT 1 |
| 204 |
#define HAVE_PREAD 1 |
| 205 |
#define HAVE_PWRITE 1 |
| 206 |
#define OS_IS_MACOSX 0 |
| 207 |
#define OS_IS_WIN32 0 |
| 208 |
#define TYPEOF_SF_COUNT_T off_t |
| 209 |
#endif |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
#ifdef _WIN32 |
| 218 |
|
| 219 |
#define C_INLINE __inline |
| 220 |
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFF |
| 221 |
|
| 222 |
#else |
| 223 |
|
| 224 |
#define C_INLINE inline |
| 225 |
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL |
| 226 |
#define HAVE_UNISTD_H 1 |
| 227 |
#define HAVE_SSIZE_T 1 |
| 228 |
|
| 229 |
#endif |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
#ifndef SNDFILE_H |
| 239 |
#define SNDFILE_H |
| 240 |
|
| 241 |
|
| 242 |
#define SNDFILE_1 |
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
#if (defined (__MWERKS__)) |
| 248 |
#else |
| 249 |
#include <sys/types.h> |
| 250 |
#endif |
| 251 |
|
| 252 |
#ifdef __cplusplus |
| 253 |
extern "C" { |
| 254 |
#endif |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
enum |
| 264 |
{ |
| 265 |
SF_FORMAT_WAV = 0x010000, |
| 266 |
SF_FORMAT_AIFF = 0x020000, |
| 267 |
SF_FORMAT_AU = 0x030000, |
| 268 |
SF_FORMAT_RAW = 0x040000, |
| 269 |
SF_FORMAT_PAF = 0x050000, |
| 270 |
SF_FORMAT_SVX = 0x060000, |
| 271 |
SF_FORMAT_NIST = 0x070000, |
| 272 |
SF_FORMAT_VOC = 0x080000, |
| 273 |
SF_FORMAT_IRCAM = 0x0A0000, |
| 274 |
SF_FORMAT_W64 = 0x0B0000, |
| 275 |
SF_FORMAT_MAT4 = 0x0C0000, |
| 276 |
SF_FORMAT_MAT5 = 0x0D0000, |
| 277 |
SF_FORMAT_PVF = 0x0E0000, |
| 278 |
SF_FORMAT_XI = 0x0F0000, |
| 279 |
SF_FORMAT_HTK = 0x100000, |
| 280 |
SF_FORMAT_SDS = 0x110000, |
| 281 |
SF_FORMAT_AVR = 0x120000, |
| 282 |
SF_FORMAT_WAVEX = 0x130000, |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
SF_FORMAT_PCM_S8 = 0x0001, |
| 287 |
SF_FORMAT_PCM_16 = 0x0002, |
| 288 |
SF_FORMAT_PCM_24 = 0x0003, |
| 289 |
SF_FORMAT_PCM_32 = 0x0004, |
| 290 |
SF_FORMAT_PCM_U8 = 0x0005, |
| 291 |
SF_FORMAT_FLOAT = 0x0006, |
| 292 |
SF_FORMAT_DOUBLE = 0x0007, |
| 293 |
SF_FORMAT_ULAW = 0x0010, |
| 294 |
SF_FORMAT_ALAW = 0x0011, |
| 295 |
SF_FORMAT_IMA_ADPCM = 0x0012, |
| 296 |
SF_FORMAT_MS_ADPCM = 0x0013, |
| 297 |
SF_FORMAT_GSM610 = 0x0020, |
| 298 |
SF_FORMAT_VOX_ADPCM = 0x0021, |
| 299 |
SF_FORMAT_G721_32 = 0x0030, |
| 300 |
SF_FORMAT_G723_24 = 0x0031, |
| 301 |
SF_FORMAT_G723_40 = 0x0032, |
| 302 |
SF_FORMAT_DWVW_12 = 0x0040, |
| 303 |
SF_FORMAT_DWVW_16 = 0x0041, |
| 304 |
SF_FORMAT_DWVW_24 = 0x0042, |
| 305 |
SF_FORMAT_DWVW_N = 0x0043, |
| 306 |
SF_FORMAT_DPCM_8 = 0x0050, |
| 307 |
SF_FORMAT_DPCM_16 = 0x0051, |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
SF_ENDIAN_FILE = 0x00000000, |
| 312 |
SF_ENDIAN_LITTLE = 0x10000000, |
| 313 |
SF_ENDIAN_BIG = 0x20000000, |
| 314 |
SF_ENDIAN_CPU = 0x30000000, |
| 315 |
|
| 316 |
SF_FORMAT_SUBMASK = 0x0000FFFF, |
| 317 |
SF_FORMAT_TYPEMASK = 0x0FFF0000, |
| 318 |
SF_FORMAT_ENDMASK = 0x30000000 |
| 319 |
} ; |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
enum |
| 332 |
{ SFC_GET_LIB_VERSION = 0x1000, |
| 333 |
SFC_GET_LOG_INFO = 0x1001, |
| 334 |
SFC_GET_NORM_DOUBLE = 0x1010, |
| 335 |
SFC_GET_NORM_FLOAT = 0x1011, |
| 336 |
SFC_SET_NORM_DOUBLE = 0x1012, |
| 337 |
SFC_SET_NORM_FLOAT = 0x1013, |
| 338 |
SFC_GET_SIMPLE_FORMAT_COUNT = 0x1020, |
| 339 |
SFC_GET_SIMPLE_FORMAT = 0x1021, |
| 340 |
SFC_GET_FORMAT_INFO = 0x1028, |
| 341 |
SFC_GET_FORMAT_MAJOR_COUNT = 0x1030, |
| 342 |
SFC_GET_FORMAT_MAJOR = 0x1031, |
| 343 |
SFC_GET_FORMAT_SUBTYPE_COUNT = 0x1032, |
| 344 |
SFC_GET_FORMAT_SUBTYPE = 0x1033, |
| 345 |
SFC_CALC_SIGNAL_MAX = 0x1040, |
| 346 |
SFC_CALC_NORM_SIGNAL_MAX = 0x1041, |
| 347 |
SFC_CALC_MAX_ALL_CHANNELS = 0x1042, |
| 348 |
SFC_CALC_NORM_MAX_ALL_CHANNELS = 0x1043, |
| 349 |
SFC_SET_ADD_PEAK_CHUNK = 0x1050, |
| 350 |
SFC_UPDATE_HEADER_NOW = 0x1060, |
| 351 |
SFC_SET_UPDATE_HEADER_AUTO = 0x1061, |
| 352 |
SFC_FILE_TRUNCATE = 0x1080, |
| 353 |
SFC_SET_RAW_START_OFFSET = 0x1090, |
| 354 |
SFC_SET_DITHER_ON_WRITE = 0x10A0, |
| 355 |
SFC_SET_DITHER_ON_READ = 0x10A1, |
| 356 |
SFC_GET_DITHER_INFO_COUNT = 0x10A2, |
| 357 |
SFC_GET_DITHER_INFO = 0x10A3, |
| 358 |
SFC_GET_EMBED_FILE_INFO = 0x10B0, |
| 359 |
SFC_SET_CLIPPING = 0x10C0, |
| 360 |
SFC_GET_CLIPPING = 0x10C1, |
| 361 |
SFC_GET_INSTRUMENT = 0x10D0, |
| 362 |
SFC_SET_INSTRUMENT = 0x10D1, |
| 363 |
|
| 364 |
|
| 365 |
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, |
| 375 |
SFC_SET_ADD_DITHER_ON_READ = 0x1071 |
| 376 |
} ; |
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
enum |
| 390 |
{ SF_STR_TITLE = 0x01, |
| 391 |
SF_STR_COPYRIGHT = 0x02, |
| 392 |
SF_STR_SOFTWARE = 0x03, |
| 393 |
SF_STR_ARTIST = 0x04, |
| 394 |
SF_STR_COMMENT = 0x05, |
| 395 |
SF_STR_DATE = 0x06 |
| 396 |
} ; |
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
enum |
| 401 |
{ |
| 402 |
SF_FALSE = 0, |
| 403 |
SF_TRUE = 1, |
| 404 |
|
| 405 |
|
| 406 |
SFM_READ = 0x10, |
| 407 |
SFM_WRITE = 0x20, |
| 408 |
SFM_RDWR = 0x30 |
| 409 |
} ; |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
enum |
| 422 |
{ SF_ERR_NO_ERROR = 0, |
| 423 |
SF_ERR_UNRECOGNISED_FORMAT = 1, |
| 424 |
SF_ERR_SYSTEM = 2 |
| 425 |
} ; |
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
typedef struct SNDFILE_tag SNDFILE ; |
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
typedef TYPEOF_SF_COUNT_T sf_count_t ; |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
struct SF_INFO |
| 449 |
{ sf_count_t frames ; |
| 450 |
int samplerate ; |
| 451 |
int channels ; |
| 452 |
int format ; |
| 453 |
int sections ; |
| 454 |
int seekable ; |
| 455 |
} ; |
| 456 |
|
| 457 |
typedef struct SF_INFO SF_INFO ; |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
typedef struct |
| 471 |
{ int format ; |
| 472 |
const char *name ; |
| 473 |
const char *extension ; |
| 474 |
} SF_FORMAT_INFO ; |
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
enum |
| 483 |
{ SFD_DEFAULT_LEVEL = 0, |
| 484 |
SFD_CUSTOM_LEVEL = 0x40000000, |
| 485 |
|
| 486 |
SFD_NO_DITHER = 500, |
| 487 |
SFD_WHITE = 501, |
| 488 |
SFD_TRIANGULAR_PDF = 502 |
| 489 |
} ; |
| 490 |
|
| 491 |
typedef struct |
| 492 |
{ int type ; |
| 493 |
double level ; |
| 494 |
const char *name ; |
| 495 |
} SF_DITHER_INFO ; |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
typedef struct |
| 502 |
{ sf_count_t offset ; |
| 503 |
sf_count_t length ; |
| 504 |
} SF_EMBED_FILE_INFO ; |
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
typedef struct |
| 510 |
{ int basenote ; |
| 511 |
int gain ; |
| 512 |
int sustain_mode ; |
| 513 |
int sustain_start, sustain_end ; |
| 514 |
int release_mode ; |
| 515 |
int release_start, reslease_end ; |
| 516 |
} SF_INSTRUMENT ; |
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
enum |
| 521 |
{ SF_LOOP_NONE = 800, |
| 522 |
SF_LOOP_FORWARD, |
| 523 |
SF_LOOP_BACKWARD |
| 524 |
} ; |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; |
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ; |
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
int sf_error (SNDFILE *sndfile) ; |
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
const char* sf_strerror (SNDFILE *sndfile) ; |
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
const char* sf_error_number (int errnum) ; |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
int sf_perror (SNDFILE *sndfile) ; |
| 573 |
int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ; |
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
int sf_format_check (const SF_INFO *info) ; |
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; |
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ; |
| 607 |
|
| 608 |
const char* sf_get_string (SNDFILE *sndfile, int str_type) ; |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; |
| 614 |
sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; |
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; |
| 627 |
sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ; |
| 628 |
|
| 629 |
sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; |
| 630 |
sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ; |
| 631 |
|
| 632 |
sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; |
| 633 |
sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ; |
| 634 |
|
| 635 |
sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; |
| 636 |
sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ; |
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; |
| 644 |
sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ; |
| 645 |
|
| 646 |
sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; |
| 647 |
sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ; |
| 648 |
|
| 649 |
sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; |
| 650 |
sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ; |
| 651 |
|
| 652 |
sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; |
| 653 |
sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ; |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
int sf_close (SNDFILE *sndfile) ; |
| 661 |
|
| 662 |
#ifdef __cplusplus |
| 663 |
} |
| 664 |
#endif |
| 665 |
|
| 666 |
#endif |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
#ifndef COMMON_H_INCLUDED |
| 686 |
#define COMMON_H_INCLUDED |
| 687 |
|
| 688 |
|
| 689 |
#ifndef SNDFILE_H |
| 690 |
#endif |
| 691 |
|
| 692 |
#define SF_BUFFER_LEN (8192*2) |
| 693 |
#define SF_FILENAME_LEN (256) |
| 694 |
#define SF_HEADER_LEN (4096) |
| 695 |
#define SF_TEXT_LEN (1024) |
| 696 |
#define SF_SYSERR_LEN (256) |
| 697 |
#define SF_MAX_STRINGS (16) |
| 698 |
|
| 699 |
#define SF_SEEK_ERROR ((sf_count_t) -1) |
| 700 |
|
| 701 |
|
| 702 |
#define BITWIDTH2BYTES(x) (((x) + 7) / 8) |
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
#define SIGNED_SIZEOF(x) ((int) sizeof (x)) |
| 709 |
|
| 710 |
#define ARRAY_LEN(x) ((int) (sizeof (x) / sizeof ((x) [0]))) |
| 711 |
|
| 712 |
#define SF_MAX(a,b) ((a) > (b) ? (a) : (b)) |
| 713 |
#define SF_MIN(a,b) ((a) < (b) ? (a) : (b)) |
| 714 |
|
| 715 |
enum |
| 716 |
{ |
| 717 |
SF_PEAK_START = 42, |
| 718 |
SF_PEAK_END = 43, |
| 719 |
|
| 720 |
|
| 721 |
SF_SCALE_MAX = 52, |
| 722 |
SF_SCALE_MIN = 53, |
| 723 |
|
| 724 |
|
| 725 |
SF_STR_ALLOW_START = 0x0100, |
| 726 |
SF_STR_ALLOW_END = 0x0200, |
| 727 |
|
| 728 |
|
| 729 |
SF_STR_LOCATE_START = 0x0400, |
| 730 |
SF_STR_LOCATE_END = 0x0800, |
| 731 |
|
| 732 |
SFD_TYPEMASK = 0x0FFFFFFF |
| 733 |
} ; |
| 734 |
|
| 735 |
#define SFM_MASK (SFM_READ | SFM_WRITE | SFM_RDWR) |
| 736 |
#define SFM_UNMASK (~SFM_MASK) |
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
enum |
| 744 |
{ |
| 745 |
|
| 746 |
|
| 747 |
SF_FORMAT_WVE = 0x4020000, |
| 748 |
SF_FORMAT_TXW = 0x4030000, |
| 749 |
SF_FORMAT_DWD = 0x4040000, |
| 750 |
|
| 751 |
|
| 752 |
SF_FORMAT_OGG = 0x4090000, |
| 753 |
|
| 754 |
SF_FORMAT_REX = 0x40A0000, |
| 755 |
SF_FORMAT_SD2 = 0x40C0000, |
| 756 |
SF_FORMAT_REX2 = 0x40D0000, |
| 757 |
SF_FORMAT_KRZ = 0x40E0000, |
| 758 |
SF_FORMAT_WMA = 0x4100000, |
| 759 |
SF_FORMAT_SHN = 0x4110000, |
| 760 |
SF_FORMAT_FLAC = 0x4120000, |
| 761 |
|
| 762 |
|
| 763 |
SF_FORMAT_VORBIS = 0x1001, |
| 764 |
|
| 765 |
SF_FORMAT_SVX_FIB = 0x1020, |
| 766 |
SF_FORMAT_SVX_EXP = 0x1021, |
| 767 |
|
| 768 |
SF_FORMAT_PCM_N = 0x1030 |
| 769 |
} ; |
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
typedef struct |
| 777 |
{ float value ; |
| 778 |
unsigned int position ; |
| 779 |
} PEAK_POS ; |
| 780 |
|
| 781 |
typedef struct |
| 782 |
{ unsigned int version ; |
| 783 |
unsigned int timestamp ; |
| 784 |
#if HAVE_FLEXIBLE_ARRAY |
| 785 |
PEAK_POS peaks [] ; |
| 786 |
#else |
| 787 |
PEAK_POS peaks [1] ; |
| 788 |
#endif |
| 789 |
} PEAK_CHUNK ; |
| 790 |
|
| 791 |
typedef struct |
| 792 |
{ int type ; |
| 793 |
int flags ; |
| 794 |
char *str ; |
| 795 |
} STR_DATA ; |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
typedef struct sf_private_tag |
| 804 |
{ |
| 805 |
double buffer [SF_BUFFER_LEN / sizeof (double)] ; |
| 806 |
char filename [SF_FILENAME_LEN] ; |
| 807 |
|
| 808 |
char syserr [SF_SYSERR_LEN] ; |
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
char logbuffer [SF_BUFFER_LEN] ; |
| 814 |
unsigned char header [SF_HEADER_LEN] ; |
| 815 |
int rwf_endian ; |
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
STR_DATA strings [SF_MAX_STRINGS] ; |
| 821 |
char str_storage [SF_BUFFER_LEN] ; |
| 822 |
char *str_end ; |
| 823 |
int str_flags ; |
| 824 |
|
| 825 |
|
| 826 |
int Magick ; |
| 827 |
|
| 828 |
|
| 829 |
int logindex ; |
| 830 |
int headindex, headend ; |
| 831 |
int has_text ; |
| 832 |
int do_not_close_descriptor ; |
| 833 |
|
| 834 |
int filedes ; |
| 835 |
|
| 836 |
int end_of_file ; |
| 837 |
int error ; |
| 838 |
|
| 839 |
int mode ; |
| 840 |
int endian ; |
| 841 |
int float_endswap ; |
| 842 |
|
| 843 |
|
| 844 |
int is_pipe ; |
| 845 |
sf_count_t pipeoffset ; |
| 846 |
|
| 847 |
|
| 848 |
int add_clipping ; |
| 849 |
|
| 850 |
SF_INFO sf ; |
| 851 |
|
| 852 |
int have_written ; |
| 853 |
int has_peak ; |
| 854 |
int peak_loc ; |
| 855 |
PEAK_CHUNK *pchunk ; |
| 856 |
|
| 857 |
sf_count_t filelength ; |
| 858 |
sf_count_t fileoffset ; |
| 859 |
|
| 860 |
sf_count_t dataoffset ; |
| 861 |
sf_count_t datalength ; |
| 862 |
sf_count_t dataend ; |
| 863 |
|
| 864 |
int blockwidth ; |
| 865 |
int bytewidth ; |
| 866 |
|
| 867 |
void *dither ; |
| 868 |
void *interleave ; |
| 869 |
|
| 870 |
int last_op ; |
| 871 |
sf_count_t read_current ; |
| 872 |
sf_count_t write_current ; |
| 873 |
|
| 874 |
void *fdata ; |
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
SF_DITHER_INFO write_dither ; |
| 879 |
SF_DITHER_INFO read_dither ; |
| 880 |
|
| 881 |
int norm_double ; |
| 882 |
int norm_float ; |
| 883 |
|
| 884 |
int auto_header ; |
| 885 |
|
| 886 |
int ieee_replace ; |
| 887 |
|
| 888 |
|
| 889 |
sf_count_t (*read_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ; |
| 890 |
sf_count_t (*read_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ; |
| 891 |
sf_count_t (*read_float) (struct sf_private_tag*, float *ptr, sf_count_t len) ; |
| 892 |
sf_count_t (*read_double) (struct sf_private_tag*, double *ptr, sf_count_t len) ; |
| 893 |
|
| 894 |
sf_count_t (*write_short) (struct sf_private_tag*, short *ptr, sf_count_t len) ; |
| 895 |
sf_count_t (*write_int) (struct sf_private_tag*, int *ptr, sf_count_t len) ; |
| 896 |
sf_count_t (*write_float) (struct sf_private_tag*, float *ptr, sf_count_t len) ; |
| 897 |
sf_count_t (*write_double) (struct sf_private_tag*, double *ptr, sf_count_t len) ; |
| 898 |
|
| 899 |
sf_count_t (*seek) (struct sf_private_tag*, int mode, sf_count_t samples_from_start) ; |
| 900 |
int (*write_header) (struct sf_private_tag*, int calc_length) ; |
| 901 |
int (*command) (struct sf_private_tag*, int command, void *data, int datasize) ; |
| 902 |
int (*close) (struct sf_private_tag*) ; |
| 903 |
|
| 904 |
char *format_desc ; |
| 905 |
} SF_PRIVATE ; |
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
enum |
| 910 |
{ SFE_NO_ERROR = SF_ERR_NO_ERROR, |
| 911 |
SFE_BAD_OPEN_FORMAT = SF_ERR_UNRECOGNISED_FORMAT, |
| 912 |
SFE_SYSTEM = SF_ERR_SYSTEM, |
| 913 |
|
| 914 |
SFE_BAD_FILE, |
| 915 |
SFE_BAD_FILE_READ, |
| 916 |
SFE_OPEN_FAILED, |
| 917 |
SFE_BAD_SNDFILE_PTR, |
| 918 |
SFE_BAD_SF_INFO_PTR, |
| 919 |
SFE_BAD_SF_INCOMPLETE, |
| 920 |
SFE_BAD_FILE_PTR, |
| 921 |
SFE_BAD_INT_PTR, |
| 922 |
SFE_BAD_STAT_SIZE, |
| 923 |
SFE_MALLOC_FAILED, |
| 924 |
SFE_UNIMPLEMENTED, |
| 925 |
SFE_BAD_READ_ALIGN, |
| 926 |
SFE_BAD_WRITE_ALIGN, |
| 927 |
SFE_UNKNOWN_FORMAT, |
| 928 |
SFE_NOT_READMODE, |
| 929 |
SFE_NOT_WRITEMODE, |
| 930 |
SFE_BAD_MODE_RW, |
| 931 |
SFE_BAD_SF_INFO, |
| 932 |
SFE_BAD_OFFSET, |
| 933 |
SFE_NO_EMBED_SUPPORT, |
| 934 |
SFE_NO_EMBEDDED_RDWR, |
| 935 |
SFE_NO_PIPE_WRITE, |
| 936 |
|
| 937 |
SFE_INTERNAL, |
| 938 |
SFE_LOG_OVERRUN, |
| 939 |
SFE_BAD_CONTROL_CMD, |
| 940 |
SFE_BAD_ENDIAN, |
| 941 |
SFE_CHANNEL_COUNT, |
| 942 |
SFE_BAD_RDWR_FORMAT, |
| 943 |
|
| 944 |
SFE_INTERLEAVE_MODE, |
| 945 |
SFE_INTERLEAVE_SEEK, |
| 946 |
SFE_INTERLEAVE_READ, |
| 947 |
|
| 948 |
SFE_BAD_SEEK, |
| 949 |
SFE_NOT_SEEKABLE, |
| 950 |
SFE_AMBIGUOUS_SEEK, |
| 951 |
SFE_WRONG_SEEK, |
| 952 |
SFE_SEEK_FAILED, |
| 953 |
|
| 954 |
SFE_BAD_OPEN_MODE, |
| 955 |
SFE_OPEN_PIPE_RDWR, |
| 956 |
SFE_RDWR_POSITION, |
| 957 |
|
| 958 |
SFE_STR_NO_SUPPORT, |
| 959 |
SFE_STR_MAX_DATA, |
| 960 |
SFE_STR_MAX_COUNT, |
| 961 |
SFE_STR_BAD_TYPE, |
| 962 |
SFE_STR_NO_ADD_END, |
| 963 |
SFE_STR_BAD_STRING, |
| 964 |
SFE_STR_WEIRD, |
| 965 |
SFE_RDWR_BAD_HEADER, |
| 966 |
|
| 967 |
SFE_WAV_NO_RIFF, |
| 968 |
SFE_WAV_NO_WAVE, |
| 969 |
SFE_WAV_NO_FMT, |
| 970 |
SFE_WAV_FMT_SHORT, |
| 971 |
SFE_WAV_FMT_TOO_BIG, |
| 972 |
SFE_WAV_BAD_FACT, |
| 973 |
SFE_WAV_BAD_PEAK, |
| 974 |
SFE_WAV_PEAK_B4_FMT, |
| 975 |
SFE_WAV_BAD_FORMAT, |
| 976 |
SFE_WAV_BAD_BLOCKALIGN, |
| 977 |
SFE_WAV_NO_DATA, |
| 978 |
SFE_WAV_ADPCM_NOT4BIT, |
| 979 |
SFE_WAV_ADPCM_CHANNELS, |
| 980 |
SFE_WAV_GSM610_FORMAT, |
| 981 |
SFE_WAV_UNKNOWN_CHUNK, |
| 982 |
SFE_WAV_WVPK_DATA, |
| 983 |
|
| 984 |
SFE_AIFF_NO_FORM, |
| 985 |
SFE_AIFF_AIFF_NO_FORM, |
| 986 |
SFE_AIFF_COMM_NO_FORM, |
| 987 |
SFE_AIFF_SSND_NO_COMM, |
| 988 |
SFE_AIFF_UNKNOWN_CHUNK, |
| 989 |
SFE_AIFF_COMM_CHUNK_SIZE, |
| 990 |
SFE_AIFF_BAD_COMM_CHUNK, |
| 991 |
SFE_AIFF_PEAK_B4_COMM, |
| 992 |
SFE_AIFF_BAD_PEAK, |
| 993 |
SFE_AIFF_NO_SSND, |
| 994 |
SFE_AIFF_NO_DATA, |
| 995 |
SFE_AIFF_RW_SSND_NOT_LAST, |
| 996 |
|
| 997 |
SFE_AU_UNKNOWN_FORMAT, |
| 998 |
SFE_AU_NO_DOTSND, |
| 999 |
SFE_AU_EMBED_BAD_LEN, |
| 1000 |
|
| 1001 |
SFE_RAW_READ_BAD_SPEC, |
| 1002 |
SFE_RAW_BAD_BITWIDTH, |
| 1003 |
SFE_RAW_BAD_FORMAT, |
| 1004 |
|
| 1005 |
SFE_PAF_NO_MARKER, |
| 1006 |
SFE_PAF_VERSION, |
| 1007 |
SFE_PAF_UNKNOWN_FORMAT, |
| 1008 |
SFE_PAF_SHORT_HEADER, |
| 1009 |
|
| 1010 |
SFE_SVX_NO_FORM, |
| 1011 |
SFE_SVX_NO_BODY, |
| 1012 |
SFE_SVX_NO_DATA, |
| 1013 |
SFE_SVX_BAD_COMP, |
| 1014 |
SFE_SVX_BAD_NAME_LENGTH, |
| 1015 |
|
| 1016 |
SFE_NIST_BAD_HEADER, |
| 1017 |
SFE_NIST_CRLF_CONVERISON, |
| 1018 |
SFE_NIST_BAD_ENCODING, |
| 1019 |
|
| 1020 |
SFE_VOC_NO_CREATIVE, |
| 1021 |
SFE_VOC_BAD_FORMAT, |
| 1022 |
SFE_VOC_BAD_VERSION, |
| 1023 |
SFE_VOC_BAD_MARKER, |
| 1024 |
SFE_VOC_BAD_SECTIONS, |
| 1025 |
SFE_VOC_MULTI_SAMPLERATE, |
| 1026 |
SFE_VOC_MULTI_SECTION, |
| 1027 |
SFE_VOC_MULTI_PARAM, |
| 1028 |
SFE_VOC_SECTION_COUNT, |
| 1029 |
SFE_VOC_NO_PIPE, |
| 1030 |
|
| 1031 |
SFE_IRCAM_NO_MARKER, |
| 1032 |
SFE_IRCAM_BAD_CHANNELS, |
| 1033 |
SFE_IRCAM_UNKNOWN_FORMAT, |
| 1034 |
|
| 1035 |
SFE_W64_64_BIT, |
| 1036 |
SFE_W64_NO_RIFF, |
| 1037 |
SFE_W64_NO_WAVE, |
| 1038 |
SFE_W64_NO_FMT, |
| 1039 |
SFE_W64_NO_DATA, |
| 1040 |
SFE_W64_FMT_SHORT, |
| 1041 |
SFE_W64_FMT_TOO_BIG, |
| 1042 |
SFE_W64_ADPCM_NOT4BIT, |
| 1043 |
SFE_W64_ADPCM_CHANNELS, |
| 1044 |
SFE_W64_GSM610_FORMAT, |
| 1045 |
|
| 1046 |
SFE_MAT4_BAD_NAME, |
| 1047 |
SFE_MAT4_NO_SAMPLERATE, |
| 1048 |
SFE_MAT4_ZERO_CHANNELS, |
| 1049 |
|
| 1050 |
SFE_MAT5_BAD_ENDIAN, |
| 1051 |
SFE_MAT5_NO_BLOCK, |
| 1052 |
SFE_MAT5_SAMPLE_RATE, |
| 1053 |
SFE_MAT5_ZERO_CHANNELS, |
| 1054 |
|
| 1055 |
SFE_PVF_NO_PVF1, |
| 1056 |
SFE_PVF_BAD_HEADER, |
| 1057 |
SFE_PVF_BAD_BITWIDTH, |
| 1058 |
|
| 1059 |
SFE_DWVW_BAD_BITWIDTH, |
| 1060 |
SFE_G72X_NOT_MONO, |
| 1061 |
|
| 1062 |
SFE_XI_BAD_HEADER, |
| 1063 |
SFE_XI_EXCESS_SAMPLES, |
| 1064 |
SFE_XI_NO_PIPE, |
| 1065 |
|
| 1066 |
SFE_HTK_NO_PIPE, |
| 1067 |
|
| 1068 |
SFE_SDS_NOT_SDS, |
| 1069 |
SFE_SDS_BAD_BIT_WIDTH, |
| 1070 |
|
| 1071 |
SFE_MAX_ERROR |
| 1072 |
} ; |
| 1073 |
|
| 1074 |
int subformat_to_bytewidth (int format) ; |
| 1075 |
int s_bitwidth_to_subformat (int bits) ; |
| 1076 |
int u_bitwidth_to_subformat (int bits) ; |
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
float float32_be_read (unsigned char *cptr) ; |
| 1082 |
float float32_le_read (unsigned char *cptr) ; |
| 1083 |
void float32_be_write (float in, unsigned char *out) ; |
| 1084 |
void float32_le_write (float in, unsigned char *out) ; |
| 1085 |
|
| 1086 |
double double64_be_read (unsigned char *cptr) ; |
| 1087 |
double double64_le_read (unsigned char *cptr) ; |
| 1088 |
void double64_be_write (double in, unsigned char *out) ; |
| 1089 |
void double64_le_write (double in, unsigned char *out) ; |
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
void psf_log_printf (SF_PRIVATE *psf, const char *format, ...) ; |
| 1094 |
void psf_log_SF_INFO (SF_PRIVATE *psf) ; |
| 1095 |
|
| 1096 |
void psf_hexdump (void *ptr, int len) ; |
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
int psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...) ; |
| 1101 |
void psf_asciiheader_printf (SF_PRIVATE *psf, const char *format, ...) ; |
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
int psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...) ; |
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
void peak_update_short (SF_PRIVATE *psf, short *ptr, size_t items) ; |
| 1110 |
void peak_update_int (SF_PRIVATE *psf, int *ptr, size_t items) ; |
| 1111 |
void peak_update_double (SF_PRIVATE *psf, double *ptr, size_t items) ; |
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
int psf_get_format_simple_count (void) ; |
| 1116 |
int psf_get_format_simple (SF_FORMAT_INFO *data) ; |
| 1117 |
|
| 1118 |
int psf_get_format_info (SF_FORMAT_INFO *data) ; |
| 1119 |
|
| 1120 |
int psf_get_format_major_count (void) ; |
| 1121 |
int psf_get_format_major (SF_FORMAT_INFO *data) ; |
| 1122 |
|
| 1123 |
int psf_get_format_subtype_count (void) ; |
| 1124 |
int psf_get_format_subtype (SF_FORMAT_INFO *data) ; |
| 1125 |
|
| 1126 |
void psf_generate_format_desc (SF_PRIVATE *psf) ; |
| 1127 |
|
| 1128 |
double psf_calc_signal_max (SF_PRIVATE *psf, int normalize) ; |
| 1129 |
int psf_calc_max_all_channels (SF_PRIVATE *psf, double *peaks, int normalize) ; |
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
const char* psf_get_string (SF_PRIVATE *psf, int str_type) ; |
| 1134 |
int psf_store_string (SF_PRIVATE *psf, int str_type, const char *str) ; |
| 1135 |
|
| 1136 |
|
| 1137 |
sf_count_t psf_default_seek (SF_PRIVATE *psf, int mode, sf_count_t samples_from_start) ; |
| 1138 |
|
| 1139 |
|
| 1140 |
void psf_get_date_str (char *str, int maxlen) ; |
| 1141 |
|
| 1142 |
int macos_guess_file_type (SF_PRIVATE *psf, const char *filename) ; |
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
int psf_fopen (SF_PRIVATE *psf, const char *pathname, int flags) ; |
| 1150 |
int psf_set_stdio (SF_PRIVATE *psf, int mode) ; |
| 1151 |
int psf_filedes_valid (SF_PRIVATE *psf) ; |
| 1152 |
void psf_set_file (SF_PRIVATE *psf, int fd) ; |
| 1153 |
|
| 1154 |
sf_count_t psf_fseek (SF_PRIVATE *psf, sf_count_t offset, int whence) ; |
| 1155 |
sf_count_t psf_fread (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ; |
| 1156 |
sf_count_t psf_fwrite (void *ptr, sf_count_t bytes, sf_count_t count, SF_PRIVATE *psf) ; |
| 1157 |
sf_count_t psf_fgets (char *buffer, sf_count_t bufsize, SF_PRIVATE *psf) ; |
| 1158 |
sf_count_t psf_ftell (SF_PRIVATE *psf) ; |
| 1159 |
sf_count_t psf_get_filelen (SF_PRIVATE *psf) ; |
| 1160 |
|
| 1161 |
int psf_is_pipe (SF_PRIVATE *psf) ; |
| 1162 |
|
| 1163 |
int psf_ftruncate (SF_PRIVATE *psf, sf_count_t len) ; |
| 1164 |
int psf_fclose (SF_PRIVATE *psf) ; |
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
int aiff_open (SF_PRIVATE *psf) ; |
| 1176 |
#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) |
| 1177 |
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR |
| 1178 |
|
| 1179 |
#define au_open sf_au_open |
| 1180 |
#define au_close sf_au_close |
| 1181 |
#endif |
| 1182 |
#endif |
| 1183 |
int au_open (SF_PRIVATE *psf) ; |
| 1184 |
int au_nh_open (SF_PRIVATE *psf) ; |
| 1185 |
int avr_open (SF_PRIVATE *psf) ; |
| 1186 |
int htk_open (SF_PRIVATE *psf) ; |
| 1187 |
int ircam_open (SF_PRIVATE *psf) ; |
| 1188 |
int mat4_open (SF_PRIVATE *psf) ; |
| 1189 |
int mat5_open (SF_PRIVATE *psf) ; |
| 1190 |
int nist_open (SF_PRIVATE *psf) ; |
| 1191 |
int paf_open (SF_PRIVATE *psf) ; |
| 1192 |
int pvf_open (SF_PRIVATE *psf) ; |
| 1193 |
int raw_open (SF_PRIVATE *psf) ; |
| 1194 |
int sds_open (SF_PRIVATE *psf) ; |
| 1195 |
int svx_open (SF_PRIVATE *psf) ; |
| 1196 |
int voc_open (SF_PRIVATE *psf) ; |
| 1197 |
int w64_open (SF_PRIVATE *psf) ; |
| 1198 |
int wav_open (SF_PRIVATE *psf) ; |
| 1199 |
int xi_open (SF_PRIVATE *psf) ; |
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
int ogg_open (SF_PRIVATE *psf) ; |
| 1204 |
int rx2_open (SF_PRIVATE *psf) ; |
| 1205 |
int sd2_open (SF_PRIVATE *psf) ; |
| 1206 |
int txw_open (SF_PRIVATE *psf) ; |
| 1207 |
int wve_open (SF_PRIVATE *psf) ; |
| 1208 |
int dwd_open (SF_PRIVATE *psf) ; |
| 1209 |
|
| 1210 |
int macbinary3_open (SF_PRIVATE *psf) ; |
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
int pcm_init (SF_PRIVATE *psf) ; |
| 1217 |
int ulaw_init (SF_PRIVATE *psf) ; |
| 1218 |
int alaw_init (SF_PRIVATE *psf) ; |
| 1219 |
int float32_init (SF_PRIVATE *psf) ; |
| 1220 |
int double64_init (SF_PRIVATE *psf) ; |
| 1221 |
int dwvw_init (SF_PRIVATE *psf, int bitwidth) ; |
| 1222 |
int gsm610_init (SF_PRIVATE *psf) ; |
| 1223 |
int vox_adpcm_init (SF_PRIVATE *psf) ; |
| 1224 |
|
| 1225 |
int dither_init (SF_PRIVATE *psf, int mode) ; |
| 1226 |
|
| 1227 |
int wav_w64_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; |
| 1228 |
int wav_w64_msadpcm_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; |
| 1229 |
|
| 1230 |
int aiff_ima_init (SF_PRIVATE *psf, int blockalign, int samplesperblock) ; |
| 1231 |
|
| 1232 |
int interleave_init (SF_PRIVATE *psf) ; |
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
void *psf_memset (void *s, int c, sf_count_t n) ; |
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
#if (defined (WIN32) || defined (_WIN32)) |
| 1246 |
#define LSF_SNPRINTF _snprintf |
| 1247 |
|
| 1248 |
#define snprintf _snprintf //XXX really? |
| 1249 |
#elif (HAVE_SNPRINTF && ! FORCE_MISSING_SNPRINTF) |
| 1250 |
#define LSF_SNPRINTF snprintf |
| 1251 |
#else |
| 1252 |
int missing_snprintf (char *str, size_t n, char const *fmt, ...) ; |
| 1253 |
#define LSF_SNPRINTF missing_snprintf |
| 1254 |
#endif |
| 1255 |
|
| 1256 |
#if (defined (WIN32) || defined (_WIN32)) |
| 1257 |
#define LSF_VSNPRINTF _vsnprintf |
| 1258 |
#elif (HAVE_VSNPRINTF && ! FORCE_MISSING_SNPRINTF) |
| 1259 |
#define LSF_VSNPRINTF vsnprintf |
| 1260 |
#else |
| 1261 |
int missing_vsnprintf (char *str, size_t n, const char *fmt, ...) ; |
| 1262 |
#define LSF_VSNPRINTF missing_vsnprintf |
| 1263 |
#endif |
| 1264 |
|
| 1265 |
#endif |
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
enum |
| 1272 |
{ SFC_TEST_AIFF_ADD_INST_CHUNK = 0x2000, |
| 1273 |
SFC_TEST_WAV_ADD_INFO_CHUNK = 0x2010 |
| 1274 |
} ; |
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
#if 0 |
| 1284 |
int sf_dither_short (const SF_DITHER_INFO *dither, const short *in, short *out, int count) ; |
| 1285 |
int sf_dither_int (const SF_DITHER_INFO *dither, const int *in, int *out, int count) ; |
| 1286 |
int sf_dither_float (const SF_DITHER_INFO *dither, const float *in, float *out, int count) ; |
| 1287 |
int sf_dither_double (const SF_DITHER_INFO *dither, const double *in, double *out, int count) ; |
| 1288 |
#endif |
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
#ifndef G72X_HEADER_FILE |
| 1321 |
#define G72X_HEADER_FILE |
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
#define G72x_BLOCK_SIZE (3*5*8) |
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
enum |
| 1335 |
{ G723_16_BITS_PER_SAMPLE = 2, |
| 1336 |
G723_24_BITS_PER_SAMPLE = 3, |
| 1337 |
G723_40_BITS_PER_SAMPLE = 5, |
| 1338 |
|
| 1339 |
G721_32_BITS_PER_SAMPLE = 4, |
| 1340 |
G721_40_BITS_PER_SAMPLE = 5, |
| 1341 |
|
| 1342 |
G723_16_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 1343 |
G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), |
| 1344 |
G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), |
| 1345 |
|
| 1346 |
G721_32_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 1347 |
G721_40_SAMPLES_PER_BLOCK = G721_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G721_40_BITS_PER_SAMPLE), |
| 1348 |
|
| 1349 |
G723_16_BYTES_PER_BLOCK = (G723_16_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 1350 |
G723_24_BYTES_PER_BLOCK = (G723_24_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 1351 |
G723_40_BYTES_PER_BLOCK = (G723_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 1352 |
|
| 1353 |
G721_32_BYTES_PER_BLOCK = (G721_32_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 1354 |
G721_40_BYTES_PER_BLOCK = (G721_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8 |
| 1355 |
} ; |
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
typedef struct |
| 1368 |
{ |
| 1369 |
unsigned long sprivateo [256 / sizeof (long)] ; |
| 1370 |
|
| 1371 |
|
| 1372 |
int blocksize, max_bytes, samplesperblock, bytesperblock ; |
| 1373 |
|
| 1374 |
|
| 1375 |
int blocks, blockcount, samplecount ; |
| 1376 |
unsigned char block [G72x_BLOCK_SIZE] ; |
| 1377 |
short samples [G72x_BLOCK_SIZE] ; |
| 1378 |
} G72x_DATA ; |
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
int g72x_reader_init (G72x_DATA *data, int codec) ; |
| 1383 |
int g72x_writer_init (G72x_DATA *data, int codec) ; |
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
int g72x_decode_block (G72x_DATA *data) ; |
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
int g72x_encode_block (G72x_DATA *data) ; |
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
#endif |
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
#ifndef G72X_PRIVATE_H |
| 1440 |
#define G72X_PRIVATE_H |
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
typedef struct private_g72x |
| 1454 |
{ long yl; |
| 1455 |
short yu; |
| 1456 |
short dms; |
| 1457 |
short dml; |
| 1458 |
short ap; |
| 1459 |
|
| 1460 |
short a[2]; |
| 1461 |
short b[6]; |
| 1462 |
short pk[2]; |
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
short dq[6]; |
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
short sr[2]; |
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
char td; |
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
int (*encoder) (int, struct private_g72x* state) ; |
| 1485 |
int (*decoder) (int, struct private_g72x* state) ; |
| 1486 |
|
| 1487 |
int codec_bits ; |
| 1488 |
int byte_index, sample_index ; |
| 1489 |
|
| 1490 |
} G72x_STATE ; |
| 1491 |
|
| 1492 |
|
| 1493 |
|
| 1494 |
int predictor_zero (G72x_STATE *state_ptr); |
| 1495 |
|
| 1496 |
int predictor_pole (G72x_STATE *state_ptr); |
| 1497 |
|
| 1498 |
int step_size (G72x_STATE *state_ptr); |
| 1499 |
|
| 1500 |
int quantize (int d, int y, short *table, int size); |
| 1501 |
|
| 1502 |
int reconstruct (int sign, int dqln, int y); |
| 1503 |
|
| 1504 |
void update (int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, G72x_STATE *state_ptr); |
| 1505 |
|
| 1506 |
int g721_encoder (int sample, G72x_STATE *state_ptr); |
| 1507 |
int g721_decoder (int code, G72x_STATE *state_ptr); |
| 1508 |
|
| 1509 |
int g723_16_encoder (int sample, G72x_STATE *state_ptr); |
| 1510 |
int g723_16_decoder (int code, G72x_STATE *state_ptr); |
| 1511 |
|
| 1512 |
int g723_24_encoder (int sample, G72x_STATE *state_ptr); |
| 1513 |
int g723_24_decoder (int code, G72x_STATE *state_ptr); |
| 1514 |
|
| 1515 |
int g723_40_encoder (int sample, G72x_STATE *state_ptr); |
| 1516 |
int g723_40_decoder (int code, G72x_STATE *state_ptr); |
| 1517 |
|
| 1518 |
int unpack_bytes (G72x_DATA *data, int bits) ; |
| 1519 |
int pack_bytes (G72x_DATA *data, int bits) ; |
| 1520 |
|
| 1521 |
void private_init_state (G72x_STATE *state_ptr) ; |
| 1522 |
|
| 1523 |
#endif |
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
#if (CPU_IS_LITTLE_ENDIAN == 1) |
| 1559 |
#define MAKE_MARKER(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24)) |
| 1560 |
#elif (CPU_IS_BIG_ENDIAN == 1) |
| 1561 |
#define MAKE_MARKER(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d)) |
| 1562 |
#else |
| 1563 |
#error "Target CPU endian-ness unknown. May need to hand edit src/config.h" |
| 1564 |
#endif |
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
#define ENDSWAP_SHORT(x) ((((x)>>8)&0xFF)+(((x)&0xFF)<<8)) |
| 1569 |
#define ENDSWAP_INT(x) ((((x)>>24)&0xFF)+(((x)>>8)&0xFF00)+(((x)&0xFF00)<<8)+(((x)&0xFF)<<24)) |
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
#if (CPU_IS_LITTLE_ENDIAN == 1) |
| 1578 |
#define LES2H_SHORT(x) (x) |
| 1579 |
#define LEI2H_INT(x) (x) |
| 1580 |
|
| 1581 |
#define BES2H_SHORT(x) ENDSWAP_SHORT(x) |
| 1582 |
#define BEI2H_INT(x) ENDSWAP_INT(x) |
| 1583 |
|
| 1584 |
#elif (CPU_IS_BIG_ENDIAN == 1) |
| 1585 |
#define LES2H_SHORT(x) ENDSWAP_SHORT(x) |
| 1586 |
#define LEI2H_INT(x) ENDSWAP_INT(x) |
| 1587 |
|
| 1588 |
#define BES2H_SHORT(x) (x) |
| 1589 |
#define BEI2H_INT(x) (x) |
| 1590 |
|
| 1591 |
#else |
| 1592 |
#error "Target CPU endian-ness unknown. May need to hand edit src/config.h" |
| 1593 |
#endif |
| 1594 |
|
| 1595 |
#define LES2H_SHORT_PTR(x) ((x) [0] + ((x) [1] << 8)) |
| 1596 |
#define LES2H_INT_PTR(x) (((x) [0] << 16) + ((x) [1] << 24)) |
| 1597 |
|
| 1598 |
#define LET2H_SHORT_PTR(x) ((x) [1] + ((x) [2] << 8)) |
| 1599 |
#define LET2H_INT_PTR(x) (((x) [0] << 8) + ((x) [1] << 16) + ((x) [2] << 24)) |
| 1600 |
|
| 1601 |
#define LEI2H_SHORT_PTR(x) ((x) [2] + ((x) [3] << 8)) |
| 1602 |
#define LEI2H_INT_PTR(x) ((x) [0] + ((x) [1] << 8) + ((x) [2] << 16) + ((x) [3] << 24)) |
| 1603 |
|
| 1604 |
#define BES2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1]) |
| 1605 |
#define BES2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16)) |
| 1606 |
|
| 1607 |
#define BET2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1]) |
| 1608 |
#define BET2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8)) |
| 1609 |
|
| 1610 |
#define BEI2H_SHORT_PTR(x) (((x) [0] << 8) + (x) [1]) |
| 1611 |
#define BEI2H_INT_PTR(x) (((x) [0] << 24) + ((x) [1] << 16) + ((x) [2] << 8) + (x) [3]) |
| 1612 |
|
| 1613 |
|
| 1614 |
|
| 1615 |
void endswap_short_array (short *ptr, int len) ; |
| 1616 |
void endswap_int_array (int *ptr, int len) ; |
| 1617 |
|
| 1618 |
|
| 1619 |
void endswap_long_array (long *ptr, int len) ; |
| 1620 |
|
| 1621 |
void endswap_short_copy (short *dest, short *src, int len) ; |
| 1622 |
void endswap_int_copy (int *dest, int *src, int len) ; |
| 1623 |
|
| 1624 |
|
| 1625 |
void endswap_long_copy (long *dest, long *src, int len) ; |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
#ifndef GSM_H |
| 1641 |
#define GSM_H |
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
typedef struct gsm_state * gsm; |
| 1649 |
typedef short gsm_signal; |
| 1650 |
typedef unsigned char gsm_byte; |
| 1651 |
typedef gsm_byte gsm_frame[33]; |
| 1652 |
|
| 1653 |
#define GSM_MAGIC 0xD |
| 1654 |
|
| 1655 |
#define GSM_PATCHLEVEL 10 |
| 1656 |
#define GSM_MINOR 0 |
| 1657 |
#define GSM_MAJOR 1 |
| 1658 |
|
| 1659 |
#define GSM_OPT_VERBOSE 1 |
| 1660 |
#define GSM_OPT_FAST 2 |
| 1661 |
#define GSM_OPT_LTP_CUT 3 |
| 1662 |
#define GSM_OPT_WAV49 4 |
| 1663 |
#define GSM_OPT_FRAME_INDEX 5 |
| 1664 |
#define GSM_OPT_FRAME_CHAIN 6 |
| 1665 |
|
| 1666 |
gsm gsm_create (void); |
| 1667 |
|
| 1668 |
|
| 1669 |
void gsm_init (gsm); |
| 1670 |
|
| 1671 |
void gsm_destroy (gsm); |
| 1672 |
|
| 1673 |
int gsm_print (FILE *, gsm, gsm_byte *); |
| 1674 |
int gsm_option (gsm, int, int *); |
| 1675 |
|
| 1676 |
void gsm_encode (gsm, gsm_signal *, gsm_byte *); |
| 1677 |
int gsm_decode (gsm, gsm_byte *, gsm_signal *); |
| 1678 |
|
| 1679 |
int gsm_explode (gsm, gsm_byte *, gsm_signal *); |
| 1680 |
void gsm_implode (gsm, gsm_signal *, gsm_byte *); |
| 1681 |
|
| 1682 |
#endif |
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
|
| 1709 |
#ifndef AU_HEADER_FILE |
| 1710 |
#define AU_HEADER_FILE |
| 1711 |
|
| 1712 |
|
| 1713 |
enum |
| 1714 |
{ AU_H_G721_32 = 200, |
| 1715 |
AU_H_G723_24 = 201, |
| 1716 |
AU_H_G723_40 = 202 |
| 1717 |
} ; |
| 1718 |
|
| 1719 |
int au_g72x_reader_init (SF_PRIVATE *psf, int codec) ; |
| 1720 |
int au_g72x_writer_init (SF_PRIVATE *psf, int codec) ; |
| 1721 |
|
| 1722 |
#endif |
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
|
| 1751 |
#ifndef WAV_W64_H_INCLUDED |
| 1752 |
#define WAV_W64_H_INCLUDED |
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
enum |
| 1759 |
{ |
| 1760 |
|
| 1761 |
WAVE_FORMAT_UNKNOWN = 0x0000, |
| 1762 |
WAVE_FORMAT_MS_PCM = 0x0001, |
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
WAVE_FORMAT_MS_ADPCM = 0x0002, |
| 1770 |
WAVE_FORMAT_IEEE_FLOAT = 0x0003, |
| 1771 |
WAVE_FORMAT_VSELP = 0x0004, |
| 1772 |
WAVE_FORMAT_IBM_CVSD = 0x0005, |
| 1773 |
WAVE_FORMAT_ALAW = 0x0006, |
| 1774 |
WAVE_FORMAT_MULAW = 0x0007, |
| 1775 |
WAVE_FORMAT_OKI_ADPCM = 0x0010, |
| 1776 |
WAVE_FORMAT_IMA_ADPCM = 0x0011, |
| 1777 |
WAVE_FORMAT_MEDIASPACE_ADPCM = 0x0012, |
| 1778 |
WAVE_FORMAT_SIERRA_ADPCM = 0x0013, |
| 1779 |
WAVE_FORMAT_G723_ADPCM = 0x0014, |
| 1780 |
WAVE_FORMAT_DIGISTD = 0x0015, |
| 1781 |
WAVE_FORMAT_DIGIFIX = 0x0016, |
| 1782 |
WAVE_FORMAT_DIALOGIC_OKI_ADPCM = 0x0017, |
| 1783 |
WAVE_FORMAT_MEDIAVISION_ADPCM = 0x0018, |
| 1784 |
WAVE_FORMAT_CU_CODEC = 0x0019, |
| 1785 |
WAVE_FORMAT_YAMAHA_ADPCM = 0x0020, |
| 1786 |
WAVE_FORMAT_SONARC = 0x0021, |
| 1787 |
WAVE_FORMAT_DSPGROUP_TRUESPEECH = 0x0022, |
| 1788 |
WAVE_FORMAT_ECHOSC1 = 0x0023, |
| 1789 |
WAVE_FORMAT_AUDIOFILE_AF36 = 0x0024, |
| 1790 |
WAVE_FORMAT_APTX = 0x0025, |
| 1791 |
WAVE_FORMAT_AUDIOFILE_AF10 = 0x0026, |
| 1792 |
WAVE_FORMAT_PROSODY_1612 = 0x0027, |
| 1793 |
WAVE_FORMAT_LRC = 0x0028, |
| 1794 |
WAVE_FORMAT_DOLBY_AC2 = 0x0030, |
| 1795 |
WAVE_FORMAT_GSM610 = 0x0031, |
| 1796 |
WAVE_FORMAT_MSNAUDIO = 0x0032, |
| 1797 |
WAVE_FORMAT_ANTEX_ADPCME = 0x0033, |
| 1798 |
WAVE_FORMAT_CONTROL_RES_VQLPC = 0x0034, |
| 1799 |
WAVE_FORMAT_DIGIREAL = 0x0035, |
| 1800 |
WAVE_FORMAT_DIGIADPCM = 0x0036, |
| 1801 |
WAVE_FORMAT_CONTROL_RES_CR10 = 0x0037, |
| 1802 |
WAVE_FORMAT_NMS_VBXADPCM = 0x0038, |
| 1803 |
WAVE_FORMAT_ROLAND_RDAC = 0x0039, |
| 1804 |
WAVE_FORMAT_ECHOSC3 = 0x003A, |
| 1805 |
WAVE_FORMAT_ROCKWELL_ADPCM = 0x003B, |
| 1806 |
WAVE_FORMAT_ROCKWELL_DIGITALK = 0x003C, |
| 1807 |
WAVE_FORMAT_XEBEC = 0x003D, |
| 1808 |
WAVE_FORMAT_G721_ADPCM = 0x0040, |
| 1809 |
WAVE_FORMAT_G728_CELP = 0x0041, |
| 1810 |
WAVE_FORMAT_MSG723 = 0x0042, |
| 1811 |
WAVE_FORMAT_MPEG = 0x0050, |
| 1812 |
WAVE_FORMAT_RT24 = 0x0052, |
| 1813 |
WAVE_FORMAT_PAC = 0x0053, |
| 1814 |
WAVE_FORMAT_MPEGLAYER3 = 0x0055, |
| 1815 |
WAVE_FORMAT_LUCENT_G723 = 0x0059, |
| 1816 |
WAVE_FORMAT_CIRRUS = 0x0060, |
| 1817 |
WAVE_FORMAT_ESPCM = 0x0061, |
| 1818 |
WAVE_FORMAT_VOXWARE = 0x0062, |
| 1819 |
WAVE_FORMAT_CANOPUS_ATRAC = 0x0063, |
| 1820 |
WAVE_FORMAT_G726_ADPCM = 0x0064, |
| 1821 |
WAVE_FORMAT_G722_ADPCM = 0x0065, |
| 1822 |
WAVE_FORMAT_DSAT = 0x0066, |
| 1823 |
WAVE_FORMAT_DSAT_DISPLAY = 0x0067, |
| 1824 |
WAVE_FORMAT_VOXWARE_BYTE_ALIGNED = 0x0069, |
| 1825 |
WAVE_FORMAT_VOXWARE_AC8 = 0x0070, |
| 1826 |
WAVE_FORMAT_VOXWARE_AC10 = 0x0071, |
| 1827 |
WAVE_FORMAT_VOXWARE_AC16 = 0x0072, |
| 1828 |
WAVE_FORMAT_VOXWARE_AC20 = 0x0073, |
| 1829 |
WAVE_FORMAT_VOXWARE_RT24 = 0x0074, |
| 1830 |
WAVE_FORMAT_VOXWARE_RT29 = 0x0075, |
| 1831 |
WAVE_FORMAT_VOXWARE_RT29HW = 0x0076, |
| 1832 |
WAVE_FORMAT_VOXWARE_VR12 = 0x0077, |
| 1833 |
WAVE_FORMAT_VOXWARE_VR18 = 0x0078, |
| 1834 |
WAVE_FORMAT_VOXWARE_TQ40 = 0x0079, |
| 1835 |
WAVE_FORMAT_SOFTSOUND = 0x0080, |
| 1836 |
WAVE_FORMAT_VOXARE_TQ60 = 0x0081, |
| 1837 |
WAVE_FORMAT_MSRT24 = 0x0082, |
| 1838 |
WAVE_FORMAT_G729A = 0x0083, |
| 1839 |
WAVE_FORMAT_MVI_MV12 = 0x0084, |
| 1840 |
WAVE_FORMAT_DF_G726 = 0x0085, |
| 1841 |
WAVE_FORMAT_DF_GSM610 = 0x0086, |
| 1842 |
|
| 1843 |
|
| 1844 |
WAVE_FORMAT_ONLIVE = 0x0089, |
| 1845 |
WAVE_FORMAT_SBC24 = 0x0091, |
| 1846 |
WAVE_FORMAT_DOLBY_AC3_SPDIF = 0x0092, |
| 1847 |
WAVE_FORMAT_ZYXEL_ADPCM = 0x0097, |
| 1848 |
WAVE_FORMAT_PHILIPS_LPCBB = 0x0098, |
| 1849 |
WAVE_FORMAT_PACKED = 0x0099, |
| 1850 |
WAVE_FORMAT_RHETOREX_ADPCM = 0x0100, |
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
IBM_FORMAT_MULAW = 0x0101, |
| 1857 |
IBM_FORMAT_ALAW = 0x0102, |
| 1858 |
IBM_FORMAT_ADPCM = 0x0103, |
| 1859 |
|
| 1860 |
WAVE_FORMAT_VIVO_G723 = 0x0111, |
| 1861 |
WAVE_FORMAT_VIVO_SIREN = 0x0112, |
| 1862 |
WAVE_FORMAT_DIGITAL_G723 = 0x0123, |
| 1863 |
WAVE_FORMAT_CREATIVE_ADPCM = 0x0200, |
| 1864 |
WAVE_FORMAT_CREATIVE_FASTSPEECH8 = 0x0202, |
| 1865 |
WAVE_FORMAT_CREATIVE_FASTSPEECH10 = 0x0203, |
| 1866 |
WAVE_FORMAT_QUARTERDECK = 0x0220, |
| 1867 |
WAVE_FORMAT_FM_TOWNS_SND = 0x0300, |
| 1868 |
WAVE_FORMAT_BZV_DIGITAL = 0x0400, |
| 1869 |
WAVE_FORMAT_VME_VMPCM = 0x0680, |
| 1870 |
WAVE_FORMAT_OLIGSM = 0x1000, |
| 1871 |
WAVE_FORMAT_OLIADPCM = 0x1001, |
| 1872 |
WAVE_FORMAT_OLICELP = 0x1002, |
| 1873 |
WAVE_FORMAT_OLISBC = 0x1003, |
| 1874 |
WAVE_FORMAT_OLIOPR = 0x1004, |
| 1875 |
WAVE_FORMAT_LH_CODEC = 0x1100, |
| 1876 |
WAVE_FORMAT_NORRIS = 0x1400, |
| 1877 |
|
| 1878 |
|
| 1879 |
WAVE_FORMAT_SOUNDSPACE_MUSICOMPRESS = 0x1500, |
| 1880 |
WAVE_FORMAT_DVM = 0x2000, |
| 1881 |
WAVE_FORMAT_INTERWAV_VSC112 = 0x7150, |
| 1882 |
WAVE_FORMAT_EXTENSIBLE = 0xFFFE |
| 1883 |
} ; |
| 1884 |
|
| 1885 |
typedef struct |
| 1886 |
{ unsigned short format ; |
| 1887 |
unsigned short channels ; |
| 1888 |
unsigned int samplerate ; |
| 1889 |
unsigned int bytespersec ; |
| 1890 |
unsigned short blockalign ; |
| 1891 |
unsigned short bitwidth ; |
| 1892 |
} MIN_WAV_FMT ; |
| 1893 |
|
| 1894 |
typedef struct |
| 1895 |
{ unsigned short format ; |
| 1896 |
unsigned short channels ; |
| 1897 |
unsigned int samplerate ; |
| 1898 |
unsigned int bytespersec ; |
| 1899 |
unsigned short blockalign ; |
| 1900 |
unsigned short bitwidth ; |
| 1901 |
unsigned short extrabytes ; |
| 1902 |
unsigned short dummy ; |
| 1903 |
} WAV_FMT_SIZE20 ; |
| 1904 |
|
| 1905 |
typedef struct |
| 1906 |
{ unsigned short format ; |
| 1907 |
unsigned short channels ; |
| 1908 |
unsigned int samplerate ; |
| 1909 |
unsigned int bytespersec ; |
| 1910 |
unsigned short blockalign ; |
| 1911 |
unsigned short bitwidth ; |
| 1912 |
unsigned short extrabytes ; |
| 1913 |
unsigned short samplesperblock ; |
| 1914 |
unsigned short numcoeffs ; |
| 1915 |
struct |
| 1916 |
{ short coeff1 ; |
| 1917 |
short coeff2 ; |
| 1918 |
} coeffs [7] ; |
| 1919 |
} MS_ADPCM_WAV_FMT ; |
| 1920 |
|
| 1921 |
typedef struct |
| 1922 |
{ unsigned short format ; |
| 1923 |
unsigned short channels ; |
| 1924 |
unsigned int samplerate ; |
| 1925 |
unsigned int bytespersec ; |
| 1926 |
unsigned short blockalign ; |
| 1927 |
unsigned short bitwidth ; |
| 1928 |
unsigned short extrabytes ; |
| 1929 |
unsigned short samplesperblock ; |
| 1930 |
} IMA_ADPCM_WAV_FMT ; |
| 1931 |
|
| 1932 |
typedef struct |
| 1933 |
{ unsigned short format ; |
| 1934 |
unsigned short channels ; |
| 1935 |
unsigned int samplerate ; |
| 1936 |
unsigned int bytespersec ; |
| 1937 |
unsigned short blockalign ; |
| 1938 |
unsigned short bitwidth ; |
| 1939 |
unsigned short extrabytes ; |
| 1940 |
unsigned short auxblocksize ; |
| 1941 |
} G72x_ADPCM_WAV_FMT ; |
| 1942 |
|
| 1943 |
|
| 1944 |
typedef struct |
| 1945 |
{ unsigned short format ; |
| 1946 |
unsigned short channels ; |
| 1947 |
unsigned int samplerate ; |
| 1948 |
unsigned int bytespersec ; |
| 1949 |
unsigned short blockalign ; |
| 1950 |
unsigned short bitwidth ; |
| 1951 |
unsigned short extrabytes ; |
| 1952 |
unsigned short samplesperblock ; |
| 1953 |
} GSM610_WAV_FMT ; |
| 1954 |
|
| 1955 |
typedef struct |
| 1956 |
{ unsigned int esf_field1 ; |
| 1957 |
unsigned short esf_field2 ; |
| 1958 |
unsigned short esf_field3 ; |
| 1959 |
char esf_field4 [8] ; |
| 1960 |
} EXT_SUBFORMAT ; |
| 1961 |
|
| 1962 |
typedef struct |
| 1963 |
{ unsigned short format ; |
| 1964 |
unsigned short channels ; |
| 1965 |
unsigned int samplerate ; |
| 1966 |
unsigned int bytespersec ; |
| 1967 |
unsigned short blockalign ; |
| 1968 |
unsigned short bitwidth ; |
| 1969 |
unsigned short extrabytes ; |
| 1970 |
unsigned short validbits ; |
| 1971 |
unsigned int channelmask ; |
| 1972 |
EXT_SUBFORMAT esf ; |
| 1973 |
} EXTENSIBLE_WAV_FMT ; |
| 1974 |
|
| 1975 |
typedef union |
| 1976 |
{ unsigned short format ; |
| 1977 |
MIN_WAV_FMT min ; |
| 1978 |
IMA_ADPCM_WAV_FMT ima ; |
| 1979 |
MS_ADPCM_WAV_FMT msadpcm ; |
| 1980 |
G72x_ADPCM_WAV_FMT g72x ; |
| 1981 |
EXTENSIBLE_WAV_FMT ext ; |
| 1982 |
GSM610_WAV_FMT gsm610 ; |
| 1983 |
WAV_FMT_SIZE20 size20 ; |
| 1984 |
char padding [512] ; |
| 1985 |
} WAV_FMT ; |
| 1986 |
|
| 1987 |
typedef struct |
| 1988 |
{ int frames ; |
| 1989 |
} FACT_CHUNK ; |
| 1990 |
|
| 1991 |
#define WAV_W64_GSM610_BLOCKSIZE 65 |
| 1992 |
#define WAV_W64_GSM610_SAMPLES 320 |
| 1993 |
|
| 1994 |
|
| 1995 |
|
| 1996 |
|
| 1997 |
|
| 1998 |
#define MSADPCM_ADAPT_COEFF_COUNT 7 |
| 1999 |
|
| 2000 |
void msadpcm_write_adapt_coeffs (SF_PRIVATE *psf) ; |
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
int wav_w64_srate2blocksize (int srate_chan_product) ; |
| 2007 |
char const* wav_w64_format_str (int k) ; |
| 2008 |
int wav_w64_read_fmt_chunk (SF_PRIVATE *psf, WAV_FMT *wav_fmt, int structsize) ; |
| 2009 |
|
| 2010 |
#endif |
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
|
| 2015 |
|
| 2016 |
|
| 2017 |
|
| 2018 |
|
| 2019 |
|
| 2020 |
|
| 2021 |
|
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
|
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
|
| 2034 |
|
| 2035 |
|
| 2036 |
|
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
|
| 2042 |
#ifndef G72X_HEADER_FILE |
| 2043 |
#define G72X_HEADER_FILE |
| 2044 |
|
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
|
| 2049 |
#define G72x_BLOCK_SIZE (3*5*8) |
| 2050 |
|
| 2051 |
|
| 2052 |
|
| 2053 |
|
| 2054 |
|
| 2055 |
|
| 2056 |
enum |
| 2057 |
{ G723_16_BITS_PER_SAMPLE = 2, |
| 2058 |
G723_24_BITS_PER_SAMPLE = 3, |
| 2059 |
G723_40_BITS_PER_SAMPLE = 5, |
| 2060 |
|
| 2061 |
G721_32_BITS_PER_SAMPLE = 4, |
| 2062 |
G721_40_BITS_PER_SAMPLE = 5, |
| 2063 |
|
| 2064 |
G723_16_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 2065 |
G723_24_SAMPLES_PER_BLOCK = G723_24_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_24_BITS_PER_SAMPLE), |
| 2066 |
G723_40_SAMPLES_PER_BLOCK = G723_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G723_40_BITS_PER_SAMPLE), |
| 2067 |
|
| 2068 |
G721_32_SAMPLES_PER_BLOCK = G72x_BLOCK_SIZE, |
| 2069 |
G721_40_SAMPLES_PER_BLOCK = G721_40_BITS_PER_SAMPLE * (G72x_BLOCK_SIZE / G721_40_BITS_PER_SAMPLE), |
| 2070 |
|
| 2071 |
G723_16_BYTES_PER_BLOCK = (G723_16_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 2072 |
G723_24_BYTES_PER_BLOCK = (G723_24_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 2073 |
G723_40_BYTES_PER_BLOCK = (G723_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 2074 |
|
| 2075 |
G721_32_BYTES_PER_BLOCK = (G721_32_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8, |
| 2076 |
G721_40_BYTES_PER_BLOCK = (G721_40_BITS_PER_SAMPLE * G72x_BLOCK_SIZE) / 8 |
| 2077 |
} ; |
| 2078 |
|
| 2079 |
|
| 2080 |
|
| 2081 |
|
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
|
| 2088 |
|
| 2089 |
typedef struct |
| 2090 |
{ |
| 2091 |
unsigned long sprivateo [256 / sizeof (long)] ; |
| 2092 |
|
| 2093 |
|
| 2094 |
int blocksize, max_bytes, samplesperblock, bytesperblock ; |
| 2095 |
|
| 2096 |
|
| 2097 |
int blocks, blockcount, samplecount ; |
| 2098 |
unsigned char block [G72x_BLOCK_SIZE] ; |
| 2099 |
short samples [G72x_BLOCK_SIZE] ; |
| 2100 |
} G72x_DATA ; |
| 2101 |
|
| 2102 |
|
| 2103 |
|
| 2104 |
int g72x_reader_init (G72x_DATA *data, int codec) ; |
| 2105 |
int g72x_writer_init (G72x_DATA *data, int codec) ; |
| 2106 |
|
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
int g72x_decode_block (G72x_DATA *data) ; |
| 2112 |
|
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
|
| 2117 |
|
| 2118 |
|
| 2119 |
int g72x_encode_block (G72x_DATA *data) ; |
| 2120 |
|
| 2121 |
|
| 2122 |
|
| 2123 |
|
| 2124 |
|
| 2125 |
|
| 2126 |
#endif |
| 2127 |
|
| 2128 |
|
| 2129 |
|
| 2130 |
|
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
|
| 2137 |
|
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
#ifndef PRIVATE_H |
| 2142 |
#define PRIVATE_H |
| 2143 |
|
| 2144 |
|
| 2145 |
#define USE_FLOAT_MUL |
| 2146 |
#define FAST |
| 2147 |
#define WAV49 |
| 2148 |
|
| 2149 |
|
| 2150 |
|
| 2151 |
|
| 2152 |
typedef short word; |
| 2153 |
typedef int longword; |
| 2154 |
|
| 2155 |
typedef unsigned short uword; |
| 2156 |
typedef unsigned int ulongword; |
| 2157 |
|
| 2158 |
struct gsm_state |
| 2159 |
{ word dp0[ 280 ] ; |
| 2160 |
|
| 2161 |
word z1; |
| 2162 |
longword L_z2; |
| 2163 |
int mp; |
| 2164 |
|
| 2165 |
word u[8] ; |
| 2166 |
word LARpp[2][8] ; |
| 2167 |
word j; |
| 2168 |
|
| 2169 |
word ltp_cut; |
| 2170 |
word nrp; |
| 2171 |
word v[9] ; |
| 2172 |
word msr; |
| 2173 |
|
| 2174 |
char verbose; |
| 2175 |
char fast; |
| 2176 |
|
| 2177 |
char wav_fmt; |
| 2178 |
unsigned char frame_index; |
| 2179 |
unsigned char frame_chain; |
| 2180 |
|
| 2181 |
|
| 2182 |
word e[50] ; |
| 2183 |
} ; |
| 2184 |
|
| 2185 |
typedef struct gsm_state GSM_STATE ; |
| 2186 |
|
| 2187 |
#define MIN_WORD (-32767 - 1) |
| 2188 |
#define MAX_WORD 32767 |
| 2189 |
|
| 2190 |
#define MIN_LONGWORD (-2147483647 - 1) |
| 2191 |
#define MAX_LONGWORD 2147483647 |
| 2192 |
|
| 2193 |
|
| 2194 |
static C_INLINE word |
| 2195 |
SASR_W (word x, word by) |
| 2196 |
{ return (x >> by) ; |
| 2197 |
} |
| 2198 |
|
| 2199 |
static C_INLINE longword |
| 2200 |
SASR_L (longword x, word by) |
| 2201 |
{ return (x >> by) ; |
| 2202 |
} |
| 2203 |
|
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
word gsm_mult (word a, word b) ; |
| 2208 |
longword gsm_L_mult (word a, word b) ; |
| 2209 |
word gsm_mult_r (word a, word b) ; |
| 2210 |
|
| 2211 |
word gsm_div (word num, word denum) ; |
| 2212 |
|
| 2213 |
word gsm_add (word a, word b ) ; |
| 2214 |
longword gsm_L_add (longword a, longword b ) ; |
| 2215 |
|
| 2216 |
word gsm_sub (word a, word b) ; |
| 2217 |
longword gsm_L_sub (longword a, longword b) ; |
| 2218 |
|
| 2219 |
word gsm_abs (word a) ; |
| 2220 |
|
| 2221 |
word gsm_norm (longword a ) ; |
| 2222 |
|
| 2223 |
longword gsm_L_asl (longword a, int n) ; |
| 2224 |
word gsm_asl (word a, int n) ; |
| 2225 |
|
| 2226 |
longword gsm_L_asr (longword a, int n) ; |
| 2227 |
word gsm_asr (word a, int n) ; |
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
|
| 2233 |
static C_INLINE longword |
| 2234 |
GSM_MULT_R (word a, word b) |
| 2235 |
{ return (((longword) (a)) * ((longword) (b)) + 16384) >> 15 ; |
| 2236 |
} |
| 2237 |
|
| 2238 |
static C_INLINE longword |
| 2239 |
GSM_MULT (word a, word b) |
| 2240 |
{ return (((longword) (a)) * ((longword) (b))) >> 15 ; |
| 2241 |
} |
| 2242 |
|
| 2243 |
static C_INLINE longword |
| 2244 |
GSM_L_MULT (word a, word b) |
| 2245 |
{ return ((longword) (a)) * ((longword) (b)) << 1 ; |
| 2246 |
} |
| 2247 |
|
| 2248 |
static C_INLINE longword |
| 2249 |
GSM_L_ADD (longword a, longword b) |
| 2250 |
{ ulongword utmp ; |
| 2251 |
|
| 2252 |
if (a < 0 && b < 0) |
| 2253 |
{ utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1) ; |
| 2254 |
return (utmp >= (ulongword) MAX_LONGWORD) ? MIN_LONGWORD : -(longword)utmp-2 ; |
| 2255 |
} ; |
| 2256 |
|
| 2257 |
if (a > 0 && b > 0) |
| 2258 |
{ utmp = (ulongword) a + (ulongword) b ; |
| 2259 |
return (utmp >= (ulongword) MAX_LONGWORD) ? MAX_LONGWORD : utmp ; |
| 2260 |
} ; |
| 2261 |
|
| 2262 |
return a + b ; |
| 2263 |
} |
| 2264 |
|
| 2265 |
static C_INLINE longword |
| 2266 |
GSM_ADD (word a, word b) |
| 2267 |
{ longword ltmp ; |
| 2268 |
|
| 2269 |
ltmp = ((longword) a) + ((longword) b) ; |
| 2270 |
|
| 2271 |
if (ltmp >= MAX_WORD) |
| 2272 |
return MAX_WORD ; |
| 2273 |
if (ltmp <= MIN_WORD) |
| 2274 |
return MIN_WORD ; |
| 2275 |
|
| 2276 |
return ltmp ; |
| 2277 |
} |
| 2278 |
|
| 2279 |
static C_INLINE longword |
| 2280 |
GSM_SUB (word a, word b) |
| 2281 |
{ longword ltmp ; |
| 2282 |
|
| 2283 |
ltmp = ((longword) a) - ((longword) b) ; |
| 2284 |
|
| 2285 |
if (ltmp >= MAX_WORD) |
| 2286 |
ltmp = MAX_WORD ; |
| 2287 |
else if (ltmp <= MIN_WORD) |
| 2288 |
ltmp = MIN_WORD ; |
| 2289 |
|
| 2290 |
return ltmp ; |
| 2291 |
} |
| 2292 |
|
| 2293 |
static C_INLINE word |
| 2294 |
GSM_ABS (word a) |
| 2295 |
{ |
| 2296 |
if (a > 0) |
| 2297 |
return a ; |
| 2298 |
if (a == MIN_WORD) |
| 2299 |
return MAX_WORD ; |
| 2300 |
return -a ; |
| 2301 |
} |
| 2302 |
|
| 2303 |
|
| 2304 |
|
| 2305 |
|
| 2306 |
|
| 2307 |
void Gsm_Coder ( |
| 2308 |
struct gsm_state * S, |
| 2309 |
word * s, |
| 2310 |
word * LARc, |
| 2311 |
word * Nc, |
| 2312 |
word * bc, |
| 2313 |
word * Mc, |
| 2314 |
word * xmaxc, |
| 2315 |
word * xMc) ; |
| 2316 |
|
| 2317 |
void Gsm_Long_Term_Predictor ( |
| 2318 |
struct gsm_state * S, |
| 2319 |
word * d, |
| 2320 |
word * dp, |
| 2321 |
word * e, |
| 2322 |
word * dpp, |
| 2323 |
word * Nc, |
| 2324 |
word * bc) ; |
| 2325 |
|
| 2326 |
void Gsm_LPC_Analysis ( |
| 2327 |
struct gsm_state * S, |
| 2328 |
word * s, |
| 2329 |
word * LARc) ; |
| 2330 |
|
| 2331 |
void Gsm_Preprocess ( |
| 2332 |
struct gsm_state * S, |
| 2333 |
word * s, word * so) ; |
| 2334 |
|
| 2335 |
void Gsm_Encoding ( |
| 2336 |
struct gsm_state * S, |
| 2337 |
word * e, |
| 2338 |
word * ep, |
| 2339 |
word * xmaxc, |
| 2340 |
word * Mc, |
| 2341 |
word * xMc) ; |
| 2342 |
|
| 2343 |
void Gsm_Short_Term_Analysis_Filter ( |
| 2344 |
struct gsm_state * S, |
| 2345 |
word * LARc, |
| 2346 |
word * d) ; |
| 2347 |
|
| 2348 |
void Gsm_Decoder ( |
| 2349 |
struct gsm_state * S, |
| 2350 |
word * LARcr, |
| 2351 |
word * Ncr, |
| 2352 |
word * bcr, |
| 2353 |
word * Mcr, |
| 2354 |
word * xmaxcr, |
| 2355 |
word * xMcr, |
| 2356 |
word * s) ; |
| 2357 |
|
| 2358 |
void Gsm_Decoding ( |
| 2359 |
struct gsm_state * S, |
| 2360 |
word xmaxcr, |
| 2361 |
word Mcr, |
| 2362 |
word * xMcr, |
| 2363 |
word * erp) ; |
| 2364 |
|
| 2365 |
void Gsm_Long_Term_Synthesis_Filtering ( |
| 2366 |
struct gsm_state* S, |
| 2367 |
word Ncr, |
| 2368 |
word bcr, |
| 2369 |
word * erp, |
| 2370 |
word * drp) ; |
| 2371 |
|
| 2372 |
void Gsm_RPE_Decoding ( |
| 2373 |
|
| 2374 |
word xmaxcr, |
| 2375 |
word Mcr, |
| 2376 |
word * xMcr, |
| 2377 |
word * erp) ; |
| 2378 |
|
| 2379 |
void Gsm_RPE_Encoding ( |
| 2380 |
|
| 2381 |
word * e, |
| 2382 |
word * xmaxc, |
| 2383 |
word * Mc, |
| 2384 |
word * xMc) ; |
| 2385 |
|
| 2386 |
void Gsm_Short_Term_Synthesis_Filter ( |
| 2387 |
struct gsm_state * S, |
| 2388 |
word * LARcr, |
| 2389 |
word * drp, |
| 2390 |
word * s) ; |
| 2391 |
|
| 2392 |
void Gsm_Update_of_reconstructed_short_time_residual_signal ( |
| 2393 |
word * dpp, |
| 2394 |
word * ep, |
| 2395 |
word * dp) ; |
| 2396 |
|
| 2397 |
|
| 2398 |
|
| 2399 |
|
| 2400 |
#ifndef GSM_TABLE_C |
| 2401 |
|
| 2402 |
extern word gsm_A [8], gsm_B [8], gsm_MIC [8], gsm_MAC [8] ; |
| 2403 |
extern word gsm_INVA [8] ; |
| 2404 |
extern word gsm_DLB [4], gsm_QLB [4] ; |
| 2405 |
extern word gsm_H [11] ; |
| 2406 |
extern word gsm_NRFAC [8] ; |
| 2407 |
extern word gsm_FAC [8] ; |
| 2408 |
|
| 2409 |
#endif |
| 2410 |
|
| 2411 |
|
| 2412 |
|
| 2413 |
|
| 2414 |
#ifdef NDEBUG |
| 2415 |
|
| 2416 |
# define gsm_debug_words(a, b, c, d) |
| 2417 |
# define gsm_debug_longwords(a, b, c, d) |
| 2418 |
# define gsm_debug_word(a, b) |
| 2419 |
# define gsm_debug_longword(a, b) |
| 2420 |
|
| 2421 |
#else |
| 2422 |
|
| 2423 |
void gsm_debug_words (char * name, int, int, word *) ; |
| 2424 |
void gsm_debug_longwords (char * name, int, int, longword *) ; |
| 2425 |
void gsm_debug_longword (char * name, longword) ; |
| 2426 |
void gsm_debug_word (char * name, word) ; |
| 2427 |
|
| 2428 |
#endif |
| 2429 |
|
| 2430 |
#endif |
| 2431 |
|
| 2432 |
|
| 2433 |
|
| 2434 |
|
| 2435 |
|
| 2436 |
|
| 2437 |
|
| 2438 |
|
| 2439 |
|
| 2440 |
|
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
|
| 2449 |
|
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
|
| 2458 |
|
| 2459 |
|
| 2460 |
|
| 2461 |
|
| 2462 |
|
| 2463 |
|
| 2464 |
|
| 2465 |
|
| 2466 |
|
| 2467 |
|
| 2468 |
|
| 2469 |
|
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
|
| 2475 |
|
| 2476 |
|
| 2477 |
|
| 2478 |
|
| 2479 |
|
| 2480 |
|
| 2481 |
|
| 2482 |
|
| 2483 |
|
| 2484 |
|
| 2485 |
|
| 2486 |
|
| 2487 |
|
| 2488 |
|
| 2489 |
|
| 2490 |
|
| 2491 |
#define HAVE_LRINT_REPLACEMENT 0 |
| 2492 |
|
| 2493 |
#if (HAVE_LRINT && HAVE_LRINTF) |
| 2494 |
|
| 2495 |
|
| 2496 |
|
| 2497 |
|
| 2498 |
|
| 2499 |
|
| 2500 |
|
| 2501 |
|
| 2502 |
|
| 2503 |
#define _ISOC9X_SOURCE 1 |
| 2504 |
#define _ISOC99_SOURCE 1 |
| 2505 |
|
| 2506 |
#define __USE_ISOC9X 1 |
| 2507 |
#define __USE_ISOC99 1 |
| 2508 |
|
| 2509 |
|
| 2510 |
#elif ( defined (WIN32) || defined (_WIN32) || defined(__PLATFORM_WINDOWS__) || defined(__LITTLE_ENDIAN__) ) |
| 2511 |
|
| 2512 |
#undef HAVE_LRINT_REPLACEMENT |
| 2513 |
#define HAVE_LRINT_REPLACEMENT 1 |
| 2514 |
|
| 2515 |
|
| 2516 |
|
| 2517 |
|
| 2518 |
|
| 2519 |
|
| 2520 |
|
| 2521 |
|
| 2522 |
#ifdef __WINDOWS_OLDSCHOOL__ |
| 2523 |
__inline long int |
| 2524 |
lrint (double flt) |
| 2525 |
{ int intgr ; |
| 2526 |
|
| 2527 |
_asm |
| 2528 |
{ fld flt |
| 2529 |
fistp intgr |
| 2530 |
} ; |
| 2531 |
|
| 2532 |
return intgr ; |
| 2533 |
} |
| 2534 |
|
| 2535 |
__inline long int |
| 2536 |
lrintf (float flt) |
| 2537 |
{ int intgr ; |
| 2538 |
|
| 2539 |
_asm |
| 2540 |
{ fld flt |
| 2541 |
fistp intgr |
| 2542 |
} ; |
| 2543 |
|
| 2544 |
return intgr ; |
| 2545 |
} |
| 2546 |
#endif |
| 2547 |
|
| 2548 |
#elif (defined (__MWERKS__) && defined (macintosh)) |
| 2549 |
|
| 2550 |
|
| 2551 |
|
| 2552 |
#undef HAVE_LRINT_REPLACEMENT |
| 2553 |
#define HAVE_LRINT_REPLACEMENT 1 |
| 2554 |
|
| 2555 |
#undef lrint |
| 2556 |
#undef lrintf |
| 2557 |
|
| 2558 |
#define lrint double2int |
| 2559 |
#define lrintf float2int |
| 2560 |
|
| 2561 |
inline int |
| 2562 |
float2int (register float in) |
| 2563 |
{ long res [2] ; |
| 2564 |
|
| 2565 |
asm |
| 2566 |
{ fctiw in, in |
| 2567 |
stfd in, res |
| 2568 |
} |
| 2569 |
return res [1] ; |
| 2570 |
} |
| 2571 |
|
| 2572 |
inline int |
| 2573 |
double2int (register double in) |
| 2574 |
{ long res [2] ; |
| 2575 |
|
| 2576 |
asm |
| 2577 |
{ fctiw in, in |
| 2578 |
stfd in, res |
| 2579 |
} |
| 2580 |
return res [1] ; |
| 2581 |
} |
| 2582 |
|
| 2583 |
#elif (defined (__MACH__) && defined (__APPLE__)) |
| 2584 |
|
| 2585 |
|
| 2586 |
|
| 2587 |
#undef HAVE_LRINT_REPLACEMENT |
| 2588 |
#define HAVE_LRINT_REPLACEMENT 1 |
| 2589 |
|
| 2590 |
#undef lrint |
| 2591 |
#undef lrintf |
| 2592 |
|
| 2593 |
#define lrint double2int |
| 2594 |
#define lrintf float2int |
| 2595 |
|
| 2596 |
inline static long int |
| 2597 |
float2int (register float in) |
| 2598 |
{ int res [2] ; |
| 2599 |
|
| 2600 |
__asm__ __volatile__ |
| 2601 |
( "fctiw %1, %1\n\t" |
| 2602 |
"stfd %1, %0" |
| 2603 |
: "=m" (res) |
| 2604 |
: "f" (in) |
| 2605 |
: "memory" |
| 2606 |
) ; |
| 2607 |
|
| 2608 |
return res [1] ; |
| 2609 |
} |
| 2610 |
|
| 2611 |
inline static long int |
| 2612 |
double2int (register double in) |
| 2613 |
{ int res [2] ; |
| 2614 |
|
| 2615 |
__asm__ __volatile__ |
| 2616 |
( "fctiw %1, %1\n\t" |
| 2617 |
"stfd %1, %0" |
| 2618 |
: "=m" (res) |
| 2619 |
: "f" (in) |
| 2620 |
: "memory" |
| 2621 |
) ; |
| 2622 |
|
| 2623 |
return res [1] ; |
| 2624 |
} |
| 2625 |
|
| 2626 |
#else |
| 2627 |
#ifndef __sgi |
| 2628 |
|
| 2629 |
|
| 2630 |
#endif |
| 2631 |
|
| 2632 |
|
| 2633 |
#define lrint(dbl) ((long) (dbl)) |
| 2634 |
#define lrintf(flt) ((long) (flt)) |
| 2635 |
|
| 2636 |
#endif |
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
|
| 2641 |
|
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
|
| 2647 |
|
| 2648 |
|
| 2649 |
|
| 2650 |
|
| 2651 |
|
| 2652 |
|
| 2653 |
|
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
#ifndef S_IRWXU |
| 2668 |
#define S_IRWXU 0000700 |
| 2669 |
#endif |
| 2670 |
|
| 2671 |
#ifndef S_IRUSR |
| 2672 |
#define S_IRUSR 0000400 |
| 2673 |
#endif |
| 2674 |
|
| 2675 |
#ifndef S_IWUSR |
| 2676 |
#define S_IWUSR 0000200 |
| 2677 |
#endif |
| 2678 |
|
| 2679 |
#ifndef S_IXUSR |
| 2680 |
#define S_IXUSR 0000100 |
| 2681 |
#endif |
| 2682 |
|
| 2683 |
#ifndef S_IRWXG |
| 2684 |
#define S_IRWXG 0000070 |
| 2685 |
#endif |
| 2686 |
|
| 2687 |
#ifndef S_IRGRP |
| 2688 |
#define S_IRGRP 0000040 |
| 2689 |
#endif |
| 2690 |
|
| 2691 |
#ifndef S_IWGRP |
| 2692 |
#define S_IWGRP 0000020 |
| 2693 |
#endif |
| 2694 |
|
| 2695 |
#ifndef S_IXGRP |
| 2696 |
#define S_IXGRP 0000010 |
| 2697 |
#endif |
| 2698 |
|
| 2699 |
#ifndef S_IRWXO |
| 2700 |
#define S_IRWXO 0000007 |
| 2701 |
#endif |
| 2702 |
|
| 2703 |
#ifndef S_IROTH |
| 2704 |
#define S_IROTH 0000004 |
| 2705 |
#endif |
| 2706 |
|
| 2707 |
#ifndef S_IWOTH |
| 2708 |
#define S_IWOTH 0000002 |
| 2709 |
#endif |
| 2710 |
|
| 2711 |
#ifndef S_IXOTH |
| 2712 |
#define S_IXOTH 0000001 |
| 2713 |
#endif |
| 2714 |
|
| 2715 |
#ifndef S_ISFIFO |
| 2716 |
#define S_ISFIFO(mode) (((mode) & _S_IFMT) == _S_IFIFO) |
| 2717 |
#endif |
| 2718 |
|
| 2719 |
#ifndef S_ISREG |
| 2720 |
#define S_ISREG(mode) (((mode) & _S_IFREG) == _S_IFREG) |
| 2721 |
#endif |
| 2722 |
|
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
#endif |