[FFmpeg-devel] [PATCH] H264 parser fix

Michael Niedermayer michaelni
Fri May 28 21:34:34 CEST 2010


On Thu, May 27, 2010 at 09:29:52PM -0700, Howard Chu wrote:
> Michael Niedermayer wrote:
>> On Tue, May 25, 2010 at 08:49:13PM -0700, Howard Chu wrote:
>>> OK. Added an explicit flag to the H264Context for this instead. Still 
>>> this
>>> feels clumsy, it should have just been done in the parser_init step. Also
>>> it feels clumsy that it has to be parsed again, when the H264Context
>>> hanging off the AVCodecContext may already have it (due to
>>> ff_h264_decode_init() having parsed it already).
>
>>> There was a suggestion on IRC to add an av_parser_init2() API which
>>> provides the AVCodecContext, to be given to a new H264 parser_init2
>>> function. It could just fallback to passing the codec_id if a given 
>>> parser
>>> doesn't implement the init2 function...
>>
>> if that works iam nt against it but it will require apps to be updated for
>> some files. not a big issue as far as iam concerned
>
> I decided it was too much trouble to add a new API for this. I also noticed 
> that mpeg4video_parser is already doing the same thing as the patch I 
> posted, so I'm going to stick with that approach. Added a "first_picture" 
> flag, which is used the same way as the flag in ParseContext1 used by 
> mpeg4video_parser.
>
> I didn't add the flag to the end of the structure, didn't think it was 
> necessary since H264Context is totally private.
>
> -- 
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/

> Index: h264_parser.c
> ===================================================================
> --- h264_parser.c	(revision 23341)
> +++ h264_parser.c	(working copy)
> @@ -245,6 +245,14 @@
>      ParseContext *pc = &h->s.parse_context;
>      int next;
>  
> +    if (h->first_picture) {
> +        h->first_picture = 0;
> +        if (avctx->extradata_size) {
> +            h->s.avctx = avctx;
> +            ff_h264_decode_extradata(h);
> +        }
> +    }
> +
>      if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
>          next= buf_size;
>      }else{
> @@ -319,6 +327,7 @@
>  {
>      H264Context *h = s->priv_data;
>      h->thread_context[0] = h;
> +    h->first_picture = 1;

a variable that starts with 0 wouldnt need this

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Thouse who are best at talking, realize last or never when they are wrong.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100528/46c69dba/attachment.pgp>



More information about the ffmpeg-devel mailing list