[MPlayer-dev-eng] About H.264 4-byte start code
lorenm at u.washington.edu
Mon Jan 12 18:07:25 CET 2009
On Mon, 12 Jan 2009, Reimar Döffinger wrote:
> On Mon, Jan 12, 2009 at 12:19:15PM +0100, Nico Sabbi wrote:
>> are you sure?
>> I remember that some time ago you explained me that the 4 leading 0s
>> were actually the right format to use
> For files according to annex B (AFAIK only raw and MPEG container) yes,
> but not in general. I also think that I didn't do the explaining, but
> that it was actually explained to me...
Annex B is the only part of the standard that mentions startcodes, so what
else would you be using?
Anyway, the rule is: startcode is 4 bytes for the first NAL in each
frame, and 3 for the rest.
Or to use the terminology from the spec: startcode is always 3 bytes, but
there shall be an additional leading zero byte for the first NAL of each
frame. This is nominally to allow byte-aligned search for the startcode
if somehow you have a non-byte-aligned bitstream.
(Any number of extra leading zero bytes is always allowed, they'll just be
interpreted as trailing in the previous NAL. So no decoder will complain
if you use 4 byte startcodes.)
More information about the MPlayer-dev-eng