Recognize AV1 in WebMDemuxer

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.
This commit is contained in:
trav90 2018-10-15 22:11:24 -05:00 • committed by Roy Tam
commit 76faa8e90f

View file

@ -8,6 +8,9 @@
#include "MediaDecoderStateMachine.h" #include "MediaDecoderStateMachine.h"
#include "AbstractMediaDecoder.h" #include "AbstractMediaDecoder.h"
#include "MediaResource.h" #include "MediaResource.h"
#ifdef MOZ_AV1
#include "AOMDecoder.h"
#endif
#include "OpusDecoder.h" #include "OpusDecoder.h"
#include "VPXDecoder.h" #include "VPXDecoder.h"
#include "WebMDemuxer.h" #include "WebMDemuxer.h"
@ -320,6 +323,9 @@ WebMDemuxer::ReadMetadata()
case NESTEGG_CODEC_VP9: case NESTEGG_CODEC_VP9:
mInfo.mVideo.mMimeType = "video/webm; codecs=vp9"; mInfo.mVideo.mMimeType = "video/webm; codecs=vp9";
break; break;
case NESTEGG_CODEC_AV1:
mInfo.mVideo.mMimeType = "video/webm; codecs=av1";
break;
default: default:
NS_WARNING("Unknown WebM video codec"); NS_WARNING("Unknown WebM video codec");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -651,6 +657,11 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
case NESTEGG_CODEC_VP9: case NESTEGG_CODEC_VP9:
isKeyframe = VPXDecoder::IsKeyframe(sample, VPXDecoder::Codec::VP9); isKeyframe = VPXDecoder::IsKeyframe(sample, VPXDecoder::Codec::VP9);
break; break;
#ifdef MOZ_AV1
case NESTEGG_CODEC_AV1:
isKeyframe = AOMDecoder::IsKeyframe(sample);
break;
#endif
default: default:
NS_WARNING("Cannot detect keyframes in unknown WebM video codec"); NS_WARNING("Cannot detect keyframes in unknown WebM video codec");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -658,10 +669,20 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
if (isKeyframe) { if (isKeyframe) {
// For both VP8 and VP9, we only look for resolution changes // For both VP8 and VP9, we only look for resolution changes
// on keyframes. Other resolution changes are invalid. // on keyframes. Other resolution changes are invalid.
auto codec = mVideoCodec == NESTEGG_CODEC_VP8 auto dimensions = nsIntSize(0, 0);
? VPXDecoder::Codec::VP8 switch (mVideoCodec) {
: VPXDecoder::Codec::VP9; case NESTEGG_CODEC_VP8:
auto dimensions = VPXDecoder::GetFrameSize(sample, codec); 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() if (mLastSeenFrameSize.isSome()
&& (dimensions != mLastSeenFrameSize.value())) { && (dimensions != mLastSeenFrameSize.value())) {
mInfo.mVideo.mDisplay = dimensions; mInfo.mVideo.mDisplay = dimensions;