[FFmpeg-devel] [PATCH v3] avcodec: Add librav1e encoder
Vittorio Giovara
vittorio.giovara at gmail.com
Thu May 30 07:41:00 EEST 2019
On Wed, May 29, 2019 at 2:28 PM Derek Buitenhuis <derek.buitenhuis at gmail.com>
wrote:
> Uses the crav1e C bindings for rav1e.
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1378,6 +1378,35 @@ makes it possible to store non-rgb pix_fmts.
>
> @end table
>
> + at section librav1e
> +
> +rav1e AV1 encoder wrapper.
> +
> +Requires the presence of the rav1e headers and library from crav1e
> +during configuration. You need to explicitly configue the build with
>
nit: typo configure
+
> +static inline RaPixelRange range_map(enum AVColorRange range)
> +
> +{
>
nit: extra line
+ switch (range) {
> + case AVCOL_RANGE_MPEG:
> + return RA_PIXEL_RANGE_LIMITED;
> + case AVCOL_RANGE_JPEG:
> + return RA_PIXEL_RANGE_FULL;
> + default:
> + return RA_PIXEL_RANGE_UNSPECIFIED;
> + }
> +}
> +
> +static inline RaChromaSampling pix_fmt_map(enum AVPixelFormat pix_fmt)
> +{
> + switch (pix_fmt) {
> + case AV_PIX_FMT_YUV420P:
> + case AV_PIX_FMT_YUV420P10:
> + case AV_PIX_FMT_YUV420P12:
> + return RA_CHROMA_SAMPLING_CS420;
> + case AV_PIX_FMT_YUV422P:
> + case AV_PIX_FMT_YUV422P10:
> + case AV_PIX_FMT_YUV422P12:
> + return RA_CHROMA_SAMPLING_CS422;
> + case AV_PIX_FMT_YUV444P:
> + case AV_PIX_FMT_YUV444P10:
> + case AV_PIX_FMT_YUV444P12:
> + return RA_CHROMA_SAMPLING_CS444;
>
no love for the J formats? ;_;
could they be added to librav1e_pix_fmts[]?
+
> +static av_cold int librav1e_encode_init(AVCodecContext *avctx)
> +{
> + librav1eContext *ctx = avctx->priv_data;
> + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
>
nit: check desc != NULL
+ RaConfig *cfg = NULL;
> + int rret;
> + int ret = 0;
> +
>
[...]
> +
> + rret = rav1e_config_parse_int(cfg, "threads", avctx->thread_count);
> + if (rret < 0)
> + av_log(avctx, AV_LOG_WARNING, "Invalid number of threads,
> defaulting to auto.\n");
> +
> + if (avctx->bit_rate && ctx->quantizer < 0) {
>
would be nice to have an info/debug line about the rc in use
> +static int librav1e_send_frame(AVCodecContext *avctx, const AVFrame
> *frame)
> +{
> + librav1eContext *ctx = avctx->priv_data;
> + int ret;
> +
> + if (!ctx->rframe && frame) {
> + const AVPixFmtDescriptor *desc =
> av_pix_fmt_desc_get(frame->format);
>
> nit: check desc != NULL
> + ctx->rframe = rav1e_frame_new(ctx->ctx);
> + if (!ctx->rframe) {
> + av_log(avctx, AV_LOG_ERROR, "Could not allocate new rav1e
> frame.\n");
> + return AVERROR(ENOMEM);
> + }
> +
>
overall lgtm
--
Vittorio
More information about the ffmpeg-devel
mailing list