diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-05-24 23:41:53 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-05-24 23:41:56 +0200 |
| commit | 0bbb2e9c99845ce7b6056048356a9710119cdbd9 (patch) | |
| tree | eb70a2aa59f63de542ab4e813cec5785bb4f764a /src/sound_frame.cc | |
| parent | cc6a2fe7ee05718d549e72eb740d0eae290f8ecb (diff) | |
Report bit depth from sound frame, and handle 16-bit.v1.9.8
Diffstat (limited to 'src/sound_frame.cc')
| -rw-r--r-- | src/sound_frame.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/sound_frame.cc b/src/sound_frame.cc index 25845d88..4d90c9c2 100644 --- a/src/sound_frame.cc +++ b/src/sound_frame.cc @@ -37,6 +37,7 @@ */ +#include "dcp_assert.h" #include "sound_frame.h" #include <asdcp/AS_DCP.h> #include <iostream> @@ -52,15 +53,28 @@ SoundFrame::SoundFrame (ASDCP::PCM::MXFReader* reader, int n, std::shared_ptr<co ASDCP::PCM::AudioDescriptor desc; reader->FillAudioDescriptor (desc); _channels = desc.ChannelCount; + _bits = desc.QuantizationBits; } int32_t SoundFrame::get (int channel, int frame) const { - uint8_t const * d = data() + (frame * _channels * 3) + (channel * 3); - /* This is slightly dubious I think */ - return (d[0] << 8 | (d[1] << 16) | (d[2] << 24)) >> 8; + switch (_bits) { + case 24: + { + uint8_t const * d = data() + (frame * _channels * 3) + (channel * 3); + /* This is slightly dubious I think */ + return (d[0] << 8 | (d[1] << 16) | (d[2] << 24)) >> 8; + } + case 16: + { + uint8_t const * d = data() + (frame * _channels * 2) + (channel * 2); + return d[0] | (d[1] << 8); + } + default: + DCP_ASSERT(false); + } } @@ -74,5 +88,5 @@ SoundFrame::channels () const int SoundFrame::samples () const { - return size() / (_channels * 3); + return size() / (_channels * _bits / 8); } |
