当前位置:网站首页>H. Relationship among Nalu, RBSP and sodb in 264
H. Relationship among Nalu, RBSP and sodb in 264
2022-06-10 21:18:00 【User 3504492】
SODB: Data bit string --> The original encoded data ( The length doesn't have to be 8 Multiple , Therefore, it needs to be supplemented )
RBSP: Sequence of raw data bytes --> stay SODB The ending bit is added after the (RBSP trailing bits One bit“1”) A few bits “0”, For byte alignment .
EBSP: Extended byte sequence payload -- > stay RBSP On this basis, the pseudo check byte is added (0X03) The reason for it is : stay NALU Add to Annexb Upper time , Each group needs to be added NALU The previous start code StartCodePrefix, If it's time to NALU Corresponding slice For the beginning of a frame Then use 4 Bit byte means ,ox00000001, Otherwise, use 3 Bit byte means ox000001.
In order to make NALU The body does not include... That conflicts with the start code , When coding , Every two bytes encountered are consecutive 0, Just insert a byte 0x03. Decoding will 0x03 Get rid of . Also known as shelling operation .
NALU: Every NAL A unit is a variable length byte string of a certain syntax element , Including header information containing one byte ( Used to represent data types ), And several integer bytes of load data . One NAL The unit can carry a coding chip 、A/B/C Type data segmentation or a sequence or image parameter set
logical relationship :
SODB + RBSP trailing bits = RBSP
NAL header(1 byte) + RBSP = NALU
Start Code Prefix(3 bytes) + NALU + Start Code Prefix(3 bytes) + NALU + ...+ = H.264BitsStream
explain :
1. SODB That is, the real code stream formed by encoding , In order to make a RBSP Is the number of whole bytes , Need to add trailing bits, The specific method of addition can be seen in JM8.6 Medium SODBtoRBSP function .
void SODBtoRBSP(Bitstream *currStream)
{
currStream->byte_buf <<= 1;
currStream->byte_buf |= 1;
currStream->bits_to_go--;
currStream->byte_buf <<= currStream->bits_to_go;
currStream->streamBuffer[currStream->byte_pos++] = currStream->byte_buf;
currStream->bits_to_go = 8;
currStream->byte_buf = 0;
}
2. NALU header For a byte , this 8 Bits correspond to forbidden_zero_bit, nal_ref_idc, nal_unit_type. NALU Of body In fact, that is RBSP. from RBSP turn NALU By RBSPtoNALU Function to implement .
typedef struct
{
int startcodeprefix_len; //! 4 for parameter sets and first slice in picture, 3 for everything else (suggested)
unsigned len; //! Length of the NAL unit (Excluding the start code, which does not belong to the NALU)
unsigned max_size; //! Nal Unit Buffer size
int nal_unit_type; //! NALU_TYPE_xxxx
int nal_reference_idc; //! NALU_PRIORITY_xxxx
int forbidden_bit; //! should be always FALSE
byte *buf; //! conjtains the first byte followed by the EBSP
} NALU_t;
int RBSPtoNALU (char *rbsp, NALU_t *nalu, int rbsp_size, int nal_unit_type, int nal_reference_idc,
int min_num_bytes, int UseAnnexbLongStartcode)
{
int len;
// Assertion , Learn to use it later assert To assert that , It's very important .
assert (nalu != NULL);
assert (nal_reference_idc <=3 && nal_reference_idc >=0);
assert (nal_unit_type > 0 && nal_unit_type <= 10);
assert (rbsp_size < MAXRBSPSIZE);
// The following is a must , So you don't need to pass in parameters
nalu->forbidden_bit = 0;
// The following two parameters are passed in
nalu->nal_reference_idc = nal_reference_idc;
nalu->nal_unit_type = nal_unit_type;
// Judge whether it is Start Code Prefix Add in front Ox00
nalu->startcodeprefix_len = UseAnnexbLongStartcode?4:3;
// Yes nalu->buf[i] Assign a value
nalu->buf[0] =
nalu->forbidden_bit << 7 |
nalu->nal_reference_idc << 5 |
nalu->nal_unit_type;
memcpy (&nalu->buf[1], rbsp, rbsp_size);
// printf ("First Byte %x\n", nalu->buf[0]);
// printf ("RBSPtoNALU: Before: NALU len %d\t RBSP %x %x %x %x\n", rbsp_size, (unsigned) nalu->buf[1], (unsigned) nalu->buf[2], (unsigned) nalu->buf[3], (unsigned) nalu->buf[4]);
len = 1 + RBSPtoEBSP (&nalu->buf[1], 0, rbsp_size, min_num_bytes);
// printf ("RBSPtoNALU: After : NALU len %d\t EBSP %x %x %x %x\n", rbsp_size, (unsigned) nalu->buf[1], (unsigned) nalu->buf[2], (unsigned) nalu->buf[3], (unsigned) nalu->buf[4]);
// printf ("len %d\n\n", len);
nalu->len = len;
return len;
}
3. Start Code Prefix by 3 Bytes . however , For addressing convenience , The data stream is required to be aligned in length , therefore H.264 It is suggested that Start Code Prefix Add several in front 0.
4. For the sake of simplicity , The logic diagram above does not consider " Prevent competition " Mechanism .
code foreman_part_qcif.yuv The first frame of , The code stream is as follows : ( contrast trace_enc.txt Analysis is enough , Because there are too many code streams , Limited space , Therefore, it is not analyzed one by one )
0000000000000000000000000000000101100111010000100000000000011110111100010110000101100010011000100000000000000000000000000
边栏推荐
- Is Jiuzhou futures regular? Is it safe to open an account
- Read the source code of micropyton - add the C extension class module (2)
- 1、 Vulkan develops theoretical fundamentals
- LeetCode:1037. 有效的回旋镖————简单
- mysql基础篇
- How to use Diablo immortal database
- LeetCode 进阶之路 - 反转字符串
- 保姆级教程:如何成为Apache Linkis文档贡献者
- 20192407 2021-2022-2 experimental report on Experiment 8 of network and system attack and Defense Technology
- Connexion MySQL errorcode 1129, State hy000, Host 'xxx' is Blocked because of many Connection Errors
猜你喜欢

Nanny tutorial: how to become a contributor to Apache linkis documents

一、Vulkan开发理论基础知识

Can you still have a wonderful life if you are laid off at the age of 35?

CET-6 - Business English - the last recitation before the test

【生成对抗网络学习 其一】经典GAN与其存在的问题和相关改进

保姆级教程:如何成为Apache Linkis文档贡献者

Attack and defense drill | network security "whistleblower": security monitoring

游戏兼容性测试(通用方案)

Construction of RT thread smart win10 64 bit compilation environment

2 pcs share a set of keyboard and mouse
随机推荐
蛮力法/1~n的幂集 v4 递归
LeetCode 进阶之路 - 加一
从h264实时流中提取Nalu单元数据
请问九洲期货是正规的吗?开户安不安全
【生成对抗网络学习 其一】经典GAN与其存在的问题和相关改进
shell实现ssh登录并执行命令
LeetCode 进阶之路 - 搜索插入位置
【无标题】破目
app測試用例
Redis集群配置
^30H5 Web Worker多线程
信号与系统复习1
蛮力法/任务分配
[generation confrontation network learning part I] classic Gan and its existing problems and related improvements
LeetCode:497. Random points in non overlapping rectangles -- medium
mysql基础篇之mysql在已有表中添加自动增加的主键(或任意一个字段)
pdf.js-----js解析pdf文件實現預覽,並獲取pdf文件中的內容(數組形式)
Pytorch deep learning -- neural network convolution layer conv2d
Unity analyzes the rendering of built-in terrain and does some interesting things
Codeforces Round #798 (Div. 2)