diff options
author | Linjie Fu | 2018-12-09 21:30:38 +0800 |
---|---|---|
committer | Zhong Li | 2018-12-10 11:19:24 +0800 |
commit | 1c96d2e3998b9a2a97447547cb2d688ec0ce09ed (patch) | |
tree | 50725906893964cda339c4708870781cf0ec658b | |
parent | de441ad52a4d9791d93c278b4cf6867815c28b92 (diff) |
lavc/qsvenc: replace assert with error return
Fix the (m)jpeg encoding regression issue as decription in tikect #7593,
due to bs->FrameType is not set in such case in
MSDK (https://github.com/Intel-Media-SDK/MediaSDK/issues/970).
(And assert on a value coming from an external library is not proper.)
Add default type check for bs->FrameType, and return invalid data error in function
ff_qsv_encode to avoid using uninitialized value.
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
-rw-r--r-- | libavcodec/qsvenc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 53ba7cad15..70772dc0e2 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1344,8 +1344,13 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, pict_type = AV_PICTURE_TYPE_P; else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB) pict_type = AV_PICTURE_TYPE_B; - else - av_assert0(!"Uninitialized pict_type!"); + else if (bs->FrameType == MFX_FRAMETYPE_UNKNOWN) { + pict_type = AV_PICTURE_TYPE_NONE; + av_log(avctx, AV_LOG_WARNING, "Unkown FrameType, set pict_type to AV_PICTURE_TYPE_NONE.\n"); + } else { + av_log(avctx, AV_LOG_ERROR, "Invalid FrameType:%d.\n", bs->FrameType); + return AVERROR_INVALIDDATA; + } #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS |