Commit 6f277e1f authored by James Almer's avatar James Almer

Merge commit '52ed83fa'

* commit '52ed83fa':
  lavc/qsvdec: expose frame pic_type and key_frame
Merged-by: 's avatarJames Almer <jamrial@gmail.com>
parents b13a1210 52ed83fa
...@@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame) ...@@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame)
return AVERROR_BUG; return AVERROR_BUG;
} }
enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
{
enum AVPictureType type;
switch (mfx_pic_type & 0x7) {
case MFX_FRAMETYPE_I:
if (mfx_pic_type & MFX_FRAMETYPE_S)
type = AV_PICTURE_TYPE_SI;
else
type = AV_PICTURE_TYPE_I;
break;
case MFX_FRAMETYPE_B:
type = AV_PICTURE_TYPE_B;
break;
case MFX_FRAMETYPE_P:
if (mfx_pic_type & MFX_FRAMETYPE_S)
type = AV_PICTURE_TYPE_SP;
else
type = AV_PICTURE_TYPE_P;
break;
}
return type;
}
static int qsv_load_plugins(mfxSession session, const char *load_plugins, static int qsv_load_plugins(mfxSession session, const char *load_plugins,
void *logctx) void *logctx)
{ {
......
...@@ -51,6 +51,8 @@ typedef struct QSVFrame { ...@@ -51,6 +51,8 @@ typedef struct QSVFrame {
AVFrame *frame; AVFrame *frame;
mfxFrameSurface1 surface; mfxFrameSurface1 surface;
mfxEncodeCtrl enc_ctrl; mfxEncodeCtrl enc_ctrl;
mfxExtDecodedFrameInfo dec_info;
mfxExtBuffer *ext_param;
int queued; int queued;
int used; int used;
...@@ -86,6 +88,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id); ...@@ -86,6 +88,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile); int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc); int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
const char *load_plugins); const char *load_plugins);
......
...@@ -232,6 +232,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame) ...@@ -232,6 +232,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext *q, QSVFrame *frame)
frame->surface.Data.MemId = &q->frames_ctx.mids[ret]; frame->surface.Data.MemId = &q->frames_ctx.mids[ret];
} }
frame->surface.Data.ExtParam = &frame->ext_param;
frame->surface.Data.NumExtParam = 1;
frame->ext_param = (mfxExtBuffer*)&frame->dec_info;
frame->dec_info.Header.BufferId = MFX_EXTBUFF_DECODED_FRAME_INFO;
frame->dec_info.Header.BufferSz = sizeof(frame->dec_info);
frame->used = 1; frame->used = 1;
...@@ -416,6 +421,10 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -416,6 +421,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF; outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
frame->interlaced_frame = frame->interlaced_frame =
!(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE); !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
frame->pict_type = ff_qsv_map_pictype(out_frame->dec_info.FrameType);
//Key frame is IDR frame is only suitable for H264. For HEVC, IRAPs are key frames.
if (avctx->codec_id == AV_CODEC_ID_H264)
frame->key_frame = !!(out_frame->dec_info.FrameType & MFX_FRAMETYPE_IDR);
/* update the surface properties */ /* update the surface properties */
if (avctx->pix_fmt == AV_PIX_FMT_QSV) if (avctx->pix_fmt == AV_PIX_FMT_QSV)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment