revert between 56095 -> 55830 in arch
[AROS.git] / workbench / classes / datatypes / wav / decoders.c
blob6e6c123f5ddb4df23df937128441a50e3783f2b2
1 /*
2 * wave.datatype
3 * (c) Fredrik Wikstrom
4 */
6 #include "wave_class.h"
7 #include "decoders.h"
9 #include "wave_pcm.h"
10 #include "wave_ima_adpcm.h"
11 #include "wave_ms_adpcm.h"
12 #include "wave_alaw.h"
13 #include "wave_ieee_float.h"
14 #include "wave_gsm610.h"
15 #include "wave_g72x.h"
17 DECODERPROTO(DecodeBlocks);
19 static struct Decoder all_decoders[] = {
20 { WAVE_FORMAT_PCM, 0, SetupPCM, NULL, DecodePCM, NULL },
21 { WAVE_FORMAT_IMA_ADPCM, 0, SetupIMA_ADPCM, NULL, DecodeBlocks, DecodeIMA_ADPCM },
22 { WAVE_FORMAT_ADPCM, 0, SetupMS_ADPCM, NULL, DecodeBlocks, DecodeMS_ADPCM },
23 { WAVE_FORMAT_IEEE_FLOAT, 0, SetupIEEE_Float, NULL, NULL, NULL },
24 { WAVE_FORMAT_ALAW, 0, SetupALaw, NULL, DecodeALaw, NULL },
25 { WAVE_FORMAT_MULAW, 0, SetupALaw, NULL, DecodeMuLaw, NULL },
26 #ifdef GSM610_SUPPORT
27 { WAVE_FORMAT_GSM610, 0, SetupGSM610, CleanupGSM610, DecodeBlocks, DecodeGSM610 },
28 #endif
29 #ifdef G72X_SUPPORT
30 { WAVE_FORMAT_G721_ADPCM, 0, SetupG72x, NULL, DecodeBlocks, DecodeG72x },
31 { WAVE_FORMAT_G723_ADPCM, 0, SetupG72x, NULL, DecodeBlocks, DecodeG72x },
32 #endif
33 { 0 }
36 struct Decoder * GetDecoder (UWORD fmtTag) {
37 struct Decoder *dec;
38 for (dec = all_decoders; dec->formatTag; dec++) {
39 if (dec->formatTag == fmtTag)
40 return dec;
42 return NULL;
45 DECODERPROTO(DecodeBlocks) {
46 LONG status;
47 LONG frames_left;
48 LONG frames;
49 LONG blocksize;
51 frames_left = numFrames;
52 frames = data->blockFrames;
53 blocksize = fmt->blockAlign;
54 while (frames_left > 0) {
55 if (frames_left < frames) frames = frames_left;
57 status = data->DecodeFrames(data, fmt, Src, Dst, 1, frames);
58 if (status != frames) {
59 return numFrames-frames_left+status;
61 Src += blocksize;
63 frames_left -= frames;
65 return numFrames;