for(;;) { if next 24 bits are 0x000001 { startCodeFound = true break; } else { flush 8 bits }
}// for(;;)
if(true == startCodeFound) { //startcode found // Flush the start code found flush 24 bits
//Now navigate up to next start code and put the in between stuff // in the nal structure. for(;;) { get next 24 bits & check if it equals to 0x000001 if(false == (next 24 bits == 000001)) { // search for pattern 0x000000 check if next 24 bits are 0x000000 if(false == result) { // copy the byte into the buffer copy one byte to the Nal unit } else { break; } } else { break; } }//for(;;) }
2. MPEG4起始码
MPEG4的特色是VOP,没有NALU的概念,仍使用startcode对每帧进行分界。MPEG4的起始码是0x000001. 另外MPEG4中很多起始码也很有用,比如video_object_sequence_start_code 0x000001B0 表示一个视频对象序列的开始,VO_start_code 0x000001B6 表示一个VOP的开始. 0x000001B6之后的两位,是00表示 I frame, 01 表示 P frame, 10 表示 B frame.