summaryrefslogtreecommitdiff
path: root/apps/codecs/wav.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/wav.c')
-rw-r--r--apps/codecs/wav.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c
index 32cff6a758..2bde1c29a5 100644
--- a/apps/codecs/wav.c
+++ b/apps/codecs/wav.c
@@ -423,10 +423,10 @@ next_track:
423 chunksize = (1 + avgbytespersec / (50*blockalign))*blockalign; 423 chunksize = (1 + avgbytespersec / (50*blockalign))*blockalign;
424 /* check that the output buffer is big enough (convert to samplespersec, 424 /* check that the output buffer is big enough (convert to samplespersec,
425 then round to the blockalign multiple below) */ 425 then round to the blockalign multiple below) */
426 if (((uint64_t)chunksize*ci->id3->frequency*channels*sizeof(long)) 426 if (((uint64_t)chunksize*ci->id3->frequency*channels*2)
427 /(uint64_t)avgbytespersec >= WAV_CHUNK_SIZE) { 427 /(uint64_t)avgbytespersec >= WAV_CHUNK_SIZE) {
428 chunksize = ((uint64_t)WAV_CHUNK_SIZE*avgbytespersec 428 chunksize = ((uint64_t)WAV_CHUNK_SIZE*avgbytespersec
429 /((uint64_t)ci->id3->frequency*channels*sizeof(long) 429 /((uint64_t)ci->id3->frequency*channels*2
430 *blockalign))*blockalign; 430 *blockalign))*blockalign;
431 } 431 }
432 432
@@ -500,14 +500,15 @@ next_track:
500 500
501 for (i = 0; i < nblocks; i++) { 501 for (i = 0; i < nblocks; i++) {
502 size_t decodedsize = samplesperblock*channels; 502 size_t decodedsize = samplesperblock*channels;
503 if (decode_dvi_adpcm(ci, ((uint8_t *)wavbuf) + i*blockalign, 503 if (decode_dvi_adpcm(ci, wavbuf + i*blockalign,
504 blockalign, channels, bitspersample, 504 blockalign, channels, bitspersample,
505 samples + i*samplesperblock*channels, 505 samples + i*samplesperblock*channels,
506 &decodedsize) != CODEC_OK) 506 &decodedsize) != CODEC_OK) {
507 i = CODEC_ERROR; 507 i = CODEC_ERROR;
508 goto exit; 508 goto exit;
509 }
509 } 510 }
510 bufsize = nblocks*samplesperblock*channels*2; 511 bufsize = nblocks*samplesperblock*channels*4;
511 } else { 512 } else {
512 DEBUGF("CODEC_ERROR: unsupported format %x\n", formattag); 513 DEBUGF("CODEC_ERROR: unsupported format %x\n", formattag);
513 i = CODEC_ERROR; 514 i = CODEC_ERROR;
@@ -561,7 +562,7 @@ decode_dvi_adpcm(struct codec_api *ci,
561 for (c = 0; c < channels && n >= 4; c++) { 562 for (c = 0; c < channels && n >= 4; c++) {
562 /* decode + push first sample */ 563 /* decode + push first sample */
563 sample[c] = (short)(buf[0]|(buf[1]<<8));/* need cast for sign-extend */ 564 sample[c] = (short)(buf[0]|(buf[1]<<8));/* need cast for sign-extend */
564 pcmout[c] = sample[c]; 565 pcmout[c] = sample[c] << 13;
565 nsamples++; 566 nsamples++;
566 stepindex[c] = buf[2]; 567 stepindex[c] = buf[2];
567 /* check for step table index overflow */ 568 /* check for step table index overflow */