[FFmpeg-devel] [PATCH v2] avcodec: Add librav1e encoder

James Almer jamrial at gmail.com
Wed May 29 19:12:48 EEST 2019


On 5/29/2019 11:41 AM, Derek Buitenhuis wrote:
> Uses the crav1e C bindings for rav1e.
> 
> Port to the new send/receive API by: James Almer <jamrial at gmail.com>.
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
> The only thing I didn't address from the last set of replies was the
> second 'ret' variable, since I prefer it that way (having a separate
> ret for avcodec values and external values.
> ---
>  configure              |   4 +
>  doc/encoders.texi      |  29 +++
>  doc/general.texi       |   7 +
>  libavcodec/Makefile    |   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/librav1e.c  | 417 +++++++++++++++++++++++++++++++++++++++++
>  6 files changed, 459 insertions(+)
>  create mode 100644 libavcodec/librav1e.c

[...]

> +end:
> +    if (cfg)
> +        rav1e_config_unref(cfg);
> +
> +    if (ret)
> +        librav1e_encode_close(avctx);

Use the FF_CODEC_CAP_INIT_CLEANUP flag in AVCodec.caps_internal instead.
It will call AVCodec.close() on AVCodec.init() failure.

[...]

> +AVCodec ff_librav1e_encoder = {
> +    .name           = "librav1e",
> +    .long_name      = NULL_IF_CONFIG_SMALL("librav1e AV1"),
> +    .type           = AVMEDIA_TYPE_VIDEO,
> +    .id             = AV_CODEC_ID_AV1,
> +    .init           = librav1e_encode_init,
> +    .send_frame     = librav1e_send_frame,
> +    .receive_packet = librav1e_receive_packet,
> +    .close          = librav1e_encode_close,
> +    .priv_data_size = sizeof(librav1eContext),
> +    .priv_class     = &class,
> +    .defaults       = librav1e_defaults,
> +    .pix_fmts       = (const enum AVPixelFormat[]) {
> +        AV_PIX_FMT_YUV420P,
> +        AV_PIX_FMT_YUV420P10,
> +        AV_PIX_FMT_YUV420P12,
> +        AV_PIX_FMT_YUV422P,
> +        AV_PIX_FMT_YUV422P10,
> +        AV_PIX_FMT_YUV422P12,
> +        AV_PIX_FMT_YUV444P,
> +        AV_PIX_FMT_YUV444P10,
> +        AV_PIX_FMT_YUV444P12,
> +        AV_PIX_FMT_GRAY8,
> +        AV_PIX_FMT_GRAY10,
> +        AV_PIX_FMT_GRAY12,
> +        AV_PIX_FMT_NONE

Nit: Split this off, like libx26* do.

> +    },
> +    .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
> +    .wrapper_name   = "librav1e",
> +};
> 



More information about the ffmpeg-devel mailing list