Mercurial > SDL_sound_CoreAudio
annotate decoders/shn.c @ 474:c66080364dff
Most decoders now report total sample play time, now. Technically, this
breaks binary compatibility with the 1.0 branch, since it extends the
Sound_Sample struct, but most (all?) programs are just passing pointers
allocated by SDL_sound around, and might be okay.
Source-level compatibility is not broken...yet! :)
--ryan.
-------- Original Message --------
Subject: SDL_sound patch: Finding total length of time of sound file.
Date: Sun, 26 Jan 2003 09:31:17 -0800 (PST)
Hi Ryan,
I am working with Eric Wing and helping him modify
SDL_sound. AS part of our efforts in improving and
enhancing SDL_sound, we like to submit this patch. We
modified the codecs to find the total time of a sound
file. Below is the explanation of the patch. The
patch is appended as an attachment to this email.
* MOTIVATION:
We needed the ability to get the total play time of a
sample (And we noticed that we're not the only ones).
Since SDL_sound blocks direct access to the specific
decoders, there is no way for a user to know this
information short of decoding the whole thing.
Because of this, we believe this will be a useful
addition, even though the accuracy may not be perfect
(subject to each decoder) or the information may not
always be available.
* CONTRIBUTORS:
Wesley Leong (modified the majority of the codecs and
verified the results)
Eric Wing (showed everyone how to do modify codec,
modified mikmod)
Wang Lam (modified a handful of codecs, researched
into specs and int overflow)
Ahilan Anantha (modified a few codecs and helped with
integer math)
* GENERAL ISSUES:
We chose the value to be milliseconds as an Sint32.
Milliseconds because that's what Sound_Seek takes as a
parameter and -1 to allow for instances/codecs where
the value could not be determined. We are
not sure if this is the final convention you want, so
we are willing to work with you on this.
We also expect the total_time field to be set on open
and never again modified by SDL_sound. Users may
access it directly much like the sample buffer and
buffer_size. We thought about recomputing the time
on DecodeAll, but since users may seek or decode small
chunks first, not all the data may be there. So this
is better done by the user. This may be good
information to document.
Currently, all the main codecs are implemented except
for QuickTime.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 08 May 2004 08:19:50 +0000 |
parents | b4abd7c48b6e |
children | 3e705c9180e5 |
rev | line source |
---|---|
86 | 1 /* |
2 * SDL_sound -- An abstract sound format decoding API. | |
3 * Copyright (C) 2001 Ryan C. Gordon. | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2.1 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 | |
20 /* | |
21 * Shorten decoder for SDL_sound. | |
22 * | |
23 * This driver handles Shorten-compressed waveforms. Despite the fact that | |
161
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
24 * SHNs tend to be much bigger than MP3s, they are still the de facto |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
25 * standard in online music trading communities. If an MP3 crunches the |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
26 * waveform to 10-20 percent of its original size, SHNs only go to about |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
27 * 50-60%. Why do the Phish fans of the world use this format then? Rabid |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
28 * music traders appreciate the sound quality; SHNs, unlike MP3s, do not |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
29 * throw away any part of the waveform. Yes, there are people that notice |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
30 * this, and further more, they demand it...and if they can't get a good |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
31 * transfer of those larger files over the 'net, they haven't underestimated |
0f958979b1dd
Updated my intro comments.
Ryan C. Gordon <icculus@icculus.org>
parents:
149
diff
changeset
|
32 * the bandwidth of CDs travelling the world through the postal system. |
86 | 33 * |
34 * Shorten homepage: http://www.softsound.com/Shorten.html | |
35 * | |
36 * The Shorten format was gleaned from the shorten codebase, by Tony | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
37 * Robinson and SoftSound Limited. |
86 | 38 * |
184
47cc2de2ae36
Changed reference to "LICENSE" file to "COPYING".
Ryan C. Gordon <icculus@icculus.org>
parents:
161
diff
changeset
|
39 * Please see the file COPYING in the source's root directory. |
86 | 40 * |
41 * This file written by Ryan C. Gordon. (icculus@clutteredmind.org) | |
42 */ | |
43 | |
106
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
44 #if HAVE_CONFIG_H |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
45 # include <config.h> |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
46 #endif |
100
6d9fdec2f708
added config.h, added --enable-debug flag, various other changes to the build system
fingolfin
parents:
86
diff
changeset
|
47 |
114
dd95a12539fd
Changed an #if defined to #ifdef, for consistency with the other
Ryan C. Gordon <icculus@icculus.org>
parents:
106
diff
changeset
|
48 #ifdef SOUND_SUPPORTS_SHN |
104
103cfcb3c014
Updated to fix build system problem.
Ryan C. Gordon <icculus@icculus.org>
parents:
101
diff
changeset
|
49 |
86 | 50 #include <stdio.h> |
51 #include <stdlib.h> | |
52 #include <string.h> | |
53 | |
106
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
54 #include "SDL_sound.h" |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
55 |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
56 #define __SDL_SOUND_INTERNAL__ |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
57 #include "SDL_sound_internal.h" |
40de367eb59e
Changing my include structure to do this right.
Ryan C. Gordon <icculus@icculus.org>
parents:
104
diff
changeset
|
58 |
86 | 59 static int SHN_init(void); |
60 static void SHN_quit(void); | |
61 static int SHN_open(Sound_Sample *sample, const char *ext); | |
62 static void SHN_close(Sound_Sample *sample); | |
63 static Uint32 SHN_read(Sound_Sample *sample); | |
221
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
64 static int SHN_rewind(Sound_Sample *sample); |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
65 static int SHN_seek(Sound_Sample *sample, Uint32 ms); |
86 | 66 |
149
1df5c106504e
Decoders can now list multiple file extensions.
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
67 static const char *extensions_shn[] = { "SHN", NULL }; |
86 | 68 const Sound_DecoderFunctions __Sound_DecoderFunctions_SHN = |
69 { | |
70 { | |
149
1df5c106504e
Decoders can now list multiple file extensions.
Ryan C. Gordon <icculus@icculus.org>
parents:
126
diff
changeset
|
71 extensions_shn, |
86 | 72 "Shorten-compressed audio data", |
73 "Ryan C. Gordon <icculus@clutteredmind.org>", | |
74 "http://www.icculus.org/SDL_sound/" | |
75 }, | |
76 | |
221
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
77 SHN_init, /* init() method */ |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
78 SHN_quit, /* quit() method */ |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
79 SHN_open, /* open() method */ |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
80 SHN_close, /* close() method */ |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
81 SHN_read, /* read() method */ |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
82 SHN_rewind, /* rewind() method */ |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
83 SHN_seek /* seek() method */ |
86 | 84 }; |
85 | |
86 | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
87 #define SHN_BUFSIZ 512 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
88 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
89 typedef struct |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
90 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
91 Sint32 version; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
92 Sint32 datatype; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
93 Sint32 nchan; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
94 Sint32 blocksize; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
95 Sint32 maxnlpc; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
96 Sint32 nmean; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
97 Sint32 nwrap; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
98 Sint32 **buffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
99 Sint32 **offset; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
100 Sint32 *qlpc; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
101 Sint32 lpcqoffset; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
102 Sint32 bitshift; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
103 int nbitget; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
104 int nbyteget; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
105 Uint8 *getbuf; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
106 Uint8 *getbufp; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
107 Uint32 gbuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
108 Uint8 *backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
109 Uint32 backBufferSize; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
110 Uint32 backBufLeft; |
233
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
111 Uint32 start_pos; |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
112 } shn_t; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
113 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
114 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
115 static const Uint32 mask_table[] = |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
116 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
117 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
118 0x0000003F, 0x0000007F, 0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
119 0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF, 0x0001FFFF, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
120 0x0003FFFF, 0x0007FFFF, 0x000FFFFF, 0x001FFFFF, 0x003FFFFF, 0x007FFFFF, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
121 0x00FFFFFF, 0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF, 0x1FFFFFFF, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
122 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
123 }; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
124 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
125 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
126 static const Uint8 ulaw_outward[13][256] = { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
127 {127,0,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,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,255,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
128 {112,114,116,118,120,122,124,126,127,0,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,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,113,115,117,119,121,123,125,255,253,251,249,247,245,243,241,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,252,250,248,246,244,242,240}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
129 {96,98,100,102,104,106,108,110,112,113,114,116,117,118,120,121,122,124,125,126,127,0,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,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,97,99,101,103,105,107,109,111,115,119,123,255,251,247,243,239,237,235,233,231,229,227,225,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,253,252,250,249,248,246,245,244,242,241,240,238,236,234,232,230,228,226,224}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
130 {80,82,84,86,88,90,92,94,96,97,98,100,101,102,104,105,106,108,109,110,112,113,114,115,116,117,118,120,121,122,123,124,125,126,127,0,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,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,81,83,85,87,89,91,93,95,99,103,107,111,119,255,247,239,235,231,227,223,221,219,217,215,213,211,209,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,253,252,251,250,249,248,246,245,244,243,242,241,240,238,237,236,234,233,232,230,229,228,226,225,224,222,220,218,216,214,212,210,208}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
131 {64,66,68,70,72,74,76,78,80,81,82,84,85,86,88,89,90,92,93,94,96,97,98,99,100,101,102,104,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,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,54,55,56,57,58,59,60,61,62,63,65,67,69,71,73,75,77,79,83,87,91,95,103,111,255,239,231,223,219,215,211,207,205,203,201,199,197,195,193,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,238,237,236,235,234,233,232,230,229,228,227,226,225,224,222,221,220,218,217,216,214,213,212,210,209,208,206,204,202,200,198,196,194,192}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
132 {49,51,53,55,57,59,61,63,64,66,67,68,70,71,72,74,75,76,78,79,80,81,82,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,101,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,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,50,52,54,56,58,60,62,65,69,73,77,83,91,103,255,231,219,211,205,201,197,193,190,188,186,184,182,180,178,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,230,229,228,227,226,225,224,223,222,221,220,218,217,216,215,214,213,212,210,209,208,207,206,204,203,202,200,199,198,196,195,194,192,191,189,187,185,183,181,179,177}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
133 {32,34,36,38,40,42,44,46,48,49,51,52,53,55,56,57,59,60,61,63,64,65,66,67,68,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,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,33,35,37,39,41,43,45,47,50,54,58,62,69,77,91,255,219,205,197,190,186,182,178,175,173,171,169,167,165,163,161,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,218,217,216,215,214,213,212,211,210,209,208,207,206,204,203,202,201,200,199,198,196,195,194,193,192,191,189,188,187,185,184,183,181,180,179,177,176,174,172,170,168,166,164,162,160}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
134 {16,18,20,22,24,26,28,30,32,33,34,36,37,38,40,41,42,44,45,46,48,49,50,51,52,53,55,56,57,58,59,60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,19,21,23,25,27,29,31,35,39,43,47,54,62,77,255,205,190,182,175,171,167,163,159,157,155,153,151,149,147,145,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,204,203,202,201,200,199,198,197,196,195,194,193,192,191,189,188,187,186,185,184,183,181,180,179,178,177,176,174,173,172,170,169,168,166,165,164,162,161,160,158,156,154,152,150,148,146,144}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
135 {2,4,6,8,10,12,14,16,17,18,20,21,22,24,25,26,28,29,30,32,33,34,35,36,37,38,40,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,58,59,60,61,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,1,3,5,7,9,11,13,15,19,23,27,31,39,47,62,255,190,175,167,159,155,151,147,143,141,139,137,135,133,131,129,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,189,188,187,186,185,184,183,182,181,180,179,178,177,176,174,173,172,171,170,169,168,166,165,164,163,162,161,160,158,157,156,154,153,152,150,149,148,146,145,144,142,140,138,136,134,132,130,128}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
136 {1,2,4,5,6,8,9,10,12,13,14,16,17,18,19,20,21,22,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,3,7,11,15,23,31,47,255,175,159,151,143,139,135,131,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,158,157,156,155,154,153,152,150,149,148,147,146,145,144,142,141,140,138,137,136,134,133,132,130,129,128}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
137 {1,2,3,4,5,6,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,7,15,31,255,159,143,135,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,142,141,140,139,138,137,136,134,133,132,131,130,129,128}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
138 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,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,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,15,255,143,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128}, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
139 {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,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,0,255,254,253,252,251,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,199,198,197,196,195,194,193,192,191,190,189,188,187,186,185,184,183,182,181,180,179,178,177,176,175,174,173,172,171,170,169,168,167,166,165,164,163,162,161,160,159,158,157,156,155,154,153,152,151,150,149,148,147,146,145,144,143,142,141,140,139,138,137,136,135,134,133,132,131,130,129,128} |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
140 }; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
141 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
142 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
143 #ifndef MIN_MACRO |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
144 #define MIN_MACRO(a,b) (((a)<(b))?(a):(b)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
145 #endif |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
146 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
147 #ifndef MAX_MACRO |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
148 #define MAX_MACRO(a,b) (((a)>(b))?(a):(b)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
149 #endif |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
150 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
151 #define POSITIVE_ULAW_ZERO 0xff |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
152 #define NEGATIVE_ULAW_ZERO 0x7f |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
153 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
154 #define CAPMAXSCHAR(x) ((x > 127) ? 127 : x) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
155 #define CAPMAXUCHAR(x) ((x > 255) ? 255 : x) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
156 #define CAPMAXSHORT(x) ((x > 32767) ? 32767 : x) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
157 #define CAPMAXUSHORT(x) ((x > 65535) ? 65535 : x) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
158 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
159 #define UNDEFINED_UINT -1 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
160 #define DEFAULT_BLOCK_SIZE 256 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
161 #define DEFAULT_V0NMEAN 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
162 #define DEFAULT_V2NMEAN 4 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
163 #define DEFAULT_MAXNLPC 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
164 #define DEFAULT_NCHAN 1 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
165 #define DEFAULT_NSKIP 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
166 #define DEFAULT_NDISCARD 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
167 #define NBITPERLONG 32 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
168 #define DEFAULT_MINSNR 256 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
169 #define DEFAULT_QUANTERROR 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
170 #define MINBITRATE 2.5 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
171 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
172 #define MEAN_VERSION0 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
173 #define MEAN_VERSION2 4 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
174 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
175 #define SHN_FN_DIFF0 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
176 #define SHN_FN_DIFF1 1 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
177 #define SHN_FN_DIFF2 2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
178 #define SHN_FN_DIFF3 3 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
179 #define SHN_FN_QUIT 4 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
180 #define SHN_FN_BLOCKSIZE 5 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
181 #define SHN_FN_BITSHIFT 6 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
182 #define SHN_FN_QLPC 7 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
183 #define SHN_FN_ZERO 8 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
184 #define SHN_FN_VERBATIM 9 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
185 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
186 #define SHN_TYPE_AU1 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
187 #define SHN_TYPE_S8 1 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
188 #define SHN_TYPE_U8 2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
189 #define SHN_TYPE_S16HL 3 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
190 #define SHN_TYPE_U16HL 4 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
191 #define SHN_TYPE_S16LH 5 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
192 #define SHN_TYPE_U16LH 6 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
193 #define SHN_TYPE_ULAW 7 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
194 #define SHN_TYPE_AU2 8 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
195 #define SHN_TYPE_AU3 9 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
196 #define SHN_TYPE_ALAW 10 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
197 #define SHN_TYPE_RIFF_WAVE 11 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
198 #define SHN_TYPE_EOF 12 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
199 #define SHN_TYPE_GENERIC_ULAW 128 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
200 #define SHN_TYPE_GENERIC_ALAW 129 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
201 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
202 #define SHN_FNSIZE 2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
203 #define SHN_CHANNELSIZE 0 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
204 #define SHN_TYPESIZE 4 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
205 #define SHN_ULONGSIZE 2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
206 #define SHN_NSKIPSIZE 1 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
207 #define SHN_LPCQSIZE 2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
208 #define SHN_LPCQUANT 5 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
209 #define SHN_XBYTESIZE 7 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
210 #define SHN_VERBATIM_CKSIZE_SIZE 5 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
211 #define SHN_VERBATIM_BYTE_SIZE 8 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
212 #define SHN_ENERGYSIZE 3 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
213 #define SHN_BITSHIFTSIZE 2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
214 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
215 #define SHN_LPCQOFFSET_VER2 (1 << SHN_LPCQUANT) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
216 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
217 |
212
8c2cb920a383
Changed the magic number macro to be more uniform with other decoders.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
218 #define SHN_MAGIC 0x676B6A61 /* looks like "ajkg" as chars. */ |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
219 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
220 #ifndef M_LN2 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
221 #define M_LN2 0.69314718055994530942 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
222 #endif |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
223 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
224 #ifndef M_PI |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
225 #define M_PI 3.14159265358979323846 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
226 #endif |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
227 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
228 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
229 static int word_get(shn_t *shn, SDL_RWops *rw, Uint32 *word) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
230 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
231 if (shn->nbyteget < 4) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
232 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
233 shn->nbyteget += SDL_RWread(rw, shn->getbuf, 1, SHN_BUFSIZ); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
234 BAIL_IF_MACRO(shn->nbyteget < 4, NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
235 shn->getbufp = shn->getbuf; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
236 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
237 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
238 if (word != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
239 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
240 *word = (((Sint32) shn->getbufp[0]) << 24) | |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
241 (((Sint32) shn->getbufp[1]) << 16) | |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
242 (((Sint32) shn->getbufp[2]) << 8) | |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
243 (((Sint32) shn->getbufp[3]) ); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
244 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
245 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
246 shn->getbufp += 4; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
247 shn->nbyteget -= 4; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
248 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
249 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
250 } /* word_get */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
251 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
252 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
253 static int uvar_get(int nbin, shn_t *shn, SDL_RWops *rw, Sint32 *word) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
254 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
255 Sint32 result; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
256 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
257 if (shn->nbitget == 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
258 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
259 BAIL_IF_MACRO(!word_get(shn, rw, &shn->gbuffer), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
260 shn->nbitget = 32; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
261 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
262 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
263 for (result = 0; !(shn->gbuffer & (1L << --shn->nbitget)); result++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
264 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
265 if (shn->nbitget == 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
266 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
267 BAIL_IF_MACRO(!word_get(shn, rw, &shn->gbuffer), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
268 shn->nbitget = 32; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
269 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
270 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
271 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
272 while (nbin != 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
273 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
274 if (shn->nbitget >= nbin) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
275 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
276 result = ( (result << nbin) | |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
277 ((shn->gbuffer >> (shn->nbitget - nbin)) & |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
278 mask_table[nbin]) ); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
279 shn->nbitget -= nbin; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
280 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
281 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
282 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
283 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
284 result = (result << shn->nbitget) | |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
285 (shn->gbuffer & mask_table[shn->nbitget]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
286 BAIL_IF_MACRO(!word_get(shn, rw, &shn->gbuffer), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
287 nbin -= shn->nbitget; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
288 shn->nbitget = 32; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
289 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
290 } /* while */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
291 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
292 if (word != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
293 *word = result; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
294 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
295 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
296 } /* uvar_get */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
297 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
298 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
299 static int var_get(int nbin, shn_t *shn, SDL_RWops *rw, Sint32 *word) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
300 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
301 BAIL_IF_MACRO(!uvar_get(nbin + 1, shn, rw, word), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
302 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
303 if ((*word) & 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
304 *word = (Sint32) ~((*word) >> 1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
305 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
306 *word = (Sint32) ((*word) >> 1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
307 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
308 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
309 } /* var_get */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
310 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
311 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
312 static int ulong_get(shn_t *shn, SDL_RWops *rw, Sint32 *word) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
313 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
314 Sint32 nbit; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
315 Sint32 retval; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
316 BAIL_IF_MACRO(!uvar_get(SHN_ULONGSIZE, shn, rw, &nbit), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
317 BAIL_IF_MACRO(!uvar_get(nbit, shn, rw, &retval), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
318 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
319 if (word != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
320 *word = retval; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
321 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
322 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
323 } /* ulong_get */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
324 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
325 |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
326 static __inline__ int uint_get(int nbit, shn_t *shn, SDL_RWops *rw, Sint32 *w) |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
327 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
328 return((shn->version == 0) ? |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
329 uvar_get(nbit, shn, rw, w) : |
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
330 ulong_get(shn, rw, w)); |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
331 } /* uint_get */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
332 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
333 |
86 | 334 static int SHN_init(void) |
335 { | |
336 return(1); /* initialization always successful. */ | |
337 } /* SHN_init */ | |
338 | |
339 | |
340 static void SHN_quit(void) | |
341 { | |
342 /* it's a no-op. */ | |
343 } /* SHN_quit */ | |
344 | |
345 | |
346 /* | |
347 * Look through the whole file for a SHN magic number. This is costly, so | |
348 * it should only be done if the user SWEARS they have a Shorten stream... | |
349 */ | |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
350 static __inline__ int extended_shn_magic_search(Sound_Sample *sample) |
86 | 351 { |
352 SDL_RWops *rw = ((Sound_SampleInternal *) sample->opaque)->rw; | |
353 Uint32 word = 0; | |
354 Uint8 ch; | |
355 | |
356 while (1) | |
357 { | |
358 BAIL_IF_MACRO(SDL_RWread(rw, &ch, sizeof (ch), 1) != 1, NULL, -1); | |
359 word = ((word << 8) & 0xFFFFFF00) | ch; | |
212
8c2cb920a383
Changed the magic number macro to be more uniform with other decoders.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
360 if (SDL_SwapBE32(word) == SHN_MAGIC) |
86 | 361 { |
362 BAIL_IF_MACRO(SDL_RWread(rw, &ch, sizeof (ch), 1) != 1, NULL, -1); | |
363 return((int) ch); | |
364 } /* if */ | |
365 } /* while */ | |
366 | |
367 return((int) ch); | |
368 } /* extended_shn_magic_search */ | |
369 | |
370 | |
371 /* look for the magic number in the RWops and see what kind of file this is. */ | |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
372 static __inline__ int determine_shn_version(Sound_Sample *sample, |
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
373 const char *ext) |
86 | 374 { |
375 SDL_RWops *rw = ((Sound_SampleInternal *) sample->opaque)->rw; | |
376 Uint32 magic; | |
377 Uint8 ch; | |
378 | |
379 /* | |
380 * Apparently the magic number can start at any byte offset in the file, | |
381 * and we should just discard prior data, but I'm going to restrict it | |
382 * to offset zero for now, so we don't chug down every file that might | |
383 * happen to pass through here. If the extension is explicitly "SHN", we | |
384 * check the whole stream, though. | |
385 */ | |
386 | |
387 if (__Sound_strcasecmp(ext, "shn") == 0) | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
388 return(extended_shn_magic_search(sample)); |
86 | 389 |
390 BAIL_IF_MACRO(SDL_RWread(rw, &magic, sizeof (magic), 1) != 1, NULL, -1); | |
212
8c2cb920a383
Changed the magic number macro to be more uniform with other decoders.
Ryan C. Gordon <icculus@icculus.org>
parents:
184
diff
changeset
|
391 BAIL_IF_MACRO(SDL_SwapLE32(magic) != SHN_MAGIC, "SHN: Not a SHN file", -1); |
86 | 392 BAIL_IF_MACRO(SDL_RWread(rw, &ch, sizeof (ch), 1) != 1, NULL, -1); |
393 BAIL_IF_MACRO(ch > 3, "SHN: Unsupported file version", -1); | |
394 | |
395 return((int) ch); | |
396 } /* determine_shn_version */ | |
397 | |
398 | |
242
12a9c2e0b00f
Fixed compiler warnings (thanks, Darrell!)
Ryan C. Gordon <icculus@icculus.org>
parents:
233
diff
changeset
|
399 static void init_shn_offset(Sint32 **offset, int nchan, int nblock, int ftype) |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
400 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
401 Sint32 mean = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
402 int chan; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
403 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
404 switch (ftype) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
405 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
406 case SHN_TYPE_AU1: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
407 case SHN_TYPE_S8: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
408 case SHN_TYPE_S16HL: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
409 case SHN_TYPE_S16LH: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
410 case SHN_TYPE_ULAW: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
411 case SHN_TYPE_AU2: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
412 case SHN_TYPE_AU3: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
413 case SHN_TYPE_ALAW: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
414 mean = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
415 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
416 case SHN_TYPE_U8: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
417 mean = 0x80; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
418 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
419 case SHN_TYPE_U16HL: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
420 case SHN_TYPE_U16LH: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
421 mean = 0x8000; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
422 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
423 default: |
387
fb519e6028e3
Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
Ryan C. Gordon <icculus@icculus.org>
parents:
377
diff
changeset
|
424 __Sound_SetError("SHN: unknown file type"); |
245
82a37ef73ae9
Whoops; fixing a compiling bug I introduced.
Ryan C. Gordon <icculus@icculus.org>
parents:
242
diff
changeset
|
425 return; |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
426 } /* switch */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
427 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
428 for(chan = 0; chan < nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
429 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
430 int i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
431 for(i = 0; i < nblock; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
432 offset[chan][i] = mean; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
433 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
434 } /* init_shn_offset */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
435 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
436 |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
437 static __inline__ Uint16 cvt_shnftype_to_sdlfmt(Sint16 shntype) |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
438 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
439 switch (shntype) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
440 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
441 case SHN_TYPE_S8: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
442 return(AUDIO_S8); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
443 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
444 case SHN_TYPE_ALAW: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
445 case SHN_TYPE_ULAW: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
446 case SHN_TYPE_AU1: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
447 case SHN_TYPE_AU2: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
448 case SHN_TYPE_AU3: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
449 case SHN_TYPE_U8: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
450 return(AUDIO_U8); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
451 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
452 case SHN_TYPE_S16HL: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
453 return(AUDIO_S16MSB); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
454 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
455 case SHN_TYPE_S16LH: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
456 return(AUDIO_S16LSB); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
457 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
458 case SHN_TYPE_U16HL: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
459 return(AUDIO_U16MSB); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
460 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
461 case SHN_TYPE_U16LH: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
462 return(AUDIO_U16LSB); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
463 } /* switch */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
464 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
465 return(0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
466 } /* cvt_shnftype_to_sdlfmt */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
467 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
468 |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
469 static __inline__ int skip_bits(shn_t *shn, SDL_RWops *rw) |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
470 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
471 int i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
472 Sint32 skip; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
473 Sint32 trash; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
474 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
475 BAIL_IF_MACRO(!uint_get(SHN_NSKIPSIZE, shn, rw, &skip), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
476 for(i = 0; i < skip; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
477 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
478 BAIL_IF_MACRO(!uint_get(SHN_XBYTESIZE, shn, rw, &trash), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
479 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
480 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
481 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
482 } /* skip_bits */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
483 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
484 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
485 static Sint32 **shn_long2d(Uint32 n0, Uint32 n1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
486 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
487 Sint32 **array0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
488 Uint32 size = (n0 * sizeof (Sint32 *)) + (n0 * n1 * sizeof (Sint32)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
489 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
490 array0 = (Sint32 **) malloc(size); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
491 if (array0 != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
492 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
493 int i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
494 Sint32 *array1 = (Sint32 *) (array0 + n0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
495 for(i = 0; i < n0; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
496 array0[i] = array1 + (i * n1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
497 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
498 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
499 return(array0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
500 } /* shn_long2d */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
501 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
502 #define riffID 0x46464952 /* "RIFF", in ascii. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
503 #define waveID 0x45564157 /* "WAVE", in ascii. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
504 #define fmtID 0x20746D66 /* "fmt ", in ascii. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
505 #define dataID 0x61746164 /* "data", in ascii. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
506 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
507 static int verb_ReadLE32(shn_t *shn, SDL_RWops *rw, Uint32 *word) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
508 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
509 int i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
510 Uint8 chars[4]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
511 Sint32 byte; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
512 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
513 for (i = 0; i < 4; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
514 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
515 if (!uvar_get(SHN_VERBATIM_BYTE_SIZE, shn, rw, &byte)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
516 return(0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
517 chars[i] = (Uint8) byte; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
518 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
519 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
520 memcpy(word, chars, sizeof (*word)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
521 *word = SDL_SwapLE32(*word); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
522 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
523 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
524 } /* verb_ReadLE32 */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
525 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
526 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
527 static int verb_ReadLE16(shn_t *shn, SDL_RWops *rw, Uint16 *word) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
528 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
529 int i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
530 Uint8 chars[2]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
531 Sint32 byte; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
532 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
533 for (i = 0; i < 2; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
534 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
535 if (!uvar_get(SHN_VERBATIM_BYTE_SIZE, shn, rw, &byte)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
536 return(0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
537 chars[i] = (Uint8) byte; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
538 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
539 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
540 memcpy(word, chars, sizeof (*word)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
541 *word = SDL_SwapLE16(*word); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
542 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
543 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
544 } /* verb_ReadLE16 */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
545 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
546 |
401
c42ac9ee2ce4
Fixed "inline" keyword to compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
387
diff
changeset
|
547 static __inline__ int parse_riff_header(shn_t *shn, Sound_Sample *sample) |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
548 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
549 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
550 SDL_RWops *rw = internal->rw; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
551 Uint16 u16; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
552 Uint32 u32; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
553 Sint32 cklen; |
474
c66080364dff
Most decoders now report total sample play time, now. Technically, this
Ryan C. Gordon <icculus@icculus.org>
parents:
425
diff
changeset
|
554 Uint32 bytes_per_second; |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
555 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
556 BAIL_IF_MACRO(!uvar_get(SHN_VERBATIM_CKSIZE_SIZE, shn, rw, &cklen), NULL, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
557 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
558 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* RIFF header */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
559 BAIL_IF_MACRO(u32 != riffID, "SHN: No RIFF header.", 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
560 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* length */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
561 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
562 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* WAVE header */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
563 BAIL_IF_MACRO(u32 != waveID, "SHN: No WAVE header.", 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
564 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
565 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* 'fmt ' header */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
566 BAIL_IF_MACRO(u32 != fmtID, "SHN: No 'fmt ' header.", 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
567 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
568 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* chunksize */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
569 BAIL_IF_MACRO(!verb_ReadLE16(shn, rw, &u16), NULL, 0); /* format */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
570 BAIL_IF_MACRO(!verb_ReadLE16(shn, rw, &u16), NULL, 0); /* channels */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
571 sample->actual.channels = u16; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
572 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* sample rate */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
573 sample->actual.rate = u32; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
574 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
575 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* bytespersec */ |
474
c66080364dff
Most decoders now report total sample play time, now. Technically, this
Ryan C. Gordon <icculus@icculus.org>
parents:
425
diff
changeset
|
576 bytes_per_second = u32; |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
577 BAIL_IF_MACRO(!verb_ReadLE16(shn, rw, &u16), NULL, 0); /* blockalign */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
578 BAIL_IF_MACRO(!verb_ReadLE16(shn, rw, &u16), NULL, 0); /* bitspersample */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
579 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
580 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* 'data' header */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
581 BAIL_IF_MACRO(u32 != dataID, "SHN: No 'data' header.", 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
582 BAIL_IF_MACRO(!verb_ReadLE32(shn, rw, &u32), NULL, 0); /* chunksize */ |
474
c66080364dff
Most decoders now report total sample play time, now. Technically, this
Ryan C. Gordon <icculus@icculus.org>
parents:
425
diff
changeset
|
583 sample->total_time = u32 / bytes_per_second * 1000; |
c66080364dff
Most decoders now report total sample play time, now. Technically, this
Ryan C. Gordon <icculus@icculus.org>
parents:
425
diff
changeset
|
584 sample->total_time += (u32 % bytes_per_second) * 1000 / bytes_per_second; |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
585 return(1); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
586 } /* parse_riff_header */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
587 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
588 |
86 | 589 static int SHN_open(Sound_Sample *sample, const char *ext) |
590 { | |
591 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | |
592 SDL_RWops *rw = internal->rw; | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
593 shn_t _shn; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
594 shn_t *shn = &_shn; /* malloc and copy later. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
595 Sint32 cmd; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
596 Sint32 chan; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
597 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
598 memset(shn, '\0', sizeof (shn_t)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
599 shn->getbufp = shn->getbuf = (Uint8 *) malloc(SHN_BUFSIZ); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
600 shn->datatype = SHN_TYPE_EOF; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
601 shn->nchan = DEFAULT_NCHAN; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
602 shn->blocksize = DEFAULT_BLOCK_SIZE; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
603 shn->maxnlpc = DEFAULT_MAXNLPC; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
604 shn->nmean = UNDEFINED_UINT; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
605 shn->version = determine_shn_version(sample, ext); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
606 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
607 if (shn->version == -1) goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
608 if (!uint_get(SHN_TYPESIZE, shn, rw, &shn->datatype)) goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
609 if (!uint_get(SHN_CHANNELSIZE, shn, rw, &shn->nchan)) goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
610 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
611 sample->actual.format = cvt_shnftype_to_sdlfmt(shn->datatype); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
612 if (sample->actual.format == 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
613 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
614 SDL_SetError(ERR_UNSUPPORTED_FORMAT); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
615 goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
616 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
617 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
618 if (shn->version > 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
619 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
620 int rc = uint_get((int) (log((double) DEFAULT_BLOCK_SIZE) / M_LN2), |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
621 shn, rw, &shn->blocksize); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
622 if (!rc) goto shn_open_puke;; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
623 if (!uint_get(SHN_LPCQSIZE, shn, rw, &shn->maxnlpc)) goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
624 if (!uint_get(0, shn, rw, &shn->nmean)) goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
625 if (!skip_bits(shn, rw)) goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
626 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
627 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
628 shn->nwrap = (shn->maxnlpc > 3) ? shn->maxnlpc : 3; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
629 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
630 /* grab some space for the input buffer */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
631 shn->buffer = shn_long2d((Uint32) shn->nchan, shn->blocksize + shn->nwrap); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
632 shn->offset = shn_long2d((Uint32) shn->nchan, MAX_MACRO(1, shn->nmean)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
633 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
634 for (chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
635 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
636 int i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
637 for(i = 0; i < shn->nwrap; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
638 shn->buffer[chan][i] = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
639 shn->buffer[chan] += shn->nwrap; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
640 } /* for */ |
86 | 641 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
642 if (shn->maxnlpc > 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
643 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
644 shn->qlpc = (int *) malloc((Uint32) (shn->maxnlpc * sizeof (Sint32))); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
645 if (shn->qlpc == NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
646 { |
387
fb519e6028e3
Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
Ryan C. Gordon <icculus@icculus.org>
parents:
377
diff
changeset
|
647 __Sound_SetError(ERR_OUT_OF_MEMORY); |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
648 goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
649 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
650 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
651 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
652 if (shn->version > 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
653 shn->lpcqoffset = SHN_LPCQOFFSET_VER2; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
654 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
655 init_shn_offset(shn->offset, shn->nchan, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
656 MAX_MACRO(1, shn->nmean), shn->datatype); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
657 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
658 if ( (!uvar_get(SHN_FNSIZE, shn, rw, &cmd)) || |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
659 (cmd != SHN_FN_VERBATIM) || |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
660 (!parse_riff_header(shn, sample)) ) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
661 { |
387
fb519e6028e3
Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
Ryan C. Gordon <icculus@icculus.org>
parents:
377
diff
changeset
|
662 if (cmd != SHN_FN_VERBATIM) /* the other conditions set error state */ |
fb519e6028e3
Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
Ryan C. Gordon <icculus@icculus.org>
parents:
377
diff
changeset
|
663 __Sound_SetError("SHN: Expected VERBATIM function"); |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
664 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
665 goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
666 return(0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
667 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
668 |
233
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
669 shn->start_pos = SDL_RWtell(rw); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
670 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
671 shn = (shn_t *) malloc(sizeof (shn_t)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
672 if (shn == NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
673 { |
387
fb519e6028e3
Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
Ryan C. Gordon <icculus@icculus.org>
parents:
377
diff
changeset
|
674 __Sound_SetError(ERR_OUT_OF_MEMORY); |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
675 goto shn_open_puke; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
676 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
677 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
678 memcpy(shn, &_shn, sizeof (shn_t)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
679 internal->decoder_private = shn; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
680 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
681 SNDDBG(("SHN: Accepting data stream.\n")); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
682 sample->flags = SOUND_SAMPLEFLAG_NONE; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
683 return(1); /* we'll handle this data. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
684 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
685 shn_open_puke: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
686 if (_shn.getbuf) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
687 free(_shn.getbuf); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
688 if (_shn.buffer != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
689 free(_shn.buffer); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
690 if (_shn.offset != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
691 free(_shn.offset); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
692 if (_shn.qlpc != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
693 free(_shn.qlpc); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
694 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
695 return(0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
696 } /* SHN_open */ |
86 | 697 |
698 | |
233
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
699 static void fix_bitshift(Sint32 *buffer, int nitem, int bitshift, int ftype) |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
700 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
701 int i; |
86 | 702 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
703 if (ftype == SHN_TYPE_AU1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
704 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
705 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
706 buffer[i] = ulaw_outward[bitshift][buffer[i] + 128]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
707 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
708 else if (ftype == SHN_TYPE_AU2) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
709 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
710 for(i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
711 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
712 if (buffer[i] >= 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
713 buffer[i] = ulaw_outward[bitshift][buffer[i] + 128]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
714 else if (buffer[i] == -1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
715 buffer[i] = NEGATIVE_ULAW_ZERO; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
716 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
717 buffer[i] = ulaw_outward[bitshift][buffer[i] + 129]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
718 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
719 } /* else if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
720 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
721 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
722 if (bitshift != 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
723 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
724 for(i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
725 buffer[i] <<= bitshift; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
726 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
727 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
728 } /* fix_bitshift */ |
86 | 729 |
730 | |
731 static void SHN_close(Sound_Sample *sample) | |
732 { | |
733 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
734 shn_t *shn = (shn_t *) internal->decoder_private; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
735 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
736 if (shn->qlpc != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
737 free(shn->qlpc); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
738 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
739 if (shn->backBuffer != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
740 free(shn->backBuffer); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
741 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
742 if (shn->offset != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
743 free(shn->offset); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
744 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
745 if (shn->buffer != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
746 free(shn->buffer); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
747 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
748 if (shn->getbuf != NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
749 free(shn->getbuf); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
750 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
751 free(shn); |
86 | 752 } /* SHN_close */ |
753 | |
754 | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
755 /* xLaw conversions... */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
756 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
757 /* adapted by ajr for int input */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
758 static Uint8 Slinear2ulaw(int sample) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
759 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
760 /* |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
761 ** This routine converts from linear to ulaw. |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
762 ** |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
763 ** Craig Reese: IDA/Supercomputing Research Center |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
764 ** Joe Campbell: Department of Defense |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
765 ** 29 September 1989 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
766 ** |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
767 ** References: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
768 ** 1) CCITT Recommendation G.711 (very difficult to follow) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
769 ** 2) "A New Digital Technique for Implementation of Any |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
770 ** Continuous PCM Companding Law," Villeret, Michel, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
771 ** et al. 1973 IEEE Int. Conf. on Communications, Vol 1, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
772 ** 1973, pg. 11.12-11.17 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
773 ** 3) MIL-STD-188-113,"Interoperability and Performance Standards |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
774 ** for Analog-to_Digital Conversion Techniques," |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
775 ** 17 February 1987 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
776 ** |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
777 ** Input: Signed 16 bit linear sample |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
778 ** Output: 8 bit ulaw sample |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
779 */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
780 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
781 #define BIAS 0x84 /* define the add-in bias for 16 bit samples */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
782 #define CLIP 32635 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
783 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
784 int sign, exponent, mantissa; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
785 Uint8 ulawbyte; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
786 static const int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
787 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
788 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
789 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
790 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
791 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
792 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
793 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
794 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
795 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
796 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
797 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
798 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
799 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
800 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
801 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
802 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
803 /* Get the sample into sign-magnitude. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
804 if (sample >= 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
805 sign = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
806 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
807 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
808 sign = 0x80; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
809 sample = -sample; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
810 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
811 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
812 /* clip the magnitude */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
813 if (sample > CLIP) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
814 sample = CLIP; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
815 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
816 /* Convert from 16 bit linear to ulaw. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
817 sample = sample + BIAS; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
818 exponent = exp_lut[( sample >> 7 ) & 0xFF]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
819 mantissa = (sample >> (exponent + 3)) & 0x0F; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
820 ulawbyte = ~(sign | (exponent << 4) | mantissa); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
821 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
822 return(ulawbyte); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
823 } /* Slinear2ulaw */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
824 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
825 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
826 /* this is derived from the Sun code - it is a bit simpler and has int input */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
827 #define QUANT_MASK (0xf) /* Quantization field mask. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
828 #define NSEGS (8) /* Number of A-law segments. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
829 #define SEG_SHIFT (4) /* Left shift for segment number. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
830 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
831 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
832 static Uint8 Slinear2alaw(Sint32 linear) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
833 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
834 int seg; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
835 Uint8 aval, mask; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
836 static const Sint32 seg_aend[NSEGS] = |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
837 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
838 0x1f,0x3f,0x7f,0xff,0x1ff,0x3ff,0x7ff,0xfff |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
839 }; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
840 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
841 linear >>= 3; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
842 if(linear >= 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
843 mask = 0xd5; /* sign (7th) bit = 1 */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
844 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
845 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
846 mask = 0x55; /* sign bit = 0 */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
847 linear = -linear - 1; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
848 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
849 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
850 /* Convert the scaled magnitude to segment number. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
851 for (seg = 0; (seg < NSEGS) && (linear > seg_aend[seg]); seg++); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
852 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
853 /* Combine the sign, segment, and quantization bits. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
854 if (seg >= NSEGS) /* out of range, return maximum value. */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
855 return((Uint8) (0x7F ^ mask)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
856 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
857 aval = (Uint8) seg << SEG_SHIFT; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
858 if (seg < 2) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
859 aval |= (linear >> 1) & QUANT_MASK; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
860 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
861 aval |= (linear >> seg) & QUANT_MASK; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
862 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
863 return (aval ^ mask); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
864 } /* Slinear2alaw */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
865 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
866 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
867 /* convert from signed ints to a given type and write */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
868 static Uint32 put_to_buffers(Sound_Sample *sample, Uint32 bw) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
869 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
870 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
871 shn_t *shn = (shn_t *) internal->decoder_private; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
872 int i, chan; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
873 Sint32 *data0 = shn->buffer[0]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
874 Sint32 nitem = shn->blocksize; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
875 int datasize = ((sample->actual.format & 0xFF) / 8); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
876 Uint32 bsiz = shn->nchan * nitem * datasize; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
877 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
878 assert(shn->backBufLeft == 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
879 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
880 if (shn->backBufferSize < bsiz) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
881 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
882 void *rc = realloc(shn->backBuffer, bsiz); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
883 if (rc == NULL) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
884 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
885 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
886 BAIL_MACRO(ERR_OUT_OF_MEMORY, 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
887 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
888 shn->backBuffer = (Uint8 *) rc; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
889 shn->backBufferSize = bsiz; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
890 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
891 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
892 switch (shn->datatype) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
893 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
894 case SHN_TYPE_AU1: /* leave the conversion to fix_bitshift() */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
895 case SHN_TYPE_AU2: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
896 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
897 Uint8 *writebufp = shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
898 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
899 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
900 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
901 *writebufp++ = data0[i]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
902 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
903 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
904 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
905 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
906 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
907 for (chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
908 *writebufp++ = shn->buffer[chan][i]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
909 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
910 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
911 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
912 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
913 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
914 case SHN_TYPE_U8: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
915 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
916 Uint8 *writebufp = shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
917 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
918 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
919 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
920 *writebufp++ = CAPMAXUCHAR(data0[i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
921 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
922 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
923 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
924 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
925 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
926 for (chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
927 *writebufp++ = CAPMAXUCHAR(shn->buffer[chan][i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
928 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
929 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
930 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
931 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
932 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
933 case SHN_TYPE_S8: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
934 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
935 Sint8 *writebufp = (Sint8 *) shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
936 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
937 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
938 for(i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
939 *writebufp++ = CAPMAXSCHAR(data0[i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
940 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
941 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
942 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
943 for(i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
944 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
945 for(chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
946 *writebufp++ = CAPMAXSCHAR(shn->buffer[chan][i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
947 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
948 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
949 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
950 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
951 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
952 case SHN_TYPE_S16HL: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
953 case SHN_TYPE_S16LH: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
954 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
955 Sint16 *writebufp = (Sint16 *) shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
956 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
957 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
958 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
959 *writebufp++ = CAPMAXSHORT(data0[i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
960 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
961 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
962 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
963 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
964 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
965 for (chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
966 *writebufp++ = CAPMAXSHORT(shn->buffer[chan][i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
967 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
968 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
969 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
970 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
971 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
972 case SHN_TYPE_U16HL: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
973 case SHN_TYPE_U16LH: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
974 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
975 Uint16 *writebufp = (Uint16 *) shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
976 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
977 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
978 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
979 *writebufp++ = CAPMAXUSHORT(data0[i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
980 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
981 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
982 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
983 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
984 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
985 for (chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
986 *writebufp++ = CAPMAXUSHORT(shn->buffer[chan][i]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
987 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
988 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
989 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
990 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
991 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
992 case SHN_TYPE_ULAW: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
993 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
994 Uint8 *writebufp = shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
995 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
996 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
997 for(i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
998 *writebufp++ = Slinear2ulaw(CAPMAXSHORT((data0[i] << 3))); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
999 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1000 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1001 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1002 for(i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1003 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1004 for(chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1005 *writebufp++ = Slinear2ulaw(CAPMAXSHORT((shn->buffer[chan][i] << 3))); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1006 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1007 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1008 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1009 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1010 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1011 case SHN_TYPE_AU3: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1012 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1013 Uint8 *writebufp = shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1014 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1015 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1016 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1017 if(data0[i] < 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1018 *writebufp++ = (127 - data0[i]) ^ 0xd5; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1019 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1020 *writebufp++ = (data0[i] + 128) ^ 0x55; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1021 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1022 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1023 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1024 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1025 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1026 for (chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1027 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1028 if (shn->buffer[chan][i] < 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1029 *writebufp++ = (127 - shn->buffer[chan][i]) ^ 0xd5; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1030 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1031 *writebufp++ = (shn->buffer[chan][i] + 128) ^ 0x55; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1032 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1033 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1034 } /* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1035 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1036 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1037 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1038 case SHN_TYPE_ALAW: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1039 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1040 Uint8 *writebufp = shn->backBuffer; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1041 if (shn->nchan == 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1042 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1043 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1044 *writebufp++ = Slinear2alaw(CAPMAXSHORT((data0[i] << 3))); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1045 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1046 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1047 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1048 for (i = 0; i < nitem; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1049 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1050 for(chan = 0; chan < shn->nchan; chan++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1051 *writebufp++ = Slinear2alaw(CAPMAXSHORT((shn->buffer[chan][i] << 3))); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1052 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1053 }/* else */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1054 } /* case */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1055 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1056 } /* switch */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1057 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1058 i = MIN_MACRO(internal->buffer_size - bw, bsiz); |
126 | 1059 memcpy((char *)internal->buffer + bw, shn->backBuffer, i); |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1060 shn->backBufLeft = bsiz - i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1061 memcpy(shn->backBuffer, shn->backBuffer + i, shn->backBufLeft); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1062 return(i); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1063 } /* put_to_buffers */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1064 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1065 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1066 #define ROUNDEDSHIFTDOWN(x, n) (((n) == 0) ? (x) : ((x) >> ((n) - 1)) >> 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1067 |
86 | 1068 static Uint32 SHN_read(Sound_Sample *sample) |
1069 { | |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1070 Uint32 retval = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1071 Sint32 chan = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1072 Uint32 cpyBytes = 0; |
86 | 1073 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1074 SDL_RWops *rw = internal->rw; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1075 shn_t *shn = (shn_t *) internal->decoder_private; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1076 Sint32 cmd; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1077 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1078 assert(shn->backBufLeft >= 0); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1079 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1080 /* see if there are leftovers to copy... */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1081 if (shn->backBufLeft > 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1082 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1083 retval = MIN_MACRO(shn->backBufLeft, internal->buffer_size); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1084 memcpy(internal->buffer, shn->backBuffer, retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1085 shn->backBufLeft -= retval; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1086 memcpy(shn->backBuffer, shn->backBuffer + retval, shn->backBufLeft); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1087 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1088 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1089 assert((shn->backBufLeft == 0) || (retval == internal->buffer_size)); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1090 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1091 /* get commands from file and execute them */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1092 while (retval < internal->buffer_size) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1093 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1094 if (!uvar_get(SHN_FNSIZE, shn, rw, &cmd)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1095 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1096 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1097 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1098 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1099 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1100 if (cmd == SHN_FN_QUIT) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1101 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1102 sample->flags |= SOUND_SAMPLEFLAG_EOF; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1103 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1104 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1105 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1106 switch(cmd) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1107 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1108 case SHN_FN_ZERO: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1109 case SHN_FN_DIFF0: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1110 case SHN_FN_DIFF1: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1111 case SHN_FN_DIFF2: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1112 case SHN_FN_DIFF3: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1113 case SHN_FN_QLPC: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1114 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1115 Sint32 i; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1116 Sint32 coffset, *cbuffer = shn->buffer[chan]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1117 Sint32 resn = 0, nlpc, j; |
86 | 1118 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1119 if (cmd != SHN_FN_ZERO) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1120 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1121 if (!uvar_get(SHN_ENERGYSIZE, shn, rw, &resn)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1122 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1123 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1124 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1125 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1126 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1127 /* version 0 differed in definition of var_get */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1128 if (shn->version == 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1129 resn--; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1130 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1131 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1132 /* find mean offset : N.B. this code duplicated */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1133 if (shn->nmean == 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1134 coffset = shn->offset[chan][0]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1135 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1136 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1137 Sint32 sum = (shn->version < 2) ? 0 : shn->nmean / 2; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1138 for (i = 0; i < shn->nmean; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1139 sum += shn->offset[chan][i]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1140 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1141 if (shn->version < 2) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1142 coffset = sum / shn->nmean; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1143 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1144 coffset = ROUNDEDSHIFTDOWN(sum / shn->nmean, shn->bitshift); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1145 } /* else */ |
86 | 1146 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1147 switch (cmd) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1148 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1149 case SHN_FN_ZERO: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1150 for (i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1151 cbuffer[i] = 0; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1152 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1153 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1154 case SHN_FN_DIFF0: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1155 for(i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1156 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1157 if (!var_get(resn, shn, rw, &cbuffer[i])) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1158 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1159 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1160 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1161 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1162 cbuffer[i] += coffset; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1163 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1164 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1165 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1166 case SHN_FN_DIFF1: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1167 for(i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1168 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1169 if (!var_get(resn, shn, rw, &cbuffer[i])) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1170 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1171 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1172 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1173 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1174 cbuffer[i] += cbuffer[i - 1]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1175 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1176 break; |
86 | 1177 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1178 case SHN_FN_DIFF2: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1179 for (i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1180 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1181 if (!var_get(resn, shn, rw, &cbuffer[i])) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1182 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1183 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1184 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1185 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1186 cbuffer[i] += (2 * cbuffer[i-1] - cbuffer[i-2]); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1187 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1188 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1189 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1190 case SHN_FN_DIFF3: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1191 for (i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1192 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1193 if (!var_get(resn, shn, rw, &cbuffer[i])) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1194 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1195 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1196 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1197 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1198 cbuffer[i] += 3 * (cbuffer[i - 1] - cbuffer[i - 2]) + cbuffer[i - 3]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1199 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1200 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1201 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1202 case SHN_FN_QLPC: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1203 if (!uvar_get(SHN_LPCQSIZE, shn, rw, &nlpc)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1204 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1205 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1206 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1207 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1208 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1209 for(i = 0; i < nlpc; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1210 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1211 if (!var_get(SHN_LPCQUANT, shn, rw, &shn->qlpc[i])) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1212 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1213 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1214 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1215 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1216 } /* for */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1217 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1218 for(i = 0; i < nlpc; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1219 cbuffer[i - nlpc] -= coffset; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1220 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1221 for(i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1222 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1223 Sint32 sum = shn->lpcqoffset; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1224 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1225 for(j = 0; j < nlpc; j++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1226 sum += shn->qlpc[j] * cbuffer[i - j - 1]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1227 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1228 if (!var_get(resn, shn, rw, &cbuffer[i])) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1229 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1230 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1231 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1232 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1233 cbuffer[i] += (sum >> SHN_LPCQUANT); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1234 } /* for */ |
86 | 1235 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1236 if (coffset != 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1237 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1238 for(i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1239 cbuffer[i] += coffset; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1240 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1241 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1242 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1243 } /* switch */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1244 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1245 /* store mean value if appropriate : N.B. Duplicated code */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1246 if (shn->nmean > 0) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1247 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1248 Sint32 sum = (shn->version < 2) ? 0 : shn->blocksize / 2; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1249 for (i = 0; i < shn->blocksize; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1250 sum += cbuffer[i]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1251 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1252 for(i = 1; i < shn->nmean; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1253 shn->offset[chan][i - 1] = shn->offset[chan][i]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1254 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1255 if (shn->version < 2) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1256 shn->offset[chan][shn->nmean - 1] = sum / shn->blocksize; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1257 else |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1258 shn->offset[chan][shn->nmean - 1] = (sum / shn->blocksize) << shn->bitshift; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1259 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1260 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1261 /* do the wrap */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1262 for(i = -shn->nwrap; i < 0; i++) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1263 cbuffer[i] = cbuffer[i + shn->blocksize]; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1264 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1265 fix_bitshift(cbuffer, shn->blocksize, shn->bitshift, shn->datatype); |
86 | 1266 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1267 if (chan == shn->nchan - 1) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1268 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1269 retval += put_to_buffers(sample, retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1270 if (sample->flags & SOUND_SAMPLEFLAG_ERROR) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1271 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1272 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1273 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1274 chan = (chan + 1) % shn->nchan; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1275 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1276 } /* case */ |
86 | 1277 |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1278 case SHN_FN_BLOCKSIZE: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1279 if (!uint_get((int) (log((double) shn->blocksize) / M_LN2), |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1280 shn, rw, &shn->blocksize)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1281 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1282 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1283 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1284 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1285 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1286 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1287 case SHN_FN_BITSHIFT: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1288 if (!uvar_get(SHN_BITSHIFTSIZE, shn, rw, &shn->bitshift)) |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1289 { |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1290 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1291 return(retval); |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1292 } /* if */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1293 break; |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1294 |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1295 case SHN_FN_VERBATIM: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1296 default: |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1297 sample->flags |= SOUND_SAMPLEFLAG_ERROR; |
387
fb519e6028e3
Changed all the Sound_SetError() calls to __Sound_SetError (or BAIL*_MACRO)
Ryan C. Gordon <icculus@icculus.org>
parents:
377
diff
changeset
|
1298 BAIL_MACRO("SHN: Unhandled function.", retval); |
101
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1299 } /* switch */ |
c08794028df4
Fully implemented. Needs testing, but it works on the Grateful Dead show I
Ryan C. Gordon <icculus@icculus.org>
parents:
100
diff
changeset
|
1300 } /* while */ |
86 | 1301 |
1302 return(retval); | |
1303 } /* SHN_read */ | |
1304 | |
221
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
1305 |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
1306 static int SHN_rewind(Sound_Sample *sample) |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
1307 { |
233
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1308 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1309 shn_t *shn = (shn_t *) internal->decoder_private; |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1310 |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1311 #if 0 |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1312 int rc = SDL_RWseek(internal->rw, shn->start_pos, SEEK_SET); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1313 BAIL_IF_MACRO(rc != shn->start_pos, ERR_IO_ERROR, 0); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1314 /* !!! FIXME: set state. */ |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1315 return(1); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1316 #else |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1317 /* |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1318 * !!! FIXME: This is really unacceptable; state should be reset and |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1319 * !!! FIXME: the RWops should be pointed to the start of the data |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1320 * !!! FIXME: to decode. The below kludge adds unneeded overhead and |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1321 * !!! FIXME: risk of failure. |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1322 */ |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1323 BAIL_IF_MACRO(SDL_RWseek(internal->rw, 0, SEEK_SET) != 0, ERR_IO_ERROR, 0); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1324 SHN_close(sample); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1325 return(SHN_open(sample, "SHN")); |
15a3b1a1291c
Kludged implementation of the rewind method.
Ryan C. Gordon <icculus@icculus.org>
parents:
221
diff
changeset
|
1326 #endif |
221
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
1327 } /* SHN_rewind */ |
c9772a9f5271
Initial implementation or stubs for rewind method. Other cleanups.
Ryan C. Gordon <icculus@icculus.org>
parents:
212
diff
changeset
|
1328 |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
1329 |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
1330 static int SHN_seek(Sound_Sample *sample, Uint32 ms) |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
1331 { |
425
b4abd7c48b6e
Added a comment for later.
Ryan C. Gordon <icculus@icculus.org>
parents:
401
diff
changeset
|
1332 /* |
b4abd7c48b6e
Added a comment for later.
Ryan C. Gordon <icculus@icculus.org>
parents:
401
diff
changeset
|
1333 * (This CAN be done for SHNs that have a seek table at the end of the |
b4abd7c48b6e
Added a comment for later.
Ryan C. Gordon <icculus@icculus.org>
parents:
401
diff
changeset
|
1334 * stream, btw.) |
b4abd7c48b6e
Added a comment for later.
Ryan C. Gordon <icculus@icculus.org>
parents:
401
diff
changeset
|
1335 */ |
351 | 1336 BAIL_MACRO("SHN: Seeking not implemented", 0); |
306
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
1337 } /* SHN_seek */ |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
1338 |
c97be6e1bd27
Added framework for Sound_Seek() support.
Ryan C. Gordon <icculus@icculus.org>
parents:
301
diff
changeset
|
1339 |
86 | 1340 #endif /* defined SOUND_SUPPORTS_SHN */ |
1341 | |
1342 /* end of shn.c ... */ | |
1343 |