RFC 6184
RTP Payload Format for H.264 Video
RFC 6184: RTP Payload Format for H.264 Video ๐
okay bestie, let's get into it. this one's from the IETF, and it's the spec for how H.264 video gets chopped up and shipped over RTP ๐
- Who wrote it: Y.-K. Wang (Huawei Technologies), R. Even (Huawei Technologies), T. Kristensen (Tandberg), and R. Jesup (WorldGate Communications) ๐
- Category: Standards Track โจ
- Date: May 2011 ๐
- ISSN: 2070-1721
- Obsoletes: RFC 3984 ๐
- Updates: nothing
Abstract
okay so the abstract is giving "here's the whole vibe" ๐ฆ this memo describes an RTP payload format for the ITU-T Recommendation H.264 video codec, and for the technically identical ISO/IEC International Standard 14496-10 video codec. it leaves out the Scalable Video Coding (SVC) extension and the Multiview Video Coding extension, because those have their own RTP payload formats defined somewhere else ๐ธ
the payload format lets you pack one or more Network Abstraction Layer Units (NALUs), made by an H.264 video encoder, into each RTP payload ๐ง and it's seriously versatile. it works for simple low bitrate conversational stuff, for internet video streaming with interleaved transmission, and for high bitrate video-on-demand. main character energy, literally ๐๐ฅ
this memo obsoletes RFC 3984. the changes from RFC 3984 are summarized in Section 14, and the backward compatibility issues are talked about in Section 15 ๐ซถ
Status of This Memo
this is an Internet Standards Track document ๐
it's a product of the Internet Engineering Task Force (IETF). it represents the consensus of the IETF community, it got public review, and the Internet Engineering Steering Group (IESG) approved it for publication โจ if you want more on Internet Standards, check out Section 2 of RFC 5741 ๐
info about the current status, any errata, and how to give feedback lives at http://www.rfc-editor.org/info/rfc6184 ๐
Copyright Notice
Copyright (c) 2011 IETF Trust and the persons identified as the document authors. All rights reserved. ๐
this document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) as they stand on the date of publication. please actually read those, bestie, because they spell out your rights and restrictions for this doc ๐ also, any Code Components pulled out of this document have to include the Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions. they come without warranty, just like the Simplified BSD License says ๐
Table of Contents
1. Introduction ....................................................4
1.1. The H.264 Codec ............................................4
1.2. Parameter Set Concept ......................................5
1.3. Network Abstraction Layer Unit Types .......................6
2. Conventions .....................................................7
3. Scope ...........................................................7
4. Definitions and Abbreviations ...................................7
4.1. Definitions ................................................7
4.2. Abbreviations ..............................................9
5. RTP Payload Format .............................................10
5.1. RTP Header Usage ..........................................10
5.2. Payload Structures ........................................12
5.3. NAL Unit Header Usage .....................................13
5.4. Packetization Modes .......................................16
5.5. Decoding Order Number (DON) ...............................17
5.6. Single NAL Unit Packet ....................................19
5.7. Aggregation Packets .......................................20
5.7.1. Single-Time Aggregation Packet (STAP) ..............22
5.7.2. Multi-Time Aggregation Packets (MTAPs) .............25
5.8. Fragmentation Units (FUs) .................................29
6. Packetization Rules ............................................33
6.1. Common Packetization Rules ................................33
6.2. Single NAL Unit Mode ......................................34
6.3. Non-Interleaved Mode ......................................34
6.4. Interleaved Mode ..........................................34
7. De-Packetization Process .......................................35
7.1. Single NAL Unit and Non-Interleaved Mode ..................35
7.2. Interleaved Mode ..........................................35
7.2.1. Size of the De-Interleaving Buffer .................36
7.2.2. De-Interleaving Process ............................36
7.3. Additional De-Packetization Guidelines ....................38
8. Payload Format Parameters ......................................39
8.1. Media Type Registration ...................................39
8.2. SDP Parameters ............................................57
8.2.1. Mapping of Payload Type Parameters to SDP ..........57
8.2.2. Usage with the SDP Offer/Answer Model ..............58
8.2.3. Usage in Declarative Session Descriptions ..........66
8.3. Examples ..................................................68
8.4. Parameter Set Considerations ..............................75
8.5. Decoder Refresh Point Procedure Using In-Band
Transport of Parameter Sets (Informative)..................78
8.5.1. IDR Procedure to Respond to a Request for
a Decoder Refresh Point ............................78
8.5.2. Gradual Recovery Procedure to Respond to
a Request for a Decoder Refresh Point ..............79
9. Security Considerations ........................................79
10. Congestion Control ............................................80
11. IANA Considerations ...........................................81
12. Informative Appendix: Application Examples ....................81
12.1. Video Telephony According to Annex A of ITU-T
Recommendation H.241 .....................................81
12.2. Video Telephony, No Slice Data Partitioning, No
NAL Unit Aggregation .....................................82
12.3. Video Telephony, Interleaved Packetization Using
NAL Unit Aggregation .....................................82
12.4. Video Telephony with Data Partitioning ...................83
12.5. Video Telephony or Streaming with FUs and Forward
Error Correction .........................................83
12.6. Low Bitrate Streaming ....................................86
12.7. Robust Packet Scheduling in Video Streaming ..............86
13. Informative Appendix: Rationale for Decoding Order Number .....87
13.1. Introduction .............................................87
13.2. Example of Multi-Picture Slice Interleaving ..............88
13.3. Example of Robust Packet Scheduling ......................89
13.4. Robust Transmission Scheduling of Redundant Coded
Slices ...................................................93
13.5. Remarks on Other Design Possibilities ....................94
14. Changes from RFC 3984 .........................................94
15. Backward Compatibility to RFC 3984 ............................96
16. Acknowledgements ..............................................98
17. References ....................................................98
17.1. Normative References .....................................98
17.2. Informative References ...................................99
1. Introduction โจ
okay so this section sets the scene. this memo specifies an RTP payload specification for the video coding standard known as ITU-T Recommendation H.264 [1], and for ISO/IEC International Standard 14496-10 [2]. both of them are also called Advanced Video Coding (AVC) ๐ฆ in this memo, the name H.264 covers both the codec and the standard, but everything here applies just as well to the ISO/IEC version ๐
and yes, we're saying it again because it matters: this memo obsoletes RFC 3984. the changes from RFC 3984 are summarized in Section 14, and the backward compatibility issues are discussed in Section 15 ๐ธ
1.1. The H.264 Codec
the H.264 codec is so broad it's unreal ๐ญ it covers every form of digital compressed video, from low bitrate internet streaming all the way up to HDTV broadcast and Digital Cinema, where the coding is nearly lossless ๐ฌ compared to where tech is right now, H.264 gives bitrate savings of 50% or more. digital satellite TV quality was reported to be doable at 1.5 Mbit/s, which is wild when today's operating point for MPEG 2 video is around 3.5 Mbit/s [10] ๐ฅ
so the codec spec [1] conceptually splits things into two parts: a Video Coding Layer (VCL) and a Network Abstraction Layer (NAL) ๐ง the VCL is where the signal processing happens. that's transform, quantization, and motion-compensated prediction, plus a loop filter. it follows the general concept of most of today's video codecs: a macroblock-based coder that uses inter picture prediction with motion compensation and transform coding of the residual signal ๐ the VCL encoder outputs slices. a slice is a bit string holding the macroblock data for an integer number of macroblocks, plus the slice header info. that header has stuff like the spatial address of the first macroblock in the slice, the initial quantization parameter, and similar details โจ macroblocks in slices are arranged in scan order, unless a different macroblock allocation is specified using the syntax of slice groups. in-picture prediction is only used within a slice. more info is in [10] ๐ซถ
the NAL encoder takes the slice output of the VCL encoder and wraps it up into Network Abstraction Layer Units (NALUs). these are built to be sent over packet networks or used in packet-oriented multiplex environments ๐ฆ Annex B of H.264 defines an encapsulation process for sending NALUs over bytestream-oriented networks. but for this memo, Annex B isn't relevant ๐
internally, the NAL uses NAL units. a NAL unit is a one-byte header plus the payload byte string ๐ the header tells you the type of the NAL unit, whether there might be bit errors or syntax violations in the payload, and how important the NAL unit is for decoding ๐ this RTP payload spec is designed to be totally unaware of the bit string inside the NAL unit payload. not its problem, bestie ๐โโ๏ธ
one of the main properties of H.264 is the complete decoupling of transmission time, decoding time, and sampling or presentation time for slices and pictures. the decoding process is unaware of time, and the H.264 syntax doesn't carry info like the number of skipped frames (which is common with the Temporal Reference in older video compression standards) โฐ there are also NAL units that affect many pictures, so they're inherently timeless ๐ that's why handling the RTP timestamp needs some special care for NAL units whose sampling or presentation time isn't defined or, at transmission time, is unknown ๐
1.2. Parameter Set Concept ๐
okay so the big H.264 vibe is making self-contained packets ๐ so you don't need header duplication from RFC 4629 [11] or MPEG-4 Visual's Header Extension Code (HEC) [12]. The trick is pulling out the info that's relevant to more than one slice and keeping it out of the media stream. This higher-layer meta info should be sent reliably, asynchronously, and in advance of the RTP packet stream that carries the slice packets. (There are also ways to send it in-band ๐ซถ for apps that don't have an out-of-band transport channel.) The combo of these higher-level parameters is called a parameter set. H.264 has two types: sequence parameter sets and picture parameter sets. An active sequence parameter set stays unchanged throughout a coded video sequence, and an active picture parameter set stays unchanged within a coded picture. These structures hold stuff like picture size, optional coding modes, and the macroblock to slice group map ๐ง
to change picture params (like picture size) without sending parameter set updates synchronously with the slice stream, the encoder and decoder can keep a list of more than one sequence and picture parameter set ๐ฅ each slice header has a codeword that tells you which sequence and picture parameter set to use.
this decoupling is lowkey iconic โจ parameter sets can be sent separately from the packet stream, by external means (e.g., as a side effect of the capability exchange) or through a (reliable or unreliable) control protocol. it may even be possible that they're never sent at all and are just fixed by an application design specification ๐
1.3. Network Abstraction Layer Unit Types ๐ฆ
tutorial info on the NAL design is in [13], [14], and [15] ๐
every NAL unit is made of a single NAL unit type octet, which also co-serves as the payload header of this RTP payload format. the payload of a NAL unit comes after it.
the syntax and semantics of the NAL unit type octet are specified in [1], but the essential properties are summed up below. the octet looks like this:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|F|NRI| Type |
+---------------+
here's what each part means, per the H.264 spec ๐
- F (1 bit): forbidden_zero_bit. H.264 declares a value of 1 as a syntax violation ๐
- NRI (2 bits): nal_ref_idc. a value of
00means the content of the NAL unit is not used to reconstruct reference pictures for inter picture prediction. these NAL units can be discarded without risking the integrity of the reference pictures. values greater than00mean the decoding of the NAL unit is required to maintain the integrity of the reference pictures ๐ซ - Type (5 bits): nal_unit_type. this specifies the NAL unit payload type as defined in Table 7-1 of [1] and later within this memo. for a reference of all currently defined NAL unit types and their semantics, see Section 7.4.1 in [1] ๐
this memo introduces new NAL unit types, which are presented in Section 5.2. the NAL unit types defined in this memo are marked as unspecified in [1]. moreover, this specification extends the semantics of F and NRI as described in Section 5.3 ๐ธ
2. Conventions ๐
the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [4]. bestie, these are the official requirement words, so read them carefully ๐ซถ
this spec uses the idea of setting and clearing a bit when bit fields get handled. setting a bit means assigning that bit the value of 1 (On). clearing a bit means assigning that bit the value of 0 (Off) ๐
3. Scope ๐ญ
this payload spec can only carry the "naked" H.264 NAL unit stream over RTP. it does NOT cover the bitstream format discussed in Annex B of H.264 ๐ โโ๏ธ the first applications will probably be in conversational multimedia, like video telephony or video conferencing, but the payload format also covers other stuff like Internet streaming and TV over IP ๐บ
4. Definitions and Abbreviations ๐ง
4.1. Definitions ๐
this document uses the definitions of [1]. the following terms, defined in [1], are summed up here for convenience โจ
access unit: a set of NAL units that always contains a primary coded picture. besides the primary coded picture, an access unit may also contain one or more redundant coded pictures or other NAL units that don't contain slices or slice data partitions of a coded picture. decoding an access unit always results in a decoded picture ๐ฌ
coded video sequence: a sequence of access units that consists, in decoding order, of an instantaneous decoding refresh (IDR) access unit followed by zero or more non-IDR access units, including all subsequent access units up to but not including any subsequent IDR access unit ๐
IDR access unit: an access unit in which the primary coded picture is an IDR picture ๐
IDR picture: a coded picture containing only slices with I or SI slice types that causes a "reset" in the decoding process. after an IDR picture is decoded, all following coded pictures in decoding order can be decoded without inter prediction from any picture decoded before the IDR picture. literally a fresh start ๐
primary coded picture: the coded representation of a picture that the decoding process uses for a bitstream conforming to H.264. the primary coded picture contains all macroblocks of the picture ๐ฐ
redundant coded picture: a coded representation of a picture or a part of a picture. the content of a redundant coded picture shall not be used by the decoding process for a bitstream conforming to H.264. the content of a redundant coded picture may be used by the decoding process for a bitstream that contains errors or losses ๐
VCL NAL unit: a collective term for coded slice and coded data partition NAL units ๐งฉ
in addition, the following definitions apply ๐
decoding order number (DON): a field in the payload structure, or a derived variable, that indicates NAL unit decoding order. values of DON are in the range of 0 to 65535, inclusive. after reaching the maximum value, DON wraps around to 0 ๐
NAL unit decoding order: a NAL unit order that conforms to the constraints on NAL unit order given in Section 7.4.1.2 in [1] ๐
NALU-time: the value that the RTP timestamp would have if the NAL unit were transported in its own RTP packet โฐ
transmission order: the order of packets in ascending RTP sequence number order (in modulo arithmetic). within an aggregation packet, the NAL unit transmission order is the same as the order of appearance of NAL units in the packet ๐ฆ
media-aware network element (MANE): a network element, such as a middlebox or application layer gateway, that is capable of parsing certain aspects of the RTP payload headers or the RTP payload and reacting to the contents ๐ต๏ธโโ๏ธ
Informative note: The concept of a MANE goes beyond normal routers or gateways in that a MANE has to be aware of the signaling (e.g., to learn about the payload type mappings of the media streams), and that it has to be trusted when working with Secure Real-time Transport Protocol (SRTP). The advantage of using MANEs is that they allow packets to be dropped according to the needs of the media coding. For example, if a MANE has to drop packets due to congestion on a certain link, it can identify and remove those packets whose elimination produces the least adverse effect on the user experience. ๐ซง
static macroblock: a certain number of macroblocks in the video stream can be defined as static, as defined in Section 8.3.2.8 in [3]. static macroblocks free up extra processing cycles for handling the non-static macroblocks. based on a given amount of video processing resources and a given resolution, a higher number of static macroblocks enables a correspondingly higher frame rate ๐๏ธ
default sub-profile: the subset of coding tools, which may be all coding tools of one profile or the common subset of coding tools of more than one profile, indicated by the profile-level-id parameter ๐ฏ
default level: the level indicated by the profile-level-id parameter, which consists of three octets: profile_idc, profile-iop, and level_idc. the default level is indicated by level_idc in most cases, and in some cases additionally by profile-iop ๐ท๏ธ
4.2. Abbreviations ๐ค
DON: Decoding Order Number
DONB: Decoding Order Number Base
DOND: Decoding Order Number Difference
FEC: Forward Error Correction
FU: Fragmentation Unit
IDR: Instantaneous Decoding Refresh
IEC: International Electrotechnical Commission
ISO: International Organization for Standardization
ITU-T: International Telecommunication Union,
Telecommunication Standardization Sector
MANE: Media-Aware Network Element
MTAP: Multi-Time Aggregation Packet
MTAP16: MTAP with 16-bit timestamp offset
MTAP24: MTAP with 24-bit timestamp offset
NAL: Network Abstraction Layer
NALU: NAL Unit
SAR: Sample Aspect Ratio
SEI: Supplemental Enhancement Information
STAP: Single-Time Aggregation Packet
STAP-A: STAP type A
STAP-B: STAP type B
TS: Timestamp
VCL: Video Coding Layer
VUI: Video Usability Information
5. RTP Payload Format ๐ท
5.1. RTP Header Usage โจ
okay so the RTP header format is defined in RFC 3550 [5], and we're gonna reprint it in Figure 1 just so you can see it all in one place ๐. this payload format uses the header fields in a way that matches that spec, so no drama there ๐ .
when one NAL unit goes in each RTP packet, the RECOMMENDED RTP payload format is the one in Section 5.6. for aggregation packets and fragmentation units, the RTP payload and the settings for some RTP header bits are in Sections 5.7.2 and 5.8, respectively ๐ฆ.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P|X| CC |M| PT | sequence number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| timestamp |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| synchronization source (SSRC) identifier |
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
| contributing source (CSRC) identifiers |
| .... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 1. RTP header according to RFC 3550
here's how the RTP header fields get set for this format ๐ธ:
Marker bit (M): 1 bit ๐ Set for the very last packet of the access unit indicated by the RTP timestamp, which is totally in line with how the M bit normally works in video formats. it helps the playout buffer handle things efficiently โจ. for aggregation packets (STAP and MTAP), the marker bit in the RTP header MUST be set to whatever the marker bit of the last NAL unit in the aggregation packet would have been if it had been sent in its own RTP packet. decoders MAY use this bit as an early hint that they've hit the last packet of an access unit, but they MUST NOT rely on that property ๐.
Informative note: Only one M bit is associated with an aggregation packet carrying multiple NAL units. so if a gateway re-packetizes an aggregation packet into several packets, it can't reliably set the M bit on those packets ๐.
Payload type (PT): 7 bits ๐ง the assignment of an RTP payload type for this new packet format is outside the scope of this document, so it's not specified here. the payload type gets assigned either through the profile being used or dynamically ๐ซถ.
Sequence number (SN): 16 bits ๐ Set and used in accordance with RFC 3550. for the single NALU and non-interleaved packetization mode, the sequence number is used to determine the decoding order for the NALU ๐ฅ.
Timestamp: 32 bits โญ the RTP timestamp is set to the sampling timestamp of the content. a 90 kHz clock rate MUST be used ๐.
if the NAL unit has no timing properties of its own (e.g., parameter set and SEI NAL units), the RTP timestamp is set to the RTP timestamp of the primary coded picture of the access unit the NAL unit is included in, according to Section 7.4.1.2 of [1] ๐.
the setting of the RTP timestamp for MTAPs is defined in Section 5.7.2 ๐ฆ.
receivers SHOULD ignore any picture timing SEI messages included in access units that have only one display timestamp. instead, receivers SHOULD use the RTP timestamp for synchronizing the display process ๐ .
if one access unit has more than one display timestamp carried in a picture timing SEI message, then the information in the SEI message SHOULD be treated as relative to the RTP timestamp. the earliest event happens at the time given by the RTP timestamp, and subsequent events come later, based on the difference in picture time values carried in the picture timing SEI message ๐.
let tSEI1, tSEI2, ..., tSEIn be the display timestamps carried in the SEI message of an access unit, where tSEI1 is the earliest of all of them. let tmadjst() be a function that adjusts the SEI message's time scale to a 90-kHz time scale. let TS be the RTP timestamp. then the display time for the event associated with tSEI1 is TS. the display time for the event with tSEIx, where x is [2..n], is TS + tmadjst (tSEIx - tSEI1) ๐งฎโจ.
Informative note: displaying coded frames as fields is commonly needed in an operation called 3:2 pulldown, where film content made of coded frames gets shown on a display that uses interlaced scanning ๐ฌ. the picture timing SEI message lets you carry multiple timestamps for the same coded picture, so the 3:2 pulldown process is perfectly controlled ๐ญ. the picture timing SEI message mechanism is necessary because only one timestamp per coded frame can be conveyed in the RTP timestamp ๐.
5.2. Payload Structures ๐ง
the payload format defines three different basic payload structures ๐. a receiver can identify the payload structure from the first byte of the RTP packet payload. that byte does double duty as the RTP payload header and, in some cases, as the first byte of the payload itself ๐ซถ. this byte is always structured as a NAL unit header, and the NAL unit type field tells you which structure is present. the possible structures are:
Single NAL Unit Packet: contains only a single NAL unit in the payload. the NAL header type field is equal to the original NAL unit type, i.e., in the range of 1 to 23, inclusive. specified in Section 5.6 ๐ธ.
Aggregation Packet: a packet type used to aggregate multiple NAL units into a single RTP payload. this packet exists in four versions: the Single-Time Aggregation Packet type A (STAP-A), the Single-Time Aggregation Packet type B (STAP-B), the Multi-Time Aggregation Packet (MTAP) with 16-bit offset (MTAP16), and the Multi-Time Aggregation Packet (MTAP) with 24-bit offset (MTAP24). the NAL unit type numbers assigned for STAP-A, STAP-B, MTAP16, and MTAP24 are 24, 25, 26, and 27, respectively. specified in Section 5.7 ๐.
Fragmentation Unit: used to fragment a single NAL unit over multiple RTP packets. it exists in two versions, FU-A and FU-B, identified with the NAL unit type numbers 28 and 29, respectively. specified in Section 5.8 ๐ฅ.
Informative note: this specification does not limit the size of NAL units encapsulated in single NAL unit packets and fragmentation units. the maximum size of a NAL unit encapsulated in any aggregation packet is 65535 bytes ๐.
table 1 summarizes the NAL unit types and the matching RTP packet types when each NAL unit is directly used as a packet payload, and it shows which sections describe them in this memo ๐.
Table 1. Summary of NAL unit types and the corresponding packet
types
NAL Unit Packet Packet Type Name Section
Type Type
-------------------------------------------------------------
0 reserved -
1-23 NAL unit Single NAL unit packet 5.6
24 STAP-A Single-time aggregation packet 5.7.1
25 STAP-B Single-time aggregation packet 5.7.1
26 MTAP16 Multi-time aggregation packet 5.7.2
27 MTAP24 Multi-time aggregation packet 5.7.2
28 FU-A Fragmentation unit 5.8
29 FU-B Fragmentation unit 5.8
30-31 reserved -
5.3. NAL Unit Header Usage โจ
okay so the NAL unit header got its big debut back in Section 1.3, but bestie, we need to look at it again ๐ here's the format, reprinted for you:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|F|NRI| Type |
+---------------+
this section is where we spell out what F and NRI mean for this spec ๐
F (1 bit): forbidden_zero_bit. a value of 0 means the NAL unit type octet and payload should not contain bit errors or other syntax violations. a value of 1 means they may contain bit errors or other syntax violations ๐
MANEs SHOULD set the F bit to indicate detected bit errors in the NAL unit. the H.264 specification requires that the F bit be equal to 0 ๐ when the F bit is set, the decoder is advised that bit errors or any other syntax violations may be present in the payload or in the NAL unit type octet. the simplest decoder reaction to a NAL unit with F equal to 1 is to discard it and conceal the lost data in the discarded NAL unit. honestly iconic, very "cut the drama and move on" ๐
NRI (2 bits): nal_ref_idc. the semantics of the value 00 and of a non-zero value stay the same as in the H.264 specification โจ so a value of 00 means the content of the NAL unit is not used to reconstruct reference pictures for inter picture prediction. those NAL units can be discarded without risking the integrity of the reference pictures. values greater than 00 mean decoding that NAL unit is required to maintain the integrity of the reference pictures ๐ฆ
but wait, there's more! according to this RTP payload spec, NRI values also show the relative transport priority, as decided by the encoder. MANEs can use that info to protect the more important NAL units better than the less important ones ๐ก๏ธ the highest transport priority is 11, then 10, then 01, and finally 00 is the lowest ๐
Informative note: any non-zero value of NRI is handled identically in H.264 decoders. so receivers do not need to manipulate the value of NRI when passing NAL units to the decoder ๐ซถ
an H.264 encoder MUST set the value of NRI according to the H.264 specification (Subclause 7.4.1) when the value of nal_unit_type is in the range of 1 to 12, inclusive. the H.264 specification says the value of NRI SHALL be equal to 0 for all NAL units having nal_unit_type equal to 6, 9, 10, 11, or 12. no cap, that's a hard rule ๐ค
for NAL units with nal_unit_type equal to 7 or 8 (a sequence parameter set or a picture parameter set, respectively), an H.264 encoder SHOULD set NRI to 11 (in binary format) โจ and for coded slice NAL units of a primary coded picture with nal_unit_type equal to 5 (a coded slice belonging to an IDR picture), an H.264 encoder SHOULD also set NRI to 11 (in binary format) ๐
for mapping the remaining nal_unit_type values to NRI values, the following example MAY be used. it has been shown to be efficient in a certain environment [14] ๐ธ other mappings MAY also be desirable, depending on the application and the H.264 profile in use. so it's flexible, bestie ๐
Informative note: data partitioning is not available in certain profiles, e.g., the Main or Baseline profiles. so NAL unit types 2, 3, and 4 can only occur if the video bitstream conforms to a profile where data partitioning is allowed, and not in streams that conform to the Main or Baseline profiles ๐ โโ๏ธ
Table 2. here's the example of NRI values for coded slices and coded slice data partitions of primary coded reference pictures:
NAL Unit Type Content of NAL Unit NRI (binary)
----------------------------------------------------------------
1 non-IDR coded slice 10
2 Coded slice data partition A 10
3 Coded slice data partition B 01
4 Coded slice data partition C 01
Informative note: as mentioned before, the NRI value of non-reference pictures is 00 as mandated by H.264 ๐ง
an H.264 encoder SHOULD set the NRI value for coded slice and coded slice data partition NAL units of redundant coded reference pictures to 01 (in binary format) ๐
the NRI definitions for NAL unit types 24 to 29, inclusive, are given in Sections 5.7 and 5.8 of this memo ๐
no NRI recommendation is given for NAL units with nal_unit_type in the range of 13 to 23, inclusive. those values are reserved for ITU-T and ISO/IEC, so they're not ours to decide ๐ no recommendation is given for NAL units with nal_unit_type equal to 0 or in the range of 30 to 31, inclusive either, since the semantics of those values are not specified in this memo ๐ซ
5.4. Packetization Modes ๐ฆ
this memo specifies three packetization modes, and they're giving three different vibes:
- Single NAL unit mode
- Non-interleaved mode
- Interleaved mode
the single NAL unit mode is targeted at conversational systems that comply with ITU-T Recommendation H.241 [3] (see Section 12.1) ๐ the non-interleaved mode is targeted at conversational systems that may not comply with ITU-T Recommendation H.241 ๐ฌ in the non-interleaved mode, NAL units are transmitted in NAL unit decoding order ๐ฆ and the interleaved mode is targeted at systems that do not require very low end-to-end latency. the interleaved mode allows NAL units to be transmitted out of NAL unit decoding order ๐
the packetization mode in use MAY be signaled by the value of the OPTIONAL packetization-mode media type parameter โจ the mode in use governs which NAL unit types are allowed in RTP payloads. Table 3 summarizes the allowed packet payload types for each packetization mode, and the full details are in Section 6 ๐
Table 3. summary of allowed NAL unit types for each packetization mode (yes = allowed, no = disallowed, ig = ignore):
Payload Packet Single NAL Non-Interleaved Interleaved
Type Type Unit Mode Mode Mode
-------------------------------------------------------------
0 reserved ig ig ig
1-23 NAL unit yes yes no
24 STAP-A no yes no
25 STAP-B no no yes
26 MTAP16 no no yes
27 MTAP24 no no yes
28 FU-A no yes yes
29 FU-B no no yes
30-31 reserved ig ig ig
some NAL unit or payload type values (marked as reserved in Table 3) are reserved for future extensions ๐ฎ NAL units of those types SHOULD NOT be sent by a sender (whether as packet payloads, aggregation units in aggregation packets, or fragmented units in FU packets), and they MUST be ignored by a receiver ๐ โโ๏ธ for example, the payload types 1-23 with the packet type "NAL unit" are allowed in "Single NAL Unit Mode" and "Non-Interleaved Mode" but disallowed in "Interleaved Mode" ๐ซ however, NAL units of types 1-23 CAN be used in "Interleaved Mode" as aggregation units in STAP-B, MTAP16, and MTAP24 packets, and as fragmented units in FU-A and FU-B packets ๐งฉ similarly, NAL units of types 1-23 can also be used in "Non-Interleaved Mode" as aggregation units in STAP-A packets or as fragmented units in FU-A packets, on top of being used directly as packet payloads ๐ซถ
5.5. Decoding Order Number (DON) โจ
okay so in the interleaved packetization mode, the transmission order of NAL units is allowed to differ from their decoding order ๐ which is kinda wild but it's the whole point ๐ Decoding order number (DON) is a field in the payload structure or a derived variable that tells you the NAL unit decoding order. The rationale and use-case examples for sending stuff out of decoding order and for using DON are in Section 13 ๐ง
the coupling between transmission and decoding order is controlled by the OPTIONAL sprop-interleaving-depth media type parameter ๐ here's how it plays out. When the value of the OPTIONAL sprop-interleaving-depth media type parameter is equal to 0 (explicitly or per default), the transmission order of NAL units MUST conform to the NAL unit decoding order ๐ซถ When the value of the OPTIONAL sprop-interleaving-depth media type parameter is greater than 0:
- the order of NAL units in an MTAP16 and an MTAP24 is not required to be the NAL unit decoding order, and
- the order of NAL units generated by de-packetizing STAP-Bs, MTAPs, and FUs in two consecutive packets is not required to be the NAL unit decoding order.
the RTP payload structures for a single NAL unit packet, an STAP-A, and an FU-A do not include DON ๐ธ STAP-B and FU-B structures include DON, and the structure of MTAPs enables derivation of DON, as specified in Section 5.7.2.
Informative note: When an FU-A occurs in interleaved mode, it always follows an FU-B, which sets its DON.
Informative note: If a transmitter wants to encapsulate a single NAL unit per packet and transmit packets out of their decoding order, STAP-B packet type can be used.
in the single NAL unit packetization mode, the transmission order of NAL units, determined by the RTP sequence number, MUST be the same as their NAL unit decoding order. in the non-interleaved packetization mode, the transmission order of NAL units in single NAL unit packets, STAP-As, and FU-As MUST be the same as their NAL unit decoding order. the NAL units within an STAP MUST appear in the NAL unit decoding order. so the decoding order is first given by the implicit order within an STAP, and then by the RTP sequence number for the order between STAPs, FUs, and single NAL unit packets ๐ฆ
the signaling of the DON value for NAL units carried in STAP-B, MTAP, and a series of fragmentation units starting with an FU-B is specified in Sections 5.7.1, 5.7.2, and 5.8, respectively. the DON value of the first NAL unit in transmission order MAY be set to any value. values of DON are in the range of 0 to 65535, inclusive. after reaching the maximum value, the value of DON wraps around to 0 ๐
the decoding order of two NAL units contained in any STAP-B, MTAP, or a series of fragmentation units starting with an FU-B is determined as follows. let DON(i) be the decoding order number of the NAL unit having index i in the transmission order. the function don_diff(m,n) works like this ๐งฎ
If DON(m) == DON(n), don_diff(m,n) = 0
If (DON(m) < DON(n) and DON(n) - DON(m) < 32768),
don_diff(m,n) = DON(n) - DON(m)
If (DON(m) > DON(n) and DON(m) - DON(n) >= 32768),
don_diff(m,n) = 65536 - DON(m) + DON(n)
If (DON(m) < DON(n) and DON(n) - DON(m) >= 32768),
don_diff(m,n) = - (DON(m) + 65536 - DON(n))
If (DON(m) > DON(n) and DON(m) - DON(n) < 32768),
don_diff(m,n) = - (DON(m) - DON(n))
a positive value of don_diff(m,n) means the NAL unit with transmission order index n follows, in decoding order, the NAL unit with transmission order index m ๐ when don_diff(m,n) is equal to 0, the two NAL units can be in either order in decoding terms. a negative value of don_diff(m,n) means the NAL unit with transmission order index n precedes, in decoding order, the NAL unit with transmission order index m.
values of DON-related fields (DON, DONB, and DOND; see Section 5.7) MUST be such that the decoding order determined by the values of DON, as specified above, conforms to the NAL unit decoding order. no skipping this one bestie ๐ซถ
if the order of two NAL units in NAL unit decoding order is switched and the new order does not conform to the NAL unit decoding order, the NAL units MUST NOT have the same value of DON. if the order of two consecutive NAL units in the NAL unit stream is switched and the new order still conforms to the NAL unit decoding order, the NAL units MAY have the same value of DON. for example, when arbitrary slice order is allowed by the video coding profile in use, all the coded slice NAL units of a coded picture are allowed to have the same value of DON. so NAL units with the same DON can be decoded in any order, and two NAL units with a different DON should be passed to the decoder in the order specified above. when two consecutive NAL units in the NAL unit decoding order have a different value of DON, the value of DON for the second NAL unit in decoding order SHOULD be the value of DON for the first, incremented by one. โจ
an example of the de-packetization process to recover the NAL unit decoding order is given in Section 7 ๐ฆ
Informative note: Receivers should not expect that the absolute difference of values of DON for two consecutive NAL units in the NAL unit decoding order will be equal to one, even in error-free transmission. an increment by one is not required, because when DON values are associated with NAL units, it may not be known yet whether all NAL units will be delivered to the receiver. for example, a gateway may not forward coded slice NAL units of non-reference pictures or SEI NAL units when there is a shortage of bitrate in the network the packets are forwarded to. in another example, a live broadcast is interrupted by pre-encoded content, such as commercials, from time to time. the first intra picture of a pre-encoded clip is transmitted in advance so it is readily available in the receiver. when transmitting that first intra picture, the originator does not exactly know how many NAL units will be encoded before the first intra picture of the pre-encoded clip follows in decoding order. so the DON values for the NAL units of the first intra picture of the pre-encoded clip have to be estimated when they are transmitted, and gaps in DON values may occur. ๐
5.6. Single NAL Unit Packet
the single NAL unit packet defined here MUST contain only one NAL unit of the types defined in [1]. this means neither an aggregation packet nor a fragmentation unit can be used within a single NAL unit packet ๐ โโ๏ธ a NAL unit stream made by de-packetizing single NAL unit packets in RTP sequence number order MUST conform to the NAL unit decoding order. the structure of the single NAL unit packet is shown in Figure 2 ๐
Informative note: The first byte of a NAL unit co-serves as the RTP payload header. so the NAL unit header literally does double duty ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|F|NRI| Type | |
+-+-+-+-+-+-+-+-+ |
| |
| Bytes 2..n of a single NAL unit |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 2. RTP payload format for single NAL unit packet ๐ฆ
5.7. Aggregation Packets โจ
okay so aggregation packets are the NAL unit bundling scheme of this payload spec ๐ฆ and they exist because the two main target networks have wildly different MTU sizes ๐ฅบ wireline IP networks usually top out around the Ethernet MTU, roughly 1500 bytes, while IP-based or non-IP-based (e.g., ITU-T H.324/M) wireless systems prefer transmission unit sizes of 254 bytes or less ๐ so to avoid transcoding between those two worlds and skip annoying packetization overhead, we bundle NAL units together ๐ซถ
Two types of aggregation packets are defined by this spec:
- Single-time aggregation packet (STAP): aggregates NAL units with identical NALU-times. There are two flavors: one without DON (STAP-A) and one that includes DON (STAP-B) ๐
- Multi-time aggregation packet (MTAP): aggregates NAL units with potentially differing NALU-times. There are two different MTAPs, and they differ in how long the NAL unit timestamp offset is ๐ฆ
Each NAL unit that gets carried in an aggregation packet is wrapped up in an aggregation unit ๐ง there are four different aggregation units with their own characteristics, and we'll get into them below ๐
Here's what the RTP payload format for aggregation packets looks like ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|F|NRI| Type | |
+-+-+-+-+-+-+-+-+ |
| |
| one or more aggregation units |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 3. RTP payload format for aggregation packets
MTAPs and STAPs share these packetization rules, so read them carefully ๐ค
- The RTP timestamp MUST be set to the earliest of the NALU-times of all the NAL units to be aggregated. โฐ
- The type field of the NAL unit type octet MUST be set to the appropriate value, as indicated in Table 4. ๐ข
- The F bit MUST be cleared if all F bits of the aggregated NAL units are zero; otherwise, it MUST be set. ๐ฉ
- The value of NRI MUST be the maximum of all the NAL units carried in the aggregation packet. ๐
Here's Table 4, the type field cheat sheet for STAPs and MTAPs ๐
Table 4. Type field for STAPs and MTAPs
Type Packet Timestamp offset DON-related fields
field length (DON, DONB, DOND)
(in bits) present
--------------------------------------------------------
24 STAP-A 0 no
25 STAP-B 0 yes
26 MTAP16 16 yes
27 MTAP24 24 yes
The marker bit in the RTP header gets set to whatever the marker bit of the last NAL unit of the aggregated packet would have been if that NAL unit rode in its own RTP packet ๐ฏ
The payload of an aggregation packet is made of one or more aggregation units. Check out Sections 5.7.1 and 5.7.2 for the four different types of aggregation units ๐ an aggregation packet can hold as many aggregation units as it needs, BUT the total amount of data obviously MUST fit into an IP packet, and the size SHOULD be picked so the resulting IP packet ends up smaller than the MTU size ๐ also, an aggregation packet MUST NOT contain fragmentation units, as specified in Section 5.8, and aggregation packets MUST NOT be nested. Translation: an aggregation packet MUST NOT contain another aggregation packet ๐ซ
Important: no aggregation packet inside another aggregation packet, ever. Nesting is a hard no ๐
5.7.1. Single-Time Aggregation Packet (STAP) โจ
bestie, a single-time aggregation packet (STAP) SHOULD be used whenever the NAL units being aggregated all share the same NALU-time ๐ the payload of an STAP-A does NOT include DON and consists of at least one single-time aggregation unit, as shown in Figure 4. The payload of an STAP-B is a 16-bit unsigned decoding order number (DON) (in network byte order) followed by at least one single-time aggregation unit, as shown in Figure 5 ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: |
+-+-+-+-+-+-+-+-+ |
| |
| single-time aggregation units |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 4. Payload format for STAP-A
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: decoding order number (DON) | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| |
| single-time aggregation units |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 5. Payload format for STAP-B
The DON field tells you the DON value for the first NAL unit in an STAP-B in transmission order ๐ข for each successive NAL unit in appearance order in an STAP-B, the DON value is equal to (the value of DON of the previous NAL unit in the STAP-B + 1) % 65536, where '%' is the modulo operation. So it just keeps counting up and wraps around ๐
A single-time aggregation unit is made of 16-bit unsigned size information (in network byte order) that says how big the NAL unit that follows is, in bytes. That size excludes these two octets but DOES include the NAL unit type octet of the NAL unit. Then comes the NAL unit itself, including its NAL unit type byte ๐ a single-time aggregation unit is byte aligned within the RTP payload, but it may NOT be aligned on a 32-bit word boundary. Figure 6 shows the structure ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: NAL unit size | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| |
| NAL unit |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 6. Structure for single-time aggregation unit
Figure 7 is an example of an RTP packet that holds an STAP-A ๐ง the STAP has two single-time aggregation units, labeled 1 and 2 in the figure โจ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RTP Header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|STAP-A NAL HDR | NALU 1 Size | NALU 1 HDR |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 1 Data |
: :
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | NALU 2 Size | NALU 2 HDR |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 2 Data |
: :
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 7. An example of an RTP packet including an STAP-A containing two single-time aggregation units
Figure 8 is an example of an RTP packet that holds an STAP-B ๐ this STAP also has two single-time aggregation units, labeled 1 and 2 in the figure ๐ธ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RTP Header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|STAP-B NAL HDR | DON | NALU 1 Size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 1 Size | NALU 1 HDR | NALU 1 Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
: :
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | NALU 2 Size | NALU 2 HDR |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 2 Data |
: :
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 8. An example of an RTP packet including an STAP-B containing two single-time aggregation units
5.7.2. Multi-Time Aggregation Packets (MTAPs) ๐
okay so MTAPs are the glow-up version of aggregation packets ๐ โจ The NAL unit payload is a 16-bit unsigned decoding order number base (DONB, sent in network byte order), followed by one or more multi-time aggregation units. Check out Figure 9 below ๐ฆ The DONB MUST contain the DON of the first NAL unit in NAL unit decoding order among the NAL units in the MTAP ๐
Informative note: The first NAL unit in the NAL unit decoding order is not necessarily the first NAL unit in the order in which the NAL units are encapsulated in an MTAP. ๐ง
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: decoding order number base | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| |
| multi-time aggregation units |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 9. NAL unit payload format for MTAPs ๐ธ
Okay, so there are two different multi-time aggregation units defined in this spec ๐ Both of them have 16 bits of unsigned size info for the next NAL unit (network byte order), an 8-bit unsigned decoding order number difference (DOND), and n bits (network byte order) of timestamp offset (TS offset) for that NAL unit. The n can be 16 or 24, so you get MTAP16 or MTAP24 ๐ Which one you pick is application dependent. The bigger the timestamp offset, the more flexible the MTAP is, but the overhead also goes up, so it's a vibe check ๐ซถ
The layouts for MTAP16 and MTAP24 are in Figures 10 and 11 ๐ธ Quick tea: an aggregation unit does not have to start or end on a 32-bit word boundary, so don't stress about alignment ๐ The DON of the NAL unit inside a multi-time aggregation unit is (DONB + DOND) % 65536, where % is the modulo operation ๐ฅ This memo doesn't say how the NAL units inside an MTAP get ordered, but in most cases NAL unit decoding order SHOULD be used ๐
Now the timestamp offset field MUST be set using this formula ๐ If the NALU-time is larger than or equal to the RTP timestamp of the packet, then the timestamp offset equals (the NALU-time of the NAL unit - the RTP timestamp of the packet). If the NALU-time is smaller than the RTP timestamp of the packet, then the timestamp offset is equal to the NALU-time + (2^32 - the RTP timestamp of the packet). Math lovers, you're welcome ๐งฎ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: NAL unit size | DOND | TS offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TS offset | |
+-+-+-+-+-+-+-+-+ NAL unit |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 10. Multi-time aggregation unit for MTAP16 โจ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
: NAL unit size | DOND | TS offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| TS offset | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| NAL unit |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 11. Multi-time aggregation unit for MTAP24 ๐ฆ
Here's the rule for the "earliest" aggregation unit in an MTAP, and it's a must ๐ Its timestamp offset MUST be zero. That means the RTP timestamp of the MTAP itself is the same as the earliest NALU-time ๐ท
Informative note: The "earliest" multi-time aggregation unit is the one that would have the smallest extended RTP timestamp among all the aggregation units of an MTAP if the NAL units contained in the aggregation units were encapsulated in single NAL unit packets. An extended timestamp is a timestamp that has more than 32 bits and is capable of counting the wraparound of the timestamp field, thus enabling one to determine the smallest value if the timestamp wraps. Such an "earliest" aggregation unit may not be the first one in the order in which the aggregation units are encapsulated in an MTAP. The "earliest" NAL unit need not be the same as the first NAL unit in the NAL unit decoding order either. ๐๐
Figure 12 shows an example RTP packet with an MTAP16 that holds two multi-time aggregation units, labeled 1 and 2 in the figure ๐ง
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RTP Header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|MTAP16 NAL HDR | decoding order number base | NALU 1 Size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 1 Size | NALU 1 DOND | NALU 1 TS offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 1 HDR | NALU 1 DATA |
+-+-+-+-+-+-+-+-+ +
: :
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | NALU 2 SIZE | NALU 2 DOND |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 2 TS offset | NALU 2 HDR | NALU 2 DATA |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
: :
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 12. An RTP packet including a multi-time aggregation packet of type MTAP16 containing two multi-time aggregation units ๐
And Figure 13 is the MTAP24 version of that same vibe, again with two multi-time aggregation units labeled 1 and 2 ๐
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| RTP Header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|MTAP24 NAL HDR | decoding order number base | NALU 1 Size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 1 Size | NALU 1 DOND | NALU 1 TS offs |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|NALU 1 TS offs | NALU 1 HDR | NALU 1 DATA |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +
: :
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | NALU 2 SIZE | NALU 2 DOND |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 2 TS offset | NALU 2 HDR |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| NALU 2 DATA |
: :
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 13. An RTP packet including a multi-time aggregation packet of type MTAP24 containing two multi-time aggregation units ๐ธ
5.8. Fragmentation Units (FUs) ๐ฆ
okay so FUs are giving "chop the big thing into pieces" ๐ This payload type lets you split one NAL unit across several RTP packets. Doing it at the application layer instead of leaning on lower-layer fragmentation (like IP) has these perks:
- The payload format can carry NAL units bigger than 64 kbytes over an IPv4 network, which shows up in pre-recorded video, especially High-Definition formats. (There's a limit on slices per picture, which means a limit on NAL units per picture, which may mean big NAL units. ๐)
- Fragmenting a single NAL unit lets you apply generic forward error correction as described in Section 12.5. ๐ก๏ธ
Fragmentation is only for a single NAL unit, not for aggregation packets. A fragment is an integer number of consecutive octets of that NAL unit. Each octet of the NAL unit MUST be part of exactly one fragment of that NAL unit. Fragments of the same NAL unit MUST be sent in consecutive order with ascending RTP sequence numbers, with no other RTP packets from the same RTP packet stream sent between the first and last fragment. Similarly, a NAL unit MUST be reassembled in RTP sequence number order. Bestie, the order is everything here. ๐ซถ
When a NAL unit is fragmented and carried in fragmentation units (FUs), it's called a fragmented NAL unit. STAPs and MTAPs MUST NOT be fragmented. FUs MUST NOT be nested, so an FU MUST NOT contain another FU. Not sure why anyone would try that, but it's a no. ๐ โโ๏ธ
The RTP timestamp of an RTP packet carrying an FU is set to the NALU-time of the fragmented NAL unit. โฐ
Figure 14 shows the RTP payload format for FU-As. An FU-A has a one-octet fragmentation unit indicator, a one-octet fragmentation unit header, and a fragmentation unit payload. ๐ธ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FU indicator | FU header | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| |
| FU payload |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 14. RTP payload format for FU-A
Figure 15 shows the RTP payload format for FU-Bs. An FU-B has a one-octet fragmentation unit indicator, a one-octet fragmentation unit header, a decoding order number (DON) in network byte order, and a fragmentation unit payload. Basically, FU-B is the same as FU-A but with an extra DON field. โจ
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| FU indicator | FU header | DON |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
| |
| FU payload |
| |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| :...OPTIONAL RTP padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 15. RTP payload format for FU-B
NAL unit type FU-B MUST be used in the interleaved packetization mode for the first fragmentation unit of a fragmented NAL unit. NAL unit type FU-B MUST NOT be used in any other case. So in interleaved mode, every fragmented NALU starts with an FU-B, followed by one or more FU-A fragments. ๐งฉ
The FU indicator octet has this format:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|F|NRI| Type |
+---------------+
Type values 28 and 29 in the FU indicator octet identify an FU-A and an FU-B, respectively. The F bit is described in Section 5.3. The NRI field value MUST be set according to the NRI field value in the fragmented NAL unit. ๐ฅ
The FU header has this format:
+---------------+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
|S|E|R| Type |
+---------------+
Here's what each field does:
- S (1 bit): When set to one, the Start bit marks the start of a fragmented NAL unit. When the following FU payload is not the start of a fragmented NAL unit payload, the Start bit is set to zero.
- E (1 bit): When set to one, the End bit marks the end of a fragmented NAL unit, meaning the last byte of the payload is also the last byte of the fragmented NAL unit. When the following FU payload is not the last fragment of a fragmented NAL unit, the End bit is set to zero.
- R (1 bit): The Reserved bit MUST be equal to 0 and MUST be ignored by the receiver. ๐ค
- Type (5 bits): The NAL unit payload type as defined in Table 7-1 of [1].
The value of DON in FU-Bs is selected as described in Section 5.5.
Informative note: The DON field in FU-Bs lets gateways fragment NAL units into FU-Bs without having to put the incoming NAL units in NAL unit decoding order. ๐ง
A fragmented NAL unit MUST NOT be sent in one FU. That means the Start bit and End bit MUST NOT both be set to one in the same FU header. ๐ซ
The FU payload is made of fragments of the fragmented NAL unit's payload, so if the FU payloads of consecutive FUs are concatenated in order, the fragmented NAL unit's payload can be rebuilt. The NAL unit type octet of the fragmented NAL unit is not included as-is in the FU payload. Instead, its info lives in the F and NRI fields of the FU indicator octet and in the type field of the FU header. An FU payload MAY have any number of octets and MAY be empty. ๐
Informative note: Empty FUs are allowed to reduce latency for a certain class of senders in nearly lossless environments. These senders packetize NALU fragments before the NALU is completely generated, so the NALU size isn't known yet. If zero-length NALU fragments weren't allowed, the sender would have to generate at least one bit of the following fragment before sending the current one. Since H.264 sometimes has several macroblocks taking up zero bits, that's undesirable and can add delay. However, using zero-length NALU fragments should be carefully weighed against the increased risk of losing at least part of the NALU, because of the extra packets sent for it. ๐ฅบ
If a fragmentation unit is lost, the receiver SHOULD discard all following fragmentation units in transmission order that belong to the same fragmented NAL unit. ๐๏ธ
A receiver in an endpoint or in a MANE MAY aggregate the first n-1 fragments of a NAL unit into an (incomplete) NAL unit, even if fragment n of that NAL unit isn't received. In this case, the forbidden_zero_bit of the NAL unit MUST be set to one to indicate a syntax violation. โ ๏ธ
6. Packetization Rules ๐
The packetization modes were introduced in Section 5.2. The packetization rules shared by more than one packetization mode are specified in Section 6.1. The rules for the single NAL unit mode, the non-interleaved mode, and the interleaved mode are specified in Sections 6.2, 6.3, and 6.4, respectively. ๐๏ธ
6.1. Common Packetization Rules ๐
All senders MUST enforce the following packetization rules, no matter which packetization mode is in use:
- Coded slice NAL units or coded slice data partition NAL units that belong to the same coded picture (and therefore share the same RTP timestamp value) MAY be sent in any order. However, for delay-critical systems, they SHOULD be sent in their original decoding order to minimize delay. Note that the decoding order is the order of the NAL units in the bitstream. โฑ๏ธ
- Parameter sets are handled according to the rules and recommendations in Section 8.4. ๐ฆ
- MANEs MUST NOT duplicate any NAL unit except for sequence or picture parameter set NAL units, since neither this memo nor the H.264 specification provides a way to identify duplicated NAL units. Sequence and picture parameter set NAL units MAY be duplicated to make their correct reception more probable, but any such duplication MUST NOT affect the contents of any active sequence or picture parameter set. Duplication SHOULD be done at the application layer, not by duplicating RTP packets (with identical sequence numbers). ๐ฏ
Senders using the non-interleaved mode and the interleaved mode MUST enforce the following packetization rule:
- In an RTP translator, MANEs MAY convert single NAL unit packets into one aggregation packet, convert an aggregation packet into several single NAL unit packets, or mix both approaches. The RTP translator SHOULD take into account at least the following parameters: path MTU size, unequal protection mechanisms (e.g., through packet-based FEC according to RFC 5109 [18], especially for sequence and picture parameter set NAL units and coded slice data partition A NAL units), bearable latency of the system, and buffering capabilities of the receiver. ๐งฎ
Informative note: An RTP translator is required to handle RTP Control Protocol (RTCP) as per RFC 3550. ๐ก
6.2. Single NAL Unit Mode ๐ธ
This mode is in use when the value of the OPTIONAL packetization-mode media type parameter is equal to 0, or when the packetization-mode is not present. All receivers MUST support this mode. It's mainly for low-delay apps that work with systems using ITU-T Recommendation H.241 [3] (see Section 12.1). Only single NAL unit packets MAY be used in this mode. STAPs, MTAPs, and FUs MUST NOT be used. The transmission order of single NAL unit packets MUST follow the NAL unit decoding order. ๐
6.3. Non-Interleaved Mode ๐ฆ
This mode is in use when the value of the OPTIONAL packetization-mode media type parameter is equal to 1. This mode SHOULD be supported. It's mainly for low-delay applications. Only single NAL unit packets, STAP-As, and FU-As MAY be used in this mode. STAP-Bs, MTAPs, and FU-Bs MUST NOT be used. The transmission order of NAL units MUST follow the NAL unit decoding order. ๐ง
6.4. Interleaved Mode ๐
This mode is in use when the value of the OPTIONAL packetization-mode media type parameter is equal to 2. Some receivers MAY support this mode. STAP-Bs, MTAPs, FU-As, and FU-Bs MAY be used. STAP-As and single NAL unit packets MUST NOT be used. The transmission order of packets and NAL units is constrained as specified in Section 5.5. ๐ซง
7. De-Packetization Process โจ
Okay bestie, so de-packetization is totally implementation dependent ๐ . That means the description below is just an example of a solid way to do it. Other schemes are fine too, as long as they spit out the exact same output for the same input. And "same output" here is strict: the resulting NAL units AND their order have to be identical ๐. Optimizations on top of these algorithms are likely possible, so go wild ๐ฆ. Section 7.1 covers the single NAL unit and non-interleaved packetization modes, Section 7.2 covers interleaved mode, and Section 7.3 has extra de-packetization tips for intelligent receivers ๐ง.
All the normal RTP buffer management stuff still applies. The big one: duplicated or outdated RTP packets (figured out from the RTP sequence number and RTP timestamp) get removed ๐๏ธ. And to work out the exact decoding time, you have to factor in any intentional delay used for inter-stream synchronization โฐ.
7.1. Single NAL Unit and Non-Interleaved Mode
The receiver has a receiver buffer to soak up transmission delay jitter ๐. Incoming packets get stored in reception order, but they're de-packetized in RTP sequence number order ๐ข. If a de-packetized packet is a single NAL unit packet, the NAL unit inside goes straight to the decoder ๐. If it's an STAP-A, the NAL units inside get passed to the decoder in the order they're encapsulated in the packet ๐ฆ. For FU-A packets carrying fragments of one NAL unit, the fragments are concatenated in their sending order to rebuild the NAL unit, and then that gets passed to the decoder ๐งฉ.
Informative note: If the decoder supports arbitrary slice order, coded slices of a picture can be passed to the decoder in any order, regardless of their reception and transmission order. ๐
7.2. Interleaved Mode
The big idea behind these de-packetization rules is to reorder NAL units from transmission order into the NAL unit decoding order ๐. It's giving puzzle-solving energy, and I'm obsessed.
The receiver has a receiver buffer that does two jobs: it compensates for transmission delay jitter AND reorders NAL units from transmission order into the NAL unit decoding order ๐ฏ. In this section, we're going to pretend there's no transmission delay jitter at all, just to keep things simple. To tell this buffer apart from the practical receiver buffer that also handles jitter, I'm calling it the de-interleaving buffer from here on ๐ซถ. Receivers SHOULD also prepare for transmission delay jitter, meaning they either reserve separate buffers for jitter and de-interleaving, or they use one receiver buffer for both ๐. Moreover, receivers SHOULD take transmission delay jitter into account in the buffering operation, for example by doing some extra initial buffering before decoding and playback start ๐.
This section is organized like so: Subsection 7.2.1 explains how to calculate the size of the de-interleaving buffer, and Subsection 7.2.2 spells out the receiver process for putting received NAL units into the NAL unit decoding order ๐.
7.2.1. Size of the De-Interleaving Buffer
Whether you're using Offer/Answer or declarative Session Description Protocol (SDP) usage, the sprop-deint-buf-req media type parameter is the one that signals how big the de-interleaving buffer needs to be ๐. So it is RECOMMENDED to set the de-interleaving buffer size, in terms of number of bytes, equal to or greater than the value of the sprop-deint-buf-req media type parameter ๐.
When the SDP Offer/Answer model or any other capability exchange procedure is used in session setup, the properties of the received stream SHOULD be such that the receiver capabilities are not exceeded ๐
โโ๏ธ. In the SDP Offer/Answer model, the receiver can say what it's capable of, meaning how much de-interleaving buffer it can allocate, using the deint-buf-cap media type parameter ๐ค. See Section 8.1 for more on the deint-buf-cap and sprop-deint-buf-req media type parameters, and Section 8.2.2 for how they get used in the SDP Offer/Answer model ๐.
7.2.2. De-Interleaving Process
There are two buffering states in the receiver: initial buffering, and buffering while playing ๐ฌ. Initial buffering kicks off when the RTP session gets initialized. Once that's done, decoding and playback start, and the receiver switches over to buffering-while-playing mode โถ๏ธ.
No matter which buffering state you're in, the receiver stores incoming NAL units in reception order into the de-interleaving buffer, following these rules ๐ฅ. NAL units from aggregation packets get stored individually, each one on its own. And the DON value gets calculated and stored for every single NAL unit ๐ข.
The receiver operation is described below with the help of the following functions and constants:
- Function AbsDON is specified in Section 8.1.
- Function don_diff is specified in Section 5.5.
- Constant N is the value of the OPTIONAL
sprop-interleaving-depthmedia type parameter (see Section 8.1) incremented by 1 โ.
Initial buffering keeps going until one of these conditions is fulfilled ๐:
- There are N or more VCL NAL units in the de-interleaving buffer.
- If
sprop-max-don-diffis present,don_diff(m,n)is greater than the value ofsprop-max-don-diff. Here, n is the NAL unit with the greatest AbsDON value among the received NAL units, and m is the NAL unit with the smallest AbsDON value among the received NAL units ๐. - Initial buffering has lasted for a duration equal to or greater than the value of the OPTIONAL
sprop-init-buf-timemedia type parameter โณ.
Here's how NAL units get removed from the de-interleaving buffer ๐งน:
- If the de-interleaving buffer contains at least N VCL NAL units, NAL units get removed and passed to the decoder, in the order specified below, until the buffer contains N-1 VCL NAL units ๐ฏ.
- If
sprop-max-don-diffis present, every NAL unit m for whichdon_diff(m,n)is greater thansprop-max-don-diffgets removed from the de-interleaving buffer and passed to the decoder, in the order specified below. Here, n is the NAL unit with the greatest AbsDON value among the NAL units in the de-interleaving buffer ๐จ.
The order for passing NAL units to the decoder works like this ๐:
- Let PDON be a variable that's initialized to 0 at the beginning of the RTP session ๐ฑ.
- For each NAL unit with a DON value, a DON distance gets calculated. If the NAL unit's DON value is larger than PDON, the DON distance is
DON - PDON. Otherwise, it's65535 - PDON + DON + 1๐งฎ. - NAL units get delivered to the decoder in ascending order of DON distance. If several NAL units share the same DON distance, they can go to the decoder in any order ๐.
- Once a desired number of NAL units have been passed to the decoder, PDON gets set to the DON value of the last NAL unit that was passed ๐.
7.3. Additional De-Packetization Guidelines
These extra de-packetization rules may be used to build an operational H.264 de-packetizer ๐ ๏ธ:
- Intelligent RTP receivers (for example, in gateways) may identify lost coded slice data partitions A (DPAs) ๐ต๏ธโโ๏ธ. If a lost DPA is detected, then after taking into account possible retransmission and FEC, a gateway may decide not to send the corresponding coded slice data partitions B and C, since their information is meaningless for H.264 decoders ๐ โโ๏ธ. That way, a MANE can cut network load by tossing useless packets without having to parse a complex bitstream ๐ง .
- Intelligent RTP receivers (for example, in gateways) may identify lost FUs. If a lost FU is found, a gateway may decide not to send the following FUs of the same fragmented NAL unit, since their information is meaningless for H.264 decoders ๐ . Again, a MANE can reduce network load by discarding useless packets without parsing a complex bitstream โจ.
- Intelligent receivers that have to discard packets or NALUs should first discard all packets/NALUs whose NRI field of the NAL unit type octet is equal to 0 ๐ธ. This minimizes the impact on user experience and keeps the reference pictures intact ๐ซถ. If more packets have to be discarded, then packets with a numerically lower NRI value should be discarded before packets with a numerically higher NRI value ๐. However, discarding any packets with an NRI bigger than 0 very likely leads to decoder drift, and it SHOULD be avoided ๐ญ.
8. Payload Format Parameters ๐
This section specifies the parameters that MAY be used to select optional features of the payload format and certain features of the bitstream ๐. The parameters are specified here as part of the media subtype registration for the ITU-T H.264 | ISO/IEC 14496-10 codec ๐. A mapping of the parameters into the Session Description Protocol (SDP) [6] is also provided for applications that use SDP ๐งพ. Equivalent parameters could be defined elsewhere for use with control protocols that don't use SDP ๐ฆ.
Some parameters tell a receiver about the properties of the stream that's going to be sent ๐. The names of all these parameters start with "sprop" for stream properties โจ. Some of these "sprop" parameters are limited by other payload or codec configuration parameters. For example, the sprop-parameter-sets parameter is constrained by the profile-level-id parameter ๐.
8.1. Media Type Registration
The media subtype for the ITU-T H.264 | ISO/IEC 14496-10 codec has been allocated from the IETF tree ๐ณ.
Media Type name: video
Media subtype name: H264
Required parameters: none
OPTIONAL parameters:
profile-level-id:
Here's the profile-level-id parameter, which is OPTIONAL ๐. It's a base16 [7] (hexadecimal) representation of three bytes from the sequence parameter set NAL unit, as specified in [1]: 1) profile_idc, 2) a byte called profile-iop, made up of the values of constraint_set0_flag, constraint_set1_flag, constraint_set2_flag, constraint_set3_flag, constraint_set4_flag, constraint_set5_flag, and reserved_zero_2bits, in bit-significance order starting from the most-significant bit, and 3) level_idc ๐งฉ. Note that reserved_zero_2bits is required to be equal to 0 in [1], but other values for it may be specified in the future by ITU-T or ISO/IEC ๐ฎ.
The profile-level-id parameter tells you the default sub-profile (that's the subset of coding tools that may have been used to generate the stream, or that the receiver supports) and the default level that the stream or the receiver supports ๐.
The default sub-profile is indicated collectively by the profile_idc byte and some fields in the profile-iop byte ๐ Depending on the values of the fields in the profile-iop byte, the default sub-profile may be the set of coding tools supported by one profile, or a common subset of coding tools of multiple profiles, as specified in Section 7.4.2.1.1 of [1]. The default level is indicated by the level_idc byte, and, when profile_idc is equal to 66, 77, or 88 (the Baseline, Main, or Extended profile) and level_idc is equal to 11, additionally by bit 4 (constraint_set3_flag) of the profile-iop byte ๐ When profile_idc is equal to 66, 77, or 88 (the Baseline, Main, or Extended profile), level_idc is equal to 11, and bit 4 (constraint_set3_flag) of the profile-iop byte is equal to 1, the default level is Level 1b โจ
Table 5 lists all profiles defined in Annex A of [1] and, for each of the profiles, the possible combinations of profile_idc and profile-iop that represent the same sub-profile ๐ฆ
Table 5. Combinations of profile_idc and profile-iop
representing the same sub-profile corresponding to the full
set of coding tools supported by one profile. In the
following, x may be either 0 or 1, while the profile names
are indicated as follows. CB: Constrained Baseline profile,
B: Baseline profile, M: Main profile, E: Extended profile,
H: High profile, H10: High 10 profile, H42: High 4:2:2
profile, H44: High 4:4:4 Predictive profile, H10I: High 10
Intra profile, H42I: High 4:2:2 Intra profile, H44I: High
4:4:4 Intra profile, and C44I: CAVLC 4:4:4 Intra profile.
Profile profile_idc profile-iop
(hexadecimal) (binary)
CB 42 (B) x1xx0000
same as: 4D (M) 1xxx0000
same as: 58 (E) 11xx0000
B 42 (B) x0xx0000
same as: 58 (E) 10xx0000
M 4D (M) 0x0x0000
E 58 00xx0000
H 64 00000000
H10 6E 00000000
H42 7A 00000000
H44 F4 00000000
H10I 6E 00010000
H42I 7A 00010000
H44I F4 00010000
C44I 2C 00010000
For example, in the table above, profile_idc equal to 58 (Extended) with profile-iop equal to 11xx0000 indicates the same sub-profile corresponding to profile_idc equal to 42 (Baseline) with profile-iop equal to x1xx0000 ๐ Note that other combinations of profile_idc and profile-iop (not listed in Table 5) may represent a sub-profile equivalent to the common subset of coding tools for more than one profile ๐
Note also that a decoder conforming to a certain profile may be able to decode bitstreams conforming to other profiles ๐ซถ
If the profile-level-id parameter is used to indicate properties of a NAL unit stream, it indicates that, to decode the stream, the minimum subset of coding tools a decoder has to support is the default sub-profile, and the lowest level the decoder has to support is the default level ๐
If the profile-level-id parameter is used for capability exchange or session setup, it indicates the subset of coding tools, which is equal to the default sub-profile, that the codec supports for both receiving and sending ๐ If max-recv-level is not present, the default level from profile-level-id indicates the highest level the codec wishes to support. If max-recv-level is present, it indicates the highest level the codec supports for receiving. For either receiving or sending, all levels that are lower than the highest level supported MUST also be supported ๐ฅ
Informative note: Capability exchange and session setup procedures should provide means to list the capabilities for each supported sub-profile separately. For example, the one-of-N codec selection procedure of the SDP Offer/Answer model can be used (Section 10.2 of [8]). The one-of-N codec selection procedure may also be used to provide different combinations ofprofile_idcandprofile-iopthat represent the same sub-profile. When there are many different combinations ofprofile_idcandprofile-iopthat represent the same sub-profile, using the one-of-N codec selection procedure may result in a fairly large SDP message. Therefore, a receiver should understand the different equivalent combinations ofprofile_idcandprofile-iopthat represent the same sub-profile and be ready to accept an offer using any of the equivalent combinations. ๐
If no profile-level-id is present, the Baseline profile, without additional constraints at Level 1, MUST be inferred ๐
max-recv-level: This parameter MAY be used to indicate the highest level a receiver supports when the highest level is higher than the default level (the level indicated by profile-level-id). The value of max-recv-level is a base16 (hexadecimal) representation of the two bytes after the syntax element profile_idc in the sequence parameter set NAL unit specified in [1]: profile-iop (as defined above) and level_idc. If the level_idc byte of max-recv-level is equal to 11 and bit 4 of the profile-iop byte of max-recv-level is equal to 1 or if the level_idc byte of max-recv-level is equal to 9 and bit 4 of the profile-iop byte of max-recv-level is equal to 0, the highest level the receiver supports is Level 1b. Otherwise, the highest level the receiver supports is equal to the level_idc byte of max-recv-level divided by 10 โจ
max-recv-level MUST NOT be present if the highest level the receiver supports is not higher than the default level ๐ง
max-mbps, max-smbps, max-fs, max-cpb, max-dpb, and max-br: These parameters MAY be used to signal the capabilities of a receiver implementation. These parameters MUST NOT be used for any other purpose. The highest level conveyed in the value of the profile-level-id parameter or the max-recv-level parameter MUST be such that the receiver is fully capable of supporting. max-mbps, max-smbps, max-fs, max-cpb, max-dpb, and max-br MAY be used to indicate capabilities of the receiver that extend the required capabilities of the signaled highest level, as specified below ๐
When more than one parameter from the set (max-mbps, max-smbps, max-fs, max-cpb, max-dpb, max-br) is present, the receiver MUST support all signaled capabilities simultaneously. For example, if both max-mbps and max-br are present, the signaled highest level with the extension of both the frame rate and bitrate is supported. That is, the receiver is able to decode NAL unit streams in which the macroblock processing rate is up to max-mbps (inclusive), the bitrate is up to max-br (inclusive), the coded picture buffer size is derived as specified in the semantics of the max-br parameter below, and the other properties comply with the highest level specified in the value of the profile-level-id parameter or the max-recv-level parameter ๐ฆ
If a receiver can support all the properties of Level A, the highest level specified in the value of the profile-level-id parameter or the max-recv-level parameter MUST be Level A (i.e., MUST NOT be lower than Level A). In other words, a receiver MUST NOT signal values of max-mbps, max-fs, max-cpb, max-dpb, and max-br that taken together meet the requirements of a higher level compared to the highest level specified in the value of the profile-level-id parameter or the max-recv-level parameter ๐
Informative note: When the OPTIONAL media type parameters are used to signal the properties of a NAL unit stream,max-mbps,max-smbps,max-fs,max-cpb,max-dpb, andmax-brare not present, and the value ofprofile-level-idmust always be such that the NAL unit stream complies fully with the specified profile and level. ๐ธ
max-mbps: The value of max-mbps is an integer indicating the maximum macroblock processing rate in units of macroblocks per second. The max-mbps parameter signals that the receiver is capable of decoding video at a higher rate than is required by the signaled highest level conveyed in the value of the profile-level-id parameter or the max-recv-level parameter ๐ฅ
When max-mbps is signaled, the receiver MUST be able to decode NAL unit streams that conform to the signaled highest level, with the exception that the MaxMBPS value in Table A-1 of [1] for the signaled highest level is replaced with the value of max-mbps. The value of max-mbps MUST be greater than or equal to the value of MaxMBPS given in Table A-1 of [1] for the highest level. Senders MAY use this knowledge to send pictures of a given size at a higher picture rate than is indicated in the signaled highest level ๐
max-smbps: The value of max-smbps is an integer indicating the maximum static macroblock processing rate in units of static macroblocks per second, under the hypothetical assumption that all macroblocks are static macroblocks. When max-smbps is signaled, the MaxMBPS value in Table A-1 of [1] should be replaced with the result of the following computation:
- If the parameter
max-mbpsis signaled, set a variable MaxMacroblocksPerSecond to the value ofmax-mbps. Otherwise, set MaxMacroblocksPerSecond equal to the value of MaxMBPS in Table A-1 [1] for the signaled highest level conveyed in the value of theprofile-level-idparameter or themax-recv-levelparameter. - Set a variable P_non-static to the proportion of non-static macroblocks in picture n.
- Set a variable P_static to the proportion of static macroblocks in picture n.
- The value of MaxMBPS in Table A-1 of [1] should be considered by the encoder to be equal to:
MaxMacroblocksPerSecond * max-smbps / (P_non-static *
max-smbps + P_static * MaxMacroblocksPerSecond)
The encoder should recompute this value for each picture. The value of max-smbps MUST be greater than or equal to the value of MaxMBPS given explicitly as the value of the max-mbps parameter or implicitly in Table A-1 of [1] for the signaled highest level. Senders MAY use this knowledge to send pictures of a given size at a higher picture rate than is indicated in the signaled highest level โจ
Okay bestie, max-fs is all about picture size ๐โจ. Its value is an integer for the maximum frame size, counted in macroblocks ๐งฑ. It basically says "my receiver can handle bigger pictures than the highest level in profile-level-id or max-recv-level requires." When max-fs is signaled, the receiver MUST be able to decode NAL unit streams that conform to the signaled highest level. The one twist is that the MaxFS value in Table A-1 of [1] for that level gets swapped out for the max-fs value. And the max-fs value MUST be greater than or equal to the MaxFS value in Table A-1 of [1] for the highest level ๐
. Senders MAY use this to send larger pictures at a proportionally lower frame rate than the signaled highest level indicates ๐ฌ.
max-cpb is the coded picture buffer one ๐ง . Its value is an integer for the maximum coded picture buffer size, in units of 1000 bits for the VCL HRD parameters and 1200 bits for the NAL HRD parameters. Note that this parameter does NOT use the units of cpbBrVclFactor and cpbBrNALFactor (see Table A-1 of [1]), so don't mix them up ๐. It signals that the receiver has more memory than the minimum coded picture buffer memory required by the signaled highest level. When max-cpb is signaled, the receiver MUST be able to decode NAL unit streams that conform to the signaled highest level. The exception is that the MaxCPB value in Table A-1 of [1] for that level gets replaced with the max-cpb value, after taking cpbBrVclFactor and cpbBrNALFactor into consideration when needed. That max-cpb value (after the same adjustment, when needed) MUST be greater than or equal to the MaxCPB value in Table A-1 of [1] for the highest level. Senders MAY use this to build coded video streams with more bitrate variation than the MaxCPB value in Table A-1 of [1] would allow ๐.
Informative note: The coded picture buffer is used in the hypothetical reference decoder (Annex C of H.264). H.264 encoders are recommended to use the hypothetical reference decoder to check that the produced bitstream conforms to the standard and to control the output bitrate. So the coded picture buffer is conceptually independent of any other potential buffers in the receiver, including de-interleaving and de-jitter buffers ๐งฉ. The coded picture buffer doesn't have to be implemented in decoders as specified in Annex C of H.264. Standard-compliant decoders can have any buffering arrangement, as long as they can decode standard-compliant bitstreams. So in practice, the input buffer for a video decoder can be integrated with the receiver's de-interleaving and de-jitter buffers ๐ซถ.
max-dpb is the decoded picture buffer one ๐ผ๏ธ. Its value is an integer for the maximum decoded picture buffer size, in units of 8/3 macroblocks. It signals that the receiver has more memory than the minimum decoded picture buffer memory required by the signaled highest level. When max-dpb is signaled, the receiver MUST be able to decode NAL unit streams that conform to the signaled highest level. The exception is that the MaxDpbMbs value in Table A-1 of [1] for that level gets replaced with max-dpb * 3 / 8. So a receiver that signals max-dpb MUST be capable of storing this many decoded frames, complementary field pairs, and non-paired fields in its decoded picture buffer:
Min(max-dpb * 3 / 8 / ( PicWidthInMbs * FrameHeightInMbs),
16)
Wherein PicWidthInMbs and FrameHeightInMbs are defined in [1] โจ.
The value of max-dpb MUST be greater than or equal to the value of MaxDpbMbs * 3 / 8, where MaxDpbMbs is given in Table A-1 of [1] for the highest level. Senders MAY use this to build coded video streams with improved compression ๐๏ธ.
Informative note: This parameter was added mainly to match a similar codepoint in the ITU-T Recommendation H.245, so that signaling gateway designs are easier ๐. The decoded picture buffer stores reconstructed samples. There is NO relationship between the size of the decoded picture buffer and the buffers used in RTP, especially de-interleaving and de-jitter buffers.
Informative note: In RFC 3984, which this document obsoletes, the unit of this parameter was 1024 bytes. This document changes the unit to 8/3 macroblocks. The reason is the changes from the 2003 version of the H.264 specification referenced by RFC 3984 to the 2010 version referenced by this document. The biggest change was to Table A-1 of the H.264 specification, which gained color formats and bit depths that weren't supported before ๐. The changed semantics of this parameter keep backward compatibility with RFC 3984 and support all profiles defined in the 2010 version of the H.264 specification ๐.
max-br is the bitrate one ๐. Its value is an integer for the maximum video bitrate, in units of 1000 bits per second for the VCL HRD parameters and 1200 bits per second for the NAL HRD parameters. Again, this parameter does NOT use the units of cpbBrVclFactor and cpbBrNALFactor (see Table A-1 of [1]) ๐.
It signals that the receiver's video decoder can decode video at a higher bitrate than the signaled highest level requires. When max-br is signaled, the receiver's video codec MUST be able to decode NAL unit streams that conform to the signaled highest level, with these exceptions inside the limits of that highest level:
- The value of
max-br(after taking cpbBrVclFactor and cpbBrNALFactor into consideration when needed) replaces the MaxBR value in Table A-1 of [1] for the highest level. - When the
max-cpbparameter is NOT present, this formula replaces the MaxCPB value in Table A-1 of [1]: (MaxCPB of the signaled level) * max-br / (MaxBR of the signaled highest level).
For example, if a receiver signals Main profile Level 1.2 capability with max-br equal to 1550, that means a maximum video bitrate of 1550 kbits/sec for VCL HRD parameters, a maximum video bitrate of 1860 kbits/sec for NAL HRD parameters, and a CPB size of 4036458 bits (1550000 / 384000 * 1000 * 1000) ๐งฎ.
The value of max-br (after taking cpbBrVclFactor and cpbBrNALFactor into consideration when needed) MUST be greater than or equal to the MaxBR value in Table A-1 of [1] for the signaled highest level. Senders MAY use this to send higher bitrate video, as allowed by the level definitions in Annex A of H.264, for better video quality ๐.
Informative note: This parameter was added mainly to match a similar codepoint in the ITU-T Recommendation H.245, so that signaling gateway designs are easier. The assumption that the network can handle such bitrates at any given time CANNOT be made from the value of this parameter ๐ โโ๏ธ. In particular, NO conclusion can be drawn that the signaled bitrate is possible under congestion control constraints ๐ฆ.
redundant-pic-cap is about backup pictures ๐. This parameter signals the capabilities of a receiver implementation. When it's equal to 0, the receiver makes no attempt to use redundant coded pictures to fix incorrectly decoded primary coded pictures. Also, when it's equal to 0, the receiver can't use redundant slices, so a sender SHOULD avoid sending redundant slices to save bandwidth ๐ธ. When it's equal to 1, the receiver can decode any redundant slice that covers a corrupted area in a primary decoded picture, at least partly. So a sender MAY send redundant slices ๐ฆธโโ๏ธ. When the parameter is NOT present, a value of 0 MUST be used for redundant-pic-cap. When it IS present, the value of redundant-pic-cap MUST be either 0 or 1.
When profile-level-id appears in the same signaling as redundant-pic-cap, and the profile in profile-level-id disallows redundant coded pictures (for example, Main profile), the value of redundant-pic-cap MUST be equal to 0. When a receiver indicates redundant-pic-cap equal to 0, the received stream SHOULD NOT contain redundant coded pictures ๐
โโ๏ธ.
Informative note: Even if redundant-pic-cap is equal to 0, the decoder can ignore redundant coded pictures, as long as it supports a profile (Baseline, Extended) that allows redundant coded pictures ๐งน.
Informative note: Even if redundant-pic-cap is equal to 1, the receiver may also pick other error concealment strategies to replace or complement decoding of redundant slices ๐จ.
sprop-parameter-sets is the starter pack ๐. This parameter MAY be used to convey any sequence and picture parameter set NAL units (we call these the initial parameter set NAL units) that can be placed in the NAL unit stream to come before any other NAL units in decoding order. The parameter MUST NOT be used to indicate codec capability in any capability exchange procedure ๐ซ. Its value is a comma-separated (',') list of base64 [7] representations of parameter set NAL units, as specified in Sections 7.3.2.1 and 7.3.2.2 of [1]. Note that a parameter set NAL unit is typically less than 10 bytes, but a picture parameter set NAL unit can be several hundred bytes ๐ง.
Informative note: When several payload types are offered in the SDP Offer/Answer model, each with its ownsprop-parameter-setsparameter, the receiver can't assume those parameter sets don't use conflicting storage locations (meaning identical values of parameter set identifiers). So a receiver should buffer allsprop-parameter-setsand make them available to the decoder instance that decodes a certain payload type ๐ง ๐.
sprop-parameter-sets is basically the strict bouncer here ๐
It MUST only contain parameter sets that conform to the profile-level-id, which means the subset of coding tools indicated by any of the parameter sets MUST be equal to the default sub-profile, and the level indicated by any of them MUST be equal to the default level. No sneaking in random sets, periodt ๐
sprop-level-parameter-sets ๐ฆ
This parameter MAY be used to convey any sequence and picture parameter set NAL units (herein referred to as the initial parameter set NAL units) that can be placed in the NAL unit stream to precede any other NAL units in decoding order and that are associated with one or more levels different than the default level. The parameter MUST NOT be used to indicate codec capability in any capability exchange procedure. So it's for extra levels, never for telling anyone what you can handle ๐
The sprop-level-parameter-sets parameter contains parameter sets for one or more levels that are different than the default level. All parameter sets associated with one level are clustered and prefixed with a three-byte field that has the same syntax as profile-level-id. This enables the receiver to install the parameter sets for one level and discard the rest. The three-byte field is named PLId, and all parameter sets associated with one level are named PSL, which has the same syntax as sprop-parameter-sets. Parameter sets for each level are represented in the form of PLId:PSL, i.e., PLId followed by a colon (':') and the base64 [7] representation of the initial parameter set NAL units for the level. Each pair of PLId:PSLs is also separated by a colon. Note that a PSL can contain multiple parameter sets for that level, separated with commas (','). It's like a little folder system, bestie ๐๏ธโจ
The subset of coding tools indicated by each PLId field MUST be equal to the default sub-profile, and the level indicated by each PLId field MUST be different than the default level. All sequence parameter sets contained in each PSL MUST have the three bytes from profile_idc to level_idc, inclusive, equal to the preceding PLId. Everything has to line up or it's a no-go ๐
Informative note: This parameter allows for efficient level downgrade or upgrade in SDP Offer/Answer and out-of-band transport of parameter sets simultaneously.
use-level-src-parameter-sets ๐ธ
This parameter MAY be used to indicate a receiver capability. The value MAY be equal to either 0 or 1. When the parameter is not present, the value MUST be inferred to be equal to 0. The value 0 indicates that the receiver does not understand the sprop-level-parameter-sets parameter, does not understand the "fmtp" source attribute as specified in Section 6.3 of [9], will ignore sprop-level-parameter-sets when present, and will ignore sprop-parameter-sets when conveyed using the "fmtp" source attribute. The value 1 indicates that the receiver understands the sprop-level-parameter-sets parameter, understands the "fmtp" source attribute as specified in Section 6.3 of [9], and is capable of using parameter sets contained in the sprop-level-parameter-sets or contained in the sprop-parameter-sets that is conveyed using the "fmtp" source attribute. So 1 means "I'm fully caught up," and 0 means "not me yet" ๐ญ
Informative note: An RFC 3984 receiver does not understandsprop-level-parameter-sets,use-level-src-parameter-sets, or the"fmtp"source attribute as specified in Section 6.3 of [9].
Therefore, during SDP Offer/Answer, an RFC 3984 receiver as the answerer will simply ignoresprop-level-parameter-setswhen present in an offer andsprop-parameter-setsconveyed using the"fmtp"source attribute, as specified in Section 6.3 of [9].
Assume that the offered payload type was accepted at a level lower than the default level. If the offered payload type includedsprop-level-parameter-setsor includedsprop-parameter-setsconveyed using the"fmtp"source attribute and if the offerer sees that the answerer has not includeduse-level-src-parameter-setsequal to 1 in the answer, the offerer knows that in-band transport of parameter sets is needed.
in-band-parameter-sets ๐ง
This parameter MAY be used to indicate a receiver capability. The value MAY be equal to either 0 or 1. The value 1 indicates that the receiver discards out-of-band parameter sets in sprop-parameter-sets and sprop-level-parameter-sets; therefore, the sender MUST transmit all parameter sets in-band. The value 0 indicates that the receiver utilizes out-of-band parameter sets included in sprop-parameter-sets and/or sprop-level-parameter-sets. However, in this case, the sender MAY still choose to send parameter sets in-band. When in-band-parameter-sets is equal to 1, use-level-src-parameter-sets MUST NOT be present or MUST be equal to 0. When the parameter is not present, this receiver capability is not specified, and therefore the sender MAY send out-of-band parameter sets only, it MAY send in-band-parameter-sets only, or it MAY send both. The sender gets to pick its vibe here ๐
level-asymmetry-allowed ๐
This parameter MAY be used in SDP Offer/Answer to indicate whether level asymmetry, i.e., sending media encoded at a different level in the offerer-to-answerer direction than the level in the answerer-to-offerer direction, is allowed. The value MAY be equal to either 0 or 1. When the parameter is not present, the value MUST be inferred to be equal to 0. The value 1 in both the offer and the answer indicates that level asymmetry is allowed. The value of 0 in either the offer or the answer indicates that level asymmetry is not allowed.
If level-asymmetry-allowed is equal to 0 (or not present) in either the offer or the answer, level asymmetry is not allowed. In this case, the level to use in the direction from the offerer to the answerer MUST be the same as the level to use in the opposite direction. Basically, if either side says no, you're both on the same level, no drama ๐
packetization-mode ๐
This parameter signals the properties of an RTP payload type or the capabilities of a receiver implementation. Only a single configuration point can be indicated; thus, when capabilities to support more than one packetization-mode are declared, multiple configuration points (RTP payload types) must be used.
When the value of packetization-mode is equal to 0 or packetization-mode is not present, the single NAL mode MUST be used. This mode is in use in standards using ITU-T Recommendation H.241 [3] (see Section 12.1). When the value of packetization-mode is equal to 1, the non-interleaved mode MUST be used. When the value of packetization-mode is equal to 2, the interleaved mode MUST be used. The value of packetization-mode MUST be an integer in the range of 0 to 2, inclusive. Three modes, one knob, zero chill-free guesswork ๐ฅ
sprop-interleaving-depth ๐
This parameter MUST NOT be present when packetization-mode is not present or the value of packetization-mode is equal to 0 or 1. This parameter MUST be present when the value of packetization-mode is equal to 2.
This parameter signals the properties of an RTP packet stream. It specifies the maximum number of VCL NAL units that precede any VCL NAL unit in the RTP packet stream in transmission order and that follow the VCL NAL unit in decoding order. Consequently, it is guaranteed that receivers can reconstruct NAL unit decoding order when the buffer size for NAL unit decoding order recovery is at least the value of sprop-interleaving-depth + 1 in terms of VCL NAL units. Big brain math, but the payoff is real โจ
The value of sprop-interleaving-depth MUST be an integer in the range of 0 to 32767, inclusive.
sprop-deint-buf-req ๐ท
This parameter MUST NOT be present when packetization-mode is not present or the value of packetization-mode is equal to 0 or 1. It MUST be present when the value of packetization-mode is equal to 2.
sprop-deint-buf-req signals the required size of the de-interleaving buffer for the RTP packet stream. The value of the parameter MUST be greater than or equal to the maximum buffer occupancy (in units of bytes) required in such a de-interleaving buffer that is specified in Section 7.2. It is guaranteed that receivers can perform the de-interleaving of interleaved NAL units into NAL unit decoding order, when the de-interleaving buffer size is at least the value of sprop-deint-buf-req in terms of bytes.
The value of sprop-deint-buf-req MUST be an integer in the range of 0 to 4294967295, inclusive.
Informative note: sprop-deint-buf-req indicates the required size of the de-interleaving buffer only. When network jitter can occur, an appropriately sized jitter buffer has to be provisioned for as well.
deint-buf-cap ๐ฆ
This parameter signals the capabilities of a receiver implementation and indicates the amount of de-interleaving buffer space in units of bytes that the receiver has available for reconstructing the NAL unit decoding order. A receiver is able to handle any stream for which the value of the sprop-deint-buf-req parameter is smaller than or equal to this parameter.
If the parameter is not present, then a value of 0 MUST be used for deint-buf-cap. The value of deint-buf-cap MUST be an integer in the range of 0 to 4294967295, inclusive.
Informative note: deint-buf-cap indicates the maximum possible size of the de-interleaving buffer of the receiver only. When network jitter can occur, an appropriately sized jitter buffer has to be provisioned for as well.
sprop-init-buf-time โญ
This parameter MAY be used to signal the properties of an RTP packet stream. The parameter MUST NOT be present if the value of packetization-mode is equal to 0 or 1.
The parameter signals the initial buffering time that a receiver MUST wait before starting decoding to recover the NAL unit decoding order from the transmission order. The parameter is the maximum value of (decoding time of the NAL unit - transmission time of a NAL unit), assuming reliable and instantaneous transmission, the same timeline for transmission and decoding, and commencement of decoding when the first packet arrives. Translation: wait long enough for the stragglers to show up ๐ซถ
An example of specifying the value of sprop-init-buf-time follows. A NAL unit stream is sent in the following interleaved order, in which the value corresponds to the decoding time and the transmission order is from left to right:
0 2 1 3 5 4 6 8 7 ...
Assuming a steady transmission rate of NAL units, the transmission times are:
0 1 2 3 4 5 6 7 8 ...
Subtracting the decoding time from the transmission time column-wise results in the following series:
0 -1 1 0 -1 1 0 -1 1 ...
Okay so picture the NAL unit transmission times lined up like beads ๐งโจ. In that example, sprop-init-buf-time comes out to 1 ๐ธ. It's coded as a non-negative base10 integer in clock ticks of a 90-kHz clock ๐
. If the parameter isn't there, no initial buffering time is defined. If it is there, the value MUST be an integer from 0 to 4294967295, inclusive ๐ฅ.
Bestie, receivers SHOULD also account for the transmission delay jitter buffering on top of that signaled value ๐ซถ. That includes buffering for jitter caused by mixers, translators, gateways, proxies, traffic-shapers, and other network elements ๐ฆ.
sprop-max-don-diff: This one MAY be used to signal the properties of an RTP packet stream ๐. It MUST NOT be used to signal transmitter, receiver, or codec capabilities ๐. It MUST NOT be present if packetization-mode is equal to 0 or 1 ๐. The value is an integer from 0 to 32767, inclusive. If it isn't present, the value is unspecified ๐. Here's how it's calculated:
sprop-max-don-diff = max{AbsDON(i) - AbsDON(j)},
for any i and any j>i,
So here i and j are the index of the NAL unit in transmission order, and AbsDON is a decoding order number that does NOT wrap around to 0 after 65535 ๐. Basically, let m and n be consecutive NAL units in transmission order. The very first NAL unit (index 0) gets AbsDON(0) = DON(0). For everything else, AbsDON works like this ๐ญ:
If DON(m) == DON(n), AbsDON(n) = AbsDON(m)
If (DON(m) < DON(n) and DON(n) - DON(m) < 32768),
AbsDON(n) = AbsDON(m) + DON(n) - DON(m)
If (DON(m) > DON(n) and DON(m) - DON(n) >= 32768),
AbsDON(n) = AbsDON(m) + 65536 - DON(m) + DON(n)
If (DON(m) < DON(n) and DON(n) - DON(m) >= 32768),
AbsDON(n) = AbsDON(m) - (DON(m) + 65536 - DON(n))
If (DON(m) > DON(n) and DON(m) - DON(n) < 32768),
AbsDON(n) = AbsDON(m) - (DON(m) - DON(n))
Here DON(i) is the decoding order number of the NAL unit at index i in transmission order. The decoding order number is specified in Section 5.5 ๐.
Informative note: Receivers may use sprop-max-don-diff to trigger which NAL units in the receiver buffer can be passed to the decoder ๐ง .
max-rcmd-nalu-size: This parameter MAY be used to signal the capabilities of a receiver ๐. It MUST NOT be used for any other purposes. Its value is the largest NALU size in bytes that the receiver can handle efficiently. It's a recommendation, not a strict upper boundary โจ. The sender MAY create larger NALUs, but it has to be aware that handling them may cost more than handling NALUs that stay within the limit ๐ .
The value MUST be an integer from 0 to 4294967295, inclusive. If this parameter isn't specified, no known limitation to the NALU size exists ๐ธ. Senders still have to consider the MTU size available between the sender and the receiver, and they SHOULD run MTU discovery for this purpose ๐ฅ.
This parameter is motivated by things like an IP to H.223 video telephony gateway, where NALUs smaller than the H.223 transport data unit are more efficient ๐ฆ. A gateway may terminate IP, so MTU discovery normally won't work beyond the gateway ๐ญ.
Informative note: Setting this parameter to a lower than necessary value may have a negative impact ๐.
sar-understood: This parameter MAY be used to indicate a receiver capability and nothing else ๐. It indicates the maximum value of aspect_ratio_idc (specified in [1]) smaller than 255 that the receiver understands. Table E-1 of [1] says aspect_ratio_idc equal to 0 is "unspecified", 1 to 16 (inclusive) are specific Sample Aspect Ratios (SARs), 17 to 254 (inclusive) are "reserved", and 255 is the Extended SAR, where the SAR width and SAR height are explicitly signaled ๐ง.
So a receiver with a decoder according to [1] understands aspect_ratio_idc from 1 to 16 (inclusive), plus aspect_ratio_idc equal to 255, in the sense that it knows exactly what the SAR is ๐. For that receiver, sar-understood is 16 ๐. If Table E-1 of [1] gets extended someday (say, the SAR for aspect_ratio_idc equal to 17 gets specified), then a receiver with a decoder that understands the extension has sar-understood equal to 17 ๐. For a receiver with a decoder according to the 2003 version of [1], sar-understood is 13, because the minimum reserved aspect_ratio_idc in that version is 14 ๐.
When sar-understood isn't present, its value MUST be inferred to be equal to 13 โจ.
sar-supported: This parameter MAY be used to indicate a receiver capability and nothing else ๐ . Its value is an integer from 1 to sar-understood, inclusive, or equal to 255 ๐ซถ. A value of sar-supported equal to N, where N is smaller than 255, means the receiver supports all the SARs for H.264 aspect_ratio_idc values (see Table E-1 of [1]) from 1 to N, inclusive, without geometric distortion ๐ธ. A value of 255 means the receiver supports all sample aspect ratios that can be expressed using two 16-bit integer values as the numerator and denominator, that is, the ones expressible with the H.264 aspect_ratio_idc value of 255 (Extended_SAR, see Table E-1 of [1]), again without geometric distortion ๐ฆ.
H.264-compliant encoders SHOULD NOT send an aspect_ratio_idc equal to 0, or an aspect_ratio_idc larger than sar-understood and smaller than 255 ๐. H.264-compliant encoders SHOULD send an aspect_ratio_idc that the receiver can display without geometrical distortion ๐ฅ. However, H.264-compliant encoders MAY choose to send pictures using any SAR ๐.
Note that the actual sample aspect ratio, or extended sample aspect ratio when present, of the stream is carried in the Video Usability Information (VUI) part of the sequence parameter set ๐.
Encoding considerations: This type is only defined for transfer via RTP (RFC 3550) ๐.
Security considerations: See Section 9 of RFC 6184 ๐.
Public specification: Please refer to RFC 6184 and its Section 17 ๐.
Additional information: None โจ
File extensions: none Macintosh file type code: none
Object identifier or OID: none
Person & email address to contact for further information: Ye-Kui Wang, yekui.wang@huawei.com ๐
Intended usage: COMMON ๐
Author: Ye-Kui Wang, yekui.wang@huawei.com ๐ง
Change controller: IETF Audio/Video Transport working group delegated from the IESG ๐
8.2. SDP Parameters โจ
The receiver MUST ignore any parameter that isn't specified in this memo ๐.
8.2.1. Mapping of Payload Type Parameters to SDP ๐ฆ
The media type video/H264 string is mapped to fields in the Session Description Protocol (SDP) [6] like this ๐ :
- The media name in the
m=line of SDP MUST be video. - The encoding name in the
a=rtpmapline of SDP MUST be H264 (the media subtype). - The clock rate in the
a=rtpmapline MUST be 90000. - The OPTIONAL parameters profile-level-id, max-recv-level, max-mbps, max-smbps, max-fs, max-cpb, max-dpb, max-br, redundant-pic-cap, use-level-src-parameter-sets, in-band-parameter-sets, level-asymmetry-allowed, packetization-mode, sprop-interleaving-depth, sprop-deint-buf-req, deint-buf-cap, sprop-init-buf-time, sprop-max-don-diff, max-rcmd-nalu-size, sar-understood, and sar-supported, when present, MUST be included in the
a=fmtpline of SDP ๐ธ. These parameters are expressed as a media type string, in the form of a semicolon-separated list of parameter=value pairs ๐. - The OPTIONAL parameters sprop-parameter-sets and sprop-level-parameter-sets, when present, MUST be included in the
a=fmtpline of SDP, or conveyed using thefmtpsource attribute as specified in Section 6.3 of [9] ๐ฅ. For a particular media format (i.e., RTP payload type), a sprop-parameter-sets or sprop-level-parameter-sets MUST NOT be both included in thea=fmtpline of SDP and conveyed using thefmtpsource attribute ๐. When included in thea=fmtpline of SDP, these parameters are expressed as a media type string, in the form of a semicolon-separated list of parameter=value pairs ๐. When conveyed using thefmtpsource attribute, these parameters are only associated with the given source and payload type as parts of thefmtpsource attribute ๐ฆ.
Informative note: Conveying sprop-parameter-sets and sprop-level-parameter-sets using the fmtp source attribute allows for out-of-band transport of parameter sets in topologies like Topo-Video-switch-MCU [29] ๐ง.
Here's an example of the media representation in SDP (Baseline profile, Level 3.0, some of the constraints of the Main profile may not be obeyed) ๐:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E;
packetization-mode=1;
sprop-parameter-sets=<parameter sets data>
8.2.2. Usage with the SDP Offer/Answer Model ๐
When H.264 is offered over RTP using SDP in an Offer/Answer model [8] for negotiation for unicast usage, the following limitations and rules apply ๐:
- The parameters identifying a media format configuration for H.264 are profile-level-id and packetization-mode. These media format configuration parameters (except for the level part of profile-level-id) MUST be used symmetrically; that is, the answerer MUST either maintain all configuration parameters or remove the media format (payload type) completely if one or more of the parameter values are not supported ๐ญ. Note that the level part of profile-level-id includes level_idc, and, for indication of Level 1b when profile_idc is equal to 66, 77, or 88, bit 4 (constraint_set3_flag) of profile-iop. The level part of profile-level-id is changeable ๐.
Informative note: The requirement for symmetric use does not apply for the level part of profile-level-id, and does not apply for the other stream properties and capability parameters ๐ซถ.
โจ Informative note: okay so in H.264 [1], every level except Level 1b is justlevel_idcdivided by 10 ๐งฎ. Level 1b sits between Level 1.0 and Level 1.1, but it gets signalled in an ad hoc way because it was specified after both of those ๐. For the Baseline, Main, and Extended profiles (withprofile_idcequal to 66, 77, and 88, respectively), Level 1b is indicated bylevel_idcequal to 11 (same as Level 1.1) plusconstraint_set3_flagequal to 1 ๐. For other profiles, Level 1b is indicated bylevel_idcequal to 9. Level 1b is still higher than Level 1 (level_idc10) and lower than Level 1.1 ๐. In SDP Offer/Answer, an answer can indicate a level equal to or lower than the level in the offer. Because Level 1b is so ad hoc, offerers and answerers must check bit 4 (constraint_set3_flag) of the middle octet ofprofile-level-idwhenprofile_idcis 66, 77, or 88 andlevel_idcis 11 ๐.
To keep these configurations easy to match, the same RTP payload type number used in the offer SHOULD also be used in the answer, as specified in [8]. An answer MUST NOT contain the payload type number used in the offer unless the configuration is exactly the same as in the offer ๐ธ.
โจ Informative note: when an offerer gets an answer, it has to compare payload types that weren't declared in the offer, based on the media type (video/H264) and the media configuration parameters above, with any payload types it has already declared. That's how it figures out whether the configuration is new or equivalent to one already offered, since a different payload type number may show up in the answer ๐ฆ.
- When present, the parameter
max-recv-leveldeclares the highest level supported for receiving. Ifmax-recv-levelis not present, the highest level supported for receiving is equal to the default level indicated by the level part ofprofile-level-id. When present,max-recv-levelMUST be higher than the default level ๐. - The parameter
level-asymmetry-allowedindicates whether level asymmetry is allowed ๐ซถ.
If level-asymmetry-allowed is equal to 0 (or not present) in either the offer or the answer, level asymmetry is not allowed. In this case, the level to use in the direction from the offerer to the answerer MUST be the same as the level to use in the opposite direction, and the common level to use is equal to the lower value of the default level in the offer and the default level in the answer ๐
โโ๏ธ.
Otherwise, level-asymmetry-allowed equals 1 in both the offer and the answer, and level asymmetry is allowed. In this case, the level to use in the offerer-to-answerer direction MUST be equal to the highest level the answerer supports for receiving, and the level to use in the answerer-to-offerer direction MUST be equal to the highest level the offerer supports for receiving ๐ฅ.
When level asymmetry is not allowed, level upgrade is not allowed either, i.e., the default level in the answer MUST be equal to or lower than the default level in the offer ๐ซโฌ๏ธ.
- The parameters
sprop-deint-buf-req,sprop-interleaving-depth,sprop-max-don-diff, andsprop-init-buf-timedescribe the properties of the RTP packet stream that the offerer or answerer is sending for the media format configuration. This is different from the usual Offer/Answer parameters, which normally declare the properties of the stream the offerer or answerer is able to receive. When dealing with H.264, the offerer assumes the answerer will be able to receive media encoded using the configuration being offered ๐.
โจ Informative note: these parameters apply to any stream sent by a declaring entity with the same configuration. In other words, they depend on their source. Rather than being bound to the payload type, the values may have to be applied to another payload type when being sent, because they apply to the configuration ๐ง.
- The capability parameters
max-mbps,max-smbps,max-fs,max-cpb,max-dpb,max-br,redundant-pic-cap,max-rcmd-nalu-size,sar-understood, andsar-supportedMAY be used to declare further capabilities of the offerer or answerer for receiving. These parameters MUST NOT be present when the direction attribute is "sendonly", and when the parameters describe the limitations of what the offerer or answerer accepts for receiving streams ๐. - An offerer has to include the size of the de-interleaving buffer,
sprop-deint-buf-req, in the offer for an interleaved H.264 stream ๐. So both sides can tell each other what they can handle for de-interleaving buffering in receiving streams, both parties are RECOMMENDED to includedeint-buf-cap. For interleaved streams, it is also RECOMMENDED to consider offering multiple payload types with different buffering requirements when the receiver's capabilities are unknown ๐. - The
sprop-parameter-setsorsprop-level-parameter-setsparameter, when present (included in thea=fmtpline of SDP, or conveyed using thefmtpsource attribute as specified in Section 6.3 of [9]), is used for out-of-band transport of parameter sets. However, when out-of-band transport of parameter sets is used, parameter sets MAY still be additionally transported in-band ๐ง .
The answerer MAY use either out-of-band or in-band transport of parameter sets for the stream it is sending, regardless of whether out-of-band parameter set transport was used in the offerer-to-answerer direction. Parameter sets included in an answer are independent of the ones included in the offer, because they are used for decoding two different video streams: one from the answerer to the offerer, and the other in the opposite direction ๐.
The following rules apply to transport of parameter sets in the offerer-to-answerer direction:
- An offer MAY include either or both of
sprop-parameter-setsandsprop-level-parameter-sets. If neithersprop-parameter-setsnorsprop-level-parameter-setsis present in the offer, then only in-band transport of parameter sets is used โจ. - If the answer includes
in-band-parameter-setsequal to 1, then the offerer MUST transmit parameter sets in-band. Otherwise, the following applies:- If the level to use in the offerer-to-answerer direction is equal to the default level in the offer, the following applies:
When there is a sprop-parameter-sets included in the a=fmtp line in the offer, the answerer MUST be prepared to use the parameter sets included in the sprop-parameter-sets for decoding the incoming NAL unit stream ๐.
When there is a sprop-parameter-sets conveyed using the fmtp source attribute in the offer, the following applies. If the answer includes use-level-src-parameter-sets equal to 1 or the fmtp source attribute, the answerer MUST be prepared to use the parameter sets included in the sprop-parameter-sets for decoding the incoming NAL unit stream. Otherwise, the offerer MUST transmit parameter sets in-band ๐ซ .
When sprop-parameter-sets is not present in the offer, the offerer MUST transmit parameter sets in-band ๐ฅฒ.
The answerer MUST ignore sprop-level-parameter-sets, when present (either included in the a=fmtp line or conveyed using the fmtp source attribute) in the offer ๐.
- Otherwise, the level to use in the offerer-to-answerer direction is not equal to the default level in the offer, and the following applies:
The answerer MUST ignore sprop-parameter-sets, when present (either included in the a=fmtp line or conveyed using the fmtp source attribute) in the offer.
When neither use-level-src-parameter-sets is equal to 1 nor the fmtp source attribute is present in the answer, the answerer MUST ignore sprop-level-parameter-sets, when present in the offer, and the offerer MUST transmit parameter sets in-band.
When either use-level-src-parameter-sets is equal to 1 or the fmtp source attribute is present in the answer, the answerer MUST be prepared to use the parameter sets that are included in sprop-level-parameter-sets for the accepted level (i.e., the default level in the answer), when present in the offer, for decoding the incoming NAL unit stream, and ignore all other parameter sets included in sprop-level-parameter-sets ๐ฐ.
When no parameter sets for the level to use in the offerer-to-answerer direction are present in sprop-level-parameter-sets in the offer, the offerer MUST transmit parameter sets in-band ๐ญ.
The following rules apply to the transport of parameter sets in the answerer-to-offerer direction:
- An answer MAY include either
sprop-parameter-setsorsprop-level-parameter-setsbut MUST NOT include both. If neithersprop-parameter-setsnorsprop-level-parameter-setsis present in the answer, then only in-band transport of parameter sets is used ๐ . - If the offer includes
in-band-parameter-setsequal to 1, the answerer MUST NOT includesprop-parameter-setsorsprop-level-parameter-setsin the answer and MUST transmit parameter sets in-band. Otherwise, the following applies:- If the level to use in the answerer-to-offerer direction is equal to the default level in the answer, the following applies:
When there is a sprop-parameter-sets included in the a=fmtp line in the answer, the offerer MUST be prepared to use the parameter sets included in the sprop-parameter-sets for decoding the incoming NAL unit stream ๐ธ.
okay bestie, so when the answer has a sprop-parameter-sets conveyed through the "fmtp" source attribute ๐ the offerer and answerer have to be super careful about who sends what. ngl this is the part where everyone gets confused, so let's go slowly ๐ซถ
If the offer has use-level-src-parameter-sets equal to 1 or the "fmtp" source attribute, the offerer MUST be prepared to use the parameter sets included in the sprop-parameter-sets for decoding the incoming NAL unit stream. Otherwise, the answerer MUST transmit parameter sets in-band. ๐
When sprop-parameter-sets is not present in the answer, the answerer MUST transmit parameter sets in-band. no cap, that's the backup plan ๐ง
The offerer MUST ignore sprop-level-parameter-sets, when present (either included in the a=fmtp line or conveyed using the "fmtp" source attribute) in the answer. ๐
- Otherwise, the level to use in the answerer-to-offerer direction is not equal to the default level in the answer, and the following applies. ๐ธ
The offerer MUST ignore sprop-parameter-sets when present (either included in the a=fmtp line of SDP or conveyed using the "fmtp" source attribute) in the answer.
When neither use-level-src-parameter-sets is equal to 1 nor the "fmtp" source attribute is present in the offer, the offerer MUST ignore sprop-level-parameter-sets, when present, and the answerer MUST transmit parameter sets in-band. ๐ญ
When either use-level-src-parameter-sets is equal to 1 or the "fmtp" source attribute is present in the offer, the offerer MUST be prepared to use the parameter sets that are included in sprop-level-parameter-sets for the level to use in the answerer-to-offerer direction, when present in the answer, for decoding the incoming NAL unit stream, and ignore all other parameter sets included in sprop-level-parameter-sets in the answer. โจ
When no parameter sets for the level to use in the answerer-to-offerer direction are present in sprop-level-parameter-sets in the answer, the answerer MUST transmit parameter sets in-band. ๐
When sprop-parameter-sets or sprop-level-parameter-sets is conveyed using the "fmtp" source attribute as specified in Section 6.3 of [9], the receiver of the parameters MUST store the parameter sets included in the sprop-parameter-sets or sprop-level-parameter-sets for the accepted level and associate them with the source given as a part of the "fmtp" source attribute. Parameter sets associated with one source MUST only be used to decode NAL units conveyed in RTP packets from the same source. When this mechanism is in use, SSRC collision detection and resolution MUST be performed as specified in [9]. ๐ฆ
Informative note: Conveyance ofsprop-parameter-setsandsprop-level-parameter-setsusing the "fmtp" source attribute may be used in topologies like Topo-Video-switch-MCU [29] to enable out-of-band transport of parameter sets. ๐
For streams being delivered over multicast, the following rules apply: ๐
- The media format configuration is identified by "profile-level-id", including the level part, and packetization-mode. These media format configuration parameters (including the level part of profile-level-id) MUST be used symmetrically; that is, the answerer MUST either maintain all configuration parameters or remove the media format (payload type) completely. Note that this implies that the level part of profile-level-id for Offer/Answer in multicast is not changeable.
To simplify the handling and matching of these configurations, the same RTP payload type number used in the offer SHOULD also be used in the answer, as specified in [8]. An answer MUST NOT contain a payload type number used in the offer unless the configuration is the same as in the offer. ๐
- Parameter sets received MUST be associated with the originating source and MUST only be used in decoding the incoming NAL unit stream from the same source. ๐
- The rules for other parameters are the same as above for unicast as long as the above rules are obeyed. ๐ซถ
Table 6 lists the interpretation of all the media type parameters that MUST be used for the different direction attributes. This is the cheat sheet, bestie ๐
Table 6. Interpretation of parameters for different direction
attributes
sendonly --+
recvonly --+ |
sendrecv --+ | |
| | |
profile-level-id C C P
max-recv-level R R -
packetization-mode C C P
sprop-deint-buf-req P - P
sprop-interleaving-depth P - P
sprop-max-don-diff P - P
sprop-init-buf-time P - P
max-mbps R R -
max-smbps R R -
max-fs R R -
max-cpb R R -
max-dpb R R -
max-br R R -
redundant-pic-cap R R -
deint-buf-cap R R -
max-rcmd-nalu-size R R -
sar-understood R R -
sar-supported R R -
in-band-parameter-sets R R -
use-level-src-parameter-sets R R -
level-asymmetry-allowed O - -
sprop-parameter-sets S - S
sprop-level-parameter-sets S - S
Legend:
C: configuration for sending and receiving streams
O: offer/answer mode
P: properties of the stream to be sent
R: receiver capabilities
S: out-of-band parameter sets
-: not usable (when present, SHOULD be ignored)
Parameters used for declaring receiver capabilities are in general downgradable, which means they express the upper limit for a sender's possible behavior. Thus, a sender MAY select to set its encoder using only lower/less or equal values of these parameters. ๐ง
Parameters declaring a configuration point are not changeable, with the exception of the level part of the profile-level-id parameter for unicast usage. ๐
When a sender's capabilities are declared and non-downgradable parameters are used in this declaration, these parameters express a configuration that is acceptable for the sender to receive streams. In order to achieve high interoperability levels, it is often advisable to offer multiple alternative configurations, e.g., for the packetization mode. It is impossible to offer multiple configurations in a single payload type. Thus, when multiple configuration offers are made, each offer requires its own RTP payload type associated with the offer. ๐ฐ
A receiver SHOULD understand all media type parameters, even if it only supports a subset of the payload format's functionality. This ensures that a receiver is capable of understanding when an offer to receive media can be downgraded to what is supported by the receiver of the offer. ๐
An answerer MAY extend the offer with additional media format configurations. However, to enable their usage, in most cases, a second offer is required from the offerer to provide the stream property parameters that the media sender will use. This also has the effect that the offerer has to be able to receive this media format configuration, not only to send it. ๐ท
If an offerer wishes to have non-symmetric capabilities between sending and receiving, the offerer can allow asymmetric levels via level-asymmetry-allowed being equal to 1. Alternatively, the offerer could offer different RTP sessions, i.e., different media lines declared as "recvonly" and "sendonly", respectively. This may have further implications on the system and may require additional external semantics to associate the two media lines. ๐งฉ
8.2.3. Usage in Declarative Session Descriptions โจ
When H.264 over RTP is offered with SDP in a declarative style, as in Real Time Streaming Protocol (RTSP) [27] or Session Announcement Protocol (SAP) [28], the following considerations are necessary. ๐ก
- All parameters capable of indicating both stream properties and receiver capabilities are used to indicate only stream properties. For example, in this case, the parameter
profile-level-iddeclares only the values used by the stream, not the capabilities for receiving streams. The result of this is that the following interpretation of the parameters MUST be used:
Declaring actual configuration or stream properties:
profile-level-idpacketization-modesprop-interleaving-depthsprop-deint-buf-reqsprop-max-don-diffsprop-init-buf-time
Out-of-band transporting of parameter sets:
sprop-parameter-setssprop-level-parameter-sets
Not usable (when present, they SHOULD be ignored):
max-mbpsmax-smbpsmax-fsmax-cpbmax-dpbmax-brmax-recv-levelredundant-pic-capmax-rcmd-nalu-sizedeint-buf-capsar-understoodsar-supportedin-band-parameter-setslevel-asymmetry-alloweduse-level-src-parameter-sets
- A receiver of the SDP is required to support all parameters and values of the parameters provided; otherwise, the receiver MUST reject (RTSP) or not participate in (SAP) the session. It falls on the creator of the session to use values that are expected to be supported by the receiving application. ๐ซ
8.3. Examples ๐ฌ
An SDP Offer/Answer exchange wherein both parties are expected to both send and receive could look like the following. Only the media-codec-specific parts of the SDP are shown. Some lines are wrapped due to text constraints. ๐
Offerer -> Answerer SDP message:
m=video 49170 RTP/AVP 100 99 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; packetization-mode=0;
sprop-parameter-sets=<parameter sets data#0>
a=rtpmap:99 H264/90000
a=fmtp:99 profile-level-id=42A01E; packetization-mode=1;
sprop-parameter-sets=<parameter sets data#1>
a=rtpmap:100 H264/90000
a=fmtp:100 profile-level-id=42A01E; packetization-mode=2;
sprop-parameter-sets=<parameter sets data#2>;
sprop-interleaving-depth=45; sprop-deint-buf-req=64000;
sprop-init-buf-time=102478; deint-buf-cap=128000
Okay so the offer is giving three different packetization looks at once ๐ โจ Payload type 98 is single NALU mode ๐, payload type 99 is non-interleaved mode ๐ฆ, and payload type 100 is interleaved mode ๐ธ. For the interleaved one, the offerer also includes the interleaving parameters it would use if the answer picks payload type 100 ๐ง. In all three cases, sprop-parameter-sets carries the initial parameter sets that the answerer needs when it's receiving a stream from the offerer, once this config is accepted. ngl the value for sprop-parameter-sets can be different for each payload type ๐
Answerer -> Offerer SDP message:
m=video 49170 RTP/AVP 100 99 97
a=rtpmap:97 H264/90000
a=fmtp:97 profile-level-id=42A01E; packetization-mode=0;
sprop-parameter-sets=<parameter sets data#3>
a=rtpmap:99 H264/90000
a=fmtp:99 profile-level-id=42A01E; packetization-mode=1;
sprop-parameter-sets=<parameter sets data#4>;
max-rcmd-nalu-size=3980
a=rtpmap:100 H264/90000
a=fmtp:100 profile-level-id=42A01E; packetization-mode=2;
sprop-parameter-sets=<parameter sets data#5>;
sprop-interleaving-depth=60;
sprop-deint-buf-req=86000; sprop-init-buf-time=156320;
deint-buf-cap=128000; max-rcmd-nalu-size=3980
As Offer/Answer negotiation covers both sending and receiving streams ๐ซถ, an offer shows the exact parameters for what the offerer is willing to receive, and the answer shows the same thing for what the answerer is willing to receive ๐ Here, the offerer said it's willing to receive payload type 98. The answerer accepts that by declaring an equivalent payload type 97 ๐. It has identical values for profile-level-id and packetization-mode (packetization-mode is 0 and sprop-deint-buf-req isn't present, so that's the match) โจ Now that payload type 98 is accepted, the answerer needs to store the parameter sets in sprop-parameter-sets=<parameter sets data#0> in case the offer decides to actually use this config ๐ In the answer, it includes the parameter sets in sprop-parameter-sets=<parameter sets data#3>, which are the ones it would use for the stream it sends if this config ends up being used ๐ฆ
The answerer also accepts receiving the two configs that payload types 99 and 100 represent ๐ธ Again, it needs to store the parameter sets in sprop-parameter-sets=<parameter sets data#1> and sprop-parameter-sets=<parameter sets data#2> in case the offer goes with either of these ๐ง For the answerer-to-offerer direction, it provides the initial parameter sets it will use to send payload types 99 and 100: sprop-parameter-sets=<parameter sets data#4> and sprop-parameter-sets=<parameter sets data#5>, respectively ๐ It also tells the offerer its memory limit for de-interleaving operations with a deint-buf-cap parameter ๐
That's only useful if the offerer decides to make a second offer, where it can take the new value into account ๐ The max-rcmd-nalu-size says the answerer can efficiently process NALUs up to 3980 bytes ๐ฅ BUT there's no guarantee that the network supports this size ๐
In this example, the offer is accepted without level downgrading (so the default level, Level 3.0, is accepted) ๐ Both sprop-parameter-sets and sprop-level-parameter-sets are in the offer. The answerer must ignore sprop-level-parameter-sets=<parameter sets data#1> and store the parameter sets in sprop-parameter-sets=<parameter sets data#0> for decoding the incoming NAL unit stream โจ The offerer must store the parameter sets in sprop-parameter-sets=<parameter sets data#2> from the answer for decoding the incoming NAL unit stream ๐ซถ Note that in this example, the parameter sets in sprop-parameter-sets=<parameter sets data#2> must be associated with Level 3.0 ๐
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#0>;
sprop-level-parameter-sets=<parameter sets data#1>
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#2>
In this one, the offer (Baseline profile, Level 1.1) gets accepted with level downgrading, so the accepted level is Level 1b ๐ฆ Both sprop-parameter-sets and sprop-level-parameter-sets are present in the offer. The answerer must ignore sprop-parameter-sets=<parameter sets data#0> and every parameter set that isn't for the accepted level (Level 1b) in sprop-level-parameter-sets=<parameter sets data#1> ๐
It must store the parameter sets for Level 1b in sprop-level-parameter-sets=<parameter sets data#1> for decoding the incoming NAL unit stream ๐ธ The offerer must store the parameter sets in sprop-parameter-sets=<parameter sets data#2> from the answer for decoding the incoming NAL unit stream ๐ง Note that the parameter sets in sprop-parameter-sets=<parameter sets data#2> must be associated with Level 1b ๐
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A00B; //Baseline profile, Level 1.1
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#0>;
sprop-level-parameter-sets=<parameter sets data#1>
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42B00B; //Baseline profile, Level 1b
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#2>;
use-level-src-parameter-sets=1
Now this one is the same kind of offer (Baseline profile, Level 1.1) accepted with level downgrading to Level 1b ๐ Both sprop-parameter-sets and sprop-level-parameter-sets show up in the offer. BUT the answerer is a legacy RFC 3984 implementation ๐ It doesn't understand sprop-level-parameter-sets, so it doesn't put use-level-src-parameter-sets (which it doesn't understand either) in the answer ๐ So the answerer must ignore both sprop-parameter-sets=<parameter sets data#0> and sprop-level-parameter-sets=<parameter sets data#1>, and the offerer must transport parameter sets in-band ๐ซถ
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A00B; //Baseline profile, Level 1.1
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#0>;
sprop-level-parameter-sets=<parameter sets data#1>
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42B00B; //Baseline profile, Level 1b
packetization-mode=1
In this example, the offer is accepted without level downgrading, and sprop-parameter-sets is in the offer ๐ The parameter sets in sprop-parameter-sets=<parameter sets data#0> must be stored and used by the encoder of the offerer and the decoder of the answerer ๐ฆ The parameter sets in sprop-parameter-sets=<parameter sets data#1> must be used by the encoder of the answerer and the decoder of the offerer ๐ธ Note that sprop-parameter-sets=<parameter sets data#0> is basically independent of sprop-parameter-sets=<parameter sets data#1> โจ
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#0>
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#1>
Next up, the offer is accepted without level downgrading, and NEITHER sprop-parameter-sets NOR sprop-level-parameter-sets is in the offer ๐ง That means there's no out-of-band transmission of parameter sets, so they have to be sent in-band ๐
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1
In this example, the offer is accepted with level downgrading and sprop-parameter-sets is in the offer ๐ Here's the tea: sprop-parameter-sets=<parameter sets data#0> contains level_idc indicating Level 3.0 ๐ The answerer wants Level 2.0, so that config can't be used. The answerer must ignore it, and in-band parameter sets must be used instead ๐
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1;
sprop-parameter-sets=<parameter sets data#0>
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A014; //Baseline profile, Level 2.0
packetization-mode=1
Also accepted with level downgrading in this one ๐ฆ Neither sprop-parameter-sets nor sprop-level-parameter-sets is in the offer, so again there's no out-of-band transmission and the parameter sets have to go in-band ๐ซถ
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A014; //Baseline profile, Level 2.0
packetization-mode=1
And the last one ๐ The offer is accepted with level upgrading, and neither sprop-parameter-sets nor sprop-level-parameter-sets is in the offer or the answer, so there's no out-of-band transmission and everything goes in-band ๐ง The level for the offerer-to-answerer direction is Level 3.0, and the level for the answerer-to-offerer direction is Level 2.0 ๐ The answerer can send at any level up to and including Level 2.0, and the offerer can send at any level up to and including Level 3.0 ๐ โจ
Offer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A014; //Baseline profile, Level 2.0
packetization-mode=1; level-asymmetry-allowed=1
Answer SDP:
m=video 49170 RTP/AVP 98
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1; level-asymmetry-allowed=1
Okay so picture this: the offerer is a Multipoint Control Unit (MCU) ๐ in a topology like Topo-Video-switch-MCU [29], and it's offering parameter sets it got (over out-of-band transport) from three other participants, B, C, and D. The answerer is participant A. Everyone is identified by their CNAME, and each CNAME maps to its own SSRC value. And the same codec configuration is used by all four of them. ๐ซถ
So participant A stores and associates the stuff in <parameter sets data#B>, <parameter sets data#C>, and <parameter sets data#D> with B, C, and D. Then it uses each set only for decoding NAL units from its own person's RTP packets. Like, <parameter sets data#B> is only for B's packets, <parameter sets data#C> is only for C's, and <parameter sets data#D> is only for D's. Iconic sorting energy ๐ โจ
Offer SDP:
m=video 49170 RTP/AVP 98
a=ssrc:SSRC-B cname:CNAME-B
a=ssrc:SSRC-C cname:CNAME-C
a=ssrc:SSRC-D cname:CNAME-D
a=ssrc:SSRC-B fmtp:98
sprop-parameter-sets=<parameter sets data#B>
a=ssrc:SSRC-C fmtp:98
sprop-parameter-sets=<parameter sets data#C>
a=ssrc:SSRC-D fmtp:98
sprop-parameter-sets=<parameter sets data#D>
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1
Answer SDP:
m=video 49170 RTP/AVP 98
a=ssrc:SSRC-A cname:CNAME-A
a=ssrc:SSRC-A fmtp:98
sprop-parameter-sets=<parameter sets data#A>
a=rtpmap:98 H264/90000
a=fmtp:98 profile-level-id=42A01E; //Baseline profile, Level 3.0
packetization-mode=1
8.4. Parameter Set Considerations ๐ธ
Okay the H.264 parameter sets are a fundamental part of the video codec and super vital to how it works (see Section 1.2) ๐. Because of what they are and how much the decoder depends on them, lost or wrongly transmitted parameter sets can barely be hidden locally at the receiver ๐ญ. If a reference points to a corrupt parameter set, that normally has fatal results for decoding. The corruption could happen from an erroneous transmission or loss of a parameter set NAL unit, but also from a parameter set update that shows up at the wrong time.
Quick definition, bestie: a parameter set update means at least one parameter in a picture parameter set or sequence parameter set changes, while that set's identifier stays exactly the same ๐ฆ. So, these recommendations are written as a guideline for the implementer of the RTP sender. Let's get into it.
Parameter set NALUs can be transported using three different principles:
A. Using a session control protocol (out-of-band) prior to the actual RTP session.
B. Using a session control protocol (out-of-band) during an ongoing RTP session.
C. Within the RTP packet stream in the payload (in-band) during an ongoing RTP session.
It is recommended to implement principles A and B within a session control protocol ๐ง. SIP and SDP can be used as described in the SDP Offer/Answer model and in the previous sections of this memo. Section 8.2.2 has a detailed discussion on transporting parameter sets in-band or out-of-band in SDP Offer/Answer, using the media type parameters sprop-parameter-sets, sprop-level-parameter-sets, use-level-src-parameter-sets, and in-band-parameter-sets. This section is the guidance on how principles A and B should be implemented within session control protocols, and it's independent of whichever protocol you're using. Principle C is supported by the RTP payload format defined in this specification. There are topologies like Topo-Video-switch-MCU [29] where principle C may be desirable ๐.
If in-band signaling of parameter sets is used, the picture and sequence parameter set NALUs SHOULD be transmitted in the RTP payload using a reliable method of delivering RTP (see below), because losing a parameter set of either type will likely stop decoding of a big chunk of the corresponding RTP packet stream ๐.
If in-band signaling of parameter sets is used, the sender SHOULD take the error characteristics into account and use mechanisms that give a high probability of delivering the parameter sets correctly. Mechanisms that boost the chance of a correct reception include packet repetition, FEC, and retransmission. Using an unreliable, out-of-band control protocol has similar disadvantages to in-band signaling (possible loss) and, on top of that, may also lead to synchronization difficulties (see below). Therefore, it is NOT RECOMMENDED ๐.
Parameter sets MAY be added or updated during the lifetime of a session using principles B and C. It is required that parameter sets be present at the decoder prior to the NAL units that refer to them. Adding or updating parameter sets can cause more problems, so the following recommendations should be considered:
- When parameter sets are added or updated, care SHOULD be taken to make sure any parameter set is delivered before it's used. When new parameter sets are added, previously unused parameter set identifiers are used. It's common for there to be no synchronization between out-of-band signaling and in-band traffic. If out-of-band signaling is used, it is RECOMMENDED that a sender not start sending NALUs that need the added or updated parameter sets before it gets an acknowledgement of delivery from the signaling protocol.
- When parameter sets are updated, the following synchronization issue should be taken into account. When overwriting a parameter set at the receiver, the sender has to make sure that the parameter set in question isn't needed by any NALU still in the network or in receiver buffers. Otherwise, decoding with a wrong parameter set may happen. To lessen this problem, it is RECOMMENDED either to overwrite only parameter sets that haven't been used for a long enough time (so all the related NALUs have been consumed), or to add a new parameter set instead (which may have negative consequences for the efficiency of the video coding) ๐.
Informative note: In some topologies like Topo-Video-switch-MCU [29], the origin of the whole set of parameter sets may come from multiple sources that may use non-unique parameter set identifiers. In this case, an offer may overwrite an existing parameter set if no other mechanism that enables uniqueness of the parameter sets in the out-of-band channel exists.
- In a multiparty session, one participant MUST associate parameter sets coming from different sources with the source identification whenever possible, e.g., by conveying out-of-band transported parameter sets, because different sources typically use independent parameter set identifier value spaces. ๐ฆ
- Adding or modifying parameter sets by using both principles B and C in the same RTP session may lead to inconsistencies in the parameter sets, because the control channel and the RTP channel aren't synchronized. Therefore, principles B and C MUST NOT both be used in the same session unless sufficient synchronization can be provided ๐ซ.
In some scenarios (e.g., when only the subset of this payload format specification corresponding to H.241 is used) or topologies, it is not possible to use out-of-band parameter set transmission. In that case, parameter sets have to be sent in-band. Here the synchronization with the non-parameter-set data in the bitstream is implicit, but the possibility of a loss has to be taken into account.
The loss probability should be reduced using the mechanisms discussed above. If a loss of a parameter set is detected, recovery may be achieved with a Decoder Refresh Point procedure, for example using RTCP feedback Full Intra Request (FIR) [30]. Two example Decoder Refresh Point procedures are provided in the informative Section 8.5 โจ.
- When parameter sets are initially provided using principle A and then later added or updated in-band (principle C), there's a risk tied to updating the parameter sets that were delivered out-of-band. If receivers miss some in-band updates (for example, because of a loss or a late tune-in), those receivers attempt to decode the bitstream using outdated parameters. It is therefore RECOMMENDED that parameter set IDs be partitioned between the out-of-band and in-band parameter sets ๐.
8.5. Decoder Refresh Point Procedure Using In-Band Transport of Parameter Sets (Informative) ๐ง
Okay so when a sender with a video encoder according to [1] gets a request for a decoder refresh point, the encoder shall enter the fast update mode by using one of the procedures specified in Sections 8.5.1 or 8.5.2. The procedure in Section 8.5.1 is the preferred response in a lossless transmission environment. Both procedures satisfy the requirement to enter the fast update mode for H.264 video encoding ๐.
8.5.1. IDR Procedure to Respond to a Request for a Decoder Refresh Point ๐
This section gives one possible way to respond to a request for a decoder refresh point.
The encoder shall, in the order presented here:
- Immediately prepare to send an IDR picture.
- Send a sequence parameter set to be used by the IDR picture to be sent. The encoder may optionally also send other sequence parameter sets.
- Send a picture parameter set to be used by the IDR picture to be sent. The encoder may optionally also send other picture parameter sets.
- Send the IDR picture.
- From this point forward in time, send any other sequence or picture parameter sets that have not yet been sent in this procedure, prior to their reference by any NAL unit, regardless of whether such parameter sets were previously sent before receiving the request for a decoder refresh point. As needed, such parameter sets may be sent in a batch, one at a time, or in any combination of these two methods. Parameter sets may be re-sent at any time for redundancy. Caution should be taken when parameter set updates are present, as described above in Section 8.4 โ ๏ธ.
8.5.2. Gradual Recovery Procedure to Respond to a Request for a Decoder Refresh Point ๐ธ
okay so this section gives you another way to respond when someone asks for a decoder refresh point ๐ it's like a second option, not the only one ๐
the encoder shall, in the order presented here:
- Send a recovery point SEI message (see Sections D.1.7 and D.2.7 of [1]).
- Repeat any sequence and picture parameter sets that were sent before the recovery point SEI message, prior to their reference by a NAL unit.
the encoder shall ensure that the decoder has access to all reference pictures for inter prediction of pictures at or after the recovery point, which is indicated by the recovery point SEI message, in output order, assuming that the transmission from now on is error-free. bestie this is the whole vibe: the decoder needs its reference pictures lined up for everything after that recovery point ๐โจ
the value of the recovery_frame_cnt syntax element in the recovery point SEI message should be small enough to ensure a fast recovery. ngl a small recovery_frame_cnt is the glow-up for quick recovery ๐ฆ
as needed, such parameter sets may be re-sent in a batch, one at a time, or in any combination of these two methods. parameter sets may be re-sent at any time for redundancy ๐ซถ redundancy is giving backup plan energy ๐ caution should be taken when parameter set updates are present, as described above in Section 8.4. ๐ญ that's the one with the parameter set update drama, so go reread it before you touch anything.
9. Security Considerations ๐
RTP packets using the payload format defined in this specification are subject to the security considerations discussed in the RTP specification [5] and in any appropriate RTP profile (for example, [16]). this implies that confidentiality of the media streams is achieved by encryption, for example, through the application of SRTP [26]. because the data compression used with this payload format is applied end-to-end, any encryption needs to be performed after compression. ๐ a potential denial-of-service threat exists for data encodings using compression techniques that have non-uniform receiver-end computational load. the attacker can inject pathological datagrams into the stream that are complex to decode and that cause the receiver to be overloaded. H.264 is particularly vulnerable to such attacks, as it is extremely simple to generate datagrams containing NAL units that affect the decoding process of many future NAL units. so, the usage of data origin authentication and data integrity protection of at least the RTP packet is RECOMMENDED, for example, with SRTP [26]. this part is serious, no cap ๐จ
note that the appropriate mechanism to ensure confidentiality and integrity of RTP packets and their payloads is very dependent on the application and on the transport and signaling protocols employed. thus, although SRTP is given as an example above, other possible choices exist. ๐ง
decoders MUST exercise caution with respect to the handling of user data SEI messages, particularly if they contain active elements, and MUST restrict their domain of applicability to the presentation containing the stream. ๐ decoders MUST be careful with user data SEI messages, especially the ones with active elements, and MUST keep them inside the presentation that holds the stream.
end-to-end security with either authentication, integrity, or confidentiality protection will prevent a MANE from performing media-aware operations other than discarding complete packets. in the case of confidentiality protection, it will even be prevented from discarding packets in a media-aware way. to be allowed to perform its operations, a MANE is required to be a trusted entity that is included in the security context establishment. ๐ main character energy for MANEs is being trusted and included in the security context, fr fr ๐
10. Congestion Control ๐
congestion control for RTP SHALL be used in accordance with RFC 3550 [5] and with any applicable RTP profile, e.g., RFC 3551 [16]. if best-effort service is being used, an additional requirement is that users of this payload format MUST monitor packet loss to ensure that the packet loss rate is within acceptable parameters. packet loss is considered acceptable if a TCP flow across the same network path, and experiencing the same network conditions, would achieve an average throughput, measured on a reasonable timescale, that is not less than the RTP flow is achieving. this condition can be satisfied by implementing congestion control mechanisms to adapt the transmission rate (or the number of layers subscribed for a layered multicast session) or by arranging for a receiver to leave the session if the loss rate is unacceptably high. ๐ฆ it's basically fairness with TCP, so don't hog the lane ๐๐จ
the bitrate adaptation necessary for obeying the congestion control principle is easily achievable when real-time encoding is used. however, when pre-encoded content is being transmitted, bandwidth adaptation requires the availability of more than one coded representation of the same content, at different bitrates, or the existence of non-reference pictures or sub-sequences [22] in the bitstream. the switching between the different representations can normally be performed in the same RTP session, e.g., by employing a concept known as SI/SP slices of the Extended profile or by switching streams at IDR picture boundaries. only when non-downgradable parameters (such as the profile part of the profile/level ID) are required to be changed does it become necessary to terminate and restart the media stream. this may be accomplished by using a different RTP payload type. ๐ so switching is smooth unless the non-downgradable stuff changes, and then it's a full restart arc ๐ญ
MANEs MAY follow the suggestions outlined in Section 7.3 and remove certain unusable packets from the packet stream when that stream was damaged due to previous packet losses. this can help reduce the network load in certain special cases. ๐งนโจ
11. IANA Considerations ๐๏ธ
the H264 media subtype name specified by RFC 3984 has been updated as defined in Section 8.1 of this memo. ๐ the name glow-up happened in Section 8.1, so go check there โจ
12. Informative Appendix: Application Examples ๐
this payload specification is very flexible in its use, in order to cover the extremely wide application space anticipated for H.264. however, this great flexibility also makes it difficult for an implementer to decide on a reasonable packetization scheme. some information on how to apply this specification to real-world scenarios is likely to appear in the form of academic publications and a test model software and description in the near future. however, some preliminary usage scenarios are described here as well. ๐๐ง
12.1. Video Telephony According to Annex A of ITU-T Recommendation H.241 ๐
H.323-based video telephony systems that use H.264 as an optional video compression scheme are required to support Annex A of H.241 [3] as a packetization scheme. the packetization mechanism defined in this Annex is technically identical with a small subset of this specification. ๐ธ
when a system operates according to Annex A of H.241, parameter set NAL units are sent in-band. only single NAL unit packets are used. many such systems are not sending IDR pictures regularly, but only when required by user interaction or by control protocol means, e.g., when switching between video channels in a Multipoint Control Unit or for error recovery requested by feedback. ๐๐
12.2. Video Telephony, No Slice Data Partitioning, No NAL Unit Aggregation ๐ฑ
the RTP part of this scheme is implemented and tested (though not the control-protocol part; see below). โ
in most real-world video telephony applications, picture parameters such as picture size or optional modes never change during the lifetime of a connection. therefore, all necessary parameter sets (usually only one) are sent as a side effect of the capability exchange/announcement process, e.g., according to the SDP syntax specified in Section 8.2 of this document. as all necessary parameter set information is established before the RTP session starts, there is no need for sending any parameter set NAL units. slice data partitioning is not used either. thus, the RTP packet stream basically consists of NAL units that carry single coded slices. ๐ซถ
the encoder chooses the size of coded slice NAL units so that they offer the best performance. often, this is done by adapting the coded slice size to the MTU size of the IP network. for small picture sizes, this may result in a one-picture-per-one-packet strategy. intra refresh algorithms clean up the loss of packets and the resulting drift-related artifacts. ๐งผโจ
12.3. Video Telephony, Interleaved Packetization Using NAL Unit Aggregation ๐งฉ
this scheme allows better error concealment and is used in H.263-based designs using RFC 4629 packetization [11]. it has been implemented, and good results were reported [13]. ๐
the VCL encoder codes the source picture so that all macroblocks (MBs) of one MB line are assigned to one slice. all slices with even MB row addresses are combined into one STAP, and all slices with odd MB row addresses are combined into another. those STAPs are transmitted as RTP packets. the establishment of the parameter sets is performed as discussed above. ๐
note that the use of STAPs is essential here, as the high number of individual slices (18 for a Common Intermediate Format (CIF) picture) would lead to unacceptably high IP/UDP/RTP header overhead (unless the source coding tool FMO is used, which is not assumed in this scenario). furthermore, some wireless video transmission systems, such as H.324M and the IP-based video telephony specified in 3GPP, are likely to use relatively small transport packet size. for example, a typical MTU size of H.223 AL3 SDU is around 100 bytes [17]. coding individual slices according to this packetization scheme provides further advantage in communication between wired and wireless networks, as individual slices are likely to be smaller than the preferred maximum packet size of wireless systems. consequently, a gateway can convert the STAPs used in a wired network into several RTP packets with only one NAL unit, which are preferred in a wireless network, and vice versa. ๐๐ถ gateways really be doing the translation dance between wired and wireless ๐
12.4. Video Telephony with Data Partitioning ๐ฆ
this scheme has been implemented and has been shown to offer good performance, especially at higher packet loss rates [13]. ๐ฅ
data partitioning is known to be useful only when some form of unequal error protection is available. normally, in single-session RTP environments, even error characteristics are assumed; that is, the packet loss probability of all packets of the session is the same statistically. however, there are means to reduce the packet loss probability of individual packets in an RTP session. a FEC packet according to RFC 5109 [18], for example, specifies which media packets are associated with the FEC packet. ๐ก๏ธ๐
in all cases, the incurred overhead is substantial but is in the same order of magnitude as the number of bits that have otherwise been spent for intra information. however, this mechanism does not add any delay to the system. โญ
again, the complete parameter set establishment is performed through control protocol means. ๐โจ
12.5. Video Telephony or Streaming with FUs and Forward Error Correction
okay this one is giving reliability ๐ก๏ธ bestie. It's been implemented and it performs really well, especially when packet loss gets high [19] ๐
The most efficient way to fight packet loss when retransmissions aren't an option is forward error correction (FEC) โจ Application layer, end-to-end FEC is often less efficient than FEC protecting each individual link, especially when the links on the transmission path have different characteristics. But it's unavoidable in some scenarios ๐ญ That's where [RFC5109] comes in. Its [18] framework gives you generic, application layer, end-to-end FEC for packet loss environments ๐ง A binary forward error correcting code is made by XORing the bits at the same bit position across different packets. The code is specified by the parameters (n,k), where k is the number of information packets in the connection and n is the total number of packets generated from those k information packets. So you get n-k parity packets for k information packets.
When you use a code with parameters (n,k) in the RFC 5109 framework, these properties are well known:
a) If it's applied over one RTP packet, RFC 5109 only gives you packet repetition ๐
b) RFC 5109 is most bitrate efficient when XOR-connected packets have equal length ๐
c) At the same packet loss probability p and a fixed k, the bigger n is, the smaller the residual error probability gets. For example, at a packet loss probability of 10%, with k=1 and n=2, the residual error probability is about 1%. With n=3, it's about 0.1% ๐ฅ
d) At the same packet loss probability p and a fixed code rate k/n, the bigger n is, the smaller the residual error probability gets. For example, at p=10%, with k=1 and n=2, the residual error rate is about 1%. But for an extended Golay code with k=12 and n=24, the residual error rate is about 0.01% ๐
For applying RFC 5109 together with H.264 baseline-coded video without using FUs, a few options might be considered:
- The video encoder produces NAL units where each video frame is coded in a single slice. With FEC, you could use a simple code, like
(n=2, k=1). So each NAL unit is basically just repeated. The downside is the bad code performance from d) above, plus low flexibility, since only(n, k=1)codes can be used ๐ญ - The video encoder produces NAL units where each video frame is encoded in one or more consecutive slices. With FEC, you could use a better code, like
(n=24, k=12), over a sequence of NAL units. Depending on how many RTP packets there are per frame, a loss may introduce a significant delay, and that delay gets smaller when more RTP packets are used per frame. Packets of completely different lengths might also be connected, which decreases bitrate efficiency according to b) above. However, with some care and for slices of 1 kb or larger, you can produce similar lengths (100-200 bytes difference), and that won't lower bit efficiency catastrophically ๐ - The video encoder produces NAL units where a certain frame contains
kslices of possibly almost equal length. Then, with FEC, you can use a better code, like(n=24, k=12), over the sequence of NAL units for each frame. The delay compared to 2) above may be reduced, but there are several obvious disadvantages. First, the coding efficiency of the encoded video drops significantly, because slice-structured coding reduces intra-frame prediction and adds slice overhead. Second, pre-encoded content, or video passing through a gateway, usually isn't coded withkslices in a way that FEC can be applied to. Finally, encoding video that produceskslices of equal length isn't straightforward and might take more than one encoding pass ๐ธ
Lots of these disadvantages can be avoided by applying FUs together with FEC โจ Each NAL unit can be split into any number of FUs of basically equal length. That means FEC with a reasonable k and n can be applied even if the encoder made no effort to produce slices of equal length. For example, a coded slice NAL unit containing an entire frame can be split into k FUs, and a parity check code (n=k+1, k) can be applied. However, this has a catch: unless all the created fragments can be recovered, the whole slice is lost. So a larger section is lost than would be if the frame had been split into several slices ๐ฅฒ
The presented technique achieves good transmission error tolerance even if no additional source coding layer redundancy (such as periodic intra frames) is present ๐ So the same coded video sequence can give maximum compression efficiency and quality over error-free transmission, and it still works for transmission over error-prone networks. The technique also lets you apply FEC to pre-encoded sequences without adding delay. In this case, pre-encoded sequences that weren't encoded for error-prone networks can still be transmitted almost reliably without adding extensive delays. On top of that, FUs of equal length make for a bitrate efficient use of RFC 5109 ๐ฆ
If the error probability depends on the length of the transmitted packet (for example, in mobile transmission [15]), the benefits of applying FUs with FEC are even more obvious ๐ The flexibility in FU size lets you apply appropriate FEC to each NAL unit, and it allows unequal error protection of NAL units.
When FUs and FEC are used, the overhead is substantial, but it's in the same order of magnitude as the number of bits that would have to be spent on intra-coded macroblocks if no FEC were applied. In [19], it was shown that the FEC-based approach enhanced overall performance, improving quality at the same error rate and same overall bitrate, including the overhead ๐
12.6. Low Bitrate Streaming
This scheme has been implemented with H.263 and non-standard RTP packetization, and it gave good results [20] ๐ง There's no technical reason why similarly good results couldn't be achievable with H.264 โจ
Today's internet streaming offers some bitrates that are pretty low, so terminals with dial-up modems can still access the content ๐ On wired IP networks, relatively large packets (say 500 - 1500 bytes) are preferred over smaller, more frequently occurring packets, in order to reduce network congestion. Big packets also cut down on RTP/UDP/IP header overhead. For low bitrate video, using large packets means that sometimes up to a few pictures should be encapsulated in one packet.
But losing one packet that holds many coded pictures would have drastic consequences for visual quality ๐ญ There's practically no way to conceal the loss of an entire picture other than repeating the previous one. One way to build relatively large packets and still keep successful loss concealment possible is to construct MTAPs that contain interleaved slices from several pictures. An MTAP should not contain spatially adjacent slices from the same picture, or spatially overlapping slices from any picture. If a packet is lost, a lost slice is likely surrounded by spatially adjacent slices of the same picture and by spatially corresponding slices of the temporally previous and succeeding pictures. So concealing the lost slice is likely to be relatively successful ๐ซถ
12.7. Robust Packet Scheduling in Video Streaming
Robust packet scheduling has been implemented with MPEG-4 Part 2 and simulated in a wireless streaming environment [21] ๐ There's no technical reason why similar or better results couldn't be achievable with H.264.
Streaming clients typically have a receiver buffer that can store a relatively large amount of data ๐ When a streaming session is first established, a client doesn't start playing the stream right away. Instead, it typically buffers the incoming data for a few seconds. This buffering helps maintain continuous playback, because if there are occasional increases in transmission delay or drops in network throughput, the client can keep decoding and playing buffered data. Without initial buffering, the client would have to freeze the display, stop decoding, and wait for incoming data ๐ญ The buffering is also needed for either automatic or selective retransmission at any protocol level. If any part of a picture is lost, a retransmission mechanism may be used to resend the lost data. If the retransmitted data arrives before its scheduled decoding or playback time, the loss is recovered perfectly ๐
Coded pictures can be ranked by how important they are to the subjective quality of the decoded sequence. For example, non-reference pictures, such as conventional B pictures, are subjectively the least important, since their absence doesn't affect decoding of any other pictures. Beyond non-reference pictures, the ITU-T H.264 | ISO/IEC 14496-10 standard includes a temporal scalability method called sub-sequences [22] ๐ธ Subjective ranking can also be done on a coded slice data partition or slice group basis. Coded slices and coded slice data partitions that are subjectively the most important can be sent earlier than their decoding order indicates. Coded slices and coded slice data partitions that are subjectively the least important can be sent later than their natural coding order indicates. So any retransmitted parts of the most important slices and coded slice data partitions are more likely to arrive before their scheduled decoding or playback time, compared to the least important slices and slice data partitions ๐
13. Informative Appendix: Rationale for Decoding Order Number โจ
13.1. Introduction
The Decoding Order Number (DON) concept was introduced mainly to enable efficient multi-picture slice interleaving (see Section 12.6) and robust packet scheduling (see Section 12.7) ๐ง In both of these applications, NAL units are transmitted out of decoding order. DON indicates the decoding order of NAL units and should be used in the receiver to recover the decoding order ๐ Example use cases for efficient multi-picture slice interleaving and for robust packet scheduling are given in Sections 13.2 and 13.3, respectively. Section 13.4 describes the benefits of the DON concept in error resiliency achieved by redundant coded pictures. Section 13.5 summarizes the alternatives to DON that were considered and justifies why DON was chosen for this RTP payload specification ๐ฆ
13.2. Example of Multi-Picture Slice Interleaving ๐งฉ
okay bestie, this one is so cute ๐ Here's a little clip of coded video in output order. R means a reference picture, N means a non-reference picture, and the number is the relative output time.
... R1 N2 R3 N4 R5 ...
Now the decoding order, left to right:
... R1 R3 N2 R5 N4 ...
The NAL units of R1, R3, N2, R5, and N4 get DON 1, 2, 3, 4, and 5, in that order. ๐
Each reference picture is split into three slice groups, scattered like this. A number is the slice group number for each macroblock in a Quarter Common Intermediate Format (QCIF) frame:
0 1 2 0 1 2 0 1 2 0 1
2 0 1 2 0 1 2 0 1 2 0
1 2 0 1 2 0 1 2 0 1 2
0 1 2 0 1 2 0 1 2 0 1
2 0 1 2 0 1 2 0 1 2 0
1 2 0 1 2 0 1 2 0 1 2
0 1 2 0 1 2 0 1 2 0 1
2 0 1 2 0 1 2 0 1 2 0
1 2 0 1 2 0 1 2 0 1 2
To keep things simple, we assume that all the macroblocks of a slice group are included in one slice. ๐ซถ Three MTAPs are built from three consecutive reference pictures. Each MTAP has three aggregation units, and each unit holds all the macroblocks from one slice group. The first MTAP has slice group 0 of picture R1, slice group 1 of picture R3, and slice group 2 of picture R5. The second MTAP has slice group 1 of picture R1, slice group 2 of picture R3, and slice group 0 of picture R5. The third MTAP has slice group 2 of picture R1, slice group 0 of picture R3, and slice group 1 of picture R5. Each non-reference picture gets wrapped up in an STAP-B. โจ
So the transmission order of NAL units looks like this:
R1, slice group 0, DON 1, carried in MTAP,RTP SN: N
R3, slice group 1, DON 2, carried in MTAP,RTP SN: N
R5, slice group 2, DON 4, carried in MTAP,RTP SN: N
R1, slice group 1, DON 1, carried in MTAP,RTP SN: N+1
R3, slice group 2, DON 2, carried in MTAP,RTP SN: N+1
R5, slice group 0, DON 4, carried in MTAP,RTP SN: N+1
R1, slice group 2, DON 1, carried in MTAP,RTP SN: N+2
R3, slice group 1, DON 2, carried in MTAP,RTP SN: N+2
R5, slice group 0, DON 4, carried in MTAP,RTP SN: N+2
N2, DON 3, carried in STAP-B, RTP SN: N+3
N4, DON 5, carried in STAP-B, RTP SN: N+4
The receiver can put the NAL units back in decoding order using the DON value attached to each NAL unit. Iconic. ๐
Now for the best part. If one of the MTAPs gets lost, the spatially adjacent and temporally co-located macroblocks still arrive, so they can be used to conceal the loss really efficiently. ๐ฆ And if one of the STAPs gets lost, the damage does not spread over time. Main character energy for the whole scheme, honestly. ๐ญ
13.3. Example of Robust Packet Scheduling ๐
okay this is the big one, so get comfy ๐ง An example of robust packet scheduling goes like this. The communication system in the example has the following components, in the order the video moves through them from source to sink:
- camera and capturing
- pre-encoding buffer
- encoder
- encoded picture buffer
- transmitter
- transmission channel
- receiver
- receiver buffer
- decoder
- decoded picture buffer
- display
Here's how the video flows through this system. Note that processing happens gradually, and at the same time, in all the components. ๐ธ The source video sequence is shot and captured into a pre-encoding buffer. The pre-encoding buffer can be used to reorder pictures from sampling order to encoding order, or to analyze multiple uncompressed frames for bitrate control purposes, for example. In some cases the pre-encoding buffer may not exist at all, and the sampled pictures are encoded right away. The encoder encodes pictures from the pre-encoding buffer and stores the output (that is, coded pictures) in the encoded picture buffer. The transmitter wraps the coded pictures from the encoded picture buffer into transmission packets and sends them to a receiver through a transmission channel. The receiver stores the received packets in the receiver buffer. The receiver buffering process typically includes buffering for transmission delay jitter. The receiver buffer can also be used to recover the correct decoding order of the coded data. The decoder reads coded data from the receiver buffer and produces decoded pictures as output into the decoded picture buffer. The decoded picture buffer is used to recover the output (or display) order of the pictures. Finally, the pictures are displayed. ๐ฌ
In the example figures that follow, I denotes an IDR picture, R denotes a reference picture, and N denotes a non-reference picture. The number after I, R, or N is the sampling time relative to the previous IDR picture in decoding order. Values below the sequence of pictures are scaled system clock timestamps. The system clock is initialized arbitrarily in this example, and time runs from left to right. Each I, R, and N picture maps onto the same timeline as the previous processing step, if there is one, assuming that encoding, transmission, and decoding take no time. So events that happen at the same time sit in the same column across all the example figures. Cute and tidy. ๐
A subset of a sequence of coded pictures is shown below in sampling order:
... N58 N59 I00 N01 N02 R03 N04 N05 R06 ... N58 N59 I00 N01 ...
... --|---|---|---|---|---|---|---|---|- ... -|---|---|---|- ...
... 58 59 60 61 62 63 64 65 66 ... 128 129 130 131 ...
Figure 16. Sequence of pictures in sampling order
The sampled pictures are buffered in the pre-encoding buffer so they can be arranged in encoding order. In this example, we assume that the non-reference pictures are predicted from both the previous and the next reference picture in output order. The exception is the non-reference pictures right before an IDR picture, which are predicted only from the previous reference picture in output order. So the pre-encoding buffer has to contain at least two pictures, and the buffering causes a delay of two picture intervals. โณ The output of the pre-encoding buffering process, and the encoding (and decoding) order of the pictures, look like this:
... N58 N59 I00 R03 N01 N02 R06 N04 N05 ...
... -|---|---|---|---|---|---|---|---|- ...
... 60 61 62 63 64 65 66 67 68 ...
Figure 17. Reordered pictures in the pre-encoding buffer
The encoder or the transmitter can set the DON value for each picture to the DON value of the previous picture in decoding order plus one. ๐ข
To keep it simple, let us assume that:
- the frame rate of the sequence is constant,
- each picture consists of only one slice,
- each slice is encapsulated in a single NAL unit packet,
- there is no transmission delay, and
- pictures are transmitted at constant intervals (that is, 1 / (frame rate)).
When pictures are transmitted in decoding order, they are received like this:
... N58 N59 I00 R03 N01 N02 R06 N04 N05 ...
... -|---|---|---|---|---|---|---|---|- ...
... 60 61 62 63 64 65 66 67 68 ...
Figure 18. Received pictures in decoding order
The OPTIONAL sprop-interleaving-depth media type parameter is set to 0, because the transmission (or reception) order is identical to the decoding order. ๐
Initially, the decoder has to buffer for one picture interval in its decoded picture buffer, so it can organize pictures from decoding order to output order. It looks like this:
... N58 N59 I00 N01 N02 R03 N04 N05 R06 ...
... -|---|---|---|---|---|---|---|---|- ...
... 61 62 63 64 65 66 67 68 69 ...
Figure 19. Output order
The amount of required initial buffering in the decoded picture buffer can be signaled in the buffering period SEI message, or with the num_reorder_frames syntax element of H.264 video usability information. num_reorder_frames indicates the maximum number of frames, complementary field pairs, or non-paired fields that precede any frame, complementary field pair, or non-paired field in the sequence in decoding order and that follow it in output order. For the sake of simplicity, we assume that num_reorder_frames is used to indicate the initial buffer in the decoded picture buffer. In this example, num_reorder_frames is equal to 1. ๐ง
Here's a spicy what-if. If the IDR picture I00 is lost during transmission and a retransmission request is issued when the system clock reads 62, there is one picture interval of time (until the system clock reaches timestamp 63) to receive the retransmitted IDR picture I00. Tight, but doable. ๐ฌ
Now let's say IDR pictures are transmitted two frame intervals earlier than their decoding position. In other words, the pictures are sent like this:
... I00 N58 N59 R03 N01 N02 R06 N04 N05 ...
... --|---|---|---|---|---|---|---|---|- ...
... 62 63 64 65 66 67 68 69 70 ...
Figure 20. Interleaving: Early IDR pictures in sending order
The OPTIONAL sprop-interleaving-depth media type parameter is set equal to 1, according to its definition. (The value of sprop-interleaving-depth in this example can be derived as follows: picture I00 is the only picture that precedes picture N58 or N59 in transmission order and follows it in decoding order. Apart from pictures I00, N58, and N59, the transmission order is the same as the decoding order of the pictures. As a coded picture is encapsulated into exactly one NAL unit, the value of sprop-interleaving-depth is equal to the maximum number of pictures that precede any picture in transmission order and follow the picture in decoding order.) ๐งฎ
The receiver buffering process holds two pictures at a time, according to the value of the sprop-interleaving-depth parameter. It orders pictures from the reception order to the correct decoding order, based on the DON value associated with each picture. The output of the receiver buffering process looks like this:
... N58 N59 I00 R03 N01 N02 R06 N04 N05 ...
... -|---|---|---|---|---|---|---|---|- ...
... 63 64 65 66 67 68 69 70 71 ...
Figure 21. Interleaving: Receiver buffer
Once again, an initial buffering delay of one picture interval is needed to organize pictures from decoding order to output order, as shown below:
... N58 N59 I00 N01 N02 R03 N04 N05 ...
... -|---|---|---|---|---|---|---|- ...
... 64 65 66 67 68 69 70 71 ...
Figure 22. Interleaving: Receiver buffer after reordering
Last but not least, the maximum delay that IDR pictures can undergo during transmission (including any possible application, transport, or link layer retransmission) is equal to three picture intervals. So the loss resiliency of IDR pictures is improved in systems that support retransmission, compared to the case where pictures are transmitted in their decoding order. Retransmission is a whole vibe here. ๐ฆ๐
13.4. Robust Transmission Scheduling of Redundant Coded Slices โจ
okay bestie, so a redundant coded picture is a coded version of a picture (or part of one) that doesn't get used in decoding if the matching primary coded picture decodes correctly ๐ซถ. It's like a backup copy waiting in the wings ๐ง. There should be no noticeable difference between any area of the decoded primary picture and the matching area you'd get from running the H.264 decoding process on any redundant picture in the same access unit. And a redundant coded slice is just a coded slice that's part of a redundant coded picture ๐.
Redundant coded pictures are a whole unequal error protection move ๐ . If the primary coded representation of a picture gets decoded incorrectly, the corresponding redundant coded picture can be decoded instead. Examples of applications and coding techniques that use this redundant codec picture feature include the video redundancy coding [23] and the protection of "key pictures" in multicast streaming [24] ๐ญ.
Here's the tea ๐ต: transmission errors are often bursty, so they can wipe out more than one consecutive transmission packet in transmission order. In low bitrate video communication, it's pretty common for an entire coded picture to fit inside one transmission packet. That means a primary coded picture and its redundant coded pictures could end up in consecutive packets, and then one burst takes out both ๐. To make the scheme tougher against bursty errors, it's beneficial to send the primary coded picture and the redundant coded picture separated by more than a single packet. The DON concept is what makes that possible ๐.
13.5. Remarks on Other Design Possibilities ๐ฆ
The slice header syntax structure of the H.264 coding standard has a frame_num syntax element that can indicate the decoding order of coded frames. BUT, it's not feasible or desirable to use frame_num to recover the decoding order, and here's why ๐:
- The receiver is required to parse at least one slice header per coded picture (before passing the coded data to the decoder).
- Coded slices from multiple coded video sequences cannot be interleaved, as the frame number syntax element is reset to 0 in each IDR picture.
- The coded fields of a complementary field pair share the same value of the
frame_numsyntax element. So the decoding order of the coded fields of a complementary field pair cannot be recovered based onframe_numor any other syntax element of the H.264 coding syntax ๐ตโ๐ซ.
The RTP payload format for transport of MPEG-4 elementary streams [25] lets you interleave access units and send multiple access units in the same RTP packet โจ. An access unit is specified in the H.264 coding standard to comprise all NAL units associated with a primary coded picture, according to Subclause 7.4.1.2 of [1]. So slices of different pictures cannot be interleaved, and the multi-picture slice interleaving technique (see Section 12.6) for improved error resilience cannot be used. Major bummer ๐ฅฒ.
14. Changes from RFC 3984 ๐
Here's the list of technical changes (including bug fixes) from RFC 3984 ๐. Besides this list, there were numerous editorial changes that aren't documented in this section. Also, Section 8.2.2 is where a lot of the important changes in this memo happen, so it deserves particular attention ๐.
- In Sections 5.4, 5.5, 6.2, 6.3, and 6.4, removed that the packetization mode in use may be signaled by external means.
- In Section 7.2.2, changed the sentence
There are N VCL NAL units in the de-interleaving buffer.
to
There are N or more VCL NAL units in the de-interleaving buffer.
- In Section 8.1, the semantics of
sprop-init-buf-time(paragraph 2), changed the sentence
The parameter is the maximum value of (transmission time of a NAL
unit - decoding time of the NAL unit), assuming reliable and
instantaneous transmission, the same timeline for transmission
and decoding, and that decoding starts when the first packet
arrives.
to
The parameter is the maximum value of (decoding time of the NAL
unit - transmission time of a NAL unit), assuming reliable and
instantaneous transmission, the same timeline for transmission
and decoding, and that decoding starts when the first packet
arrives.
- Added media type parameters
max-smbps,sprop-level-parameter-sets,use-level-src-parameter-sets,in-band-parameter-sets,sar-understood, andsar-supported๐. - In Section 8.1, removed the specification of
parameter-add. Other descriptions ofparameter-add(in Sections 8.2 and 8.4) were also removed ๐๏ธ. - In Section 8.1, added a constraint to
sprop-parameter-setssuch that it can only contain parameter sets for the same profile and level as indicated byprofile-level-id๐. - In Section 8.2.1, added that
sprop-parameter-setsandsprop-level-parameter-setsmay be either included in the "a=fmtp" line of SDP or conveyed using the "fmtp" source attribute as specified in Section 6.3 of [9] ๐ง. - In Section 8.2.2, removed
sprop-deint-buf-reqfrom being part of the media format configuration in usage with the SDP Offer/Answer model. - In Section 8.2.2, made it clear that level is downgradable in the SDP Offer/Answer model, i.e., the use of the level part of
profile-level-iddoes not need to be symmetric (the level included in the answer can be lower than or equal to the level included in the offer) โฌ๏ธ. - In Section 8.2.2, removed that the capability parameters may be used to declare encoding capabilities.
- In Section 8.2.2, added rules on how to use
sprop-parameter-setsandsprop-level-parameter-setsfor out-of-band transport of parameter sets, with or without level downgrading. - In Section 8.2.2, clarified the rules of using the media type parameters with SDP Offer/Answer for multicast ๐ก.
- In Section 8.2.2, completed and corrected the list of how different media type parameters shall be interpreted in the different combinations of offer or answer and direction attribute.
- In Section 8.4, changed the text such that both out-of-band and in-band transport of parameter sets are allowed, and neither is recommended or required ๐ซถ.
- Added Section 8.5 (informative) providing example methods for decoder refresh to handle parameter set losses ๐.
- Added media type parameters
max-recv-levelandlevel-asymmetry-allowedand adjusted associated text and examples for level upgrade and asymmetry ๐.
15. Backward Compatibility to RFC 3984 ๐ธ
The current document is a revision of RFC 3984 and obsoletes it. The technical changes relative to RFC 3984 are listed in Section 14, and this section covers the backward compatibility issues ๐.
It should be noted that for the majority of cases, there will be no compatibility issues for legacy implementations per RFC 3984 and new implementations per this document to interwork. Compatibility issues may only occur when both of the following conditions are true: 1) legacy implementations and new implementations are interworking, and 2) parameter sets are transported out-of-band. When such compatibility issues do occur, it's easy to debug and find the reason for the incompatibility using the following analyses ๐.
Items 1, 2, 3, 7, 9, 10, 12, and 13 are bug-fix types of changes and do not incur any backward compatibility issues ๐โ .
Item 4 (addition of six new media type parameters) doesn't incur any backward compatibility issues for SDP Offer/Answer-based applications, because legacy RFC 3984 receivers ignore these parameters, and it's fine for legacy RFC 3984 senders not to use them since they're optional. HOWEVER, there's a backward compatibility issue for declarative-usage-based applications (only for the parameter sprop-level-parameter-sets, since the other five parameters aren't usable in declarative usage) ๐ฌ. For example, declarative-usage-based applications using RTSP and SAP have a backward compatibility issue, because the SDP receiver per RFC 3984 cannot accept a session whose SDP includes an unrecognized parameter. So the RTSP or SAP server may have to prepare two sets of streams: one for legacy RFC 3984 receivers and one for receivers according to this memo ๐ฌ.
Items 5, 6, and 11 are related to out-of-band transport of parameter sets. There are the following backward compatibility issues:
- When a legacy sender per RFC 3984 includes parameter sets for a level different than the default level indicated by
profile-level-idtosprop-parameter-sets, the parameter value ofsprop-parameter-setsis invalid to the receiver per this memo. Therefore, the session may be rejected ๐ซ. - In SDP Offer/Answer between a legacy offerer per RFC 3984 and an answerer per this memo, when the answerer includes in the answer parameter sets that are not a superset of the parameter sets included in the offer, the parameter value of
sprop-parameter-setsis invalid to the offerer, and the session may not be initiated properly (related to change item 11) ๐. - When one endpoint A per this memo includes
in-band-parameter-setsequal to 1, the other side B per RFC 3984 doesn't understand that it must transmit parameter sets in-band, and B may still exclude parameter sets in the in-band stream it is sending. Consequently, endpoint A cannot decode the stream it receives ๐.
Item 7 (allowance of conveying sprop-parameter-sets and sprop-level-parameter-sets using the "fmtp" source attribute as specified in Section 6.3 of [9]) is similar to item 4. It doesn't incur any backward compatibility issues for SDP Offer/Answer-based applications, because legacy RFC 3984 receivers ignore the "fmtp" source attribute, and it's fine for legacy RFC 3984 senders not to use the "fmtp" source attribute since it's optional. However, there's a backward compatibility issue for SDP declarative-usage-based applications, e.g., those using RTSP and SAP, because the SDP receiver per RFC 3984 cannot accept a session whose SDP includes an unrecognized parameter (i.e., the "fmtp" source attribute). So the RTSP or SAP server may have to prepare two sets of streams: one for legacy RFC 3984 receivers and one for receivers according to this memo ๐.
Item 14 doesn't incur any backward compatibility issues, because out-of-band transport of parameter sets is still allowed ๐ฅฐ.
Item 15 doesn't incur any backward compatibility issues, because the added Section 8.5 is informative ๐.
Item 16 doesn't create any backward compatibility issues, because the handling of the default level is the same if either end is RFC 3984 compliant. Furthermore, RFC-3984-compliant ends would simply ignore the new media type parameters, if present ๐งโโ๏ธโจ.
16. Acknowledgements ๐ซถ
Okay bestie, huge thank-yous go out to Stephan Wenger, Miska Hannuksela, Thomas Stockhammer, Magnus Westerlund, and David Singer, who wrote RFC 3984 and made this whole thing possible ๐ธโจ. Then there's Dave Lindbergh, Philippe Gentric, Gonzalo Camarillo, Gary Sullivan, Joerg Ott, and Colin Perkins, who gave RFC 3984 a careful review, which is so iconic ๐ง๐. And finally, Stephen Botzko, Magnus Westerlund, Alex Eleftheriadis, Thomas Schierl, Tom Taylor, Ali Begen, Aaron Wells, Stuart Taylor, Robert Sparks, Dan Romascanu, and Niclas Comstedt get a massive shoutout for their valuable comments and input while this memo was being built ๐๐. Honestly the whole group is absolutely slaying ๐
17. References ๐
17.1. Normative References
These are the must-read ones, the stuff the spec is built on ๐ฆ
- [1] ITU-T Recommendation H.264, "Advanced video coding for generic audiovisual services", March 2010.
- [2] ISO/IEC International Standard 14496-10:2008.
- [3] ITU-T Recommendation H.241, "Extended video procedures and control signals for H.300-series terminals", May 2006.
- [4] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
- [5] Schulzrinne, H., Casner, S., Frederick, R., and V. Jacobson, "RTP: A Transport Protocol for Real-Time Applications", STD 64, RFC 3550, July 2003.
- [6] Handley, M., Jacobson, V., and C. Perkins, "SDP: Session Description Protocol", RFC 4566, July 2006.
- [7] Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, October 2006.
- [8] Rosenberg, J. and H. Schulzrinne, "An Offer/Answer Model with Session Description Protocol (SDP)", RFC 3264, June 2002.
- [9] Lennox, J., Ott, J., and T. Schierl, "Source-Specific Media Attributes in the Session Description Protocol (SDP)", RFC 5576, June 2009.
17.2. Informative References
These are the extra reading for when you want to go deep ๐ค๐
- [10] Luthra, A., Sullivan, G.J., and T. Wiegand (eds.), "Introduction to the special issue on the H.264/AVC video coding standard", IEEE Transactions on Circuits and Systems for Video Technology, Vol. 13, No. 7, July 2003.
- [11] Ott, J., Bormann, C., Sullivan, G., Wenger, S., and R. Even, Ed., "RTP Payload Format for ITU-T Rec. H.263 Video", RFC 4629, January 2007.
- [12] ISO/IEC International Standard 14496-2:2004.
- [13] Wenger, S., "H.264/AVC over IP", IEEE Transaction on Circuits and Systems for Video Technology, Vol. 13, No. 7, July 2003.
- [14] Wenger, S., "H.26L over IP: The IP-Network Adaptation Layer", Proceedings Packet Video Workshop, April 2002.
- [15] Stockhammer, T., Hannuksela, M.M., and S. Wenger, "H.26L/JVT Coding Network Abstraction Layer and IP-Based Transport", IEEE International Conference on Image Processing (ICIP 2002), Rochester, NY, September 2002.
- [16] Schulzrinne, H. and S. Casner, "RTP Profile for Audio and Video Conferences with Minimal Control", STD 65, RFC 3551, July 2003.
- [17] ITU-T Recommendation H.223, "Multiplexing protocol for low bit rate multimedia communication", July 2001.
- [18] Li, A., Ed., "RTP Payload Format for Generic Forward Error Correction", RFC 5109, December 2007.
- [19] Stockhammer, T., Wiegand, T., Oelbaum, T., and F. Obermeier, "Video Coding and Transport Layer Techniques for H.264/AVC-Based Transmission over Packet-Lossy Networks", IEEE International Conference on Image Processing (ICIP 2003), Barcelona, Spain, September 2003.
- [20] Varsa, V. and M. Karczewicz, "Slice interleaving in compressed video packetization", Packet Video Workshop 2000.
- [21] Kang, S.H. and A. Zakhor, "Packet scheduling algorithm for wireless video streaming", Packet Video Workshop 2002.
- [22] Hannuksela, M.M., "Enhanced Concept of GOP", JVT-B042, available http://ftp3.itu.int/av-arch/video-site/0201_Gen/JVT-B042.doc, January 2002.
- [23] Wenger, S., "Video Redundancy Coding in H.263+", 1997 International Workshop on Audio-Visual Services over Packet Networks, September 1997.
- [24] Wang, Y.-K., Hannuksela, M.M., and M. Gabbouj, "Error Resilient Video Coding Using Unequally Protected Key Pictures", in Proc. International Workshop VLBV03, September 2003.
- [25] van der Meer, J., Mackie, D., Swaminathan, V., Singer, D., and P. Gentric, "RTP Payload Format for Transport of MPEG-4 Elementary Streams", RFC 3640, November 2003.
- [26] Baugher, M., McGrew, D., Naslund, M., Carrara, E., and K. Norrman, "The Secure Real-time Transport Protocol (SRTP)", RFC 3711, March 2004.
- [27] Schulzrinne, H., Rao, A., and R. Lanphier, "Real Time Streaming Protocol (RTSP)", RFC 2326, April 1998.
- [28] Handley, M., Perkins, C., and E. Whelan, "Session Announcement Protocol", RFC 2974, October 2000.
- [29] Westerlund, M. and S. Wenger, "RTP Topologies", RFC 5117, January 2008.
- [30] Wenger, S., Chandra, U., Westerlund, M., and B. Burman, "Codec Control Messages in the RTP Audio-Visual Profile with Feedback (AVPF)", RFC 5104, February 2008.
Authors' Addresses ๐
Meet the crew who wrote this ๐ Here are their contact details, exactly as they appear in the original:
Ye-Kui Wang
Huawei Technologies
400 Crossing Blvd, 2nd Floor
Bridgewater, NJ 08807
USA
Phone: +1-908-541-3518
EMail: yekui.wang@huawei.com
Roni Even
Huawei Technologies
14 David Hamelech
Tel Aviv 64953
Israel
Phone: +972-545481099
EMail: even.roni@huawei.com
Tom Kristensen
TANDBERG
Philip Pedersens vei 22
N-1366 Lysaker
Norway
Phone: +47 67125125
EMail: tom.kristensen@tandberg.com, tomkri@ifi.uio.no
Randell Jesup
WorldGate Communications
3800 Horizon Blvd, Suite #103
Trevose, PA 19053-4947
USA
Phone: +1-215-354-5166
EMail: rjesup@wgate.com, randell_ietf@jesup.org
๐ฆ where this page comes from
- ietf: rfc6184 2011-05
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms