diff options
author | Anton Khirnov <anton@khirnov.net> | 2015-06-16 18:22:11 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-07-08 23:39:28 +0200 |
commit | 3a85397e8bb477eb34678d9edc52893f57003226 (patch) | |
tree | fbdd149aa2a4662523cff8cf8ce46fd134477cc0 /libavcodec/qsvenc.c | |
parent | 69ab9f53f901eac6a649e22d28cf093357870627 (diff) | |
download | ffmpeg-3a85397e8bb477eb34678d9edc52893f57003226.tar.gz |
lavc: add Intel libmfx-based MPEG2 encoder
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r-- | libavcodec/qsvenc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 2830b0d836..690d5aa36d 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -153,6 +153,7 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) (mfxExtBuffer*)&extradata, }; + int need_pps = avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO; int ret; q->param.ExtParam = ext_buffers; @@ -164,19 +165,20 @@ static int qsv_retrieve_enc_params(AVCodecContext *avctx, QSVEncContext *q) q->packet_size = q->param.mfx.BufferSizeInKB * 1000; - if (!extradata.SPSBufSize || !extradata.PPSBufSize) { + if (!extradata.SPSBufSize || (need_pps && !extradata.PPSBufSize)) { av_log(avctx, AV_LOG_ERROR, "No extradata returned from libmfx.\n"); return AVERROR_UNKNOWN; } - avctx->extradata = av_malloc(extradata.SPSBufSize + extradata.PPSBufSize + + avctx->extradata = av_malloc(extradata.SPSBufSize + need_pps * extradata.PPSBufSize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); memcpy(avctx->extradata, sps_buf, extradata.SPSBufSize); - memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize); - avctx->extradata_size = extradata.SPSBufSize + extradata.PPSBufSize; + if (need_pps) + memcpy(avctx->extradata + extradata.SPSBufSize, pps_buf, extradata.PPSBufSize); + avctx->extradata_size = extradata.SPSBufSize + need_pps * extradata.PPSBufSize; memset(avctx->extradata + avctx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); return 0; |