audioparams: cache channel_count

This commit is contained in:
Thomas Wilshaw
2021-04-24 13:23:34 +01:00
parent 573597bec3
commit 8373579009
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ rational AudioParams::bytes_to_time(const qint64 &bytes) const
int AudioParams::channel_count() const
{
return av_get_channel_layout_nb_channels(channel_layout());
return channel_count_;
}
int AudioParams::bytes_per_sample_per_channel() const
+8
View File
@@ -66,6 +66,9 @@ public:
format_(kFormatInvalid)
{
set_default_footage_parameters();
// Cache channel count
channel_count_ = av_get_channel_layout_nb_channels(channel_layout());
}
AudioParams(const int& sample_rate, const uint64_t& channel_layout, const Format& format) :
@@ -75,6 +78,9 @@ public:
{
set_default_footage_parameters();
timebase_ = sample_rate_as_time_base();
// Cache channel count
channel_count_ = av_get_channel_layout_nb_channels(this->channel_layout());
}
int sample_rate() const
@@ -201,6 +207,8 @@ private:
uint64_t channel_layout_;
int channel_count_;
Format format_;
// Footage-specific