calculate audio bytes as a 64-bit number

This commit is contained in:
itsmattkc
2020-10-24 13:55:07 +11:00
parent cf07e52b76
commit 7e637a7372
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -49,11 +49,11 @@ const QVector<uint64_t> AudioParams::kSupportedChannelLayouts = {
AV_CH_LAYOUT_7POINT1 AV_CH_LAYOUT_7POINT1
}; };
int AudioParams::time_to_bytes(const double &time) const qint64 AudioParams::time_to_bytes(const double &time) const
{ {
Q_ASSERT(is_valid()); Q_ASSERT(is_valid());
return time_to_samples(time) * channel_count() * bytes_per_sample_per_channel(); return qint64(time_to_samples(time)) * channel_count() * bytes_per_sample_per_channel();
} }
bool AudioParams::operator==(const AudioParams &other) const bool AudioParams::operator==(const AudioParams &other) const
@@ -68,7 +68,7 @@ bool AudioParams::operator!=(const AudioParams &other) const
return !(*this == other); return !(*this == other);
} }
int AudioParams::time_to_bytes(const rational &time) const qint64 AudioParams::time_to_bytes(const rational &time) const
{ {
return time_to_bytes(time.toDouble()); return time_to_bytes(time.toDouble());
} }
+2 -2
View File
@@ -64,8 +64,8 @@ public:
return format_; return format_;
} }
int time_to_bytes(const double& time) const; qint64 time_to_bytes(const double& time) const;
int time_to_bytes(const rational& time) const; qint64 time_to_bytes(const rational& time) const;
int time_to_samples(const double& time) const; int time_to_samples(const double& time) const;
int time_to_samples(const rational& time) const; int time_to_samples(const rational& time) const;
int samples_to_bytes(const int& samples) const; int samples_to_bytes(const int& samples) const;