Message ID | 1522227010-8760-1-git-send-email-zhong.li@intel.com |
---|---|
State | New |
Headers | show |
Series |
|
Related | show |
Resend it since forgot to remove AV_PICTURE_TYPE_NONE in v3. Please let me know if still have any problem to accept this patch, and I'm glad to update it. > -----Original Message----- > From: Li, Zhong > Sent: Wednesday, March 28, 2018 4:50 PM > To: libav-devel@libav.org > Cc: Li, Zhong <zhong.li@intel.com>; Liu, ChaoX A <chaox.a.liu@intel.com> > Subject: [PATCH] lavc/qsvdec: expose frame pic_type > > Currently pict_type are unset. > Add an extra param to fetch the picture type from qsv decoder > > v2: fix the compile error since AV_PICTURE_TYPE_NONE is not existed in > libav. > v3: remove the key_frame setting because the judgement “key frame is > equal to IDR frame” only suitable for H264. > For HEVC, all IRAP frames are key frames, and other codecs have no IDR > frame. > > Signed-off-by: ChaoX A Liu <chaox.a.liu@intel.com> > Signed-off-by: Zhong Li <zhong.li@intel.com>
On Wed, Mar 28, 2018 at 04:50:10PM +0800, Zhong Li wrote: > Currently pict_type are unset. > Add an extra param to fetch the picture type from qsv decoder > > v2: fix the compile error since AV_PICTURE_TYPE_NONE is not existed in libav. > v3: remove the key_frame setting because the judgement “key frame is equal > to IDR frame” only suitable for H264. These look like sensible patch annotations that you can add with --annotate when using git-send-email, but they should not be part of the log message. How you fixed compilation failures needs not be preserved for posterity ;) > --- a/libavcodec/qsv.c > +++ b/libavcodec/qsv.c > @@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame) > > +enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type) > +{ > + enum AVPictureType type; > + switch (mfx_pic_type & 0x7) { > + case MFX_FRAMETYPE_I: Please indent switch and case at the same level. Diego
> From: libav-devel [mailto:libav-devel-bounces@libav.org] On Behalf Of > Diego Biurrun > Sent: Thursday, March 29, 2018 12:55 AM > To: libav development <libav-devel@libav.org> > Subject: Re: [libav-devel] [PATCH] lavc/qsvdec: expose frame pic_type > > On Wed, Mar 28, 2018 at 04:50:10PM +0800, Zhong Li wrote: > > Currently pict_type are unset. > > Add an extra param to fetch the picture type from qsv decoder > > > > v2: fix the compile error since AV_PICTURE_TYPE_NONE is not existed in > libav. > > v3: remove the key_frame setting because the judgement “key frame is > > equal to IDR frame” only suitable for H264. > > These look like sensible patch annotations that you can add with --annotate > when using git-send-email, but they should not be part of the log message. > How you fixed compilation failures needs not be preserved for posterity ;) Agree, will remove it in the updated patch. > > > --- a/libavcodec/qsv.c > > +++ b/libavcodec/qsv.c > > @@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext > > *ctx, QSVFrame *frame) > > > > +enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type) { > > + enum AVPictureType type; > > + switch (mfx_pic_type & 0x7) { > > + case MFX_FRAMETYPE_I: > > Please indent switch and case at the same level. > > Diego Yup, will update it, thanks for pointing this. : )
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index e78633d..ffe7e6c 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, QSVFrame *frame) 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, void *logctx) { diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index 975c8de..07ddc59 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -48,6 +48,8 @@ typedef struct QSVMid { typedef struct QSVFrame { AVFrame *frame; mfxFrameSurface1 surface; + mfxExtDecodedFrameInfo dec_info; + mfxExtBuffer *ext_param; int queued; int used; @@ -83,6 +85,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_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, const char *load_plugins); diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index d05d48f..682cd43 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -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.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; @@ -418,6 +423,7 @@ FF_ENABLE_DEPRECATION_WARNINGS outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF; frame->interlaced_frame = !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE); + frame->pict_type = ff_qsv_map_pictype(out_frame->dec_info.FrameType); /* update the surface properties */ if (avctx->pix_fmt == AV_PIX_FMT_QSV)