зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1280346: [mp4] Always use SPS dimensions if available. r=gerald,rillian
H264 decoders always use those anyway, so may as well use them in the demuxer if SPS NAL is available. This guarantees that we have correct dimensions when reading the MP4 metadata, and will have the side benefit that when loadedmetadata is fired, the dimensions provided at the time will be final; not having to wait to decode the first frame. MozReview-Commit-ID: 3j70Xqw8jJY --HG-- extra : rebase_source : 6bc0f1fa1c2db35bcaa683cc1a68042d122e2892
This commit is contained in:
Родитель
1637787858
Коммит
a18ecfafaa
|
@ -236,12 +236,22 @@ MP4TrackDemuxer::MP4TrackDemuxer(MP4Demuxer* aParent,
|
|||
{
|
||||
EnsureUpToDateIndex(); // Force update of index
|
||||
|
||||
VideoInfo* videoInfo = mInfo->GetAsVideoInfo();
|
||||
// Collect telemetry from h264 AVCC SPS.
|
||||
if (mInfo->GetAsVideoInfo() &&
|
||||
if (videoInfo &&
|
||||
(mInfo->mMimeType.EqualsLiteral("video/mp4") ||
|
||||
mInfo->mMimeType.EqualsLiteral("video/avc"))) {
|
||||
mNeedSPSForTelemetry =
|
||||
AccumulateSPSTelemetry(mInfo->GetAsVideoInfo()->mExtraData);
|
||||
RefPtr<MediaByteBuffer> extraData = videoInfo->mExtraData;
|
||||
mNeedSPSForTelemetry = AccumulateSPSTelemetry(extraData);
|
||||
mp4_demuxer::SPSData spsdata;
|
||||
if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata) &&
|
||||
spsdata.pic_width > 0 && spsdata.pic_height > 0 &&
|
||||
mp4_demuxer::H264::EnsureSPSIsSane(spsdata)) {
|
||||
videoInfo->mImage.width = spsdata.pic_width;
|
||||
videoInfo->mImage.height = spsdata.pic_height;
|
||||
videoInfo->mDisplay.width = spsdata.display_width;
|
||||
videoInfo->mDisplay.height = spsdata.display_height;
|
||||
}
|
||||
} else {
|
||||
// No SPS to be found.
|
||||
mNeedSPSForTelemetry = false;
|
||||
|
|
|
@ -210,7 +210,8 @@ MP4VideoInfo::Update(const mp4parse_track_info* track,
|
|||
bool
|
||||
MP4VideoInfo::IsValid() const
|
||||
{
|
||||
return mDisplay.width > 0 && mDisplay.height > 0;
|
||||
return (mDisplay.width > 0 && mDisplay.height > 0) ||
|
||||
(mImage.width > 0 && mImage.height > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче