зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1665776 - p6: implement VPx support in WMF encoder. r=bryce
Differential Revision: https://phabricator.services.mozilla.com/D121023
This commit is contained in:
Родитель
89a7c5d4f9
Коммит
b597a55a60
|
@ -74,7 +74,15 @@ static const char* ErrorStr(HRESULT hr) {
|
|||
}
|
||||
|
||||
static const char* CodecStr(const GUID& aGUID) {
|
||||
return IsEqualGUID(aGUID, MFVideoFormat_H264) ? "H.264" : "???";
|
||||
if (IsEqualGUID(aGUID, MFVideoFormat_H264)) {
|
||||
return "H.264";
|
||||
} else if (IsEqualGUID(aGUID, MFVideoFormat_VP80)) {
|
||||
return "VP8";
|
||||
} else if (IsEqualGUID(aGUID, MFVideoFormat_VP90)) {
|
||||
return "VP9";
|
||||
} else {
|
||||
return "Unsupported codec";
|
||||
}
|
||||
}
|
||||
|
||||
static UINT32 EnumHW(const GUID& aSubtype, IMFActivate**& aActivates) {
|
||||
|
@ -160,6 +168,8 @@ nsTArray<MFTEncoder::Info> MFTEncoder::Enumerate() {
|
|||
}
|
||||
|
||||
PopulateHWEncoderInfo(MFVideoFormat_H264, infos);
|
||||
PopulateHWEncoderInfo(MFVideoFormat_VP90, infos);
|
||||
PopulateHWEncoderInfo(MFVideoFormat_VP80, infos);
|
||||
|
||||
wmf::MFShutdown();
|
||||
return infos;
|
||||
|
|
|
@ -6,36 +6,32 @@
|
|||
|
||||
#include "WMFEncoderModule.h"
|
||||
|
||||
#include "MP4Decoder.h"
|
||||
#include "WMFMediaDataEncoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
extern LazyLogModule sPEMLog;
|
||||
|
||||
static MediaDataEncoder::CodecType MimeTypeToCodecType(
|
||||
const nsACString& aMimeType) {
|
||||
if (MP4Decoder::IsH264(aMimeType)) {
|
||||
return MediaDataEncoder::CodecType::H264;
|
||||
} else {
|
||||
MOZ_ASSERT(false, "Unsupported Mimetype");
|
||||
return MediaDataEncoder::CodecType::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
bool WMFEncoderModule::SupportsMimeType(const nsACString& aMimeType) const {
|
||||
return CanCreateWMFEncoder(MimeTypeToCodecType(aMimeType));
|
||||
return CanCreateWMFEncoder(CreateEncoderParams::CodecTypeForMime(aMimeType));
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataEncoder> WMFEncoderModule::CreateVideoEncoder(
|
||||
const CreateEncoderParams& aParams) const {
|
||||
MediaDataEncoder::CodecType codec =
|
||||
MimeTypeToCodecType(aParams.mConfig.mMimeType);
|
||||
CreateEncoderParams::CodecTypeForMime(aParams.mConfig.mMimeType);
|
||||
RefPtr<MediaDataEncoder> encoder;
|
||||
switch (codec) {
|
||||
case MediaDataEncoder::CodecType::H264:
|
||||
encoder = new WMFMediaDataEncoder<MediaDataEncoder::H264Config>(
|
||||
aParams.ToH264Config(), aParams.mTaskQueue);
|
||||
break;
|
||||
case MediaDataEncoder::CodecType::VP8:
|
||||
encoder = new WMFMediaDataEncoder<MediaDataEncoder::VP8Config>(
|
||||
aParams.ToVP8Config(), aParams.mTaskQueue);
|
||||
case MediaDataEncoder::CodecType::VP9:
|
||||
encoder = new WMFMediaDataEncoder<MediaDataEncoder::VP9Config>(
|
||||
aParams.ToVP9Config(), aParams.mTaskQueue);
|
||||
break;
|
||||
default:
|
||||
// Do nothing.
|
||||
break;
|
||||
|
|
|
@ -27,6 +27,10 @@ static const GUID CodecToSubtype(MediaDataEncoder::CodecType aCodec) {
|
|||
switch (aCodec) {
|
||||
case MediaDataEncoder::CodecType::H264:
|
||||
return MFVideoFormat_H264;
|
||||
case MediaDataEncoder::CodecType::VP8:
|
||||
return MFVideoFormat_VP80;
|
||||
case MediaDataEncoder::CodecType::VP9:
|
||||
return MFVideoFormat_VP90;
|
||||
default:
|
||||
MOZ_ASSERT(false, "Unsupported codec");
|
||||
return GUID_NULL;
|
||||
|
@ -186,9 +190,14 @@ already_AddRefed<IMFMediaType> CreateInputType(Config& aConfig) {
|
|||
: nullptr;
|
||||
}
|
||||
|
||||
static HRESULT SetCodecSpecific(
|
||||
IMFMediaType* aOutputType,
|
||||
const MediaDataEncoder::H264Specific& aSpecific) {
|
||||
template <typename T>
|
||||
HRESULT SetCodecSpecific(IMFMediaType* aOutputType, const T& aSpecific) {
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
template <>
|
||||
HRESULT SetCodecSpecific(IMFMediaType* aOutputType,
|
||||
const MediaDataEncoder::H264Specific& aSpecific) {
|
||||
return aOutputType->SetUINT32(MF_MT_MPEG2_PROFILE,
|
||||
GetProfile(aSpecific.mProfileLevel));
|
||||
}
|
||||
|
@ -446,11 +455,9 @@ RefPtr<GenericPromise> WMFMediaDataEncoder<T>::SetBitrate(
|
|||
});
|
||||
}
|
||||
|
||||
template <>
|
||||
nsCString
|
||||
WMFMediaDataEncoder<MediaDataEncoder::H264Config>::GetDescriptionName() const {
|
||||
MOZ_ASSERT(mConfig.mCodecType == CodecType::H264);
|
||||
return MFTEncoder::GetFriendlyName(MFVideoFormat_H264);
|
||||
template <typename T>
|
||||
nsCString WMFMediaDataEncoder<T>::GetDescriptionName() const {
|
||||
return MFTEncoder::GetFriendlyName(CodecToSubtype(mConfig.mCodecType));
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче