mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1388660
- part1 : AudioData::IsAudible() should return false when its data is super small and near to zero. r=jwwang
When the value of data is too small to be heard, AudioData::IsAudible() should return false so that we won't show the sound indicator for silent media. In this case, the loudness of reported video is -673 dBFS, it's impossible to be heard. MozReview-Commit-ID: Ewiko7RpkeX --HG-- extra : rebase_source : 692e1af570648546deabc3fe4ae4c4b36bf8f356
This commit is contained in:
parent
6cea13ecbd
commit
d5273690a3
@ -31,6 +31,16 @@ using media::TimeUnit;
|
||||
const char* AudioData::sTypeName = "audio";
|
||||
const char* VideoData::sTypeName = "video";
|
||||
|
||||
bool
|
||||
IsDataLoudnessHearable(const AudioDataValue aData)
|
||||
{
|
||||
// We can transfer the digital value to dBFS via following formula. According
|
||||
// to American SMPTE standard, 0 dBu equals -20 dBFS. In theory 0 dBu is still
|
||||
// hearable, so we choose a smaller value as our threshold. If the loudness
|
||||
// is under this threshold, it might not be hearable.
|
||||
return 20.0f * std::log10(AudioSampleToFloat(aData)) > -100;
|
||||
}
|
||||
|
||||
void
|
||||
AudioData::EnsureAudioBuffer()
|
||||
{
|
||||
@ -66,7 +76,7 @@ AudioData::IsAudible() const
|
||||
|
||||
for (uint32_t frame = 0; frame < mFrames; ++frame) {
|
||||
for (uint32_t channel = 0; channel < mChannels; ++channel) {
|
||||
if (mAudioData[frame * mChannels + channel] != 0) {
|
||||
if (IsDataLoudnessHearable(mAudioData[frame * mChannels + channel])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user