Index: webrtc/modules/interface/module_common_types.h |
diff --git a/webrtc/modules/interface/module_common_types.h b/webrtc/modules/interface/module_common_types.h |
index 1202eee0435c3774b7daf45a2eb20384dc6d4205..962603923dca4c5e8030b35910a7923ce8e4b72e 100644 |
--- a/webrtc/modules/interface/module_common_types.h |
+++ b/webrtc/modules/interface/module_common_types.h |
@@ -32,8 +32,15 @@ struct RTPAudioHeader { |
}; |
const int16_t kNoPictureId = -1; |
+const int16_t kMaxOneBytePictureId = 0x7F; // 7 bits |
+const int16_t kMaxTwoBytePictureId = 0x7FFF; // 15 bits |
const int16_t kNoTl0PicIdx = -1; |
const uint8_t kNoTemporalIdx = 0xFF; |
+const uint8_t kNoSpatialIdx = 0xFF; |
+const uint8_t kNoGofIdx = 0xFF; |
+const int kMaxVp9RefPics = 3; |
+const int kMaxVp9FramesInGof = 16; |
+const int kMaxVp9NumberOfSpatialLayers = 8; |
const int kNoKeyIdx = -1; |
struct RTPVideoHeaderVP8 { |
@@ -62,6 +69,129 @@ struct RTPVideoHeaderVP8 { |
// in a VP8 partition. Otherwise false |
}; |
+enum TemporalStructureMode { |
+ kTemporalStructureMode1, // 1 temporal layer structure - i.e., IPPP... |
+ kTemporalStructureMode2, // 2 temporal layers 0-1-0-1... |
+ kTemporalStructureMode3 // 3 temporal layers 0-2-1-2-0-2-1-2... |
+}; |
+ |
+struct GofInfoVP9 { |
+ void SetGofInfoVP9(TemporalStructureMode tm) { |
+ switch (tm) { |
+ case kTemporalStructureMode1: |
+ numFramesInGof = 1; |
+ temporalIdx[0] = 0; |
+ temporalUpSwitch[0] = false; |
+ numRefPics[0] = 1; |
+ pidDiff[0][0] = 1; |
+ break; |
+ case kTemporalStructureMode2: |
+ numFramesInGof = 2; |
+ temporalIdx[0] = 0; |
+ temporalUpSwitch[0] = true; |
+ numRefPics[0] = 1; |
+ pidDiff[0][0] = 2; |
+ |
+ temporalIdx[1] = 1; |
+ temporalUpSwitch[1] = false; |
+ numRefPics[1] = 1; |
+ pidDiff[1][0] = 1; |
+ break; |
+ case kTemporalStructureMode3: |
+ numFramesInGof = 3; |
+ temporalIdx[0] = 0; |
+ temporalUpSwitch[0] = true; |
+ numRefPics[0] = 1; |
+ pidDiff[0][0] = 4; |
+ |
+ temporalIdx[1] = 1; |
+ temporalUpSwitch[1] = false; |
+ numRefPics[1] = 1; |
+ pidDiff[1][0] = 2; |
+ |
+ temporalIdx[2] = 2; |
+ temporalUpSwitch[2] = false; |
+ numRefPics[2] = 1; |
+ pidDiff[2][0] = 1; |
+ break; |
+ default: |
+ assert(false); |
+ } |
+ } |
+ |
+ void CopyGofInfoVP9(const GofInfoVP9& src) { |
+ numFramesInGof = src.numFramesInGof; |
+ for (uint8_t i = 0; i < numFramesInGof; i++) { |
+ temporalIdx[i] = src.temporalIdx[i]; |
+ temporalUpSwitch[i] = src.temporalUpSwitch[i]; |
+ numRefPics[i] = src.numRefPics[i]; |
+ for (uint8_t r = 0; r < numRefPics[i]; r++) { |
+ pidDiff[i][r] = src.pidDiff[i][r]; |
+ } |
+ } |
+ } |
+ |
+ uint8_t numFramesInGof; |
stefan-webrtc
2015/07/09 14:48:58
Might want to make this and the other types below
|
+ uint8_t temporalIdx[kMaxVp9FramesInGof]; |
+ bool temporalUpSwitch[kMaxVp9FramesInGof]; |
+ uint8_t numRefPics[kMaxVp9FramesInGof]; |
+ int16_t pidDiff[kMaxVp9FramesInGof][kMaxVp9RefPics]; |
+}; |
+ |
+struct RTPVideoHeaderVP9 { |
+ void InitRTPVideoHeaderVP9() { |
+ interPicPredicted = false; |
+ flexibleMode = false; |
+ beginningOfFrame = false; |
+ endOfFrame = false; |
+ ssDataAvailable = false; |
+ pictureId = kNoPictureId; |
+ maxPictureId = kMaxTwoBytePictureId; |
+ tl0PicIdx = kNoTl0PicIdx; |
+ temporalIdx = kNoTemporalIdx; |
+ spatialIdx = kNoSpatialIdx; |
+ temporalUpSwitch = false; |
+ interLayerPredicted = false; |
+ gofIdx = kNoGofIdx; |
+ numRefPics = 0; |
+ } |
+ |
+ bool interPicPredicted; // This layer frame is dependent on previously coded |
+ // frame(s). |
+ bool flexibleMode; // This frame is in flexible mode. |
+ bool beginningOfFrame; // True if this packet is the first in a VP9 layer |
+ // frame. |
+ bool endOfFrame; // True if this packet is the last in a VP9 layer frame. |
+ bool ssDataAvailable; // True if SS data is available in this payload |
+ // descriptor. |
+ int16_t pictureId; // Picture ID index, 15 bits; |
+ // kNoPictureId if PictureID does not exist. |
+ int16_t maxPictureId; // Maximum picture ID index; either 0x7F or 0x7FFF; |
+ int16_t tl0PicIdx; // TL0PIC_IDX, 8 bits; |
+ // kNoTl0PicIdx means no value provided. |
+ uint8_t temporalIdx; // Temporal layer index, or kNoTemporalIdx. |
+ uint8_t spatialIdx; // Spatial layer index, or kNoSpatialIdx. |
stefan-webrtc
2015/07/09 14:48:58
WDYT of making these indices int? Same below for g
|
+ bool temporalUpSwitch; // True if upswitch to higher frame rate is possible |
+ // starting from this frame. |
+ bool interLayerPredicted; // Frame is dependent on directly lower spatial |
+ // layer frame. |
+ |
+ uint8_t gofIdx; // Index to predefined temporal frame info in SS data. |
+ |
+ uint8_t |
+ numRefPics; // Number of reference pictures used by current layer frame. |
+ int16_t pidDiff[kMaxVp9RefPics]; // P_DIFF signaled to derive the PictureID |
+ // of the reference pictures. |
+ int16_t refPictureId[kMaxVp9RefPics]; // PictureID of the reference pictures. |
+ |
+ // SS data. |
+ uint8_t numSpatialLayers; |
stefan-webrtc
2015/07/09 14:48:58
int
|
+ bool spatialLayerResolutionPresent; |
+ uint16_t width[kMaxVp9NumberOfSpatialLayers]; |
+ uint16_t height[kMaxVp9NumberOfSpatialLayers]; |
stefan-webrtc
2015/07/09 14:48:58
int
|
+ GofInfoVP9 gof; |
+}; |
+ |
// The packetization types that we support: single, aggregated, and fragmented. |
enum H264PacketizationTypes { |
kH264SingleNalu, // This packet contains a single NAL unit. |
@@ -85,6 +215,7 @@ struct RTPVideoHeaderH264 { |
union RTPVideoTypeHeader { |
RTPVideoHeaderVP8 VP8; |
+ RTPVideoHeaderVP9 VP9; |
RTPVideoHeaderH264 H264; |
}; |
@@ -92,6 +223,7 @@ enum RtpVideoCodecTypes { |
kRtpVideoNone, |
kRtpVideoGeneric, |
kRtpVideoVp8, |
+ kRtpVideoVp9, |
kRtpVideoH264 |
}; |
// Since RTPVideoHeader is used as a member of a union, it can't have a |