From f35c6df5a9734040a0c5d9a030d67f571a0966e4 Mon Sep 17 00:00:00 2001
From: Mukund Manikarnike <mukunm@gmail.com>
Date: Mon, 15 Jul 2019 08:34:39 -0700
Subject: [PATCH] Issue#6001:Fix for incorrect refs frame count in ffprobe

Description of the issue and sample files are available below:
https://trac.ffmpeg.org/ticket/6001

Description of the fix is below:
After parsing SPS, the reference frame count wasn't being copied
to the codec context. Hence, what was being returned in the output
was the default value inserted into the context on initialization.

Signed-off-by: Mukund Manikarnike <mukunm@gmail.com>
---
 libavcodec/h264_ps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index e8738d8502..f0af9f8809 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -483,6 +483,8 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx,
     }
 
     sps->ref_frame_count = get_ue_golomb_31(gb);
+    // Copy reference frame count to codec context.
+    avctx->refs = sps->ref_frame_count;    
     if (avctx->codec_tag == MKTAG('S', 'M', 'V', '2'))
         sps->ref_frame_count = FFMAX(2, sps->ref_frame_count);
     if (sps->ref_frame_count > MAX_DELAYED_PIC_COUNT) {
-- 
2.21.0

