[FFmpeg-cvslog] Don't fill in frame gaps with copied refs after flush

Joakim Plate git at videolan.org
Fri Nov 18 21:32:49 CET 2011


ffmpeg | branch: master | Joakim Plate <elupus at ecce.se> | Fri Nov 18 20:36:13 2011 +0100| [babf4fe01a808327d53977ba319c113a930180b1] | committer: Michael Niedermayer

Don't fill in frame gaps with copied refs after flush

The filled in refs cause corruptions in the video frame
for a long time after it should have recovered.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=babf4fe01a808327d53977ba319c113a930180b1
---

 libavcodec/h264.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index c389f96..b659c38 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -2367,7 +2367,7 @@ static void implicit_weight_table(H264Context *h, int field){
 static void idr(H264Context *h){
     int i;
     ff_h264_remove_all_refs(h);
-    h->prev_frame_num= 0;
+    h->prev_frame_num= -1;
     h->prev_frame_num_offset= 0;
     h->prev_poc_msb=
     h->prev_poc_lsb= 0;
@@ -2882,7 +2882,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
 
     if(h0->current_slice == 0){
         // Shorten frame num gaps so we don't have to allocate reference frames just to throw them away
-        if(h->frame_num != h->prev_frame_num) {
+        if(h->frame_num != h->prev_frame_num && h->prev_frame_num >= 0) {
             int unwrap_prev_frame_num = h->prev_frame_num, max_frame_num = 1<<h->sps.log2_max_frame_num;
 
             if (unwrap_prev_frame_num > h->frame_num) unwrap_prev_frame_num -= max_frame_num;
@@ -2896,7 +2896,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
             }
         }
 
-        while(h->frame_num !=  h->prev_frame_num &&
+        while(h->frame_num !=  h->prev_frame_num && h->prev_frame_num >= 0 &&
               h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){
             Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL;
             av_log(h->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num);



More information about the ffmpeg-cvslog mailing list