diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-05-24 23:50:03 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-05-24 23:50:04 +0200 |
| commit | 9a2c81f1355f2c7e5f9f317176fdafe8e33cf078 (patch) | |
| tree | 08c3aafa044ed56abc0d0b25545cd1716ac9cf66 /src/lib/dcp_decoder.cc | |
| parent | 3ff837180e0905653cefce0030c94d987f91a9e4 (diff) | |
Read 16-bit audio DCPs correctly.
As far as I can tell they are totally non-standard, but apparently
the IMS3000 plays them so I guess we should too.
Diffstat (limited to 'src/lib/dcp_decoder.cc')
| -rw-r--r-- | src/lib/dcp_decoder.cc | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 84b51cae8..e9db479d1 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -235,15 +235,32 @@ DCPDecoder::pass () auto sf = _sound_reader->get_frame (entry_point + frame); auto from = sf->data (); - int const channels = _dcp_content->audio->stream()->channels (); - int const frames = sf->size() / (3 * channels); + int const channels = _dcp_content->audio->stream()->channels(); + int const frames = sf->size() / (sf->bits() * channels / 8); auto data = make_shared<AudioBuffers>(channels, frames); auto data_data = data->data(); - for (int i = 0; i < frames; ++i) { - for (int j = 0; j < channels; ++j) { - data_data[j][i] = static_cast<int> ((from[0] << 8) | (from[1] << 16) | (from[2] << 24)) / static_cast<float> (INT_MAX - 256); - from += 3; + + switch (sf->bits()) { + case 24: + { + for (int i = 0; i < frames; ++i) { + for (int j = 0; j < channels; ++j) { + data_data[j][i] = static_cast<int>((from[0] << 8) | (from[1] << 16) | (from[2] << 24)) / static_cast<float> (INT_MAX - 256); + from += 3; + } + } + break; + } + case 16: + { + for (int i = 0; i < frames; ++i) { + for (int j = 0; j < channels; ++j) { + data_data[j][i] = static_cast<int>(from[0] << 16 | (from[1] << 24)) / static_cast<float> (INT_MAX - 256); + from += 2; + } } + break; + } } audio->emit (film(), _dcp_content->audio->stream(), data, ContentTime::from_frames (_offset, vfr) + _next); |
