summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-12-25 22:34:21 +0100
committerCarl Hetherington <cth@carlh.net>2022-12-25 22:34:21 +0100
commitf3617efde1751ac9e55f692369dc4ba3c6350ca8 (patch)
tree48c17abf1dbadf276229c3aafdcd9b06d155a771
parent0fabbb1680b5042570d50a2276004e2c0e62321c (diff)
Show audio bit depth in content properties (#559).
-rw-r--r--src/lib/audio_content.cc3
-rw-r--r--src/lib/audio_stream.cc17
-rw-r--r--src/lib/audio_stream.h6
-rw-r--r--src/lib/content_factory.cc3
-rw-r--r--src/lib/dcp_content.cc5
-rw-r--r--src/lib/ffmpeg_audio_stream.cc6
-rw-r--r--src/lib/ffmpeg_audio_stream.h14
-rw-r--r--src/lib/ffmpeg_examiner.cc3
-rw-r--r--test/frame_rate_test.cc2
9 files changed, 42 insertions, 17 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index 192a50068..6a93ff119 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -314,6 +314,9 @@ AudioContent::add_properties (shared_ptr<const Film> film, list<UserProperty>& p
if (stream) {
p.push_back (UserProperty(UserProperty::AUDIO, _("Channels"), stream->channels()));
p.push_back (UserProperty(UserProperty::AUDIO, _("Content sample rate"), stream->frame_rate(), _("Hz")));
+ if (auto bits = stream->bit_depth()) {
+ p.push_back(UserProperty(UserProperty::AUDIO, _("Content bit depth"), *bits, _("bits")));
+ }
}
FrameRateChange const frc (_parent->active_video_frame_rate(film), film->video_frame_rate());
diff --git a/src/lib/audio_stream.cc b/src/lib/audio_stream.cc
index bd53c9b26..f771d44a2 100644
--- a/src/lib/audio_stream.cc
+++ b/src/lib/audio_stream.cc
@@ -24,19 +24,24 @@
#include "constants.h"
-AudioStream::AudioStream (int frame_rate, Frame length, int channels)
+using boost::optional;
+
+
+AudioStream::AudioStream(int frame_rate, Frame length, int channels, optional<int> bit_depth)
: _frame_rate (frame_rate)
, _length (length)
, _mapping (AudioMapping (channels, MAX_DCP_AUDIO_CHANNELS))
+ , _bit_depth(bit_depth)
{
}
-AudioStream::AudioStream (int frame_rate, Frame length, AudioMapping mapping)
+AudioStream::AudioStream(int frame_rate, Frame length, AudioMapping mapping, optional<int> bit_depth)
: _frame_rate (frame_rate)
, _length (length)
, _mapping (mapping)
+ , _bit_depth(bit_depth)
{
}
@@ -56,3 +61,11 @@ AudioStream::channels () const
boost::mutex::scoped_lock lm (_mutex);
return _mapping.input_channels ();
}
+
+optional<int>
+AudioStream::bit_depth() const
+{
+ boost::mutex::scoped_lock lm(_mutex);
+ return _bit_depth;
+}
+
diff --git a/src/lib/audio_stream.h b/src/lib/audio_stream.h
index 470d9c854..cf874242f 100644
--- a/src/lib/audio_stream.h
+++ b/src/lib/audio_stream.h
@@ -33,8 +33,8 @@ struct audio_sampling_rate_test;
class AudioStream
{
public:
- AudioStream (int frame_rate, Frame length, int channels);
- AudioStream (int frame_rate, Frame length, AudioMapping mapping);
+ AudioStream(int frame_rate, Frame length, int channels, boost::optional<int> bit_depth);
+ AudioStream(int frame_rate, Frame length, AudioMapping mapping, boost::optional<int> bit_depth);
virtual ~AudioStream () {}
void set_mapping (AudioMapping mapping);
@@ -55,6 +55,7 @@ public:
}
int channels () const;
+ boost::optional<int> bit_depth() const;
protected:
mutable boost::mutex _mutex;
@@ -66,6 +67,7 @@ private:
int _frame_rate;
Frame _length;
AudioMapping _mapping;
+ boost::optional<int> _bit_depth;
};
diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc
index 5f1e6c9b7..b23a088b4 100644
--- a/src/lib/content_factory.cc
+++ b/src/lib/content_factory.cc
@@ -81,7 +81,8 @@ content_factory (cxml::ConstNodePtr node, int version, list<string>& notes)
"Stream", 0,
node->number_child<int> ("AudioFrameRate"),
node->number_child<Frame> ("AudioLength"),
- AudioMapping (node->node_child ("AudioMapping"), version)
+ AudioMapping(node->node_child("AudioMapping"), version),
+ 16
)
);
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index 3cc724b8e..cdf104f03 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -105,7 +105,8 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
node->optional_number_child<Frame>("AudioLength").get_value_or (
video->length() * node->number_child<int>("AudioFrameRate") / video_frame_rate().get()
),
- AudioMapping (node->node_child ("AudioMapping"), version)
+ AudioMapping(node->node_child("AudioMapping"), version),
+ 24
)
);
}
@@ -238,7 +239,7 @@ DCPContent::examine (shared_ptr<const Film> film, shared_ptr<Job> job)
boost::mutex::scoped_lock lm (_mutex);
audio = make_shared<AudioContent>(this);
}
- auto as = make_shared<AudioStream>(examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels());
+ auto as = make_shared<AudioStream>(examiner->audio_frame_rate(), examiner->audio_length(), examiner->audio_channels(), 24);
audio->set_stream (as);
auto m = as->mapping ();
m.make_default (film ? film->audio_processor() : 0);
diff --git a/src/lib/ffmpeg_audio_stream.cc b/src/lib/ffmpeg_audio_stream.cc
index 05e1a3fc8..9400eb60d 100644
--- a/src/lib/ffmpeg_audio_stream.cc
+++ b/src/lib/ffmpeg_audio_stream.cc
@@ -39,7 +39,8 @@ FFmpegAudioStream::FFmpegAudioStream (cxml::ConstNodePtr node, int version)
, AudioStream (
node->number_child<int>("FrameRate"),
node->optional_number_child<Frame>("Length").get_value_or(0),
- AudioMapping (node->node_child("Mapping"), version)
+ AudioMapping(node->node_child("Mapping"), version),
+ node->optional_number_child<int>("BitDepth")
)
{
optional<ContentTime::Type> const f = node->optional_number_child<ContentTime::Type>("FirstAudio");
@@ -63,4 +64,7 @@ FFmpegAudioStream::as_xml (xmlpp::Node* root) const
if (codec_name) {
root->add_child("CodecName")->add_child_text(codec_name.get());
}
+ if (bit_depth()) {
+ root->add_child("BitDepth")->add_child_text(raw_convert<string>(bit_depth().get()));
+ }
}
diff --git a/src/lib/ffmpeg_audio_stream.h b/src/lib/ffmpeg_audio_stream.h
index a5ed90c97..aae982f9e 100644
--- a/src/lib/ffmpeg_audio_stream.h
+++ b/src/lib/ffmpeg_audio_stream.h
@@ -30,20 +30,20 @@ struct ffmpeg_pts_offset_test;
class FFmpegAudioStream : public FFmpegStream, public AudioStream
{
public:
- FFmpegAudioStream (std::string name, int id, int frame_rate, Frame length, int channels)
+ FFmpegAudioStream(std::string name, int id, int frame_rate, Frame length, int channels, int bit_depth)
: FFmpegStream (name, id)
- , AudioStream (frame_rate, length, channels)
+ , AudioStream(frame_rate, length, channels, bit_depth)
{}
- FFmpegAudioStream (std::string name, std::string codec_name_, int id, int frame_rate, Frame length, int channels)
+ FFmpegAudioStream(std::string name, std::string codec_name_, int id, int frame_rate, Frame length, int channels, int bit_depth)
: FFmpegStream (name, id)
- , AudioStream (frame_rate, length, channels)
+ , AudioStream(frame_rate, length, channels, bit_depth)
, codec_name (codec_name_)
{}
- FFmpegAudioStream (std::string name, int id, int frame_rate, Frame length, AudioMapping mapping)
+ FFmpegAudioStream(std::string name, int id, int frame_rate, Frame length, AudioMapping mapping, int bit_depth)
: FFmpegStream (name, id)
- , AudioStream (frame_rate, length, mapping)
+ , AudioStream(frame_rate, length, mapping, bit_depth)
{}
FFmpegAudioStream (cxml::ConstNodePtr, int);
@@ -61,7 +61,7 @@ private:
/* Constructor for tests */
FFmpegAudioStream ()
: FFmpegStream ("", 0)
- , AudioStream (0, 0, 0)
+ , AudioStream(0, 0, 0, 0)
{}
};
diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc
index fdcacb465..46f4f236e 100644
--- a/src/lib/ffmpeg_examiner.cc
+++ b/src/lib/ffmpeg_examiner.cc
@@ -91,7 +91,8 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
s->id,
s->codecpar->sample_rate,
llrint ((double(_format_context->duration) / AV_TIME_BASE) * s->codecpar->sample_rate),
- s->codecpar->channels
+ s->codecpar->channels,
+ s->codecpar->bits_per_raw_sample ? s->codecpar->bits_per_raw_sample : s->codecpar->bits_per_coded_sample
)
);
diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc
index 90216af5c..610ac0380 100644
--- a/test/frame_rate_test.cc
+++ b/test/frame_rate_test.cc
@@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test)
afr.push_back (30);
Config::instance()->set_allowed_dcp_frame_rates (afr);
- shared_ptr<FFmpegAudioStream> stream (new FFmpegAudioStream ("foo", 0, 0, 0, 0));
+ auto stream = std::make_shared<FFmpegAudioStream>("foo", 0, 0, 0, 0, 0);
content->audio.reset (new AudioContent (content.get()));
content->audio->add_stream (stream);
content->_video_frame_rate = 24;