From 0126cd95ccc37aa327e8eff6e4f58dda4f861adf Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 1 Feb 2017 20:20:07 +0100 Subject: [PATCH] avcodec/ituh263dec: Correct timestamp recovery for B frames Improves u263_b-frames_5.avi Signed-off-by: Michael Niedermayer --- libavcodec/ituh263dec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 4a8bbf7798..31951abd65 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -928,8 +928,9 @@ int ff_h263_decode_picture_header(MpegEncContext *s) } /* temporal reference */ i = get_bits(&s->gb, 8); /* picture timestamp */ - if( (s->picture_number&~0xFF)+i < s->picture_number) - i+= 256; + + i -= (i - (s->picture_number & 0xFF) + 128) & ~0xFF; + s->picture_number= (s->picture_number&~0xFF) + i; /* PTYPE starts here */