On Thu, 7 Sep 2017 20:49:04 +0100
Mark Thompson <[email protected]> wrote:
> ---
> (Also version bump.)
>
> Written intending to also be useful for encoders, but there won't actually be
> any implementations.
>
>
> doc/APIchanges | 3 +++
> libavcodec/avcodec.h | 69
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 72 insertions(+)
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ed90be890..1f12969ea 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -13,6 +13,9 @@ libavutil: 2017-03-23
>
> API changes, most recent first:
>
> +2017-xx-xx - xxxxxxx - lavc 58.x+1.0 - avcodec.h
> + Add AVCodecHWConfig and AVCodec.hw_configs.
> +
> 2016-xx-xx - xxxxxxx - lavf 58.1.0 - avio.h
> Add avio_read_partial().
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 162f1abe4..53cd58c2a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -35,6 +35,7 @@
> #include "libavutil/cpu.h"
> #include "libavutil/dict.h"
> #include "libavutil/frame.h"
> +#include "libavutil/hwcontext.h"
> #include "libavutil/log.h"
> #include "libavutil/pixfmt.h"
> #include "libavutil/rational.h"
> @@ -2735,6 +2736,65 @@ typedef struct AVProfile {
> const char *name; ///< short name for the profile
> } AVProfile;
>
> +enum {
> + /**
> + * The codec supports this format via the hw_device_ctx interface.
> + *
> + * When selecting this format, AVCodecContext.hw_device_ctx should
> + * have been set to a device of the specified type before calling
> + * avcodec_open2().
> + */
> + AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01,
> + /**
> + * The codec supports this format via the hw_frames_ctx interface.
> + *
> + * When selecting this format for a decoder,
> + * AVCodecContext.hw_frames_ctx should be set to a suitable frames
> + * context inside the get_format() callback. The frames context
> + * must have been created on a device of the specified type.
> + */
> + AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02,
> + /**
> + * The codec supports this format by some internal method.
> + *
> + * This format can be selected without any additional configuration -
> + * no device or frames are required.
> + */
> + AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04,
> + /**
> + * The codec supports this format by some ad-hoc method.
> + *
> + * Additional settings and/or function calls are required. See the
> + * codec-specific documentation for details. (Methods requiring
> + * this sort of configuration are deprecated and others should be
> + * used in preference.)
> + */
> + AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08,
> +};
I really like how explicit this is. It sort of provides a new API user
with a starting point, and what to expect from a specific codec.
> +
> +typedef struct AVCodecHWConfig {
> + /**
> + * A hardware pixel format which the codec can use.
> + */
> + enum AVPixelFormat pix_fmt;
> + /**
> + * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible
> + * setup methods which can be used with this configuration.
> + */
> + int methods;
> + /**
> + * Set if this configuration is for a decoder which uses AVHWAccel.
> + */
> + int hwaccel;
So a bool, i.e. 1 or 0?
> + /**
> + * The device type associated with the configuration.
> + *
> + * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and
> + * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused.
> + */
> + enum AVHWDeviceType device_type;
> +} AVCodecHWConfig;
> +
> typedef struct AVCodecDefault AVCodecDefault;
>
> struct AVSubtitle;
> @@ -2770,6 +2830,15 @@ typedef struct AVCodec {
> const AVClass *priv_class; ///< AVClass for the private
> context
> const AVProfile *profiles; ///< array of recognized
> profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
>
> + /**
> + * Array of hardware configurations supported by the codec, or NULL
> + * if no hardware supported.
> + *
> + * The array is terminated by a configuration with a pix_fmt of
> + * AV_PIX_FMT_NONE.
> + */
> + const AVCodecHWConfig *hw_configs;
> +
> /*****************************************************************
> * No fields below this line are part of the public API. They
> * may not be used outside of libavcodec and can be changed and
Generally LGTM.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel