当前位置:网站首页>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
边栏推荐
- 设计多层PCB板需要注意哪些事项?
- The excess part of the table setting is hidden. Move the mouse to display all
- P5723 [deep base 4. example 13] prime number pocket
- 获取的网络时间 + 时区(+8)
- 20192407 2021-2022-2 experimental report on Experiment 8 of network and system attack and Defense Technology
- Read the source code of micropyton - add the C extension class module (2)
- 01js基础 null与undefined区别 类型转换 == 代码块 逻辑运算符
- Pytorch deep learning -- convolution operation and code examples
- 六级考试-商务英语-考前最后一背
- 蛮力法/u到v是否存在简单路径
猜你喜欢

^30H5 Web Worker多线程

Pytorch deep learning -- neural network convolution layer conv2d

魔塔类游戏实现源码及关卡生成

「运维有小邓」自助帐户解锁工具
![js基础及常考面试题之 [] == ![]结果为true, []==[]结果为false 详解](/img/42/bcda46a9297a544b44fea31be3f686.png)
js基础及常考面试题之 [] == ![]结果为true, []==[]结果为false 详解

72. editing distance ●●

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

自定义日期组件,左右按钮控制向前或向后翻年、翻月、翻周、翻日

电子招标采购商城系统:优化传统采购业务,提速企业数字化升级

2台电脑共享一套键盘鼠标
随机推荐
node(express)实现增删改查、分页等接口
从h264实时流中提取Nalu单元数据
Node (express) implements interfaces such as adding, deleting, modifying, and paging
保姆级教程:如何成为Apache Linkis文档贡献者
CET-6 - Business English - the last recitation before the test
leetcode 划分数组使最大差为 K
蛮力法/1~n的全排列 v3 递归
分布式服务理论基础
LeetCode 进阶之路 - 136.只出现一次的数字
一、Vulkan开发理论基础知识
LeetCode 进阶之路 - 搜索插入位置
Brute force method /k integers out of 1~n integers
连接mysql报错 errorCode 1129, state HY000, Host ‘xxx‘ is blocked because of many connection errors
Portable FDW framework for Pb
Redis cache breakdown
Redis缓存雪崩
RuntimeError: Attempting to deserialize object on CUDA device 1 but torch. cuda. device_ count() is 1.
KCon 2022 议题大众评选火热进行中!不要错过“心仪”的议题哦~
連接mysql報錯 errorCode 1129, state HY000, Host ‘xxx‘ is blocked because of many connection errors
简解深度学习Attention