diff mbox

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

Message ID 1553775208-25791-1-git-send-email-decai.lin@intel.com
State New
Headers show

Commit Message

Decai Lin March 28, 2019, 12:13 p.m. UTC
Signed-off-by: Decai Lin <decai.lin@intel.com>
---
 libavcodec/h264_slice.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox

Patch

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;