diff --git a/config/external/gkcodecs/gkcodecs.symbols b/config/external/gkcodecs/gkcodecs.symbols index bbd1ec809150..ad67794ee3a6 100644 --- a/config/external/gkcodecs/gkcodecs.symbols +++ b/config/external/gkcodecs/gkcodecs.symbols @@ -97,6 +97,7 @@ opus_multistream_encoder_create opus_multistream_encoder_ctl opus_multistream_encoder_destroy opus_packet_get_nb_channels +opus_packet_get_nb_samples opus_packet_get_nb_frames opus_packet_get_samples_per_frame opus_packet_parse diff --git a/dom/media/webm/WebMDemuxer.cpp b/dom/media/webm/WebMDemuxer.cpp index 882d11938110..5c52624070f9 100644 --- a/dom/media/webm/WebMDemuxer.cpp +++ b/dom/media/webm/WebMDemuxer.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #define WEBM_DEBUG(arg, ...) \ DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \ @@ -819,15 +820,19 @@ nsresult WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, sample->mDuration = TimeUnit::Invalid(); } else { TimeUnit padding = TimeUnit::FromNanoseconds(discardPadding); - if (padding > sample->mDuration || mProcessedDiscardPadding) { + size_t samples = opus_packet_get_nb_samples( + sample->Data(), AssertedCast(sample->Size()), + AssertedCast(mInfo.mAudio.mRate)); + TimeUnit packetDuration = TimeUnit(samples, mInfo.mAudio.mRate); + if (padding > packetDuration || mProcessedDiscardPadding) { WEBM_DEBUG( "Padding frames larger than packet size, flagging the packet for " "error (padding: %s, duration: %s, already processed: %s)", - padding.ToString().get(), sample->mDuration.ToString().get(), + padding.ToString().get(), packetDuration.ToString().get(), mProcessedDiscardPadding ? "true" : "false"); sample->mDuration = TimeUnit::Invalid(); } else { - sample->mDuration -= padding; + sample->mDuration = packetDuration - padding; } } mProcessedDiscardPadding = true;