2 * This file is part of Libav.
4 * Libav is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * Libav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with Libav; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef AVUTIL_HWCONTEXT_INTERNAL_H
20 #define AVUTIL_HWCONTEXT_INTERNAL_H
25 #include "hwcontext.h"
29 typedef struct HWContextType
{
30 enum AVHWDeviceType type
;
34 * An array of pixel formats supported by the AVHWFramesContext instances
35 * Terminated by AV_PIX_FMT_NONE.
37 const enum AVPixelFormat
*pix_fmts
;
40 * size of the public hardware-specific context,
41 * i.e. AVHWDeviceContext.hwctx
43 size_t device_hwctx_size
;
45 * size of the private data, i.e.
46 * AVHWDeviceInternal.priv
48 size_t device_priv_size
;
51 * Size of the hardware-specific device configuration.
52 * (Used to query hwframe constraints.)
54 size_t device_hwconfig_size
;
57 * size of the public frame pool hardware-specific context,
58 * i.e. AVHWFramesContext.hwctx
60 size_t frames_hwctx_size
;
62 * size of the private data, i.e.
63 * AVHWFramesInternal.priv
65 size_t frames_priv_size
;
67 int (*device_create
)(AVHWDeviceContext
*ctx
, const char *device
,
68 AVDictionary
*opts
, int flags
);
69 int (*device_derive
)(AVHWDeviceContext
*dst_ctx
,
70 AVHWDeviceContext
*src_ctx
, int flags
);
72 int (*device_init
)(AVHWDeviceContext
*ctx
);
73 void (*device_uninit
)(AVHWDeviceContext
*ctx
);
75 int (*frames_get_constraints
)(AVHWDeviceContext
*ctx
,
77 AVHWFramesConstraints
*constraints
);
79 int (*frames_init
)(AVHWFramesContext
*ctx
);
80 void (*frames_uninit
)(AVHWFramesContext
*ctx
);
82 int (*frames_get_buffer
)(AVHWFramesContext
*ctx
, AVFrame
*frame
);
83 int (*transfer_get_formats
)(AVHWFramesContext
*ctx
,
84 enum AVHWFrameTransferDirection dir
,
85 enum AVPixelFormat
**formats
);
86 int (*transfer_data_to
)(AVHWFramesContext
*ctx
, AVFrame
*dst
,
88 int (*transfer_data_from
)(AVHWFramesContext
*ctx
, AVFrame
*dst
,
91 int (*map_to
)(AVHWFramesContext
*ctx
, AVFrame
*dst
,
92 const AVFrame
*src
, int flags
);
93 int (*map_from
)(AVHWFramesContext
*ctx
, AVFrame
*dst
,
94 const AVFrame
*src
, int flags
);
96 int (*frames_derive_to
)(AVHWFramesContext
*dst_ctx
,
97 AVHWFramesContext
*src_ctx
, int flags
);
98 int (*frames_derive_from
)(AVHWFramesContext
*dst_ctx
,
99 AVHWFramesContext
*src_ctx
, int flags
);
102 struct AVHWDeviceInternal
{
103 const HWContextType
*hw_type
;
107 * For a derived device, a reference to the original device
108 * context it was derived from.
110 AVBufferRef
*source_device
;
113 struct AVHWFramesInternal
{
114 const HWContextType
*hw_type
;
117 AVBufferPool
*pool_internal
;
120 * For a derived context, a reference to the original frames
121 * context it was derived from.
123 AVBufferRef
*source_frames
;
125 * Flags to apply to the mapping from the source to the derived
126 * frame context when trying to allocate in the derived context.
128 int source_allocation_map_flags
;
131 typedef struct HWMapDescriptor
{
133 * A reference to the original source of the mapping.
137 * A reference to the hardware frames context in which this
138 * mapping was made. May be the same as source->hw_frames_ctx,
141 AVBufferRef
*hw_frames_ctx
;
145 void (*unmap
)(AVHWFramesContext
*ctx
,
146 struct HWMapDescriptor
*hwmap
);
148 * Hardware-specific private data associated with the mapping.
153 int ff_hwframe_map_create(AVBufferRef
*hwframe_ref
,
154 AVFrame
*dst
, const AVFrame
*src
,
155 void (*unmap
)(AVHWFramesContext
*ctx
,
156 HWMapDescriptor
*hwmap
),
160 extern const HWContextType ff_hwcontext_type_cuda
;
161 extern const HWContextType ff_hwcontext_type_d3d11va
;
162 extern const HWContextType ff_hwcontext_type_dxva2
;
163 extern const HWContextType ff_hwcontext_type_qsv
;
164 extern const HWContextType ff_hwcontext_type_vaapi
;
165 extern const HWContextType ff_hwcontext_type_vdpau
;
167 #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */