Commit 67e81d79 authored by Mark Thompson's avatar Mark Thompson

lavc: Use hardware config information in ff_get_format()

This removes the dependency that hardware pixel formats previously had on
AVHWAccel instances, meaning only those which actually do something need
exist after this patch.

Also updates avcodec_default_get_format() to be able to choose hardware
formats if either a matching device has been supplied or no additional
external configuration is required, and avcodec_get_hw_frames_parameters()
to use the hardware config rather than searching the old hwaccel list.

The FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS mechanism is deleted because it
no longer does anything (the codec already contains the pointers to the
matching hwaccels).
parent 758fbc54
......@@ -3652,13 +3652,6 @@ typedef struct AVHWAccel {
* that avctx->hwaccel_priv_data is invalid.
*/
int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx);
/**
* Some hwaccels are ambiguous if only the id and pix_fmt fields are used.
* If non-NULL, the associated AVCodec must have
* FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS set.
*/
const AVClass *decoder_class;
} AVHWAccel;
/**
......
......@@ -1120,7 +1120,6 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] = {
.type = AVMEDIA_TYPE_VIDEO, \
.id = AV_CODEC_ID_##X, \
.pix_fmt = AV_PIX_FMT_CUDA, \
.decoder_class = &x##_cuvid_class, \
}; \
AVCodec ff_##x##_cuvid_decoder = { \
.name = #x "_cuvid", \
......@@ -1135,7 +1134,6 @@ static const AVCodecHWConfigInternal *cuvid_hw_configs[] = {
.receive_frame = cuvid_output_frame, \
.flush = cuvid_flush, \
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \
.caps_internal = FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS, \
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \
AV_PIX_FMT_NV12, \
AV_PIX_FMT_P010, \
......
This diff is collapsed.
......@@ -69,11 +69,6 @@
*/
#define FF_CODEC_CAP_SLICE_THREAD_HAS_MF (1 << 5)
/**
* Allow only AVHWAccels which have a matching decoder_class field.
*/
#define FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS (1 << 6)
#ifdef TRACE
# define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
#else
......@@ -377,6 +372,12 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame,
* Select the (possibly hardware accelerated) pixel format.
* This is a wrapper around AVCodecContext.get_format() and should be used
* instead of calling get_format() directly.
*
* The list of pixel formats must contain at least one valid entry, and is
* terminated with AV_PIX_FMT_NONE. If it is possible to decode to software,
* the last entry in the list must be the most accurate software format.
* If it is not possible to decode to software, AVCodecContext.sw_pix_fmt
* must be set before calling this function.
*/
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment