[FFmpeg-cvslog] avcodec/h264: in the absence of recovery points, be more tolerant on accepting plain I frames

Michael Niedermayer git at videolan.org
Tue Jun 10 00:38:52 CEST 2014


ffmpeg | branch: release/2.1 | Michael Niedermayer <michaelni at gmx.at> | Wed Jun  4 04:25:14 2014 +0200| [e8bb67c2a912618a41108c1f13178630f0f85471] | committer: Carl Eugen Hoyos

avcodec/h264: in the absence of recovery points, be more tolerant on accepting plain I frames

Fixes: Ticket3652
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 19c9d1e8e71da04c3ac940206619c0a2d01e5193)

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

 libavcodec/h264.c      |    1 +
 libavcodec/h264.h      |    2 ++
 libavcodec/h264_refs.c |    2 +-
 libavcodec/h264_sei.c  |    2 ++
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index b3593c6..807994f 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -4854,6 +4854,7 @@ again:
                 if(!idr_cleared)
                     idr(h); // FIXME ensure we don't lose some frames if there is reordering
                 idr_cleared = 1;
+                h->has_recovery_point = 1;
             case NAL_SLICE:
                 init_get_bits(&hx->gb, ptr, bit_length);
                 hx->intra_gb_ptr      =
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 63a3437..4473334 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -658,6 +658,8 @@ typedef struct H264Context {
 
     FPA sei_fpa;
 
+    int has_recovery_point;
+
     int luma_weight_flag[2];    ///< 7.4.3.2 luma_weight_lX_flag
     int chroma_weight_flag[2];  ///< 7.4.3.2 chroma_weight_lX_flag
 
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 3f29daf..e6228c2 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -740,7 +740,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
     if (   err >= 0
         && h->long_ref_count==0
         && (h->short_ref_count<=2 || h->pps.ref_count[0] <= 1 && h->pps.ref_count[1] <= 1 && pps_count == 1)
-        && h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME)
+        && h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) + (2*!h->has_recovery_point)
         && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
         h->cur_pic_ptr->sync |= 1;
         if(!h->avctx->has_b_frames)
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index 7d5558a..d65f40e 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -184,6 +184,8 @@ static int decode_recovery_point(H264Context *h)
     if (h->avctx->debug & FF_DEBUG_PICT_INFO)
         av_log(h->avctx, AV_LOG_DEBUG, "sei_recovery_frame_cnt: %d\n", h->sei_recovery_frame_cnt);
 
+    h->has_recovery_point = 1;
+
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list