[FFmpeg-devel] [PATCH] H264 parser fix

Howard Chu hyc
Tue May 25 16:29:11 CEST 2010

Michael Niedermayer wrote:
> On Mon, May 24, 2010 at 11:25:05AM -0700, Howard Chu wrote:
>> Michael Niedermayer wrote:
>>> On Wed, May 19, 2010 at 01:15:17AM -0700, Howard Chu wrote:
>>>> When decoding an H264 stream that uses global headers, you get an endless
>>>> stream of "non-existing PPS referenced" messages. This message comes from
>>>> h264_parser.c, and it happens because it's using an H264Context hanging
>>>> off
>>>> the AVCodecParserContext, which is separate from the H264Context hanging
>>>> off the AVCodecContext, and only the AVCodecContext contains the
>>>> extradata
>>>> that provides the PPS and SPS.
>>>> This patch is admittedly a hack, but it stops the error. It just checks
>>>> in
>>>> the AVCodecContext if the PPS wasn't found in the AVCodecParserContext.
>>> ugly ugly ugly
>>> if iam not mistaken this would be fixed by making the parser work with
>>> mov/mkv ("avc") style h264
>> I read thru mov.c and matroskadec.c and couldn't find anything relevant, so
>> I don't understand what your suggestion means.
> i thought that the problem is that the parser is feeded a format it does not
> support. I did not confirm this but i see no reason that this is a different
> issue.

That is not the problem I was reporting. The parser has no trouble with the 
data format. It is simply missing the PPS and SPS because they were not 
available in the AVCodecParserContext. The extradata is only available in the 

> The format difference should be easiest vissible by looking at code
> surrounding is_avc in h264.c
> if this is the issue the parser should be improved to suport the slghtly
> differnt way to pack things and also to look in extradata.

Before we can tell the parser to look in the extradata, we have to give the 
parser a way to access it, ideally when the parser is initialized. Right now 
there's no reliable way to do that. It seems odd to me that the parser entry 
points all require an AVCodecContext but av_parser_init() only takes a 
codec_id. If av_parser_init() took an AVCodecContext instead, all of the 
necessary information would be available.
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

More information about the ffmpeg-devel mailing list