This patch fixes setting of `key_frame` flag in AVFrame when input h264 packets represents individual fields of interlaced video.
In this case, pairs of two consecutive fields represents a single decoded picture and have identical `CurrPicIdx`, however, only
the first field is entirely intra-coded and has the flag `intra_pic_flag` set and the second field was resetting the flag before
it was even read in the function `cuvid_output_frame`.
diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index f21273c..7be57de 100644
|
a
|
b
|
static int CUDAAPI cuvid_handle_picture_decode(void *opaque, CUVIDPICPARAMS* pic
|
| 342 | 342 | |
| 343 | 343 | av_log(avctx, AV_LOG_TRACE, "pfnDecodePicture\n"); |
| 344 | 344 | |
| 345 | | ctx->key_frame[picparams->CurrPicIdx] = picparams->intra_pic_flag; |
| | 345 | if(picparams->intra_pic_flag) { |
| | 346 | ctx->key_frame[picparams->CurrPicIdx] = picparams->intra_pic_flag; |
| | 347 | } |
| 346 | 348 | |
| 347 | 349 | ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams)); |
| 348 | 350 | if (ctx->internal_error < 0) |
| … |
… |
static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
|
| 603 | 605 | } |
| 604 | 606 | |
| 605 | 607 | frame->key_frame = ctx->key_frame[parsed_frame.dispinfo.picture_index]; |
| | 608 | ctx->key_frame[parsed_frame.dispinfo.picture_index] = 0; |
| 606 | 609 | frame->width = avctx->width; |
| 607 | 610 | frame->height = avctx->height; |
| 608 | 611 | if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) |