summaryrefslogtreecommitdiffstats
path: root/dom/media/platforms/wmf/WMFUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/platforms/wmf/WMFUtils.cpp')
-rw-r--r--dom/media/platforms/wmf/WMFUtils.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/dom/media/platforms/wmf/WMFUtils.cpp b/dom/media/platforms/wmf/WMFUtils.cpp
index d096979919..dda9df808e 100644
--- a/dom/media/platforms/wmf/WMFUtils.cpp
+++ b/dom/media/platforms/wmf/WMFUtils.cpp
@@ -177,7 +177,8 @@ Maybe<gfx::YUVColorSpace> GetYUVColorSpace(IMFMediaType* aType) {
}
int32_t MFOffsetToInt32(const MFOffset& aOffset) {
- return int32_t(aOffset.value + (aOffset.fract / 65536.0f));
+ return AssertedCast<int32_t>(AssertedCast<float>(aOffset.value) +
+ (AssertedCast<float>(aOffset.fract) / 65536.0f));
}
TimeUnit GetSampleDuration(IMFSample* aSample) {
@@ -204,7 +205,7 @@ GetPictureRegion(IMFMediaType* aMediaType, gfx::IntRect& aOutPictureRegion) {
// Determine if "pan and scan" is enabled for this media. If it is, we
// only display a region of the video frame, not the entire frame.
BOOL panScan =
- MFGetAttributeUINT32(aMediaType, MF_MT_PAN_SCAN_ENABLED, FALSE);
+ !!MFGetAttributeUINT32(aMediaType, MF_MT_PAN_SCAN_ENABLED, FALSE);
// If pan and scan mode is enabled. Try to get the display region.
HRESULT hr = E_FAIL;
@@ -300,11 +301,14 @@ const char* MFTMessageTypeToStr(MFT_MESSAGE_TYPE aMsg) {
GUID AudioMimeTypeToMediaFoundationSubtype(const nsACString& aMimeType) {
if (aMimeType.EqualsLiteral("audio/mpeg")) {
return MFAudioFormat_MP3;
- } else if (MP4Decoder::IsAAC(aMimeType)) {
+ }
+ if (MP4Decoder::IsAAC(aMimeType)) {
return MFAudioFormat_AAC;
- } else if (aMimeType.EqualsLiteral("audio/vorbis")) {
+ }
+ if (aMimeType.EqualsLiteral("audio/vorbis")) {
return MFAudioFormat_Vorbis;
- } else if (aMimeType.EqualsLiteral("audio/opus")) {
+ }
+ if (aMimeType.EqualsLiteral("audio/opus")) {
return MFAudioFormat_Opus;
}
NS_WARNING("Unsupport audio mimetype");
@@ -314,17 +318,19 @@ GUID AudioMimeTypeToMediaFoundationSubtype(const nsACString& aMimeType) {
GUID VideoMimeTypeToMediaFoundationSubtype(const nsACString& aMimeType) {
if (MP4Decoder::IsH264(aMimeType)) {
return MFVideoFormat_H264;
- } else if (VPXDecoder::IsVP8(aMimeType)) {
+ }
+ if (VPXDecoder::IsVP8(aMimeType)) {
return MFVideoFormat_VP80;
- } else if (VPXDecoder::IsVP9(aMimeType)) {
+ }
+ if (VPXDecoder::IsVP9(aMimeType)) {
return MFVideoFormat_VP90;
}
#ifdef MOZ_AV1
- else if (AOMDecoder::IsAV1(aMimeType)) {
+ if (AOMDecoder::IsAV1(aMimeType)) {
return MFVideoFormat_AV1;
}
#endif
- else if (MP4Decoder::IsHEVC(aMimeType)) {
+ if (MP4Decoder::IsHEVC(aMimeType)) {
return MFVideoFormat_HEVC;
}
NS_WARNING("Unsupport video mimetype");
@@ -368,7 +374,9 @@ void AACAudioSpecificConfigToUserData(uint8_t aAACProfileLevelIndication,
// the rest can be all 0x00.
BYTE heeInfo[heeInfoLen] = {0};
WORD* w = (WORD*)heeInfo;
- w[0] = 0x0; // Payload type raw AAC packet
+ // If extradata has been provided, assume raw AAC packets (0). Otherwise,
+ // assume ADTS (1)
+ w[0] = aConfigLength ? 0 : 1;
w[1] = aAACProfileLevelIndication;
aOutUserData.AppendElements(heeInfo, heeInfoLen);
@@ -377,10 +385,10 @@ void AACAudioSpecificConfigToUserData(uint8_t aAACProfileLevelIndication,
// The AudioSpecificConfig is TTTTTFFF|FCCCCGGG
// (T=ObjectType, F=Frequency, C=Channel, G=GASpecificConfig)
// If frequency = 0xf, then the frequency is explicitly defined on 24 bits.
- int8_t frequency =
+ uint8_t frequency =
(aAudioSpecConfig[0] & 0x7) << 1 | (aAudioSpecConfig[1] & 0x80) >> 7;
- int8_t channels = (aAudioSpecConfig[1] & 0x78) >> 3;
- int8_t gasc = aAudioSpecConfig[1] & 0x7;
+ uint8_t channels = (aAudioSpecConfig[1] & 0x78) >> 3;
+ uint8_t gasc = aAudioSpecConfig[1] & 0x7;
if (frequency != 0xf && channels && !gasc) {
// We enter this condition if the AudioSpecificConfig should theorically
// be 2 bytes long but it's not.