Bug 1073003 - Fix -Wnarrowing warnings. r=ehsan
--- a/dom/media/omx/OMXCodecDescriptorUtil.cpp
+++ b/dom/media/omx/OMXCodecDescriptorUtil.cpp
@@ -79,18 +79,18 @@ struct AVCParamSet {
return mSize + 2; // 2 more bytes for length value.
}
// Append 2 bytes length value and NAL unit bitstream to aOutputBuf.
void AppendTo(nsTArray<uint8_t>* aOutputBuf)
{
// 2 bytes length value.
uint8_t size[] = {
- (mSize & 0xFF00) >> 8, // MSB.
- mSize & 0x00FF, // LSB.
+ uint8_t((mSize & 0xFF00) >> 8), // MSB.
+ uint8_t(mSize & 0x00FF), // LSB.
};
aOutputBuf->AppendElements(size, sizeof(size));
aOutputBuf->AppendElements(mPtr, mSize);
}
const uint8_t* mPtr; // Pointer to NAL unit.
const size_t mSize; // NAL unit length in bytes.
--- a/dom/media/omx/OMXCodecWrapper.cpp
+++ b/dom/media/omx/OMXCodecWrapper.cpp
@@ -490,20 +490,20 @@ OMXVideoEncoder::AppendFrame(nsTArray<ui
if (mBlobFormat == BlobFormat::AVC_NAL) {
// Append NAL format data without modification.
aOutputBuf->AppendElements(aData, aSize);
return;
}
// Replace start code with data length.
uint8_t length[] = {
- (aSize >> 24) & 0xFF,
- (aSize >> 16) & 0xFF,
- (aSize >> 8) & 0xFF,
- aSize & 0xFF,
+ uint8_t((aSize >> 24) & 0xFF),
+ uint8_t((aSize >> 16) & 0xFF),
+ uint8_t((aSize >> 8) & 0xFF),
+ uint8_t(aSize & 0xFF),
};
aOutputBuf->AppendElements(length, sizeof(length));
aOutputBuf->AppendElements(aData + sizeof(length), aSize);
}
// MediaCodec::setParameters() is available only after API level 18.
#if ANDROID_VERSION >= 18
nsresult
@@ -903,24 +903,24 @@ OMXAudioEncoder::AppendDecoderConfig(nsT
NS_ENSURE_TRUE(csdSize == 2, ERROR_MALFORMED);
// Encoder output must be consistent with kAACFrameDuration:
// 14th bit (frame length flag) == 0 => 1024 (kAACFrameDuration) samples.
NS_ENSURE_TRUE((aData->data()[1] & 0x04) == 0, ERROR_MALFORMED);
// Decoder config descriptor
const uint8_t decConfig[] = {
0x04, // Decoder config descriptor tag.
- 15 + csdSize, // Size: following bytes + csd size.
+ uint8_t(15 + csdSize), // Size: following bytes + csd size.
0x40, // Object type: MPEG-4 audio.
0x15, // Stream type: audio, reserved: 1.
0x00, 0x03, 0x00, // Buffer size: 768 (kAACFrameSize).
0x00, 0x01, 0x77, 0x00, // Max bitrate: 96000 (kAACBitrate).
0x00, 0x01, 0x77, 0x00, // Avg bitrate: 96000 (kAACBitrate).
0x05, // Decoder specific descriptor tag.
- csdSize, // Data size.
+ uint8_t(csdSize), // Data size.
};
// SL config descriptor.
const uint8_t slConfig[] = {
0x06, // SL config descriptor tag.
0x01, // Size.
0x02, // Fixed value.
};