MFX_FRAMETYPE_IDR is ORed to the frame type for AVC and HEVC keyframes, and MFX_FRAMETYPE_I is taken as keyframe flag for other codecs when getting the output surface from the SDK, hence we may mark the output frame as keyframe accordingly.
Unified · Split
| @@ -931,12 +931,18 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, · 930 unmodified lines | ||
| 931 | 931 | frame->flags |= AV_FRAME_FLAG_INTERLACED * |
| 932 | 932 | !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE); |
| 933 | 933 | frame->pict_type = ff_qsv_map_pictype(aframe.frame->dec_info.FrameType); |
| 934 | − //Key frame is IDR frame is only suitable for H264. For HEVC, IRAPs are key frames. | |
| 935 | − if (avctx->codec_id == AV_CODEC_ID_H264) { | |
| 934 | + | |
| 935 | + if (avctx->codec_id == AV_CODEC_ID_H264 || | |
| 936 | + avctx->codec_id == AV_CODEC_ID_HEVC) { | |
| 936 | 937 | if (aframe.frame->dec_info.FrameType & MFX_FRAMETYPE_IDR) |
| 937 | 938 | frame->flags |= AV_FRAME_FLAG_KEY; |
| 938 | 939 | else |
| 939 | 940 | frame->flags &= ~AV_FRAME_FLAG_KEY; |
| 941 | + } else { | |
| 942 | + if (aframe.frame->dec_info.FrameType & MFX_FRAMETYPE_I) | |
| 943 | + frame->flags |= AV_FRAME_FLAG_KEY; | |
| 944 | + else | |
| 945 | + frame->flags &= ~AV_FRAME_FLAG_KEY; | |
| 940 | 946 | } |
| 941 | 947 | frame->crop_left = outsurf->Info.CropX; |
| 942 | 948 | frame->crop_top = outsurf->Info.CropY; |