diff options
author | trav90 <travawine@palemoon.org> | 2018-10-08 21:16:39 -0500 |
---|---|---|
committer | trav90 <travawine@palemoon.org> | 2018-10-08 21:16:39 -0500 |
commit | 3ec54eeacb8fcb5b844aa07c803cf52d1aedb0d4 (patch) | |
tree | 46a07f8191fa06696999fb7ce4d7cbddc3afad75 | |
parent | 55c6aa422da84f581c3bbb0d2c0fa9b282a9d669 (diff) | |
download | UXP-3ec54eeacb8fcb5b844aa07c803cf52d1aedb0d4.tar UXP-3ec54eeacb8fcb5b844aa07c803cf52d1aedb0d4.tar.gz UXP-3ec54eeacb8fcb5b844aa07c803cf52d1aedb0d4.tar.lz UXP-3ec54eeacb8fcb5b844aa07c803cf52d1aedb0d4.tar.xz UXP-3ec54eeacb8fcb5b844aa07c803cf52d1aedb0d4.zip |
Call VPXDecoder libvpx wrappers for WebM
Use the new helper functions instead of calling libvpx directly. This simplifies adding other codecs in the future.
-rw-r--r-- | dom/media/webm/WebMDemuxer.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/dom/media/webm/WebMDemuxer.cpp b/dom/media/webm/WebMDemuxer.cpp index ac371fa7f..b39bec661 100644 --- a/dom/media/webm/WebMDemuxer.cpp +++ b/dom/media/webm/WebMDemuxer.cpp @@ -9,6 +9,7 @@ #include "AbstractMediaDecoder.h" #include "MediaResource.h" #include "OpusDecoder.h" +#include "VPXDecoder.h" #include "WebMDemuxer.h" #include "WebMBufferedParser.h" #include "gfx2DGlue.h" @@ -24,12 +25,9 @@ #include "mozilla/Sprintf.h" #include <algorithm> +#include <numeric> #include <stdint.h> -#define VPX_DONT_DEFINE_STDINT_TYPES -#include "vpx/vp8dx.h" -#include "vpx/vpx_decoder.h" - #define WEBM_DEBUG(arg, ...) MOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, ("WebMDemuxer(%p)::%s: " arg, this, __func__, ##__VA_ARGS__)) extern mozilla::LazyLogModule gMediaDemuxerLog; @@ -636,22 +634,25 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl // Packet is encrypted, can't peek, use packet info isKeyframe = nestegg_packet_has_keyframe(holder->Packet()) == NESTEGG_PACKET_HAS_KEYFRAME_TRUE; } else { - vpx_codec_stream_info_t si; - PodZero(&si); - si.sz = sizeof(si); + auto sample = MakeSpan(data, length); switch (mVideoCodec) { case NESTEGG_CODEC_VP8: - vpx_codec_peek_stream_info(vpx_codec_vp8_dx(), data, length, &si); + isKeyframe = VPXDecoder::IsKeyframe(sample, VPXDecoder::Codec::VP8); break; case NESTEGG_CODEC_VP9: - vpx_codec_peek_stream_info(vpx_codec_vp9_dx(), data, length, &si); + isKeyframe = VPXDecoder::IsKeyframe(sample, VPXDecoder::Codec::VP9); break; + default: + NS_WARNING("Cannot detect keyframes in unknown WebM video codec"); + return NS_ERROR_FAILURE; } - isKeyframe = si.is_kf; if (isKeyframe) { - // We only look for resolution changes on keyframes for both VP8 and - // VP9. Other resolution changes are invalid. - auto dimensions = nsIntSize(si.w, si.h); + // 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); if (mLastSeenFrameSize.isSome() && (dimensions != mLastSeenFrameSize.value())) { mInfo.mVideo.mDisplay = dimensions; |