h264: Calculate a tighter recovery_frame.
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 24 Oct 2011 10:17:24 +0000 (12:17 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 24 Oct 2011 10:17:24 +0000 (12:17 +0200)
Reduces delay with mplayers TS demuxer.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/h264.c

index b353bee..ce633ea 100644 (file)
@@ -3863,7 +3863,8 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
             if((err = decode_slice_header(hx, h)))
                break;
 
-            if (h->sei_recovery_frame_cnt >= 0 && h->recovery_frame < 0) {
+            if (   h->sei_recovery_frame_cnt >= 0
+                && (h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1) > h->sei_recovery_frame_cnt) {
                 h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) %
                                     (1 << h->sps.log2_max_frame_num);
             }