On 07/03/16 00:03, Mark Thompson wrote:
> ---
> libavutil/hwcontext.c | 44 +++++++++++++++++++++++++++++++
> libavutil/hwcontext.h | 60
> ++++++++++++++++++++++++++++++++++++++++++
> libavutil/hwcontext_internal.h | 10 +++++++
> 3 files changed, 114 insertions(+)
>
> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> index b6d0518..e373504 100644
> --- a/libavutil/hwcontext.c
> +++ b/libavutil/hwcontext.c
> @@ -400,3 +400,47 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref,
> AVFrame *frame, int flags)
>
> return 0;
> }
> +
> +void *av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
> +{
> + AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data;
> + const HWContextType *hw_type = ctx->internal->hw_type;
> +
> + if (hw_type->device_hwconfig_size == 0)
> + return NULL;
> +
> + return av_mallocz(hw_type->device_hwconfig_size);
> +}
Not sure using the AVBufferRef is really needed here.
> +AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref,
> + const void
> *hwconfig)
> +{
> + AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data;
> + const HWContextType *hw_type = ctx->internal->hw_type;
> + AVHWFramesConstraints *constraints;
> +
> + if (!hw_type->frames_get_constraints)
> + return NULL;
> +
> + constraints = av_mallocz(sizeof(*constraints));
> + if (!constraints)
> + return NULL;
> +
> + constraints->min_width = constraints->min_height = 0;
> + constraints->max_width = constraints->max_height = INT_MAX;
> +
> + if (hw_type->frames_get_constraints(ctx, hwconfig, constraints) >= 0) {
> + return constraints;
> + } else {
> + av_hwframe_constraints_free(&constraints);
> + return NULL;
> + }
> +}
Same.
> +void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
> +{
> + if (*constraints) {
> + av_freep(&(*constraints)->valid_sw_formats);
> + }
> + av_freep(constraints);
> +}
> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
> index 81ae817..2505330 100644
> --- a/libavutil/hwcontext.h
> +++ b/libavutil/hwcontext.h
> @@ -326,4 +326,64 @@ int av_hwframe_transfer_get_formats(AVBufferRef
> *hwframe_ctx,
> enum AVPixelFormat **formats, int flags);
>
>
> +/**
> + * This struct describes the constraints on hardware frames attached to
> + * a given device with a hardware-specific configuration. This is returned
> + * by av_hwdevice_get_hwframe_constraints() and must be freed by
> + * av_hwframe_constraints_free() after use.
> + */
> +typedef struct AVHWFramesConstraints {
> + /**
> + * A list of possible values for sw_format in the hw_frames_ctx,
> + * terminated by AV_PIX_FMT_NONE. Can be NULL if this information is
> + * not known.
> + */
> + enum AVPixelFormat *valid_sw_formats;
> +
> + /**
> + * The minimum size of frames in this hw_frames_ctx.
> + * (Zero if not known.)
> + */
> + int min_width;
> + int min_height;
> +
> + /**
> + * The maximum size of frames in this hw_frames_ctx.
> + * (INT_MAX if not known / no limit.)
> + */
> + int max_width;
> + int max_height;
> +} AVHWFramesConstraints;
Usually we use -1 for not known/unset.
The rest looks fine.
lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel