зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358662 - Implement keyframe and framesize VPXDecoder helpers. r=jya
Encapsulate code from WebMDemuxer to query keyframe and frame resolution inside VPXDecoder, so we have a clean wrapper for all the libvpx functions we use. MozReview-Commit-ID: ASRRhNl0A41 --HG-- extra : rebase_source : a1421462f6fc66a2abd965782ec408a8bcf7fe1f
This commit is contained in:
Родитель
ebeeb5aa45
Коммит
20c544fb86
|
@ -124,16 +124,8 @@ VPXDecoder::ProcessDecode(MediaRawData* aSample)
|
|||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||
|
||||
#if defined(DEBUG)
|
||||
vpx_codec_stream_info_t si;
|
||||
PodZero(&si);
|
||||
si.sz = sizeof(si);
|
||||
if (mCodec == Codec::VP8) {
|
||||
vpx_codec_peek_stream_info(vpx_codec_vp8_dx(), aSample->Data(), aSample->Size(), &si);
|
||||
} else if (mCodec == Codec::VP9) {
|
||||
vpx_codec_peek_stream_info(vpx_codec_vp9_dx(), aSample->Data(), aSample->Size(), &si);
|
||||
}
|
||||
NS_ASSERTION(bool(si.is_kf) == aSample->mKeyframe,
|
||||
"VPX Decode Keyframe error sample->mKeyframe and si.si_kf out of sync");
|
||||
NS_ASSERTION(IsKeyframe(*aSample, mCodec) == aSample->mKeyframe,
|
||||
"VPX Decode Keyframe error sample->mKeyframe and sample data out of sync");
|
||||
#endif
|
||||
|
||||
if (vpx_codec_err_t r = vpx_codec_decode(&mVPX, aSample->Data(), aSample->Size(), nullptr, 0)) {
|
||||
|
@ -314,5 +306,37 @@ VPXDecoder::IsVP9(const nsACString& aMimeType)
|
|||
return IsVPX(aMimeType, VPXDecoder::VP9);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
VPXDecoder::IsKeyframe(Span<const uint8_t> aBuffer, Codec aCodec)
|
||||
{
|
||||
vpx_codec_stream_info_t si;
|
||||
if (aCodec == Codec::VP8) {
|
||||
vpx_codec_peek_stream_info(vpx_codec_vp8_dx(), aBuffer.Elements(), aBuffer.Length(), &si);
|
||||
return bool(si.is_kf);
|
||||
} else if (aCodec == Codec::VP9) {
|
||||
vpx_codec_peek_stream_info(vpx_codec_vp9_dx(), aBuffer.Elements(), aBuffer.Length(), &si);
|
||||
return bool(si.is_kf);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsIntSize
|
||||
VPXDecoder::GetFrameSize(Span<const uint8_t> aBuffer, Codec aCodec)
|
||||
{
|
||||
vpx_codec_stream_info_t si;
|
||||
PodZero(&si);
|
||||
si.sz = sizeof(si);
|
||||
|
||||
if (aCodec == Codec::VP8) {
|
||||
vpx_codec_peek_stream_info(vpx_codec_vp8_dx(), aBuffer.Elements(), aBuffer.Length(), &si);
|
||||
} else if (aCodec == Codec::VP9) {
|
||||
vpx_codec_peek_stream_info(vpx_codec_vp9_dx(), aBuffer.Elements(), aBuffer.Length(), &si);
|
||||
}
|
||||
|
||||
return nsIntSize(si.w, si.h);
|
||||
}
|
||||
} // namespace mozilla
|
||||
#undef LOG
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define VPXDecoder_h_
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "mozilla/Span.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#define VPX_DONT_DEFINE_STDINT_TYPES
|
||||
|
@ -45,6 +46,12 @@ public:
|
|||
static bool IsVP8(const nsACString& aMimeType);
|
||||
static bool IsVP9(const nsACString& aMimeType);
|
||||
|
||||
// Return true if a sample is a keyframe for the specified codec.
|
||||
static bool IsKeyframe(Span<const uint8_t> aBuffer, Codec aCodec);
|
||||
|
||||
// Return the frame dimensions for a sample for the specified codec.
|
||||
static nsIntSize GetFrameSize(Span<const uint8_t> aBuffer, Codec aCodec);
|
||||
|
||||
private:
|
||||
~VPXDecoder();
|
||||
RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample);
|
||||
|
|
Загрузка…
Ссылка в новой задаче