avcodec/ituh263dec: Correct timestamp recovery for B frames
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 1 Feb 2017 19:20:07 +0000 (20:20 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 1 Feb 2017 21:01:34 +0000 (22:01 +0100)
Improves u263_b-frames_5.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/ituh263dec.c

index 4a8bbf7..31951ab 100644 (file)
@@ -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 */