[vlc-commits] packetizer: h264: fix recovery point test

Francois Cartegnie git at videolan.org
Fri Mar 16 19:19:54 CET 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar 16 18:35:25 2018 +0100| [910d0112a9103ed0d52d7cd0999b64cf38ad1002] | committer: Francois Cartegnie

packetizer: h264: fix recovery point test

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=910d0112a9103ed0d52d7cd0999b64cf38ad1002
---

 modules/packetizer/h264.c       | 12 ++++++++----
 modules/packetizer/h264_slice.c |  2 +-
 modules/packetizer/h264_slice.h |  4 ++--
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 7386b07c36..76b6ed5286 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -114,6 +114,7 @@ struct decoder_sys_t
     int i_next_block_flags;
     bool b_recovered;
     unsigned i_recoveryfnum;
+    unsigned i_recoverystartfnum;
 
     /* POC */
     h264_poc_context_t pocctx;
@@ -789,6 +790,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
          p_sys->i_recoveryfnum == UINT_MAX )
     {
         p_sys->i_recoveryfnum = p_sys->slice.i_frame_num + p_sys->i_recovery_frame_cnt;
+        p_sys->i_recoverystartfnum = p_sys->slice.i_frame_num;
         b_need_sps_pps = true; /* SPS/PPS must be inserted for SEI recovery */
         msg_Dbg( p_dec, "Recovering using SEI, prerolling %u reference pics", p_sys->i_recovery_frame_cnt );
     }
@@ -797,10 +799,12 @@ static block_t *OutputPicture( decoder_t *p_dec )
     {
         assert(p_sys->b_recovered == false);
         const unsigned maxFrameNum = 1 << (p_sps->i_log2_max_frame_num + 4);
-        if( (p_sys->i_recoveryfnum > maxFrameNum &&
-            (unsigned)p_sys->slice.i_frame_num <= maxFrameNum / 2 &&
-            (unsigned)p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum % maxFrameNum ) ||
-            (unsigned)p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum )
+
+        if( ( p_sys->i_recoveryfnum > maxFrameNum &&
+              p_sys->slice.i_frame_num < p_sys->i_recoverystartfnum &&
+              p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum % maxFrameNum ) ||
+            ( p_sys->i_recoveryfnum <= maxFrameNum &&
+              p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum ) )
         {
             p_sys->i_recoveryfnum = UINT_MAX;
             p_sys->b_recovered = true;
diff --git a/modules/packetizer/h264_slice.c b/modules/packetizer/h264_slice.c
index 964fcafe88..d05256e93e 100644
--- a/modules/packetizer/h264_slice.c
+++ b/modules/packetizer/h264_slice.c
@@ -270,7 +270,7 @@ void h264_compute_poc( const h264_sequence_parameter_set_t *p_sps,
 
         if( p_slice->i_nal_type == H264_NAL_SLICE_IDR )
             frameNumOffset = 0;
-        else if( p_ctx->prevFrameNum > (unsigned) p_slice->i_frame_num )
+        else if( p_ctx->prevFrameNum > p_slice->i_frame_num )
             frameNumOffset = p_ctx->prevFrameNumOffset + maxFrameNum;
         else
             frameNumOffset = p_ctx->prevFrameNumOffset;
diff --git a/modules/packetizer/h264_slice.h b/modules/packetizer/h264_slice.h
index 301e57397f..029c94f65c 100644
--- a/modules/packetizer/h264_slice.h
+++ b/modules/packetizer/h264_slice.h
@@ -37,7 +37,7 @@ typedef struct
 
     enum h264_slice_type_e type;
     int i_pic_parameter_set_id;
-    int i_frame_num;
+    unsigned i_frame_num;
 
     int i_field_pic_flag;
     int i_bottom_field_flag;
@@ -59,7 +59,7 @@ static inline void h264_slice_init( h264_slice_t *p_slice )
     p_slice->i_nal_type = -1;
     p_slice->i_nal_ref_idc = -1;
     p_slice->i_idr_pic_id = -1;
-    p_slice->i_frame_num = -1;
+    p_slice->i_frame_num = 0;
     p_slice->type = H264_SLICE_TYPE_UNKNOWN;
     p_slice->i_pic_parameter_set_id = -1;
     p_slice->i_field_pic_flag = 0;



More information about the vlc-commits mailing list