Bug 1984505 - Improve Opus packet duration error output in WebM demuxer. r=padenot a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D262818
This commit is contained in:
committed by
rvandermeulen@mozilla.com
parent
44ff633cd5
commit
e124e4aaac
@@ -820,19 +820,31 @@ nsresult WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType,
|
||||
sample->mDuration = TimeUnit::Invalid();
|
||||
} else {
|
||||
TimeUnit padding = TimeUnit::FromNanoseconds(discardPadding);
|
||||
size_t samples = opus_packet_get_nb_samples(
|
||||
const int samples = opus_packet_get_nb_samples(
|
||||
sample->Data(), AssertedCast<int32_t>(sample->Size()),
|
||||
AssertedCast<int32_t>(mInfo.mAudio.mRate));
|
||||
TimeUnit packetDuration = TimeUnit(samples, mInfo.mAudio.mRate);
|
||||
if (padding > packetDuration || mProcessedDiscardPadding) {
|
||||
if (samples <= 0) {
|
||||
WEBM_DEBUG(
|
||||
"Padding frames larger than packet size, flagging the packet for "
|
||||
"error (padding: %s, duration: %s, already processed: %s)",
|
||||
padding.ToString().get(), packetDuration.ToString().get(),
|
||||
mProcessedDiscardPadding ? "true" : "false");
|
||||
"Invalid number of samples, flagging packet for error (padding: "
|
||||
"%s, samples: %d, already processed: %s, error: %s)",
|
||||
padding.ToString().get(), samples,
|
||||
mProcessedDiscardPadding ? "true" : "false",
|
||||
(samples == OPUS_BAD_ARG) ? "OPUS_BAD_ARG"
|
||||
: (samples == OPUS_INVALID_PACKET) ? "OPUS_INVALID_PACKET"
|
||||
: "Undefined Error");
|
||||
sample->mDuration = TimeUnit::Invalid();
|
||||
} else {
|
||||
sample->mDuration = packetDuration - padding;
|
||||
TimeUnit packetDuration = TimeUnit(samples, mInfo.mAudio.mRate);
|
||||
if (padding > packetDuration || mProcessedDiscardPadding) {
|
||||
WEBM_DEBUG(
|
||||
"Padding frames larger than packet size, flagging packet for "
|
||||
"error (padding: %s, duration: %s, already processed: %s)",
|
||||
padding.ToString().get(), packetDuration.ToString().get(),
|
||||
mProcessedDiscardPadding ? "true" : "false");
|
||||
sample->mDuration = TimeUnit::Invalid();
|
||||
} else {
|
||||
sample->mDuration = packetDuration - padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
mProcessedDiscardPadding = true;
|
||||
|
||||
Reference in New Issue
Block a user