[FFmpeg-devel] [PATCH] Optimization: support for libx264's mb_info

Anton Khirnov anton at khirnov.net
Thu Jun 22 11:44:22 EEST 2023


Quoting Carotti, Elias (2023-06-21 17:53:09)
> +
> +    /**
> +     * Provide macro block encoder-specific hinting information for the encoder
> +     * processing.  It can be used to pass information about which macroblock
> +     * can be skipped because it hasn't changed from the corresponding one in
> +     * the previous frame. This is useful for applications which know in
> +     * advance this information to speed up real-time encoding.  Currently only
> +     * used by libx264.

I'd avoid any such claims here, because this comment will certainly not
be kept up to date.

> +/**
> + * Allocate memory for a vector of AVVideoRect in the given AVFrame
> + * {@code frame} as AVFrameSideData of type AV_FRAME_DATA_VIDEO_HINT_INFO.
> + * The side data contains a list of rectangles for the portions of the frame
> + * which changed from the last encoded one (and the remainder are assumed to be
> + * changed), or, alternately (depending on the type parameter) the unchanged
> + * ones (and the remanining ones are those which changed).
> + * Macroblocks will thus be hinted either to be P_SKIP-ped or go through the
> + * regular encoding procedure.
> + */
> +AVVideoHint *av_video_hint_create_side_data(AVFrame *frame,
> +                                            AVVideoRect *rects,
> +                                            size_t num_rects,
> +                                            AVVideoHintType type);
> +
> +AVVideoHint *av_video_hint_alloc(AVVideoRect *rects,
> +                                 size_t nb_rects,
> +                                 AVVideoHintType type,
> +                                 size_t *out_size);

If AVVideoHint is extended in the future, you will have a weird
situation where some fields are set by the allocation function, while
others have to be set manually by the caller.

You're also assuming the caller has an explicit array of AVVideoRect,
while they may actually want to fill them in through some other means.

Finally, it still seems to me this is largely duplicating
AVVideoEncParams and you could get your functionality by adding your
AVVideoHintType there.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list