diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/media/MediaFormatReader.cpp | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/MediaFormatReader.cpp')
-rw-r--r-- | dom/media/MediaFormatReader.cpp | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 7eb8e4e5e2..0d7daaa3d8 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -1770,6 +1770,13 @@ void MediaFormatReader::NotifyNewOutput( if (aTrack == TrackInfo::kAudioTrack) { decoder.mNumOfConsecutiveUtilityCrashes = 0; } + decoder.mDecodePerfRecorder->Record( + sample->mTime.ToMicroseconds(), + [startTime = sample->mTime.ToMicroseconds(), + endTime = + sample->GetEndTime().ToMicroseconds()](PlaybackStage& aStage) { + aStage.SetStartTimeAndEndTime(startTime, endTime); + }); } } LOG("Done processing new %s samples", TrackTypeToStr(aTrack)); @@ -1962,6 +1969,38 @@ void MediaFormatReader::RequestDemuxSamples(TrackType aTrack) { } } +void MediaFormatReader::DecoderData::StartRecordDecodingPerf( + const TrackType aTrack, const MediaRawData* aSample) { + if (!mDecodePerfRecorder) { + mDecodePerfRecorder.reset(new PerformanceRecorderMulti<PlaybackStage>()); + } + const int32_t height = aTrack == TrackInfo::kVideoTrack + ? GetCurrentInfo()->GetAsVideoInfo()->mImage.height + : 0; + MediaInfoFlag flag = MediaInfoFlag::None; + flag |= + aSample->mKeyframe ? MediaInfoFlag::KeyFrame : MediaInfoFlag::NonKeyFrame; + if (aTrack == TrackInfo::kVideoTrack) { + flag |= mIsHardwareAccelerated ? MediaInfoFlag::HardwareDecoding + : MediaInfoFlag::SoftwareDecoding; + const nsCString& mimeType = GetCurrentInfo()->mMimeType; + if (MP4Decoder::IsH264(mimeType)) { + flag |= MediaInfoFlag::VIDEO_H264; + } else if (VPXDecoder::IsVPX(mimeType, VPXDecoder::VP8)) { + flag |= MediaInfoFlag::VIDEO_VP8; + } else if (VPXDecoder::IsVPX(mimeType, VPXDecoder::VP9)) { + flag |= MediaInfoFlag::VIDEO_VP9; + } +#ifdef MOZ_AV1 + else if (AOMDecoder::IsAV1(mimeType)) { + flag |= MediaInfoFlag::VIDEO_AV1; + } +#endif + } + mDecodePerfRecorder->Start(aSample->mTime.ToMicroseconds(), + MediaStage::RequestDecode, height, flag); +} + void MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack, MediaRawData* aSample) { MOZ_ASSERT(OnTaskQueue()); @@ -1980,41 +2019,15 @@ void MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack, aSample->mDuration.ToMicroseconds(), aSample->mKeyframe ? " kf" : "", aSample->mEOS ? " eos" : ""); - const int32_t height = - aTrack == TrackInfo::kVideoTrack - ? decoder.GetCurrentInfo()->GetAsVideoInfo()->mImage.height - : 0; - MediaInfoFlag flag = MediaInfoFlag::None; - flag |= - aSample->mKeyframe ? MediaInfoFlag::KeyFrame : MediaInfoFlag::NonKeyFrame; - if (aTrack == TrackInfo::kVideoTrack) { - flag |= VideoIsHardwareAccelerated() ? MediaInfoFlag::HardwareDecoding - : MediaInfoFlag::SoftwareDecoding; - const nsCString& mimeType = decoder.GetCurrentInfo()->mMimeType; - if (MP4Decoder::IsH264(mimeType)) { - flag |= MediaInfoFlag::VIDEO_H264; - } else if (VPXDecoder::IsVPX(mimeType, VPXDecoder::VP8)) { - flag |= MediaInfoFlag::VIDEO_VP8; - } else if (VPXDecoder::IsVPX(mimeType, VPXDecoder::VP9)) { - flag |= MediaInfoFlag::VIDEO_VP9; - } -#ifdef MOZ_AV1 - else if (AOMDecoder::IsAV1(mimeType)) { - flag |= MediaInfoFlag::VIDEO_AV1; - } -#endif - } - PerformanceRecorder<PlaybackStage> perfRecorder(MediaStage::RequestDecode, - height, flag); + decoder.StartRecordDecodingPerf(aTrack, aSample); if (mMediaEngineId && aSample->mCrypto.IsEncrypted()) { aSample->mShouldCopyCryptoToRemoteRawData = true; } decoder.mDecoder->Decode(aSample) ->Then( mTaskQueue, __func__, - [self, aTrack, &decoder, perfRecorder(std::move(perfRecorder))]( - MediaDataDecoder::DecodedData&& aResults) mutable { - perfRecorder.Record(); + [self, aTrack, + &decoder](MediaDataDecoder::DecodedData&& aResults) mutable { decoder.mDecodeRequest.Complete(); self->NotifyNewOutput(aTrack, std::move(aResults)); }, |