6 #include <proto/exec.h>
17 WORD blockAlign
; /* amount to read for each block */
20 WORD extraSize
; /* 2 */
24 struct WAV_G72x_state
{
25 struct g72x_state stat
[MAX_CHANNELS
];
26 int (*decoder
)(int code
, struct g72x_state
*state_ptr
);
29 DEC_SETUPPROTO(SetupG72x
) {
30 struct G72x_Format
* fmt
;
31 struct WAV_G72x_state
* state
;
33 fmt
= (struct G72x_Format
*)data
->fmt
;
35 if (fmt
->extraSize
!= 2)
37 //if (fmt->numChannels != 1)
38 // return ERROR_NOT_IMPLEMENTED;
40 fmt
->auxSize
= le2nat16(fmt
->auxSize
);
42 data
->state
= state
= (struct WAV_G72x_state
*)AllocVec(sizeof(*state
), MEMF_CLEAR
);
43 if (!state
) return ERROR_NO_FREE_STORE
;
45 for (ch
= 0; ch
< fmt
->numChannels
; ch
++)
46 g72x_init_state(&state
->stat
[ch
]);
48 switch (fmt
->formatTag
) {
49 case WAVE_FORMAT_G721_ADPCM
:
50 switch (fmt
->bitsPerSample
) {
52 fmt
->blockAlign
= 64*fmt
->numChannels
+ fmt
->auxSize
;
53 state
->decoder
= g721_decoder
;
56 return DTERROR_UNKNOWN_COMPRESSION
;
59 case WAVE_FORMAT_G723_ADPCM
:
60 switch (fmt
->bitsPerSample
) {
62 fmt
->blockAlign
= 32*fmt
->numChannels
+ fmt
->auxSize
;
63 state
->decoder
= g723_16_decoder
;
66 fmt
->blockAlign
= 48*fmt
->numChannels
+ fmt
->auxSize
;
67 state
->decoder
= g723_24_decoder
;
70 fmt
->blockAlign
= 80*fmt
->numChannels
+ fmt
->auxSize
;
71 state
->decoder
= g723_40_decoder
;
74 return DTERROR_UNKNOWN_COMPRESSION
;
78 return DTERROR_UNKNOWN_COMPRESSION
;
80 data
->blockFrames
= 128;
84 /*DEC_CLEANUPPROTO(CleanupG72x) {
85 struct ClassBase * libBase;
86 struct WAV_G72x_state * state;
87 libBase = data->libBase;
88 state = (struct WAV_G72x_state *)data->state;
92 DECODERPROTO(DecodeG72x
) {
93 struct WAV_G72x_state
* state
;
96 state
= (struct WAV_G72x_state
*)data
->state
;
97 bitpack_init(&bp
, Src
+((struct G72x_Format
*)fmt
)->auxSize
, 0);
98 for (fr
= 0; fr
< numFrames
; fr
++) {
99 for (ch
= 0; ch
< fmt
->numChannels
; ch
++) {
101 (state
->decoder(bitpack_read_msb(&bp
, fmt
->bitsPerSample
), &state
->stat
[ch
]) >> 8);