From d06aa24ba583ad08025da9e1b29afcd8218ff9b0 Mon Sep 17 00:00:00 2001 From: Mark Thompson Date: Tue, 25 Oct 2016 20:38:47 +0100 Subject: hwcontext: Hardware frame mapping Adds the new av_hwframe_map() function, which allows mapping between hardware frames and normal memory, along with internal support for implementing it. Also adds av_hwframe_ctx_create_derived(), for creating a hardware frames context associated with one device using frames mapped from another by some hardware-specific means. --- libavutil/hwcontext_internal.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'libavutil/hwcontext_internal.h') diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h index a391e2599e..11e3a68e4c 100644 --- a/libavutil/hwcontext_internal.h +++ b/libavutil/hwcontext_internal.h @@ -85,6 +85,11 @@ typedef struct HWContextType { const AVFrame *src); int (*transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src); + + int (*map_to)(AVHWFramesContext *ctx, AVFrame *dst, + const AVFrame *src, int flags); + int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst, + const AVFrame *src, int flags); } HWContextType; struct AVHWDeviceInternal { @@ -97,8 +102,43 @@ struct AVHWFramesInternal { void *priv; AVBufferPool *pool_internal; + + /** + * For a derived context, a reference to the original frames + * context it was derived from. + */ + AVBufferRef *source_frames; }; +typedef struct HWMapDescriptor { + /** + * A reference to the original source of the mapping. + */ + AVFrame *source; + /** + * A reference to the hardware frames context in which this + * mapping was made. May be the same as source->hw_frames_ctx, + * but need not be. + */ + AVBufferRef *hw_frames_ctx; + /** + * Unmap function. + */ + void (*unmap)(AVHWFramesContext *ctx, + struct HWMapDescriptor *hwmap); + /** + * Hardware-specific private data associated with the mapping. + */ + void *priv; +} HWMapDescriptor; + +int ff_hwframe_map_create(AVBufferRef *hwframe_ref, + AVFrame *dst, const AVFrame *src, + void (*unmap)(AVHWFramesContext *ctx, + HWMapDescriptor *hwmap), + void *priv); + + extern const HWContextType ff_hwcontext_type_cuda; extern const HWContextType ff_hwcontext_type_dxva2; extern const HWContextType ff_hwcontext_type_qsv; -- cgit v1.2.3