NAL(Network Abstraction
Layer)基本上可分两种:1,以有序字节流方式传送的针对H.320的;2,针对IP网络的RTP打包方式的。 NAL作用:specified to format that data and provide header information in a manner appropriate for conveyance on a variety of communication channels or storage media. NAL的处理过程基本上分为两步: 1,将VCL层输出的SODB封装成nal_unit. Nal_unit是一个通用封装格式,可以适用于有序字节流方式和IP包交换方式。 2,针对不同的传送网络(电路交换|包交换),将nal_unit 封装成针对不同网络的封装格式。 第一步的具体过程: VCL层输出的比特流SODB(String Of Data Bits),到nal_unit之间,经过了以下三步处理: 1,SODB字节对齐处理后封装成RBSP(Raw Byte Sequence Payload)。 2,为防止RBSP的字节流与有序字节流传送方式下的SCP(start_code_prefix_one_3bytes,0x000001)出现字节竞争情形,循环检测RBSP前三个字节,在出现字节竞争时在第三字节前加入emulation_prevention_three_byte (0x03),具体方法: nal_unit( NumBytesInNALunit ) { forbidden_zero_bit nal_ref_idc nal_unit_type NumBytesInRBSP = 0 for( i = 1; i < NumBytesInNALunit; i++ ) { if( i + 2 < NumBytesInNALunit && next_bits( 24 ) = = 0x000003 ) { rbsp_byte[ NumBytesInRBSP++ ] rbsp_byte[ NumBytesInRBSP++ ] i += 2 emulation_prevention_three_byte } else rbsp_byte[ NumBytesInRBSP++ ] } } 3,防字节竞争处理后的RBSP再加一个字节的header(forbidden_zero_bit+ nal_ref_idc+ nal_unit_type),封装成nal_unit. 第二步的具体过程: case1:有序字节流的封装 byte_stream_nal_unit( NumBytesInNALunit ) { while( next_bits( 24 ) != 0x000001 ) zero_byte if( more_data_in_byte_stream( ) ) { start_code_prefix_one_3bytes nal_unit( NumBytesInNALunit ) } } Case2:IP网络的RTP打包封装 |
|
来自: SamBookshelf > 《H264》