[FFmpeg-cvslog] qsvdec: Pass the correct profile to libmfx
Mark Thompson
git at videolan.org
Fri Mar 31 23:13:38 EEST 2017
ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Wed Oct 26 21:26:10 2016 +0100| [cd1047f3911fa0d34c86f470537f343d23c8b956] | committer: Mark Thompson
qsvdec: Pass the correct profile to libmfx
This was correct for H.26[45], because libmfx uses the same values
derived from profile_idc and the constraint_set flags, but it is
wrong for other codecs.
Also avoid passing FF_LEVEL_UNKNOWN (-99) as the level, as this is
certainly invalid.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cd1047f3911fa0d34c86f470537f343d23c8b956
---
libavcodec/qsv.c | 16 ++++++++++++++++
libavcodec/qsv_internal.h | 1 +
libavcodec/qsvdec.c | 4 ++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 6c53489..f292082 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -55,6 +55,22 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
return AVERROR(ENOSYS);
}
+int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile)
+{
+ if (profile == FF_PROFILE_UNKNOWN)
+ return MFX_PROFILE_UNKNOWN;
+ switch (codec_id) {
+ case AV_CODEC_ID_H264:
+ case AV_CODEC_ID_HEVC:
+ return profile;
+ case AV_CODEC_ID_VC1:
+ return 4 * profile + 1;
+ case AV_CODEC_ID_MPEG2VIDEO:
+ return 0x10 * profile;
+ }
+ return MFX_PROFILE_UNKNOWN;
+}
+
static const struct {
mfxStatus mfxerr;
int averr;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index a8f4867..7ac347e 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -80,6 +80,7 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
const char *warning_string);
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);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 6131100..9b5dc1d 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -144,8 +144,8 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
return ret;
param.mfx.CodecId = ret;
- param.mfx.CodecProfile = avctx->profile;
- param.mfx.CodecLevel = avctx->level;
+ param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, avctx->profile);
+ param.mfx.CodecLevel = avctx->level == FF_LEVEL_UNKNOWN ? MFX_LEVEL_UNKNOWN : avctx->level;
param.mfx.FrameInfo.BitDepthLuma = desc->comp[0].depth;
param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
More information about the ffmpeg-cvslog
mailing list