History

lavc/qsvdec: fix keyframes

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.

Haihao Xiang committed 2 years ago

Commit dbdd9cc1 parent a11122f1 file · +8 −2Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/qsvdec.c+8−2
@@ -931,12 +931,18 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q, · 930 unmodified lines
931931 frame->flags |= AV_FRAME_FLAG_INTERLACED *
932932 !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
933933 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) {
936937 if (aframe.frame->dec_info.FrameType & MFX_FRAMETYPE_IDR)
937938 frame->flags |= AV_FRAME_FLAG_KEY;
938939 else
939940 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;
940946 }
941947 frame->crop_left = outsurf->Info.CropX;
942948 frame->crop_top = outsurf->Info.CropY;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t