Bug 1314147 - Recognize AV1 in WebMDemuxer. r=jya
Call AOMDecoder to handle AV1 video tracks from the WebM container.
The new decoder is very similar to VPXDecoder so we can use parallel
calls. This codec is still build-time conditional.
MozReview-Commit-ID: 5cexCZiNBqo
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -3,16 +3,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsError.h"
#include "MediaDecoderStateMachine.h"
#include "AbstractMediaDecoder.h"
#include "MediaResource.h"
+#ifdef MOZ_AV1
+#include "AOMDecoder.h"
+#endif
#include "OpusDecoder.h"
#include "VPXDecoder.h"
#include "WebMDemuxer.h"
#include "WebMBufferedParser.h"
#include "gfx2DGlue.h"
#include "mozilla/Atomics.h"
#include "mozilla/EndianUtils.h"
#include "mozilla/SharedThreadPool.h"
@@ -322,16 +325,19 @@ WebMDemuxer::ReadMetadata()
mVideoCodec = nestegg_track_codec_id(context, track);
switch(mVideoCodec) {
case NESTEGG_CODEC_VP8:
mInfo.mVideo.mMimeType = "video/webm; codecs=vp8";
break;
case NESTEGG_CODEC_VP9:
mInfo.mVideo.mMimeType = "video/webm; codecs=vp9";
break;
+ case NESTEGG_CODEC_AV1:
+ mInfo.mVideo.mMimeType = "video/webm; codecs=av1";
+ break;
default:
NS_WARNING("Unknown WebM video codec");
return NS_ERROR_FAILURE;
}
// Picture region, taking into account cropping, before scaling
// to the display size.
unsigned int cropH = params.crop_right + params.crop_left;
unsigned int cropV = params.crop_bottom + params.crop_top;
@@ -677,27 +683,42 @@ WebMDemuxer::GetNextPacket(TrackInfo::Tr
auto sample = MakeSpan(data, length);
switch (mVideoCodec) {
case NESTEGG_CODEC_VP8:
isKeyframe = VPXDecoder::IsKeyframe(sample, VPXDecoder::Codec::VP8);
break;
case NESTEGG_CODEC_VP9:
isKeyframe = VPXDecoder::IsKeyframe(sample, VPXDecoder::Codec::VP9);
break;
+#ifdef MOZ_AV1
+ case NESTEGG_CODEC_AV1:
+ isKeyframe = AOMDecoder::IsKeyframe(sample);
+ break;
+#endif
default:
NS_WARNING("Cannot detect keyframes in unknown WebM video codec");
return NS_ERROR_FAILURE;
}
if (isKeyframe) {
// For both VP8 and VP9, we only look for resolution changes
// on keyframes. Other resolution changes are invalid.
- auto codec = mVideoCodec == NESTEGG_CODEC_VP8
- ? VPXDecoder::Codec::VP8
- : VPXDecoder::Codec::VP9;
- auto dimensions = VPXDecoder::GetFrameSize(sample, codec);
+ auto dimensions = nsIntSize(0, 0);
+ switch (mVideoCodec) {
+ case NESTEGG_CODEC_VP8:
+ dimensions = VPXDecoder::GetFrameSize(sample, VPXDecoder::Codec::VP8);
+ break;
+ case NESTEGG_CODEC_VP9:
+ dimensions = VPXDecoder::GetFrameSize(sample, VPXDecoder::Codec::VP9);
+ break;
+#ifdef MOZ_AV1
+ case NESTEGG_CODEC_AV1:
+ dimensions = AOMDecoder::GetFrameSize(sample);
+ break;
+#endif
+ }
if (mLastSeenFrameSize.isSome()
&& (dimensions != mLastSeenFrameSize.value())) {
mInfo.mVideo.mDisplay = dimensions;
mSharedVideoTrackInfo =
new TrackInfoSharedPtr(mInfo.mVideo, ++sStreamSourceID);
}
mLastSeenFrameSize = Some(dimensions);
}