6 #include "wave_gsm610.h"
7 #include "gsm/private.h"
14 WORD blockAlign
; /* amount to read for each block */
17 WORD extraSize
; /* 2 */
26 DEC_SETUPPROTO(SetupGSM610
) {
28 struct GSM610_Format
* fmt
;
29 struct gsmstate
* state
;
31 fmt
= (struct GSM610_Format
*)data
->fmt
;
33 if (fmt
->numChannels
!= 1)
34 return ERROR_NOT_IMPLEMENTED
;
36 data
->state
= state
= AllocVec(sizeof(*state
), MEMF_CLEAR
);
37 if (!state
) return ERROR_NO_FREE_STORE
;
39 // state->handle = gsm_create();
40 state
->handle
= (gsm
)AllocMem(sizeof(struct gsm_state
), MEMF_CLEAR
);
42 return ERROR_NO_FREE_STORE
;
43 state
->handle
->nrp
=40;
45 // gsm_option(state->handle, GSM_OPT_WAV49, &valP);
46 state
->handle
->wav_fmt
= TRUE
;
49 if (fmt
->extraSize
== 0 || fmt
->samplesPerBlock
== 0)
50 data
->blockFrames
= 320;
51 else if (fmt
->extraSize
== 2)
52 data
->blockFrames
= read_le16(&fmt
->samplesPerBlock
);
56 state
->samples
= AllocVec(2*data
->blockFrames
, MEMF_CLEAR
);
58 return ERROR_NO_FREE_STORE
;
63 DEC_CLEANUPPROTO(CleanupGSM610
) {
64 struct gsmstate
* state
;
66 state
= (struct gsmstate
*)data
->state
;
68 FreeVec(state
->samples
);
70 // gsm_destroy(state->handle);
71 if (state
->handle
) FreeMem(state
->handle
, sizeof(struct gsm_state
));
76 DECODERPROTO(DecodeGSM610
) {
77 struct gsmstate
* state
;
80 state
= (struct gsmstate
*)data
->state
;
82 for (ch
= 0; ch
< fmt
->numChannels
; ch
++) {
83 /* decode the long 33 byte half */
84 if (gsm_decode(state
->handle
, Src
, state
->samples
) < 0) {
87 /* decode the short 32 byte half */
88 if (gsm_decode(state
->handle
, Src
+33, state
->samples
+160) < 0) {
91 buff
= state
->samples
;
92 for (fr
= 0; fr
< numFrames
; fr
++) {
93 *Dst
[ch
]++ = (*buff
++)>> 8;