summaryrefslogtreecommitdiff
path: root/dom/media/webm/WebMDemuxer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/webm/WebMDemuxer.cpp')
-rw-r--r--dom/media/webm/WebMDemuxer.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/dom/media/webm/WebMDemuxer.cpp b/dom/media/webm/WebMDemuxer.cpp
index 090229365e..1009fedc69 100644
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -378,6 +378,7 @@ WebMDemuxer::ReadMetadata()
mInfo.mVideo.mDisplay = displaySize;
mInfo.mVideo.mImage = frameSize;
mInfo.mVideo.SetImageRect(pictureRect);
+ mInfo.mVideo.SetAlpha(params.alpha_mode);
switch (params.stereo_mode) {
case NESTEGG_VIDEO_MONO:
@@ -656,6 +657,21 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
WEBM_DEBUG("nestegg_packet_data failed r=%d", r);
return NS_ERROR_DOM_MEDIA_DEMUXER_ERR;
}
+ unsigned char* alphaData;
+ size_t alphaLength = 0;
+ // Check packets for alpha information if file has declared alpha frames
+ // may be present.
+ if (mInfo.mVideo.HasAlpha()) {
+ r = nestegg_packet_additional_data(holder->Packet(),
+ 1,
+ &alphaData,
+ &alphaLength);
+ if (r == -1) {
+ WEBM_DEBUG(
+ "nestegg_packet_additional_data failed to retrieve alpha data r=%d",
+ r);
+ }
+ }
bool isKeyframe = false;
if (aType == TrackInfo::kAudioTrack) {
isKeyframe = true;
@@ -713,10 +729,19 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl
WEBM_DEBUG("push sample tstamp: %ld next_tstamp: %ld length: %ld kf: %d",
tstamp, next_tstamp, length, isKeyframe);
- RefPtr<MediaRawData> sample = new MediaRawData(data, length);
- if (length && !sample->Data()) {
- // OOM.
- return NS_ERROR_OUT_OF_MEMORY;
+ RefPtr<MediaRawData> sample;
+ if (mInfo.mVideo.HasAlpha() && alphaLength != 0) {
+ sample = new MediaRawData(data, length, alphaData, alphaLength);
+ if (length && !sample->Data() || (alphaLength && !sample->AlphaData())) {
+ // OOM.
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ } else {
+ sample = new MediaRawData(data, length);
+ if (length && !sample->Data()) {
+ // OOM.
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
}
sample->mTimecode = tstamp;
sample->mTime = tstamp;