Bug 1137474: Basic vp9 support added to upstream (using 'generic' packetization) r=pkerr

This commit is contained in:
Randell Jesup 2015-03-03 01:31:33 -05:00
parent d7ef0ecef9
commit 52aaf48f23
10 changed files with 80 additions and 2 deletions

View File

@ -66,8 +66,36 @@ struct RTPVideoHeaderH264 {
bool single_nalu;
};
// XXX fix vp9 (bug 1138629)
struct RTPVideoHeaderVP9 {
void InitRTPVideoHeaderVP9() {
nonReference = false;
pictureId = kNoPictureId;
tl0PicIdx = kNoTl0PicIdx;
temporalIdx = kNoTemporalIdx;
layerSync = false;
keyIdx = kNoKeyIdx;
partitionId = 0;
beginningOfPartition = false;
}
bool nonReference; // Frame is discardable.
int16_t pictureId; // Picture ID index, 15 bits;
// kNoPictureId if PictureID does not exist.
int16_t tl0PicIdx; // TL0PIC_IDX, 8 bits;
// kNoTl0PicIdx means no value provided.
uint8_t temporalIdx; // Temporal layer index, or kNoTemporalIdx.
bool layerSync; // This frame is a layer sync frame.
// Disabled if temporalIdx == kNoTemporalIdx.
int keyIdx; // 5 bits; kNoKeyIdx means not used.
int partitionId; // VP9 partition ID
bool beginningOfPartition; // True if this packet is the first
// in a VP9 partition. Otherwise false
};
union RTPVideoTypeHeader {
RTPVideoHeaderVP8 VP8;
RTPVideoHeaderVP9 VP9;
RTPVideoHeaderH264 H264;
};
@ -75,6 +103,7 @@ enum RtpVideoCodecTypes {
kRtpVideoNone,
kRtpVideoGeneric,
kRtpVideoVp8,
kRtpVideoVp9,
kRtpVideoH264
};
struct RTPVideoHeader {

View File

@ -25,6 +25,7 @@ RtpPacketizer* RtpPacketizer::Create(RtpVideoCodecTypes type,
case kRtpVideoVp8:
assert(rtp_type_header != NULL);
return new RtpPacketizerVp8(rtp_type_header->VP8, max_payload_len);
case kRtpVideoVp9:
case kRtpVideoGeneric:
return new RtpPacketizerGeneric(frame_type, max_payload_len);
case kRtpVideoNone:
@ -39,6 +40,7 @@ RtpDepacketizer* RtpDepacketizer::Create(RtpVideoCodecTypes type) {
return new RtpDepacketizerH264();
case kRtpVideoVp8:
return new RtpDepacketizerVp8();
case kRtpVideoVp9: // XXX fix vp9 packetization (bug 1138629)
case kRtpVideoGeneric:
return new RtpDepacketizerGeneric();
case kRtpVideoNone:

View File

@ -427,6 +427,8 @@ class RTPPayloadVideoStrategy : public RTPPayloadStrategy {
RtpVideoCodecTypes videoType = kRtpVideoGeneric;
if (RtpUtility::StringCompare(payloadName, "VP8", 3)) {
videoType = kRtpVideoVp8;
} else if (RtpUtility::StringCompare(payloadName, "VP9", 3)) {
videoType = kRtpVideoVp9;
} else if (RtpUtility::StringCompare(payloadName, "H264", 4)) {
videoType = kRtpVideoH264;
} else if (RtpUtility::StringCompare(payloadName, "I420", 4)) {

View File

@ -84,6 +84,8 @@ int32_t RTPSenderVideo::RegisterVideoPayload(
RtpVideoCodecTypes videoType = kRtpVideoGeneric;
if (RtpUtility::StringCompare(payloadName, "VP8", 3)) {
videoType = kRtpVideoVp8;
} else if (RtpUtility::StringCompare(payloadName, "VP9", 3)) {
videoType = kRtpVideoVp9;
} else if (RtpUtility::StringCompare(payloadName, "H264", 4)) {
videoType = kRtpVideoH264;
} else if (RtpUtility::StringCompare(payloadName, "I420", 4)) {
@ -336,7 +338,7 @@ bool RTPSenderVideo::Send(const RtpVideoCodecTypes videoType,
// output multiple partitions for VP8. Should remove below check after the
// issue is fixed.
const RTPFragmentationHeader* frag =
(videoType == kRtpVideoVp8) ? NULL : fragmentation;
(videoType == kRtpVideoVp8 || videoType == kRtpVideoVp9) ? NULL : fragmentation;
packetizer->SetPayloadData(data, payload_bytes_to_send, frag);

View File

@ -137,6 +137,33 @@ void VCMEncodedFrame::CopyCodecSpecific(const RTPVideoHeader* header)
_codecSpecificInfo.codecType = kVideoCodecH264;
break;
}
case kRtpVideoVp9: {
if (_codecSpecificInfo.codecType != kVideoCodecVP9) {
// This is the first packet for this frame.
_codecSpecificInfo.codecSpecific.VP9.pictureId = -1;
_codecSpecificInfo.codecSpecific.VP9.temporalIdx = 0;
_codecSpecificInfo.codecSpecific.VP9.layerSync = false;
_codecSpecificInfo.codecSpecific.VP9.keyIdx = -1;
_codecSpecificInfo.codecType = kVideoCodecVP9;
}
_codecSpecificInfo.codecSpecific.VP9.nonReference =
header->codecHeader.VP9.nonReference;
if (header->codecHeader.VP9.pictureId != kNoPictureId) {
_codecSpecificInfo.codecSpecific.VP9.pictureId =
header->codecHeader.VP9.pictureId;
}
if (header->codecHeader.VP9.temporalIdx != kNoTemporalIdx) {
_codecSpecificInfo.codecSpecific.VP9.temporalIdx =
header->codecHeader.VP9.temporalIdx;
_codecSpecificInfo.codecSpecific.VP9.layerSync =
header->codecHeader.VP9.layerSync;
}
if (header->codecHeader.VP9.keyIdx != kNoKeyIdx) {
_codecSpecificInfo.codecSpecific.VP9.keyIdx =
header->codecHeader.VP9.keyIdx;
}
break;
}
default: {
_codecSpecificInfo.codecType = kVideoCodecUnknown;
break;

View File

@ -42,6 +42,17 @@ void CopyCodecSpecific(const CodecSpecificInfo* info, RTPVideoHeader** rtp) {
(*rtp)->codec = kRtpVideoH264;
(*rtp)->simulcastIdx = info->codecSpecific.H264.simulcastIdx;
return;
case kVideoCodecVP9:
(*rtp)->codec = kRtpVideoVp9;
(*rtp)->codecHeader.VP9.InitRTPVideoHeaderVP9();
(*rtp)->codecHeader.VP9.pictureId = info->codecSpecific.VP9.pictureId;
(*rtp)->codecHeader.VP9.nonReference =
info->codecSpecific.VP9.nonReference;
(*rtp)->codecHeader.VP9.temporalIdx = info->codecSpecific.VP9.temporalIdx;
(*rtp)->codecHeader.VP9.layerSync = info->codecSpecific.VP9.layerSync;
(*rtp)->codecHeader.VP9.tl0PicIdx = info->codecSpecific.VP9.tl0PicIdx;
(*rtp)->codecHeader.VP9.keyIdx = info->codecSpecific.VP9.keyIdx;
return;
case kVideoCodecGeneric:
(*rtp)->codec = kRtpVideoGeneric;
(*rtp)->simulcastIdx = info->codecSpecific.generic.simulcast_idx;

View File

@ -98,6 +98,7 @@ void VCMPacket::Reset() {
void VCMPacket::CopyCodecSpecifics(const RTPVideoHeader& videoHeader) {
switch (videoHeader.codec) {
case kRtpVideoVp8:
case kRtpVideoVp9:
// Handle all packets within a frame as depending on the previous packet
// TODO(holmer): This should be changed to make fragments independent
// when the VP8 RTP receiver supports fragments.
@ -110,7 +111,7 @@ void VCMPacket::CopyCodecSpecifics(const RTPVideoHeader& videoHeader) {
else
completeNALU = kNaluIncomplete;
codec = kVideoCodecVP8;
codec = videoHeader.codec == kRtpVideoVp8 ? kVideoCodecVP8 : kVideoCodecVP9;
return;
case kRtpVideoH264:
isFirstPacket = videoHeader.isFirstPacket;

View File

@ -137,6 +137,7 @@ int32_t VideoSender::RegisterSendCodec(const VideoCodec* sendCodec,
return VCM_CODEC_ERROR;
}
// XXX fix VP9 (bug 1138629)
int numLayers = (sendCodec->codecType != kVideoCodecVP8)
? 1
: sendCodec->codecSpecific.VP8.numberOfTemporalLayers;

View File

@ -87,6 +87,8 @@ static void LogCodec(const VideoCodec& codec) {
<< codec.codecSpecific.H264.spsLen
<< ", ppslen: "
<< codec.codecSpecific.H264.ppsLen;
} else if (codec.codecType == kVideoCodecVP9) {
LOG(LS_INFO) << "VP9 specific settings";
}
}

View File

@ -636,6 +636,7 @@ void ViEEncoder::DeliverFrame(int id,
return;
}
#endif
// XXX fix VP9 (bug 1138629)
#ifdef MOZ_WEBRTC_OMX
// XXX effectively disable resolution changes until Bug 1067437 is resolved with new DSP code