[FFmpeg-devel] [PATCH] mpeg4video: ignore broken GOP headers

Michael Niedermayer michaelni
Mon Feb 14 13:18:22 CET 2011


On Sun, Feb 13, 2011 at 07:22:19PM +0100, Janne Grunau wrote:
> On Sun, Feb 13, 2011 at 03:57:44PM +0000, Mans Rullgard wrote:
> > From: Anatoly Nenashev <anatoly.nenashev at ovsoft.ru>
> > 
> > Some MPEG4 cameras produce files with empty GOP headers.
> > This patch makes the decoder ignore such broken headers and proceed
> > with the following I-frame.  Without this change, the following
> > start code is missed resulting in the entire I-frame being skipped.
> > 
> > Signed-off-by: Mans Rullgard <mans at mansr.com>
> > ---
> >  libavcodec/mpeg4videodec.c |   21 +++++++++++----------
> >  1 files changed, 11 insertions(+), 10 deletions(-)
> > 
> > diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> > index 673c4e8..617dcb9 100644
> > --- a/libavcodec/mpeg4videodec.c
> > +++ b/libavcodec/mpeg4videodec.c
> > @@ -1494,16 +1494,17 @@ end:
> >  
> >  static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
> >      int hours, minutes, seconds;
> > -
> > -    hours= get_bits(gb, 5);
> > -    minutes= get_bits(gb, 6);
> > -    skip_bits1(gb);
> > -    seconds= get_bits(gb, 6);
> > -
> > -    s->time_base= seconds + 60*(minutes + 60*hours);
> > -
> > -    skip_bits1(gb);
> > -    skip_bits1(gb);
> > +    unsigned time_code = show_bits(gb, 18);
> > +
> > +    if (time_code & 0x40) {     /* marker_bit */
> > +        hours   = time_code >> 13;
> > +        minutes = time_code >>  7 & 0x3f;
> > +        seconds = time_code       & 0x3f;
> > +        s->time_base = seconds + 60*(minutes + 60*hours);
> > +        skip_bits(gb, 20);      /* time_code, closed_gov, broken_link */
> > +    } else {
> > +        av_log(s->avctx, AV_LOG_WARNING, "GOP header missing marker_bit\n");
> > +    }
> >  
> >      return 0;
> >  }
> 
> ok

rejected and implemented correctly in ffmpeg at videolan

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

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110214/48e1d3f5/attachment.pgp>



More information about the ffmpeg-devel mailing list