[FFmpeg-devel] [PATCH v13 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

James Almer jamrial at gmail.com
Fri May 31 06:16:37 EEST 2019


On 5/31/2019 12:50 AM, Jing Sun wrote:
> Signed-off-by: Zhengxu Huang <zhengxu.huang at intel.com>
> Signed-off-by: Hassene Tmar <hassene.tmar at intel.com>
> Signed-off-by: Jun Zhao <jun.zhao at intel.com>
> Signed-off-by: Jing Sun <jing.a.sun at intel.com>
> ---
>  configure                |   4 +
>  libavcodec/Makefile      |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/libsvt_hevc.c | 499 +++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/version.h     |   2 +-
>  5 files changed, 506 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/libsvt_hevc.c

[...]

> +static int eb_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
> +                           const AVFrame *frame, int *got_packet)
> +{
> +    SvtContext *svt_enc = avctx->priv_data;
> +    EB_BUFFERHEADERTYPE *header_ptr = &svt_enc->in_buf;
> +    EB_ERRORTYPE svt_ret;
> +    int av_ret;
> +
> +    if (EOS_RECEIVED == svt_enc->eos_flag)
> +        return AVERROR_EOF;

You should return 0 here. AVCodec.encode2() must not return AVERROR_EOF.
Anything < 0 is considered an error.

Since this can only happen after EOF, a return value of 0 and
*got_packet == 0 will effectively signal EOF.

> +
> +    if (!frame) {
> +        if (!svt_enc->eos_flag) {
> +            svt_enc->eos_flag = EOS_SENT;
> +
> +            header_ptr->nAllocLen = 0;
> +            header_ptr->nFilledLen = 0;
> +            header_ptr->nTickCount = 0;
> +            header_ptr->pBuffer = NULL;
> +            header_ptr->nFlags = EB_BUFFERFLAG_EOS;
> +
> +            EbH265EncSendPicture(svt_enc->svt_handle, header_ptr);
> +
> +            av_log(avctx, AV_LOG_DEBUG, "Sent EOS\n");
> +        }
> +    } else {
> +        read_in_data(&svt_enc->enc_params, frame, header_ptr);
> +        header_ptr->pts = frame->pts;
> +
> +        EbH265EncSendPicture(svt_enc->svt_handle, header_ptr);
> +
> +        av_log(avctx, AV_LOG_DEBUG, "Sent PTS %ld\n", header_ptr->pts);

Use PRId64 instead of ld.

> +    }
> +
> +    header_ptr = NULL;
> +    svt_ret = EbH265GetPacket(svt_enc->svt_handle, &header_ptr, svt_enc->eos_flag);
> +
> +    if (svt_ret == EB_NoErrorEmptyQueue) {
> +        *got_packet = 0;
> +        av_log(avctx, AV_LOG_DEBUG, "Received none\n");
> +        return 0;
> +    }
> +
> +    av_log(avctx, AV_LOG_DEBUG, "Received PTS %ld packet\n", header_ptr->pts);

Same.


More information about the ffmpeg-devel mailing list