[FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper
James Almer
jamrial at gmail.com
Fri May 10 07:04:42 EEST 2019
On 5/10/2019 1:41 AM, Jing Sun wrote:
> + if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> + EB_BUFFERHEADERTYPE *header_ptr = NULL;
> +
> + svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, &header_ptr);
> + if (svt_ret != EB_ErrorNone) {
> + av_log(avctx, AV_LOG_ERROR, "Error when build stream header.\n");
> + goto failed_init_enc;
> + }
> +
> + avctx->extradata_size = header_ptr->nFilledLen;
> + avctx->extradata = av_mallocz(avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
> + if (!avctx->extradata) {
> + av_log(avctx, AV_LOG_ERROR,
> + "Cannot allocate HEVC header of size %d.\n", avctx->extradata_size);
> + svt_ret = EB_ErrorInsufficientResources;
> + goto failed_init_enc;
> + }
> + memset(avctx->extradata, 0x0, avctx->extradata_size+AV_INPUT_BUFFER_PADDING_SIZE);
You used av_mallocz() to allocate the buffer, so it's already fully zeroed.
In any case, it would be faster to instead use av_malloc() above, then
only zero the padding bytes here. Since you're copying the actual data
in the line below, nothing will remain uninitialized.
> + memcpy(avctx->extradata, header_ptr->pBuffer, avctx->extradata_size);
> + }
More information about the ffmpeg-devel
mailing list