Revision | ec9388d4023c7f0e7d2620b1a8cba0ebd8e1cecc (tree) |
---|---|
Time | 2020-09-24 19:33:32 |
Author | Starg <starg@user...> |
Commiter | Starg |
[decode] Fix decoding of 24bit FLAC samples
@@ -313,12 +313,14 @@ static FLAC__StreamDecoderWriteStatus flac_write_callback(const FLAC__StreamDeco | ||
313 | 313 | for (int i = 0; i < sdr->channels; i++) { |
314 | 314 | switch (sdr->data_type) { |
315 | 315 | case SAMPLE_TYPE_INT32: |
316 | - memcpy(((FLAC__int32 *)sdr->data[i]) + context->current_size_in_samples, buffer[i], frame->header.blocksize * sizeof(FLAC__int32)); | |
316 | + for (unsigned int j = 0; j < frame->header.blocksize; j++) { | |
317 | + ((FLAC__int32*)sdr->data[i])[context->current_size_in_samples + j] = buffer[i][j] << (32 - frame->header.bits_per_sample); | |
318 | + } | |
317 | 319 | break; |
318 | 320 | |
319 | 321 | case SAMPLE_TYPE_INT16: |
320 | 322 | for (unsigned int j = 0; j < frame->header.blocksize; j++) { |
321 | - sdr->data[i][context->current_size_in_samples + j] = (FLAC__int16)buffer[i][j]; | |
323 | + sdr->data[i][context->current_size_in_samples + j] = (FLAC__int16)(buffer[i][j] << (16 - frame->header.bits_per_sample)); | |
322 | 324 | } |
323 | 325 | break; |
324 | 326 | } |