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());
#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)
{
}
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;
+}
+
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);
}
int channels () const;
+ boost::optional<int> bit_depth() const;
protected:
mutable boost::mutex _mutex;
int _frame_rate;
Frame _length;
AudioMapping _mapping;
+ boost::optional<int> _bit_depth;
};
"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
)
);
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
)
);
}
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);
, 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");
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()));
+ }
}
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);
/* Constructor for tests */
FFmpegAudioStream ()
: FFmpegStream ("", 0)
- , AudioStream (0, 0, 0)
+ , AudioStream(0, 0, 0, 0)
{}
};
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
)
);
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;