On 7/26/2018 4:51 AM, Zhong Li wrote: > Requirement from ticket #7254. > Currently only H264 supported by MSDK. > > Signed-off-by: Zhong Li <zhong...@intel.com> > --- > libavcodec/qsvenc.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > libavcodec/qsvenc.h | 2 ++ > libavcodec/qsvenc_h264.c | 5 +++++ > 3 files changed, 50 insertions(+) > > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c > index 8096945..1294ed2 100644 > --- a/libavcodec/qsvenc.c > +++ b/libavcodec/qsvenc.c > @@ -1139,6 +1139,10 @@ static int encode_frame(AVCodecContext *avctx, > QSVEncContext *q, > { > AVPacket new_pkt = { 0 }; > mfxBitstream *bs; > +#if QSV_VERSION_ATLEAST(1, 26) > + mfxExtAVCEncodedFrameInfo *enc_info; > + mfxExtBuffer **enc_buf; > +#endif > > mfxFrameSurface1 *surf = NULL; > mfxSyncPoint *sync = NULL; > @@ -1172,6 +1176,22 @@ static int encode_frame(AVCodecContext *avctx, > QSVEncContext *q, > bs->Data = new_pkt.data; > bs->MaxLength = new_pkt.size; > > +#if QSV_VERSION_ATLEAST(1, 26) > + if (avctx->codec_id == AV_CODEC_ID_H264) { > + enc_info = av_mallocz(sizeof(*enc_info)); > + if (!enc_info) > + return AVERROR(ENOMEM); > + > + enc_info->Header.BufferId = MFX_EXTBUFF_ENCODED_FRAME_INFO; > + enc_info->Header.BufferSz = sizeof (*enc_info); > + bs->NumExtParam = 1; > + enc_buf = av_mallocz(sizeof(mfxExtBuffer *));
This allocation is unchecked, and also leaks. You free bs and enc_info everywhere, but not enc_buf. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel