summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshihisa Uchida <uchida@rockbox.org>2010-03-07 07:15:21 +0000
committerYoshihisa Uchida <uchida@rockbox.org>2010-03-07 07:15:21 +0000
commitf640b89a12eb6a222c0371624fe56a2a6dd6d649 (patch)
treeb7d4ea57d7ce48e23f1d23ba61375e35c371c92f
parent792f7335af244ced7e467047a0e450998547fa2e (diff)
downloadrockbox-f640b89a12eb6a222c0371624fe56a2a6dd6d649.tar.gz
rockbox-f640b89a12eb6a222c0371624fe56a2a6dd6d649.zip
wave codec
- does not get dwAvgBytesPerSec wave/aiff/smaf/wave64 codec - corrects the problem that codec_main() returns invalid value. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25051 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/aiff.c60
-rw-r--r--apps/codecs/smaf.c19
-rw-r--r--apps/codecs/wav.c38
-rw-r--r--apps/codecs/wav64.c15
4 files changed, 65 insertions, 67 deletions
diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c
index 3ad6ecfbbf..18a48a329a 100644
--- a/apps/codecs/aiff.c
+++ b/apps/codecs/aiff.c
@@ -75,7 +75,6 @@ enum codec_status codec_main(void)
75 struct pcm_format format; 75 struct pcm_format format;
76 uint32_t bytesdone, decodedsamples; 76 uint32_t bytesdone, decodedsamples;
77 uint32_t num_sample_frames = 0; 77 uint32_t num_sample_frames = 0;
78 uint32_t i = CODEC_OK;
79 size_t n; 78 size_t n;
80 int bufcount; 79 int bufcount;
81 int endofstream; 80 int endofstream;
@@ -85,13 +84,14 @@ enum codec_status codec_main(void)
85 off_t firstblockposn; /* position of the first block in file */ 84 off_t firstblockposn; /* position of the first block in file */
86 bool is_aifc = false; 85 bool is_aifc = false;
87 const struct pcm_codec *codec; 86 const struct pcm_codec *codec;
87 uint32_t size;
88 88
89 /* Generic codec initialisation */ 89 /* Generic codec initialisation */
90 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH); 90 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH);
91 91
92next_track: 92next_track:
93 if (codec_init()) { 93 if (codec_init()) {
94 i = CODEC_ERROR; 94 status = CODEC_ERROR;
95 goto exit; 95 goto exit;
96 } 96 }
97 97
@@ -103,14 +103,14 @@ next_track:
103 /* assume the AIFF header is less than 1024 bytes */ 103 /* assume the AIFF header is less than 1024 bytes */
104 buf = ci->request_buffer(&n, 1024); 104 buf = ci->request_buffer(&n, 1024);
105 if (n < 54) { 105 if (n < 54) {
106 i = CODEC_ERROR; 106 status = CODEC_ERROR;
107 goto done; 107 goto done;
108 } 108 }
109 109
110 if (memcmp(buf, "FORM", 4) != 0) 110 if (memcmp(buf, "FORM", 4) != 0)
111 { 111 {
112 DEBUGF("CODEC_ERROR: does not aiff format %c%c%c%c\n", buf[0], buf[1], buf[2], buf[3]); 112 DEBUGF("CODEC_ERROR: does not aiff format %c%c%c%c\n", buf[0], buf[1], buf[2], buf[3]);
113 i = CODEC_ERROR; 113 status = CODEC_ERROR;
114 goto done; 114 goto done;
115 } 115 }
116 if (memcmp(&buf[8], "AIFF", 4) == 0) 116 if (memcmp(&buf[8], "AIFF", 4) == 0)
@@ -120,7 +120,7 @@ next_track:
120 else 120 else
121 { 121 {
122 DEBUGF("CODEC_ERROR: does not aiff format %c%c%c%c\n", buf[8], buf[9], buf[10], buf[11]); 122 DEBUGF("CODEC_ERROR: does not aiff format %c%c%c%c\n", buf[8], buf[9], buf[10], buf[11]);
123 i = CODEC_ERROR; 123 status = CODEC_ERROR;
124 goto done; 124 goto done;
125 } 125 }
126 126
@@ -138,13 +138,13 @@ next_track:
138 while (format.numbytes == 0 && n >= 8) 138 while (format.numbytes == 0 && n >= 8)
139 { 139 {
140 /* chunkSize */ 140 /* chunkSize */
141 i = ((buf[4]<<24)|(buf[5]<<16)|(buf[6]<<8)|buf[7]); 141 size = ((buf[4]<<24)|(buf[5]<<16)|(buf[6]<<8)|buf[7]);
142 if (memcmp(buf, "COMM", 4) == 0) { 142 if (memcmp(buf, "COMM", 4) == 0) {
143 if ((!is_aifc && i < 18) || (is_aifc && i < 22)) 143 if ((!is_aifc && size < 18) || (is_aifc && size < 22))
144 { 144 {
145 DEBUGF("CODEC_ERROR: 'COMM' chunk size=%lu < %d\n", 145 DEBUGF("CODEC_ERROR: 'COMM' chunk size=%lu < %d\n",
146 (unsigned long)i, (is_aifc)?22:18); 146 (unsigned long)size, (is_aifc)?22:18);
147 i = CODEC_ERROR; 147 status = CODEC_ERROR;
148 goto done; 148 goto done;
149 } 149 }
150 /* num_channels */ 150 /* num_channels */
@@ -157,7 +157,7 @@ next_track:
157 /* sample_rate (don't use last 4 bytes, only integer fs) */ 157 /* sample_rate (don't use last 4 bytes, only integer fs) */
158 if (buf[16] != 0x40) { 158 if (buf[16] != 0x40) {
159 DEBUGF("CODEC_ERROR: weird sampling rate (no @)\n"); 159 DEBUGF("CODEC_ERROR: weird sampling rate (no @)\n");
160 i = CODEC_ERROR; 160 status = CODEC_ERROR;
161 goto done; 161 goto done;
162 } 162 }
163 format.samplespersec = ((buf[18]<<24)|(buf[19]<<16)|(buf[20]<<8)|buf[21])+1; 163 format.samplespersec = ((buf[18]<<24)|(buf[19]<<16)|(buf[20]<<8)|buf[21])+1;
@@ -184,7 +184,7 @@ next_track:
184 } else if (memcmp(buf, "SSND", 4)==0) { 184 } else if (memcmp(buf, "SSND", 4)==0) {
185 if (format.bitspersample == 0) { 185 if (format.bitspersample == 0) {
186 DEBUGF("CODEC_ERROR: unsupported chunk order\n"); 186 DEBUGF("CODEC_ERROR: unsupported chunk order\n");
187 i = CODEC_ERROR; 187 status = CODEC_ERROR;
188 goto done; 188 goto done;
189 } 189 }
190 /* offset2snd */ 190 /* offset2snd */
@@ -193,35 +193,35 @@ next_track:
193 format.blockalign = ((buf[12]<<24)|(buf[13]<<16)|(buf[14]<<8)|buf[15]) >> 3; 193 format.blockalign = ((buf[12]<<24)|(buf[13]<<16)|(buf[14]<<8)|buf[15]) >> 3;
194 if (format.blockalign == 0) 194 if (format.blockalign == 0)
195 format.blockalign = format.channels * format.bitspersample >> 3; 195 format.blockalign = format.channels * format.bitspersample >> 3;
196 format.numbytes = i - 8 - offset2snd; 196 format.numbytes = size - 8 - offset2snd;
197 i = 8 + offset2snd; /* advance to the beginning of data */ 197 size = 8 + offset2snd; /* advance to the beginning of data */
198 } else if (is_aifc && (memcmp(buf, "FVER", 4)==0)) { 198 } else if (is_aifc && (memcmp(buf, "FVER", 4)==0)) {
199 /* Format Version Chunk (AIFC only chunk) */ 199 /* Format Version Chunk (AIFC only chunk) */
200 /* skip this chunk */ 200 /* skip this chunk */
201 } else { 201 } else {
202 DEBUGF("unsupported AIFF chunk: '%c%c%c%c', size=%lu\n", 202 DEBUGF("unsupported AIFF chunk: '%c%c%c%c', size=%lu\n",
203 buf[0], buf[1], buf[2], buf[3], (unsigned long)i); 203 buf[0], buf[1], buf[2], buf[3], (unsigned long)size);
204 } 204 }
205 205
206 if (i & 0x01) /* odd chunk sizes must be padded */ 206 size += 8 + (size & 0x01); /* odd chunk sizes must be padded */
207 i++; 207
208 buf += i + 8; 208 buf += size;
209 if (n < (i + 8)) { 209 if (n < size) {
210 DEBUGF("CODEC_ERROR: AIFF header size > 1024\n"); 210 DEBUGF("CODEC_ERROR: AIFF header size > 1024\n");
211 i = CODEC_ERROR; 211 status = CODEC_ERROR;
212 goto done; 212 goto done;
213 } 213 }
214 n -= i + 8; 214 n -= size;
215 } /* while 'SSND' */ 215 } /* while 'SSND' */
216 216
217 if (format.channels == 0) { 217 if (format.channels == 0) {
218 DEBUGF("CODEC_ERROR: 'COMM' chunk not found or 0-channels file\n"); 218 DEBUGF("CODEC_ERROR: 'COMM' chunk not found or 0-channels file\n");
219 i = CODEC_ERROR; 219 status = CODEC_ERROR;
220 goto done; 220 goto done;
221 } 221 }
222 if (format.numbytes == 0) { 222 if (format.numbytes == 0) {
223 DEBUGF("CODEC_ERROR: 'SSND' chunk not found or has zero length\n"); 223 DEBUGF("CODEC_ERROR: 'SSND' chunk not found or has zero length\n");
224 i = CODEC_ERROR; 224 status = CODEC_ERROR;
225 goto done; 225 goto done;
226 } 226 }
227 227
@@ -230,13 +230,13 @@ next_track:
230 { 230 {
231 DEBUGF("CODEC_ERROR: AIFC does not support compressionType: 0x%x\n", 231 DEBUGF("CODEC_ERROR: AIFC does not support compressionType: 0x%x\n",
232 (unsigned int)format.formattag); 232 (unsigned int)format.formattag);
233 i = CODEC_ERROR; 233 status = CODEC_ERROR;
234 goto done; 234 goto done;
235 } 235 }
236 236
237 if (!codec->set_format(&format)) 237 if (!codec->set_format(&format))
238 { 238 {
239 i = CODEC_ERROR; 239 status = CODEC_ERROR;
240 goto done; 240 goto done;
241 } 241 }
242 242
@@ -248,20 +248,20 @@ next_track:
248 ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); 248 ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO);
249 } else { 249 } else {
250 DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); 250 DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n");
251 i = CODEC_ERROR; 251 status = CODEC_ERROR;
252 goto done; 252 goto done;
253 } 253 }
254 254
255 if (format.samplesperblock == 0) 255 if (format.samplesperblock == 0)
256 { 256 {
257 DEBUGF("CODEC_ERROR: samplesperblock is 0\n"); 257 DEBUGF("CODEC_ERROR: samplesperblock is 0\n");
258 i = CODEC_ERROR; 258 status = CODEC_ERROR;
259 goto done; 259 goto done;
260 } 260 }
261 if (format.blockalign == 0) 261 if (format.blockalign == 0)
262 { 262 {
263 DEBUGF("CODEC_ERROR: blockalign is 0\n"); 263 DEBUGF("CODEC_ERROR: blockalign is 0\n");
264 i = CODEC_ERROR; 264 status = CODEC_ERROR;
265 goto done; 265 goto done;
266 } 266 }
267 267
@@ -272,7 +272,7 @@ next_track:
272 if (format.chunksize == 0) 272 if (format.chunksize == 0)
273 { 273 {
274 DEBUGF("CODEC_ERROR: chunksize is 0\n"); 274 DEBUGF("CODEC_ERROR: chunksize is 0\n");
275 i = CODEC_ERROR; 275 status = CODEC_ERROR;
276 goto done; 276 goto done;
277 } 277 }
278 278
@@ -329,13 +329,13 @@ next_track:
329 329
330 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); 330 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
331 } 331 }
332 i = CODEC_OK; 332 status = CODEC_OK;
333 333
334done: 334done:
335 if (ci->request_next_track()) 335 if (ci->request_next_track())
336 goto next_track; 336 goto next_track;
337 337
338exit: 338exit:
339 return i; 339 return status;
340} 340}
341 341
diff --git a/apps/codecs/smaf.c b/apps/codecs/smaf.c
index fccb6cbc64..9309937700 100644
--- a/apps/codecs/smaf.c
+++ b/apps/codecs/smaf.c
@@ -276,7 +276,6 @@ enum codec_status codec_main(void)
276{ 276{
277 int status = CODEC_OK; 277 int status = CODEC_OK;
278 uint32_t decodedsamples; 278 uint32_t decodedsamples;
279 uint32_t i = CODEC_OK;
280 size_t n; 279 size_t n;
281 int bufcount; 280 int bufcount;
282 int endofstream; 281 int endofstream;
@@ -289,7 +288,7 @@ enum codec_status codec_main(void)
289 288
290next_track: 289next_track:
291 if (codec_init()) { 290 if (codec_init()) {
292 i = CODEC_ERROR; 291 status = CODEC_ERROR;
293 goto exit; 292 goto exit;
294 } 293 }
295 294
@@ -307,7 +306,7 @@ next_track:
307 306
308 if (!parse_header(&format, &n)) 307 if (!parse_header(&format, &n))
309 { 308 {
310 i = CODEC_ERROR; 309 status = CODEC_ERROR;
311 goto done; 310 goto done;
312 } 311 }
313 312
@@ -315,13 +314,13 @@ next_track:
315 if (codec == 0) 314 if (codec == 0)
316 { 315 {
317 DEBUGF("CODEC_ERROR: unsupport audio format: 0x%x\n", (int)format.formattag); 316 DEBUGF("CODEC_ERROR: unsupport audio format: 0x%x\n", (int)format.formattag);
318 i = CODEC_ERROR; 317 status = CODEC_ERROR;
319 goto done; 318 goto done;
320 } 319 }
321 320
322 if (!codec->set_format(&format)) 321 if (!codec->set_format(&format))
323 { 322 {
324 i = CODEC_ERROR; 323 status = CODEC_ERROR;
325 goto done; 324 goto done;
326 } 325 }
327 326
@@ -339,7 +338,7 @@ next_track:
339 if (format.blockalign == 0) 338 if (format.blockalign == 0)
340 { 339 {
341 DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); 340 DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n");
342 i = CODEC_ERROR; 341 status = CODEC_ERROR;
343 goto done; 342 goto done;
344 } 343 }
345 if (format.numbytes == 0) { 344 if (format.numbytes == 0) {
@@ -355,7 +354,7 @@ next_track:
355 if (format.chunksize == 0) 354 if (format.chunksize == 0)
356 { 355 {
357 DEBUGF("CODEC_ERROR: chunksize is 0\n"); 356 DEBUGF("CODEC_ERROR: chunksize is 0\n");
358 i = CODEC_ERROR; 357 status = CODEC_ERROR;
359 goto done; 358 goto done;
360 } 359 }
361 360
@@ -367,7 +366,7 @@ next_track:
367 ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); 366 ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO);
368 } else { 367 } else {
369 DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n"); 368 DEBUGF("CODEC_ERROR: more than 2 channels unsupported\n");
370 i = CODEC_ERROR; 369 status = CODEC_ERROR;
371 goto done; 370 goto done;
372 } 371 }
373 372
@@ -423,13 +422,13 @@ next_track:
423 422
424 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); 423 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
425 } 424 }
426 i = CODEC_OK; 425 status = CODEC_OK;
427 426
428done: 427done:
429 if (ci->request_next_track()) 428 if (ci->request_next_track())
430 goto next_track; 429 goto next_track;
431 430
432exit: 431exit:
433 return i; 432 return status;
434} 433}
435 434
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c
index 8576ddda41..f4e7f778fd 100644
--- a/apps/codecs/wav.c
+++ b/apps/codecs/wav.c
@@ -155,7 +155,6 @@ enum codec_status codec_main(void)
155{ 155{
156 int status = CODEC_OK; 156 int status = CODEC_OK;
157 uint32_t decodedsamples; 157 uint32_t decodedsamples;
158 uint32_t i;
159 size_t n; 158 size_t n;
160 int bufcount; 159 int bufcount;
161 int endofstream; 160 int endofstream;
@@ -163,6 +162,7 @@ enum codec_status codec_main(void)
163 uint8_t *wavbuf; 162 uint8_t *wavbuf;
164 off_t firstblockposn; /* position of the first block in file */ 163 off_t firstblockposn; /* position of the first block in file */
165 const struct pcm_codec *codec; 164 const struct pcm_codec *codec;
165 uint32_t size;
166 166
167 /* Generic codec initialisation */ 167 /* Generic codec initialisation */
168 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH); 168 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH);
@@ -218,11 +218,11 @@ next_track:
218 } 218 }
219 219
220 /* chunkSize */ 220 /* chunkSize */
221 i = (buf[4]|(buf[5]<<8)|(buf[6]<<16)|(buf[7]<<24)); 221 size = (buf[4]|(buf[5]<<8)|(buf[6]<<16)|(buf[7]<<24));
222 if (memcmp(buf, "fmt ", 4) == 0) { 222 if (memcmp(buf, "fmt ", 4) == 0) {
223 if (i < 16) { 223 if (size < 16) {
224 DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n", 224 DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n",
225 (unsigned long)i); 225 (unsigned long)size);
226 status = CODEC_ERROR; 226 status = CODEC_ERROR;
227 goto done; 227 goto done;
228 } 228 }
@@ -231,26 +231,26 @@ next_track:
231 /* wChannels */ 231 /* wChannels */
232 format.channels=buf[10]|(buf[11]<<8); 232 format.channels=buf[10]|(buf[11]<<8);
233 /* skipping dwSamplesPerSec */ 233 /* skipping dwSamplesPerSec */
234 /* dwAvgBytesPerSec */ 234 /* skipping dwAvgBytesPerSec */
235 format.avgbytespersec = buf[16]|(buf[17]<<8)|(buf[18]<<16)|(buf[19]<<24);
236 /* wBlockAlign */ 235 /* wBlockAlign */
237 format.blockalign=buf[20]|(buf[21]<<8); 236 format.blockalign=buf[20]|(buf[21]<<8);
238 /* wBitsPerSample */ 237 /* wBitsPerSample */
239 format.bitspersample=buf[22]|(buf[23]<<8); 238 format.bitspersample=buf[22]|(buf[23]<<8);
240 if (format.formattag != WAVE_FORMAT_PCM) { 239 if (format.formattag != WAVE_FORMAT_PCM) {
241 if (i < 18) { 240 if (size < 18) {
242 /* this is not a fatal error with some formats, 241 /* this is not a fatal error with some formats,
243 * we'll see later if we can't decode it */ 242 * we'll see later if we can't decode it */
244 DEBUGF("CODEC_WARNING: non-PCM WAVE (formattag=0x%x) " 243 DEBUGF("CODEC_WARNING: non-PCM WAVE (formattag=0x%x) "
245 "doesn't have ext. fmt descr (chunksize=%d<18).\n", 244 "doesn't have ext. fmt descr (chunksize=%d<18).\n",
246 (unsigned int)format.formattag, (int)i); 245 (unsigned int)format.formattag, (int)size);
247 } 246 }
248 else 247 else
249 { 248 {
250 format.size = buf[24]|(buf[25]<<8);
251 if (format.formattag != WAVE_FORMAT_EXTENSIBLE) 249 if (format.formattag != WAVE_FORMAT_EXTENSIBLE)
252 format.samplesperblock = buf[26]|(buf[27]<<8); 250 format.samplesperblock = buf[26]|(buf[27]<<8);
253 else { 251 else
252 {
253 format.size = buf[24]|(buf[25]<<8);
254 if (format.size < 22) { 254 if (format.size < 22) {
255 DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " 255 DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is "
256 "missing extension\n"); 256 "missing extension\n");
@@ -297,26 +297,26 @@ next_track:
297 goto done; 297 goto done;
298 } 298 }
299 } else if (memcmp(buf, "data", 4) == 0) { 299 } else if (memcmp(buf, "data", 4) == 0) {
300 format.numbytes = i; 300 format.numbytes = size;
301 /* advance to start of data */ 301 /* advance to start of data */
302 ci->advance_buffer(8); 302 ci->advance_buffer(8);
303 firstblockposn += 8; 303 firstblockposn += 8;
304 break; 304 break;
305 } else if (memcmp(buf, "fact", 4) == 0) { 305 } else if (memcmp(buf, "fact", 4) == 0) {
306 /* dwSampleLength */ 306 /* dwSampleLength */
307 if (i >= 4) 307 if (size >= 4)
308 format.totalsamples = 308 format.totalsamples =
309 (buf[8]|(buf[9]<<8)|(buf[10]<<16)|(buf[11]<<24)); 309 (buf[8]|(buf[9]<<8)|(buf[10]<<16)|(buf[11]<<24));
310 } else { 310 } else {
311 DEBUGF("unknown WAVE chunk: '%c%c%c%c', size=%lu\n", 311 DEBUGF("unknown WAVE chunk: '%c%c%c%c', size=%lu\n",
312 buf[0], buf[1], buf[2], buf[3], (unsigned long)i); 312 buf[0], buf[1], buf[2], buf[3], (unsigned long)size);
313 } 313 }
314 314
315 /* go to next chunk (even chunk sizes must be padded) */ 315 /* go to next chunk (even chunk sizes must be padded) */
316 if (i & 0x01) 316 size += 8 + (size & 0x01);
317 i++; 317
318 ci->advance_buffer(i+8); 318 ci->advance_buffer(size);
319 firstblockposn += i + 8; 319 firstblockposn += size;
320 } 320 }
321 321
322 if (!codec) 322 if (!codec)
@@ -340,7 +340,7 @@ next_track:
340 if (format.blockalign == 0) 340 if (format.blockalign == 0)
341 { 341 {
342 DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); 342 DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n");
343 i = CODEC_ERROR; 343 status = CODEC_ERROR;
344 goto done; 344 goto done;
345 } 345 }
346 if (format.numbytes == 0) { 346 if (format.numbytes == 0) {
@@ -356,7 +356,7 @@ next_track:
356 if (format.chunksize == 0) 356 if (format.chunksize == 0)
357 { 357 {
358 DEBUGF("CODEC_ERROR: chunksize is 0\n"); 358 DEBUGF("CODEC_ERROR: chunksize is 0\n");
359 i = CODEC_ERROR; 359 status = CODEC_ERROR;
360 goto done; 360 goto done;
361 } 361 }
362 362
diff --git a/apps/codecs/wav64.c b/apps/codecs/wav64.c
index a9e5ca126a..f70fb53ba4 100644
--- a/apps/codecs/wav64.c
+++ b/apps/codecs/wav64.c
@@ -163,7 +163,6 @@ enum codec_status codec_main(void)
163{ 163{
164 int status = CODEC_OK; 164 int status = CODEC_OK;
165 uint32_t decodedsamples; 165 uint32_t decodedsamples;
166 uint32_t i;
167 size_t n; 166 size_t n;
168 int bufcount; 167 int bufcount;
169 int endofstream; 168 int endofstream;
@@ -255,10 +254,10 @@ next_track:
255 } 254 }
256 else 255 else
257 { 256 {
258 format.size = buf[40]|(buf[41]<<8);
259 if (format.formattag != WAVE_FORMAT_EXTENSIBLE) 257 if (format.formattag != WAVE_FORMAT_EXTENSIBLE)
260 format.samplesperblock = buf[42]|(buf[43]<<8); 258 format.samplesperblock = buf[42]|(buf[43]<<8);
261 else { 259 else {
260 format.size = buf[40]|(buf[41]<<8);
262 if (format.size < 22) { 261 if (format.size < 22) {
263 DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " 262 DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is "
264 "missing extension\n"); 263 "missing extension\n");
@@ -320,10 +319,10 @@ next_track:
320 } 319 }
321 320
322 /* go to next chunk (8byte bound) */ 321 /* go to next chunk (8byte bound) */
323 if (size & 0x07) 322 size += 24 + ((1 + ~size) & 0x07);
324 size += 8 - (size & 0x7); 323
325 ci->advance_buffer(size + 24); 324 ci->advance_buffer(size);
326 firstblockposn += size + 24; 325 firstblockposn += size;
327 } 326 }
328 327
329 if (!codec) 328 if (!codec)
@@ -347,7 +346,7 @@ next_track:
347 if (format.blockalign == 0) 346 if (format.blockalign == 0)
348 { 347 {
349 DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n"); 348 DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-blockalign file\n");
350 i = CODEC_ERROR; 349 status = CODEC_ERROR;
351 goto done; 350 goto done;
352 } 351 }
353 if (format.numbytes == 0) { 352 if (format.numbytes == 0) {
@@ -363,7 +362,7 @@ next_track:
363 if (format.chunksize == 0) 362 if (format.chunksize == 0)
364 { 363 {
365 DEBUGF("CODEC_ERROR: chunksize is 0\n"); 364 DEBUGF("CODEC_ERROR: chunksize is 0\n");
366 i = CODEC_ERROR; 365 status = CODEC_ERROR;
367 goto done; 366 goto done;
368 } 367 }
369 368