[MPlayer-dev-eng] About H.264 4-byte start code
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Jan 12 11:00:07 CET 2009
On Mon, Jan 12, 2009 at 10:17:37AM +0800, Jetta wrote:
> I apologize first if this issue is inappropriate in this maillist.
> I want to use our own new H.264 decoder in MPlayer(in libavcodec), now i
> have a problem.
> Our H264 decoding library assumes that H.264 stream's start code is
> 4-byte 0x00000001, but in Mplayer, it seems to use 3-byte pattern 0x000001
> by calling the function "demux_pattern_3" when read packet. So the input
> date given to H264 decoder will just have 0x000001 start code.
> Can i just write a new function just like "demux_pattern_4" in file
> "demuxer.c" to solve this problem?
No, read the standard. Section 6.1 clearly says that the start code is
a three-byte sequence, if your decoder does not accept that, it probably
only works works with raw H.264 encoded as specified by Annex B.
I'd expect a good H.264 decoder library to also support the frame-based
format, but if it does not, you will have to convert the data, just
adding the additional 0 is unlikely to work in the general case.
The code in libavodec/h264_mp4toannexb_bsf.c should be similar to what
you need to do (unless you are indeed only interesting in decoding a raw
H.264 stream and don't care about mov/mp4).
Greetings,
Reimar Döffinger
More information about the MPlayer-dev-eng
mailing list