diff mbox series

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

Message ID 20220216085146.26078-1-lq@chinaffmpeg.org
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/h264_slice: compute prev_frame_num_offset to correct value | expand


Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Steven Liu Feb. 16, 2022, 8:51 a.m. UTC
From: Shitao Wang <wangshitao@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@kuaishou.com>
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
 libavcodec/h264_slice.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series


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,
+        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;