diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-05-24 22:00:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-05-24 22:00:53 +0100 |
| commit | 4f03da3aa12525cb8389ddefee629f5d0b2ac0aa (patch) | |
| tree | 0552aa98738c47c9328c4b86adad7348607ea8a4 /src/lib/audio_buffers.cc | |
| parent | 5b44e42b4a90331c88b15ed02a7f3d333690b9eb (diff) | |
Partial addition of DCP audio channel count to Film.
Diffstat (limited to 'src/lib/audio_buffers.cc')
| -rw-r--r-- | src/lib/audio_buffers.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc index cd8fcd35b..c3e89f130 100644 --- a/src/lib/audio_buffers.cc +++ b/src/lib/audio_buffers.cc @@ -193,7 +193,7 @@ AudioBuffers::move (int from, int to, int frames) /** Add data from from `from', `from_channel' to our channel `to_channel' */ void -AudioBuffers::accumulate (AudioBuffers const * from, int from_channel, int to_channel) +AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, int to_channel) { int const N = frames (); assert (from->frames() == N); @@ -214,9 +214,24 @@ AudioBuffers::ensure_size (int frames) } for (int i = 0; i < _channels; ++i) { - _data[i] = static_cast<float*> (realloc (_data[i], _frames * sizeof (float))); + _data[i] = static_cast<float*> (realloc (_data[i], frames * sizeof (float))); if (!_data[i]) { throw bad_alloc (); } } + + _allocated_frames = frames; +} + +void +AudioBuffers::accumulate_frames (AudioBuffers const * from, int read_offset, int write_offset, int frames) +{ + assert (_channels == from->channels ()); + + for (int i = 0; i < _channels; ++i) { + for (int j = 0; j < frames; ++j) { + _data[i][j + write_offset] += from->data()[i][j + read_offset]; + } + } } + |
