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