(b) 兩標準的宏塊cbp值計算也不相同。H.264中,Intra_16*16宏塊的亮度(色度)cbp直接通過讀mb type得到;非Intra_16*16宏塊的亮度cbp=coded_block_pattern%16,色度cbp=coded_block_pattern/16 。其中,亮度cbp最低4位有效,每位決定對應宏塊的殘差系數能不能為0;色度cbp為0時,對應殘差系數為0,cbp為1時,DC殘差系數不為0,AC系數為0,cbp為2時,DC、AC殘差系數都不為0。AVS-M中,當宏塊類型不是P_skip時,直接從碼流中得到cbp的索引值,并以此索引值查表得到codenum值,再以codenum查表分別得到幀內/幀間cbp。此cbp為6位,每位代表宏塊按8*8劃分時能不能包含非零系數,當變換系數不為0時,需進一步讀cbp_4*4中每位值來判斷一個8*8塊中4個4*4塊的系數能不能為0。 --------------------------------------------------------------------------------------------- 總的來說H264的碼流的打包方式有兩種,一種為annex-b byte stream format的格式,這個是絕大部分編碼器的默認輸出格式,就是每個幀的開頭的3~4個字節是H264的start_code,0x00000001或者0x000001。 另一種是原始的NAL打包格式,就是開始的若干字節(1,2,4字節)是NAL的長度,而不是start_code,此時必須借助某個全局的數據來獲得編碼器的profile,level,PPS,SPS等信息才可以解碼。 ---------------------------------------------------------------------------- AVC vs. H.264 AVC and H.264 are synonymous. The standard is known by the full names "ISO/IEC 14496-10" and "ITU-T Recommendation H.264". In addition, a number of alternate names are used (or have been) in reference to this standard. These include:
MPEG-4 part 10
MPEG-4 AVC
AVC
MPEG-4 (in the broadcasting world MPEG4 part 2 is ignored)
H.264
JVT (Joint Video Team, nowadays rarely used referring to actual spec)
H.26L (early drafts went by this name)
All of the above (and those I've missed) include the Annex B byte-stream format. Unlike earlier MPEG1/2/4 and H.26x codecs, the H.264 specification proper does not define a full bit-stream syntax. It describes a number of NAL (Network Abstraction Layer) units, a sequence of which can be decoded into video frames. These NAL units have no boundary markers, and rely on some unspecified format to provide framing.
Annex B of of the document specifies one such format, which wraps NAL units in a format resembling a traditional MPEG video elementary stream, thus making it suitable for use with containers like MPEG PS/TS unable to provide the required framing. Other formats, such as ISO base media based formats, are able to properly separate the NAL units and do not need the Annex B wrapping.
The H.264 spec suffers from a deficiency. It defines several header-type NAL units (SPS and PPS) without specifying how to pack them into the single codec data field available in most containers. Fortunately, most containers seem to have adopted the packing used by the ISO format known as MP4. 1. H.264起始碼 ?? 在網絡傳輸h264數據時,一個UDP包就是一個NALU,解碼器可以很方便的檢測出NAL分界和解碼。但是如果編碼數據存儲為一個文件,原來的解碼器將無法從數據流中分別出每個NAL的起始位置和終止位置,為此h.264用起始碼來解決這一問題。