comparison decoders/wav.c @ 401:c42ac9ee2ce4

Fixed "inline" keyword to compile.
author Ryan C. Gordon <icculus@icculus.org>
date Fri, 12 Jul 2002 23:16:24 +0000
parents fb519e6028e3
children c66080364dff 50bb9a6cebfe
comparison
equal deleted inserted replaced
400:9d0b5ec9cc26 401:c42ac9ee2ce4
70 WAV_seek /* seek() method */ 70 WAV_seek /* seek() method */
71 }; 71 };
72 72
73 73
74 /* Better than SDL_ReadLE16, since you can detect i/o errors... */ 74 /* Better than SDL_ReadLE16, since you can detect i/o errors... */
75 static inline int read_le16(SDL_RWops *rw, Uint16 *ui16) 75 static __inline__ int read_le16(SDL_RWops *rw, Uint16 *ui16)
76 { 76 {
77 int rc = SDL_RWread(rw, ui16, sizeof (Uint16), 1); 77 int rc = SDL_RWread(rw, ui16, sizeof (Uint16), 1);
78 BAIL_IF_MACRO(rc != 1, ERR_IO_ERROR, 0); 78 BAIL_IF_MACRO(rc != 1, ERR_IO_ERROR, 0);
79 *ui16 = SDL_SwapLE16(*ui16); 79 *ui16 = SDL_SwapLE16(*ui16);
80 return(1); 80 return(1);
81 } /* read_le16 */ 81 } /* read_le16 */
82 82
83 83
84 /* Better than SDL_ReadLE32, since you can detect i/o errors... */ 84 /* Better than SDL_ReadLE32, since you can detect i/o errors... */
85 static inline int read_le32(SDL_RWops *rw, Uint32 *ui32) 85 static __inline__ int read_le32(SDL_RWops *rw, Uint32 *ui32)
86 { 86 {
87 int rc = SDL_RWread(rw, ui32, sizeof (Uint32), 1); 87 int rc = SDL_RWread(rw, ui32, sizeof (Uint32), 1);
88 BAIL_IF_MACRO(rc != 1, ERR_IO_ERROR, 0); 88 BAIL_IF_MACRO(rc != 1, ERR_IO_ERROR, 0);
89 *ui32 = SDL_SwapLE32(*ui32); 89 *ui32 = SDL_SwapLE32(*ui32);
90 return(1); 90 return(1);
91 } /* read_le32 */ 91 } /* read_le32 */
92 92
93 93
94 /* This is just cleaner on the caller's end... */ 94 /* This is just cleaner on the caller's end... */
95 static inline int read_uint8(SDL_RWops *rw, Uint8 *ui8) 95 static __inline__ int read_uint8(SDL_RWops *rw, Uint8 *ui8)
96 { 96 {
97 int rc = SDL_RWread(rw, ui8, sizeof (Uint8), 1); 97 int rc = SDL_RWread(rw, ui8, sizeof (Uint8), 1);
98 BAIL_IF_MACRO(rc != 1, ERR_IO_ERROR, 0); 98 BAIL_IF_MACRO(rc != 1, ERR_IO_ERROR, 0);
99 return(1); 99 return(1);
100 } /* read_uint8 */ 100 } /* read_uint8 */
320 #define FIXED_POINT_COEF_BASE 256 320 #define FIXED_POINT_COEF_BASE 256
321 #define FIXED_POINT_ADAPTION_BASE 256 321 #define FIXED_POINT_ADAPTION_BASE 256
322 #define SMALLEST_ADPCM_DELTA 16 322 #define SMALLEST_ADPCM_DELTA 16
323 323
324 324
325 static inline int read_adpcm_block_headers(Sound_Sample *sample) 325 static __inline__ int read_adpcm_block_headers(Sound_Sample *sample)
326 { 326 {
327 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 327 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
328 SDL_RWops *rw = internal->rw; 328 SDL_RWops *rw = internal->rw;
329 wav_t *w = (wav_t *) internal->decoder_private; 329 wav_t *w = (wav_t *) internal->decoder_private;
330 fmt_t *fmt = w->fmt; 330 fmt_t *fmt = w->fmt;
356 fmt->fmt.adpcm.nibble_state = 0; 356 fmt->fmt.adpcm.nibble_state = 0;
357 return(1); 357 return(1);
358 } /* read_adpcm_block_headers */ 358 } /* read_adpcm_block_headers */
359 359
360 360
361 static inline void do_adpcm_nibble(Uint8 nib, 361 static __inline__ void do_adpcm_nibble(Uint8 nib,
362 ADPCMBLOCKHEADER *header, 362 ADPCMBLOCKHEADER *header,
363 Sint32 lPredSamp) 363 Sint32 lPredSamp)
364 { 364 {
365 static const Sint32 max_audioval = ((1<<(16-1))-1); 365 static const Sint32 max_audioval = ((1<<(16-1))-1);
366 static const Sint32 min_audioval = -(1<<(16-1)); 366 static const Sint32 min_audioval = -(1<<(16-1));
367 static const Sint32 AdaptionTable[] = 367 static const Sint32 AdaptionTable[] =
368 { 368 {
394 header->iSamp2 = header->iSamp1; 394 header->iSamp2 = header->iSamp1;
395 header->iSamp1 = lNewSamp; 395 header->iSamp1 = lNewSamp;
396 } /* do_adpcm_nibble */ 396 } /* do_adpcm_nibble */
397 397
398 398
399 static inline int decode_adpcm_sample_frame(Sound_Sample *sample) 399 static __inline__ int decode_adpcm_sample_frame(Sound_Sample *sample)
400 { 400 {
401 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 401 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
402 wav_t *w = (wav_t *) internal->decoder_private; 402 wav_t *w = (wav_t *) internal->decoder_private;
403 fmt_t *fmt = w->fmt; 403 fmt_t *fmt = w->fmt;
404 ADPCMBLOCKHEADER *headers = fmt->fmt.adpcm.blockheaders; 404 ADPCMBLOCKHEADER *headers = fmt->fmt.adpcm.blockheaders;
433 fmt->fmt.adpcm.nibble = nib; 433 fmt->fmt.adpcm.nibble = nib;
434 return(1); 434 return(1);
435 } /* decode_adpcm_sample_frame */ 435 } /* decode_adpcm_sample_frame */
436 436
437 437
438 static inline void put_adpcm_sample_frame1(void *_buf, fmt_t *fmt) 438 static __inline__ void put_adpcm_sample_frame1(void *_buf, fmt_t *fmt)
439 { 439 {
440 Uint16 *buf = (Uint16 *) _buf; 440 Uint16 *buf = (Uint16 *) _buf;
441 ADPCMBLOCKHEADER *headers = fmt->fmt.adpcm.blockheaders; 441 ADPCMBLOCKHEADER *headers = fmt->fmt.adpcm.blockheaders;
442 int i; 442 int i;
443 for (i = 0; i < fmt->wChannels; i++) 443 for (i = 0; i < fmt->wChannels; i++)
444 *(buf++) = headers[i].iSamp1; 444 *(buf++) = headers[i].iSamp1;
445 } /* put_adpcm_sample_frame1 */ 445 } /* put_adpcm_sample_frame1 */
446 446
447 447
448 static inline void put_adpcm_sample_frame2(void *_buf, fmt_t *fmt) 448 static __inline__ void put_adpcm_sample_frame2(void *_buf, fmt_t *fmt)
449 { 449 {
450 Uint16 *buf = (Uint16 *) _buf; 450 Uint16 *buf = (Uint16 *) _buf;
451 ADPCMBLOCKHEADER *headers = fmt->fmt.adpcm.blockheaders; 451 ADPCMBLOCKHEADER *headers = fmt->fmt.adpcm.blockheaders;
452 int i; 452 int i;
453 for (i = 0; i < fmt->wChannels; i++) 453 for (i = 0; i < fmt->wChannels; i++)