Commit 1c96d2e3 authored by Linjie Fu's avatar Linjie Fu Committed by Zhong Li

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: 's avatarLinjie Fu <linjie.fu@intel.com>
Signed-off-by: 's avatarZhong Li <zhong.li@intel.com>
parent de441ad5
...@@ -1344,8 +1344,13 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, ...@@ -1344,8 +1344,13 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q,
pict_type = AV_PICTURE_TYPE_P; pict_type = AV_PICTURE_TYPE_P;
else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB) else if (bs->FrameType & MFX_FRAMETYPE_B || bs->FrameType & MFX_FRAMETYPE_xB)
pict_type = AV_PICTURE_TYPE_B; pict_type = AV_PICTURE_TYPE_B;
else else if (bs->FrameType == MFX_FRAMETYPE_UNKNOWN) {
av_assert0(!"Uninitialized pict_type!"); 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 #if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS FF_DISABLE_DEPRECATION_WARNINGS
......
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