[FFmpeg-devel] [PATCH v1 1/1] avcodec/h264: workaround if the IDR frame_num is non-zero for some error clips.

Decai Lin decai.lin at intel.com
Thu Mar 28 14:13:28 EET 2019


Signed-off-by: Decai Lin <decai.lin at intel.com>
---
 libavcodec/h264_slice.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 1c9a270..1bc9bdb 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1477,6 +1477,11 @@ static int h264_field_start(H264Context *h, const H264SliceContext *sl,
     /* Shorten frame num gaps so we don't have to allocate reference
      * frames just to throw them away */
     if (h->poc.frame_num != h->poc.prev_frame_num) {
+        /* In case for some error clips the IDR frame_num is not-zero, set the
+         * prev_frame_num = frame_num -1; otherwise will generate frame num gap. */
+        if (nal->type == H264_NAL_IDR_SLICE && h->poc.frame_num != 0)
+            h->poc.prev_frame_num = h->poc.frame_num - 1;
+
         int unwrap_prev_frame_num = h->poc.prev_frame_num;
         int max_frame_num         = 1 << sps->log2_max_frame_num;
 
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list