From aecf440f5ab20bd49d41616c201db87fb1f56fc5 Mon Sep 17 00:00:00 2001
From: Yogender Gupta <ygupta@nvidia.com>
Date: Fri, 12 Jan 2018 16:23:12 +0530
Subject: [PATCH] cuviddec : Set key_frame for the decoded frame

---
 libavcodec/cuviddec.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index c23033c..54f6cb7 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -74,6 +74,8 @@ typedef struct CuvidContext
     int internal_error;
     int decoder_flushing;
 
+    int key_frame[32];
+
     cudaVideoCodec codec_type;
     cudaVideoChromaFormat chroma_format;
 
@@ -340,6 +342,8 @@ static int CUDAAPI cuvid_handle_picture_decode(void *opaque, CUVIDPICPARAMS* pic
 
     av_log(avctx, AV_LOG_TRACE, "pfnDecodePicture\n");
 
+    ctx->key_frame[picparams->CurrPicIdx] = picparams->intra_pic_flag;
+
     ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams));
     if (ctx->internal_error < 0)
         return 0;
@@ -590,6 +594,7 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
             goto error;
         }
 
+        frame->key_frame = ctx->key_frame[parsed_frame.dispinfo.picture_index];
         frame->width = avctx->width;
         frame->height = avctx->height;
         if (avctx->pkt_timebase.num && avctx->pkt_timebase.den)
-- 
2.10.1.windows.1

