当前位置:网站首页>Annexb and avcc are two methods of data segmentation in decoding
Annexb and avcc are two methods of data segmentation in decoding
2022-07-07 15:41:00 【When can Xiaobai advance to success】
at present H.264 There are two popular ways of packaging , One is called AnnexB, One is called avcC. For both formats , The degree of support of each family is also different , for example ,Android Hard decoding MediaCodec We only accept AnnexB Formatted data , and Apple Of VideoToolBox, Only support avcC The format of . So this requires our practitioners to have an understanding of both formats . This chapter , Let's introduce AnnexB
1、AnnexB
1.1 Introduce
If we put more NALU Write it in a file , Multiple NALU The first one is connected and threaded into a string , because NALU Its length is different , There is no specific identifier to indicate that you are an independent NALU, When we read this file, there is no way to write it together NALU Effectively distinguish . To solve this problem , We have to give NALU Add some data , Will all NALU Segmentation . AnnexB It's used to deal with NALU A format in which layers are packed .
AnnexB The principle of format is very simple , It's in one NALU Add three or four bytes to the front , The contents of these bytes are 0 0 0 1 perhaps 0 0 1. When we read a H264 When it's flowing , Once encountered 0 0 0 1 perhaps 0 0 1, We think of a new NALU Here we go , therefore , These bytes used as separators , It is also commonly known as start code, Start code .
1.2 Anti contention byte (Emulation Prevention Bytes)
But only in NALU Adding the start code in front of it will cause problems , Because in the original code stream , It is possible that 0 0 0 1 perhaps 0 0 1 Of , This will cause the reader to send a NALU Wrong segmentation into multiple NALU. To prevent this from happening ,AnnexB Anti contention bytes are introduced (Emulation Prevention Bytes) The concept of .
The so-called anti contention byte (Emulation Prevention Bytes), It's just for you NALU Before adding the start code , First traverse the code stream , Find the existing in the code stream 0 0 0,0 0 1,0 0 2,0 0 3 Bytes of , Then modify it as follows
0 0 0 => 0 0 3 0
0 0 1 => 0 0 3 1
0 0 2 => 0 0 3 2
0 0 3 => 0 0 3 3
Copy code
That is, above 4 Under different circumstances , stay 0 0 after , Insert a byte , The content is 3. The code stream processed in this way , No longer with the start code (0 0 1, 0 0 0 1) Conflict due to repetition .
Of course , During decoding , Successfully split through the start code NALU After the data , Also remove the anti contention bytes .
0 0 3 0 => 0 0 0
0 0 3 1 => 0 0 1
0 0 3 2 => 0 0 2
0 0 3 3 => 0 0 3
Copy code
Only in this way can we get real NALU stream .
Two 、avcC
AnnexB The principle is in every NALU Write a special start code in front , Use this starting code as NALU The delimiter , Thus dividing each NALU. and avcC In another way . That is in NALU Write a few bytes in front , These bytes form an integer ( Big endian byte order ) This integer represents the whole NALU The length of . When reading , First read out this integer , Get this NALU The length of , Then read the whole by length NALU.
2.1 avcC Detailed explanation
Introducing avcC Before the format , Let's first introduce two special NALU, these two items. NALU Namely SPS and PPS,SPS and PPS Stored decoding all the way H.264 Necessary parameter information of code stream , in other words , You want to decode all the way H.264, You must first get SPS and PPS. In a later lesson , We will introduce in detail SPS and PPS, Now all you need to know is ,SPS and PPS Are two special and important NALU.
stay AnnexB in ,SPS and PPS It is regarded as ordinary NALU To deal with ; And in the avcC in ,SPS and PPS Information is treated as special information .
Adopt in one way avcC packaged H.264 In the stream , The first thing we will see is a passage called extradata The data of , This data defines this H.264 Basic attribute data of flow , Of course , Also includes SPS and PPS data .
Let's take a look extradata data format
bits
8 version ( always 0x01 )
8 avc profile ( sps[0][1] )
8 avc compatibility ( sps[0][2] )
8 avc level ( sps[0][3] )
6 reserved ( all bits on )
2 NALULengthSizeMinusOne // This value is ( Prefix length -1)
3 reserved ( all bits on )
5 number of SPS NALUs (usually 1)
repeated once per SPS:
16 SPS size
variable SPS NALU data
8 number of PPS NALUs (usually 1)
repeated once per PPS
16 PPS size
variable PPS NALU data
Copy code
Let's take a look at this value NALULengthSizeMinusOne, By adding this value to 1 , We've come to the conclusion that each of the following NALU Prefix before ( It's an integer that represents the length ) Bytes of
for example , This NALULengthSizeMinusOne yes 3, Then each NALU The length of the prefix is 4 Bytes . When we read subsequent data , You can read it first 4 Bytes , And then turn these four bytes into integers , This is this. NALU The length of the , Be careful , This length does not include the starting 4 Bytes , It's simple NALU The length of .
边栏推荐
- [quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)
- Super simple and fully automated generation super signature system (cloud Xiaoduo minclouds.com cloud service instance), free application in-house test app distribution and hosting platform, maintenan
- [quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
- [quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
- Ctfshow, information collection: web6
- Ctfshow, information collection: web12
- Create lib Library in keil and use lib Library
- Oracle control file loss recovery archive mode method
- 知否|两大风控最重要指标与客群好坏的关系分析
- webgl_ Enter the three-dimensional world (1)
猜你喜欢
[quick start of Digital IC Verification] 22. Ahb-sramc of SystemVerilog project practice (2) (Introduction to AMBA bus)
Summer safety is very important! Emergency safety education enters kindergarten
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
[make a boat diary] [shapr3d STL format to gcode]
Ctfshow, information collection: web9
#HPDC智能基座人才发展峰会随笔
[quick start of Digital IC Verification] 23. AHB sramc of SystemVerilog project practice (3) (basic points of AHB protocol)
Ctfshow, information collection: web4
Super signature principle (fully automated super signature) [Yun Xiaoduo]
Getting started with webgl (2)
随机推荐
【兰州大学】考研初试复试资料分享
[quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
Ctfshow, information collection: web14
【搞船日记】【Shapr3D的STL格式转Gcode】
Guangzhou Development Zone enables geographical indication products to help rural revitalization
全日制研究生和非全日制研究生的区别!
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
Ctfshow, information collection: web6
Qu'est - ce qu'une violation de données
Getting started with webgl (4)
2.Golang基础知识
【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)
MySQL bit type resolution
Monthly observation of internet medical field in May 2022
webgl_ Graphic transformation (rotation, translation, zoom)
什麼是數據泄露
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
银行需要搭建智能客服模块的中台能力,驱动全场景智能客服务升级
【数据挖掘】视觉模式挖掘:Hog特征+余弦相似度/k-means聚类
有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?