2012年1月2日 星期一

JM18裡的MB_Type

(1).MB_TYPE
//  Available MB modes
enum {
  PSKIP        =  0,
  BSKIP_DIRECT =  0,
  P16x16       =  1,
  P16x8        =  2,
  P8x16        =  3,
  SMB8x8       =  4,
  SMB8x4       =  5,
  SMB4x8       =  6,
  SMB4x4       =  7,
  P8x8         =  8,
  I4MB         =  9,
  I16MB        = 10,
  IBLOCK       = 11,
  SI4MB        = 12,
  I8MB         = 13,
  IPCM         = 14,
  MAXMODE      = 15
} MBModeTypes;

(2).NALU的bits配置
http://brytsai.blogspot.com/2010/02/h.html


H.264中如何判斷某一段是否為SPS(Sequence Parameter Set)或PPS(Picture Parameter Set)

在H.264中,無論是SPS、PPS或者是slice data,都是由一個NAL unit所組成。一個NAL unit的開始皆為00 00 00 01,下一個byte的值將決定這個NAL unit是屬於SPS或者是PPS還是slice data。
事實上下一個byte的值是由三個部份所組成,包括forbidden_bit、nal_reference_idc和nal_unit_type。其中 forbidden_bit佔1bit,一般來說其值為0。而nal_reference_idc佔2bit,其值用來表示此NAL在重建過程中重要程度。至於佔了5bit的nal_unit_type就比較重要了,用來表示該NAL unit是屬於何種類型。
下表是H.264標準中定義所有NAL的類型
#define NALU_TYPE_SLICE 1
#define NALU_TYPE_DPA 2
#define NALU_TYPE_DPB 3
#define NALU_TYPE_DPC 4
#define NALU_TYPE_IDR 5
#define NALU_TYPE_SEI 6
#define NALU_TYPE_SPS 7
#define NALU_TYPE_PPS 8
#define NALU_TYPE_AUD 9
#define NALU_TYPE_EOSEQ 10
#define NALU_TYPE_EOSTREAM 11
#define NALU_TYPE_FILL 12
因此當nal_unit_type值為7時,則這個NAL unit即為SPS。而值為8時,這個NAL unit為PPS。
舉例來說,若擷取某一段H.264 bitstream為00 00 00 01 67 42 e0 14 da 05 82 51。
因為67 = 0 11 00111,nal_unit_tye = 00111 = 7,所以這一段為SPS。
又另一例00 00 00 01 68 ce 30 c4 80 00 00 00 00 00 00 00
68 = 01000,nal_unit_tye = 01000 = 8,所以這一段為PPS。