H264编解码 分析二 PPS (编解码未懂)

PPS 序列参数集合

PPS 属于 [RTP header] + 单一NAL单元模式 ,所以RTP包结构如下

 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             |
|                             ....                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|F|NRI|  type   |                                               |
+-+-+-+-+-+-+-+-+                                               |
|                                                               |
|               Bytes 2..n of a Single NAL unit                 |
|                                                               |
|                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               :...OPTIONAL RTP padding        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

先看 抓到的 dump

0000   80 60 e2 1e ff 6d 85 0f c6 0a 3f ef 68 e8 9e 2c   ..ÿm..Æ.?ïhè.,
0010   b2 2c                                             ²,

在上面12个byte是 [RTP Header] 对应的码流 和SPS 一样的RTP Header

80 60 e2 1e 
ff 6d 85 0f 
c6 0a 3f ef 
====>转化 二进制
1000 0000 0110 0000 1110 0010 0001 1110 v=2 p=0 x=0 CC=0 M=0 PT=96 SN=57886 
1111 1111 0110 1101 1000 0101 0000 1111 timestamp 
1100 0110 0000 1010 0011 1111 1110 1111 ssrc 

对应wireshark 解析

Real-Time Transport Protocol
    10.. .... = Version: RFC 1889 Version (2)
    ..0. .... = Padding: False
    ...0 .... = Extension: False
    .... 0000 = Contributing source identifiers count: 0
    0... .... = Marker: False
    Payload type: DynamicRTP-Type-96 (96)
    Sequence number: 57886
    Timestamp: 4285367567
    Synchronization Source identifier: 0xc60a3fef (3322560495)

NALU 码流 .根据单一NAL单元模式 判断 前1byte 是[NALU Header]

0000   68 e8 9e 2c b2 2c                                 hè.,²,

===> 转化 第一个字节
0110 0111  F=0 NRI=11 特别重要 type=8 说明是pps  

wireshark 解析

H.264
    NAL unit header or first byte of the payload
        0... .... = F bit: No bit errors or other syntax violations
        .11. .... = Nal_ref_idc (NRI): 3
        ...0 0111 = Type: NAL unit - Sequence parameter set (8)

剩下的就看下H264 NAL Unit Payload NALU的负载

NALU payload
e8 9e 2c b2 2c

从下面的 解析就知道意义

H264 NAL Unit Payload
    1... .... = pic_parameter_set_id: 0
    .1.. .... = seq_parameter_set_id: 0
    ..1. .... = entropy_coding_mode_flag: 1
    ...0 .... = pic_order_present_flag: 0
    .... 1... = num_slice_groups_minus1: 0
    .... .000  1001 .... = num_ref_idx_l0_active_minus1: 8
    .... 1... = num_ref_idx_l1_active_minus1: 0
    .... .1.. = weighted_pred_flag: 1
    .... ..10 = weighted_bipred_idc: 2
    0010 1... = pic_init_qp_minus26(se(v)): -2
    .... .1.. = pic_init_qs_minus26: 0
    .... ..00  101. .... = chroma_qp_index_offset(se(v)): -2
    ...1 .... = deblocking_filter_control_present_flag: 1
    .... 0... = constrained_intra_pred_flag: 0
    .... .0.. = redundant_pic_cnt_present_flag: 0
    .... ..1. = transform_8x8_mode_flag: 1
    .... ...0 = pic_scaling_matrix_present_flag: 0
    0010 1... = second_chroma_qp_index_offset(se(v)): -2
    .... .1.. = rbsp_stop_bit: 1
    .... ..00 = rbsp_trailing_bits: 0

pic_parameter_set_id: 0  用以指定本参数集的序号,该序号在各片的片头被引用
seq_parameter_set_id: 0 指明本图像参数集所引用的序列参数集的序号
entropy_coding_mode_flag: 1  指明熵编码的选择,本句法元素为0时,表示熵编码使用 CAVLC,本句
法元素为1时表示熵编码使用 CABAC
pic_order_present_flag: 0  POC 的三种计算方法在片层还各需要用一些句法元素作为参数,本句法
元素等于1时表示在片头会有句法元素指明这些参数;本句法元素等于0时,表示片头不会给出这
些参数,这些参数使用默认值
num_slice_groups_minus1: 0   本句法元素加1后指明图像中片组的个数。H.264 中没有专门的句法元
素用于指明是否使用片组模式,当本句法元素等于0(即只有一个片组),表示不使用片组模式,后
面也不会跟有用于计算片组映射的句法元素
num_ref_idx_l0_active_minus1: 81后指明目前参考帧队列的长度,即有多少个参考帧
num_ref_idx_l1_active_minus1: 0  同上
weighted_pred_flag: 1   指明是否允许P和SP片的加权预测
weighted_bipred_idc: 2   加权像素预测处理 不同值,对应不同的加权方法
pic_init_qp_minus26(se(v)): -226 后用以指明亮度分量的量化参数的初始值。在 H.264 中,量化参数
分三个级别给出:图像参数集、片头、宏块。在图像参数集给出的是一个初始值
pic_init_qs_minus26: 0 同上 只是用于 SP 和 SI
chroma_qp_index_offset(se(v)): -2   色度分量的量化参数是根据亮度分量的量化参数计算出来的
deblocking_filter_control_present_flag: 1 编码器可以通过元素显式地控制去块滤波的强
度,本元素指明是在片头是否会有元素传递这个控制信息。如果元素等于 0,那些
用于传递滤波强度的元素不会出现,解码器将独立地计算出滤波强度。
constrained_intra_pred_flag: 0  在 P 和 B 片中,帧内编码的宏块的邻近宏块可能是采用的帧间
编码。等于 1 时,表示帧内编码的宏块不能用帧间编码的宏块的像素作为自己的预测,
即帧内编码的宏块只能用邻近帧内编码的宏块的像素作为自己的预测;等于 0 时,表示不存在这种限制

redundant_pic_cnt_present_flag: 0  是否会出现 redundant_pic_cnt
transform_8x8_mode_flag: 1
pic_scaling_matrix_present_flag: 0
second_chroma_qp_index_offset(se(v)): -2
rbsp_stop_bit: 1
rbsp_trailing_bits: 0  第一个比特是 0,接下来填充 0,直到字节对齐

能理解多少,记多少,为后面学习编码和解码打基础

猜你喜欢

转载自blog.csdn.net/engineer_james/article/details/81782780