Parameter Sets
A parameter set is supposed to contain information that is expected to rarely change and offers the decoding of a large number of VCL NAL units.
Parameter Sets用于供解码时用, 其中的信息很少变化.
SPS & PPS
A Network Abstraction Layer (NAL) definition allowing the same video syntax to be used in many network environments.
One very fundamental design concept of H.264 is to generate self-contained packets, to remove the header duplication as in MPEG-4's Header Extension Code (HEC).[30]
This was achieved by decoupling information relevant to more than one slice from the media stream. The combination of the higher-level parameters is called a parameter set.[30]
The H.264 specification includes two types of parameter sets: Sequence Parameter Set (SPS) and Picture Parameter Set (PPS).
An active sequence parameter set remains unchanged throughout a coded video sequence, and an active picture parameter set remains unchanged within a coded picture.
The sequence and picture parameter set structures contain information such as picture size, optional coding modes employed, and macroblock to slice group map.
SPS和PPS都是NAL层的概念, 是为了适应更多的网络环境.
SPS信息在整个视频编码序列中是不变的.
PPS信息在一幅编码图像之内是不变的.
There are two types of parameter sets:
sequence parameter sets (SPS), which apply to a series of consecutive coded video pictures called a coded video sequence.
picture parameter sets (PPS), which apply to the decoding of one or more individual pictures within a coded video sequence.
SPS用于描述一个视频编码序列.
PPS用于描述一个或多个独立的图像(在视频编码序列中).
The sequence and picture parameter-set mechanism decouples the transmission of infrequently changing information from the transmission of coded representations of the values of the samples in the video pictures.
SPS和PPS将变化不频繁的信息和视频图像分离出来.
Each VCL NAL unit contains an identifier that refers to the content of the relevant picture parameter set and each picture parameter set contains an identifier that refers to the content of the relevant sequence parameter set.
In this manner, a small amount of data (the identifier) can be used to refer to a larger amount of information (the parameter set) without repeating that information within each VCL NAL unit.
每个 VCL NAL unit都有一个PPS的id;
每个PPS都有一个SPS的id.
这样很小的数据量(id)就可以代表整个parameter set, 不用每次在VCL NAL unit中重复这些信息.
这个做法很聪明!!!
- SPS 仅在PPS中被引用.
- SPS参数仅在IDR图像时才会发生变化.
Sequence and picture parameter sets can be sent well ahead of the VCL NAL units that they apply to, and can be repeated to provide robustness against data loss.
在发送VCL NAL units之前, 先发送SPS和PPS, 然后重复使用.
In some applications, parameter sets may be sent within the channel that carries the VCL NAL units (termed "in-band" transmission).
实际项目中就是这么用的,比如有个项目是rtmp输出,会先发送sps和pps信息(以AVCC的形式),然后再发送每个图像的信息,解码器会利用收到的sps和pps对图像进行解码.
In other applications, it can be advantageous to convey the parameter sets "out-of-band" using a more reliable transport mechanism than the video channel itself.
Reference:
https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC
https://en.wikipedia.org/wiki/Network_Abstraction_Layer#Parameter_Sets
http://iphome.hhi.de/wiegand/assets/pdfs/DIC_H264_07.pdf