diff options
Diffstat (limited to 'apps/codecs/au.c')
-rw-r--r-- | apps/codecs/au.c | 63 |
1 files changed, 19 insertions, 44 deletions
diff --git a/apps/codecs/au.c b/apps/codecs/au.c index cf2a799be6..19348bc299 100644 --- a/apps/codecs/au.c +++ b/apps/codecs/au.c | |||
@@ -45,35 +45,17 @@ enum | |||
45 | AU_FORMAT_ALAW, /* G.711 ALAW */ | 45 | AU_FORMAT_ALAW, /* G.711 ALAW */ |
46 | }; | 46 | }; |
47 | 47 | ||
48 | static int support_formats[28][2] = { | 48 | static const char support_formats[9][2] = { |
49 | { AU_FORMAT_UNSUPPORT, 0 }, | 49 | { AU_FORMAT_UNSUPPORT, 0 }, /* encoding */ |
50 | { AU_FORMAT_MULAW, 8 }, /* G.711 MULAW */ | 50 | { AU_FORMAT_MULAW, 8 }, /* 1: G.711 MULAW */ |
51 | { AU_FORMAT_PCM, 8 }, /* Linear PCM 8bit (signed) */ | 51 | { AU_FORMAT_PCM, 8 }, /* 2: Linear PCM 8bit (signed) */ |
52 | { AU_FORMAT_PCM, 16 }, /* Linear PCM 16bit (signed, big endian) */ | 52 | { AU_FORMAT_PCM, 16 }, /* 3: Linear PCM 16bit (signed, big endian) */ |
53 | { AU_FORMAT_PCM, 24 }, /* Linear PCM 24bit (signed, big endian) */ | 53 | { AU_FORMAT_PCM, 24 }, /* 4: Linear PCM 24bit (signed, big endian) */ |
54 | { AU_FORMAT_PCM, 32 }, /* Linear PCM 32bit (signed, big endian) */ | 54 | { AU_FORMAT_PCM, 32 }, /* 5: Linear PCM 32bit (signed, big endian) */ |
55 | { AU_FORMAT_IEEE_FLOAT, 32 }, /* Linear PCM float 32bit (signed, big endian) */ | 55 | { AU_FORMAT_IEEE_FLOAT, 32 }, /* 6: Linear PCM float 32bit (signed, big endian) */ |
56 | { AU_FORMAT_IEEE_FLOAT, 64 }, /* Linear PCM float 64bit (signed, big endian) */ | 56 | { AU_FORMAT_IEEE_FLOAT, 64 }, /* 7: Linear PCM float 64bit (signed, big endian) */ |
57 | { AU_FORMAT_UNSUPPORT, 0 }, /* Fragmented sample data */ | 57 | /* encoding 8 - 26 unsupported. */ |
58 | { AU_FORMAT_UNSUPPORT, 0 }, /* DSP program */ | 58 | { AU_FORMAT_ALAW, 8 }, /* 27: G.711 ALAW */ |
59 | { AU_FORMAT_UNSUPPORT, 0 }, /* 8bit fixed point */ | ||
60 | { AU_FORMAT_UNSUPPORT, 0 }, /* 16bit fixed point */ | ||
61 | { AU_FORMAT_UNSUPPORT, 0 }, /* 24bit fixed point */ | ||
62 | { AU_FORMAT_UNSUPPORT, 0 }, /* 32bit fixed point */ | ||
63 | { AU_FORMAT_UNSUPPORT, 0 }, | ||
64 | { AU_FORMAT_UNSUPPORT, 0 }, | ||
65 | { AU_FORMAT_UNSUPPORT, 0 }, | ||
66 | { AU_FORMAT_UNSUPPORT, 0 }, | ||
67 | { AU_FORMAT_UNSUPPORT, 0 }, /* 16bit linear with emphasis */ | ||
68 | { AU_FORMAT_UNSUPPORT, 0 }, /* 16bit linear compressed */ | ||
69 | { AU_FORMAT_UNSUPPORT, 0 }, /* 16bit linear with emphasis and compression */ | ||
70 | { AU_FORMAT_UNSUPPORT, 0 }, /* Music kit DSP commands */ | ||
71 | { AU_FORMAT_UNSUPPORT, 0 }, | ||
72 | { AU_FORMAT_UNSUPPORT, 0 }, /* G.721 MULAW */ | ||
73 | { AU_FORMAT_UNSUPPORT, 0 }, /* G.722 */ | ||
74 | { AU_FORMAT_UNSUPPORT, 0 }, /* G.723 3bit */ | ||
75 | { AU_FORMAT_UNSUPPORT, 0 }, /* G.723 5bit */ | ||
76 | { AU_FORMAT_ALAW, 8 }, /* G.711 ALAW */ | ||
77 | }; | 59 | }; |
78 | 60 | ||
79 | const struct pcm_entry au_codecs[] = { | 61 | const struct pcm_entry au_codecs[] = { |
@@ -108,16 +90,17 @@ static unsigned int get_be32(uint8_t *buf) | |||
108 | 90 | ||
109 | static int convert_au_format(unsigned int encoding, struct pcm_format *fmt) | 91 | static int convert_au_format(unsigned int encoding, struct pcm_format *fmt) |
110 | { | 92 | { |
111 | if (encoding > 27) | 93 | fmt->formattag = AU_FORMAT_UNSUPPORT; |
112 | { | 94 | if (encoding < 8) |
113 | fmt->formattag = AU_FORMAT_UNSUPPORT; | ||
114 | fmt->bitspersample = 0; | ||
115 | } | ||
116 | else | ||
117 | { | 95 | { |
118 | fmt->formattag = support_formats[encoding][0]; | 96 | fmt->formattag = support_formats[encoding][0]; |
119 | fmt->bitspersample = support_formats[encoding][1]; | 97 | fmt->bitspersample = support_formats[encoding][1]; |
120 | } | 98 | } |
99 | else if (encoding == 27) | ||
100 | { | ||
101 | fmt->formattag = support_formats[8][0]; | ||
102 | fmt->bitspersample = support_formats[8][1]; | ||
103 | } | ||
121 | 104 | ||
122 | return fmt->formattag; | 105 | return fmt->formattag; |
123 | } | 106 | } |
@@ -138,7 +121,7 @@ enum codec_status codec_main(void) | |||
138 | int offset = 0; | 121 | int offset = 0; |
139 | 122 | ||
140 | /* Generic codec initialisation */ | 123 | /* Generic codec initialisation */ |
141 | ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH); | 124 | ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); |
142 | 125 | ||
143 | next_track: | 126 | next_track: |
144 | if (codec_init()) { | 127 | if (codec_init()) { |
@@ -199,11 +182,6 @@ next_track: | |||
199 | } | 182 | } |
200 | /* skip sample rate */ | 183 | /* skip sample rate */ |
201 | format.channels = get_be32(buf + 20); | 184 | format.channels = get_be32(buf + 20); |
202 | if (format.channels == 0) { | ||
203 | DEBUGF("CODEC_ERROR: sun audio 0-channels file\n"); | ||
204 | status = CODEC_ERROR; | ||
205 | goto done; | ||
206 | } | ||
207 | } | 185 | } |
208 | 186 | ||
209 | /* advance to first WAVE chunk */ | 187 | /* advance to first WAVE chunk */ |
@@ -215,9 +193,6 @@ next_track: | |||
215 | codec = 0; | 193 | codec = 0; |
216 | bytesdone = 0; | 194 | bytesdone = 0; |
217 | 195 | ||
218 | /* blockalign = 1 sample */ | ||
219 | format.blockalign = format.bitspersample * format.channels >> 3; | ||
220 | |||
221 | /* get codec */ | 196 | /* get codec */ |
222 | codec = get_au_codec(format.formattag); | 197 | codec = get_au_codec(format.formattag); |
223 | if (!codec) | 198 | if (!codec) |