[FFmpeg-devel] [PATCH 1/2] avcodec/h264_slice: compute prev_frame_num_offset to correct value

Steven Liu lq at chinaffmpeg.org
Wed Feb 16 10:51:45 EET 2022


From: Shitao Wang <wangshitao at kuaishou.com>

If H.264 stream decode under loss packet transport network, h264_slice
will process prev_frame_num_offset in wrong way, it will dup picture,
This is different to JM, so compute the prev_frame_num_offset when
prev_frame_num >= (1 << sps->log2_max_frame_num), then it will
same as JM.

Signed-off-by: Shitao Wang <wangshitao at kuaishou.com>
Signed-off-by: Steven Liu <liuqi05 at kuaishou.com>
---
 libavcodec/h264_slice.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 110a41772a..6f21c48b2d 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1667,6 +1667,8 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
         }
 
         h->poc.prev_frame_num++;
+        if (h->poc.prev_frame_num >= (1 << sps->log2_max_frame_num))
+            h->poc.prev_frame_num_offset += 1 << sps->log2_max_frame_num;
         h->poc.prev_frame_num        %= 1 << sps->log2_max_frame_num;
         h->cur_pic_ptr->frame_num = h->poc.prev_frame_num;
         h->cur_pic_ptr->invalid_gap = !sps->gaps_in_frame_num_allowed_flag;
-- 
2.25.0



More information about the ffmpeg-devel mailing list