[FFmpeg-devel] [PATCH] Fix empty G-VOP header decoding in MPEG-4
Måns Rullgård
mans
Tue Feb 8 20:00:41 CET 2011
Anatoly Nenashev <anatoly.nenashev at ovsoft.ru> writes:
> Hi all!
> There are some cameras which send mpeg-4 streams with empty G-VOP header.
> This part of stream looks like this:
> ... 00 00 01 B3 00 00 00 01 B6 ...
> Sample file uploaded in issue 2592.
> FFmpeg reports "header damaged" and ignores first I-frame in G-VOP.
> Attached patch fix this problem.
>
> Anatoly.
>
>
> diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
> index 5303da3..b012c7f 100644
> --- a/libavcodec/mpeg4videodec.c
> +++ b/libavcodec/mpeg4videodec.c
> @@ -1494,17 +1494,14 @@ end:
>
> static int mpeg4_decode_gop_header(MpegEncContext * s, GetBitContext *gb){
> int hours, minutes, seconds;
> + int val;
>
> - hours= get_bits(gb, 5);
> - minutes= get_bits(gb, 6);
> - skip_bits1(gb);
> - seconds= get_bits(gb, 6);
> -
> + val = show_bits(gb, 24);
Why 24? The time_code field is 18 bits.
> + hours = (val >> 19) & 0x1F;
> + minutes = (val >> 13) & 0x3F;
> + seconds = (val >> 6) & 0x3F;
> s->time_base= seconds + 60*(minutes + 60*hours);
>
> - skip_bits1(gb);
> - skip_bits1(gb);
> -
> return 0;
> }
Looking at this, I wonder why this is there at all. The s->time_base
field is only used to incorrectly set the pts field of the decoded
frame (now I understand why those values always are wrong). The
actual PTS is passed from the input packet to the pkt_pts field of the
output frame.
IMO this nonsense should be removed. The time_code field in the
bitstream has nothing to do with PTS.
--
M?ns Rullg?rd
mans at mansr.com
More information about the ffmpeg-devel
mailing list