I have said it before and I’ll say it again: video quality in visualcommunications is a lot more than just the video codec.
H.264 and slices
I recently had to explain why we need “multi-slicing” to be supported inour H.264 video encoder and how this influences the sensitivity (or robustness)to packet losses.
You see – in classic video coding, the video frame is split into macroblocks, where each macroblock is compressedseparately. In H.264, a number of consecutive macroblocks can be grouped into aslice and so a frame can be comprised of several slices.
From a network perspective, a slice or a group of slices are encapsulatedinto a NALU – a Network Abstraction Layer Unit, which serves as a container.This allows a decoder to decode it independently of the other NALUs of a frame.
The way these NALUs are created, packetized and sent over the networkaffects packet loss resilience.
Group | Type | Packet | Type name |
Single | 1-23 | NAL unit | Single NAL unit packet per H.264 |
Aggregation | 24 | STAP-A | Single-time aggregation packet |
25 | STAP-B | Single-time aggregation packet | |
26 | MTAP16 | Multi-time aggregation packet | |
27 | MTAP24 | Multi-time aggregation packet | |
Fragmentation | 28 | FU-A | Fragmentation unit |
29 | FU-B | Fragmentation unit |
Packet types, as defined in RFC3984
As can be seen in the table above, packet types are divided in generalinto 3: single NALU per packet, multiple NALU in one packet and one NALUfragmented over multiple packets.
Single NALU per packet
The most straight forward solution is to place each NALU in its ownpacket. And while this makes everything easy on the decoder side, as you justdecode the packet you receive, it is quite a headache on the encoder side. Why?Because of that nagging little thing called MTU size. You see – if you want a NALU to fitinto a packet, you must make sure that it is within the MTU size of thenetwork. And if you really want to be effective, you should probably try tomake each NALU as close as possible to the MTU size itself.
When I wrote “multi-slicing” earlier, I generally meant that the encodershould be capable of encoding a frame into multiple slices, where each slicecan fit nicely into the MTU size (which is a configurable and not a staticvalue).
I should tell you that most out of the box encoders don’t do such a goodjob when it comes to supporting multi-slicing.
Aggregating multiple NALUs per packet
Another option is to take several NALUs and place them in a single packet.
With the resolutions used today, and the resolutions coming in the future,the need to split a frame into more slices, with a negligible but existentoverhead of a slice header, makes little sense. The only reasonable place Iknow of where this is a common practice is when dealing with circuit switching:3G-324M doesn’t like payloads that are largerthan 254 bytes, and when interworking with IP it makes sense to aggregate thesesmaller NALUs into larger network packets.
Fragmenting a NALU between packets
What is left is the ability to take a single NALU and fragment it betweenseveral network packets, placing each part in a separateRTPpacket. This is important when MTU size becomes a restriction, and NALUs aremuch bigger than it.
The down side of it is that when you miss a packet, the whole set ofpackets of the same NALU are considered lost since they cannot be decoded anylonger, which makes for bad implementation to use over IP networks.
It is also the most common approach of general purpose encoders, as it isthe easiest to implement in the encoder: you encode each frame as a single NALUand let the transport layer of the system deal with it.