summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-02-13 23:20:51 +0100
committerCarl Hetherington <cth@carlh.net>2023-02-13 23:20:51 +0100
commit6cb2308b3cb68b7950dcb6a216e5ddf1abe961ac (patch)
tree66efb6281719e02a85585ab28a06369442278ff0
parentde5ad19f419a4443789236cc085a9a6b7df3ed1b (diff)
Cleanup: extract pass_audio().
-rw-r--r--src/lib/dcp_decoder.cc39
-rw-r--r--src/lib/dcp_decoder.h1
2 files changed, 24 insertions, 16 deletions
diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc
index 3bcb52902..1dc37d384 100644
--- a/src/lib/dcp_decoder.cc
+++ b/src/lib/dcp_decoder.cc
@@ -183,6 +183,28 @@ DCPDecoder::pass_video(Frame frame, dcp::Size size)
}
+void
+DCPDecoder::pass_audio(Frame frame, double video_frame_rate)
+{
+ auto const entry_point = (*_reel)->main_sound()->entry_point().get_value_or(0);
+ 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);
+ 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;
+ }
+ }
+
+ audio->emit(film(), _dcp_content->audio->stream(), data, ContentTime::from_frames(_offset, video_frame_rate) + _next);
+}
+
+
Decoder::PassResult
DCPDecoder::pass ()
{
@@ -215,22 +237,7 @@ DCPDecoder::pass ()
}
if (_sound_reader && (_decode_referenced || !_dcp_content->reference_audio())) {
- auto const entry_point = (*_reel)->main_sound()->entry_point().get_value_or(0);
- 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);
- 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;
- }
- }
-
- audio->emit (film(), _dcp_content->audio->stream(), data, ContentTime::from_frames (_offset, vfr) + _next);
+ pass_audio(frame, vfr);
}
if (_atmos_reader) {
diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h
index 3dc3d323c..dfe941eb0 100644
--- a/src/lib/dcp_decoder.h
+++ b/src/lib/dcp_decoder.h
@@ -74,6 +74,7 @@ private:
void next_reel ();
void get_readers ();
void pass_video(Frame frame, dcp::Size size);
+ void pass_audio(Frame frame, double video_frame_rate);
void pass_texts (dcpomatic::ContentTime next, dcp::Size size);
void pass_texts (
dcpomatic::ContentTime next,