FFmpeg
Loading...
Searching...
No Matches
hwcontext_internal.h
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg 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.
8 *
9 * FFmpeg 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.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef AVUTIL_HWCONTEXT_INTERNAL_H
20#define AVUTIL_HWCONTEXT_INTERNAL_H
21
22#include <stddef.h>
23
24#include "buffer.h"
25#include "hwcontext.h"
26#include "thread.h"
27#include "frame.h"
28#include "pixfmt.h"
29
30typedef struct HWContextType {
32 const char *name;
33
34 /**
35 * An array of pixel formats supported by the AVHWFramesContext instances
36 * Terminated by AV_PIX_FMT_NONE.
37 */
39
40 /**
41 * size of the public hardware-specific context,
42 * i.e. AVHWDeviceContext.hwctx
43 */
45
46 /**
47 * Size of the hardware-specific device configuration.
48 * (Used to query hwframe constraints.)
49 */
51
52 /**
53 * size of the public frame pool hardware-specific context,
54 * i.e. AVHWFramesContext.hwctx
55 */
57
58 int (*device_create)(AVHWDeviceContext *ctx, const char *device,
59 AVDictionary *opts, int flags);
61 AVHWDeviceContext *src_ctx,
62 AVDictionary *opts, int flags);
63
66
68 const void *hwconfig,
69 AVHWFramesConstraints *constraints);
70
73
75
76 /**
77 * Allocate a buffer of size bytes for av_hwframe_get_transfer_buffer(),
78 * av_buffer_alloc() is used if this is not set or returns NULL.
79 *
80 * @param device_ref the AVBufferRef of the AVHWDeviceContext
81 */
82 AVBufferRef *(*transfer_buffer_alloc)(void *device_ref, size_t size);
85 enum AVPixelFormat **formats);
87 const AVFrame *src);
89 const AVFrame *src);
90
92 const AVFrame *src, int flags);
94 const AVFrame *src, int flags);
95
97 AVHWFramesContext *src_ctx, int flags);
99 AVHWFramesContext *src_ctx, int flags);
101
102typedef struct FFHWFramesContext {
103 /**
104 * The public AVHWFramesContext. See hwcontext.h for it.
105 */
107
109
111
112 /**
113 * Buffers of transfer_pool_size bytes for av_hwframe_get_transfer_buffer(),
114 * both guarded by transfer_pool_lock.
115 */
119
120 /**
121 * For a derived context, a reference to the original frames
122 * context it was derived from.
123 */
125 /**
126 * Flags to apply to the mapping from the source to the derived
127 * frame context when trying to allocate in the derived context.
128 */
131
136
137typedef struct HWMapDescriptor {
138 /**
139 * A reference to the original source of the mapping.
140 */
142 /**
143 * A reference to the hardware frames context in which this
144 * mapping was made. May be the same as source->hw_frames_ctx,
145 * but need not be.
146 */
148 /**
149 * Unmap function.
150 */
152 struct HWMapDescriptor *hwmap);
153 /**
154 * Hardware-specific private data associated with the mapping.
155 */
156 void *priv;
158
159int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
160 AVFrame *dst, const AVFrame *src,
161 void (*unmap)(AVHWFramesContext *ctx,
162 HWMapDescriptor *hwmap),
163 void *priv);
164
165/**
166 * Replace the current hwmap of dst with the one from src, used for indirect
167 * mappings like VAAPI->(DRM)->OpenCL/Vulkan where a direct interop is missing
168 */
170
185
186#endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:97
static AVFormatContext * ctx
static AVDictionary * opts
refcounted data buffer API
#define flags(name, subs,...)
Definition cbs_h264.c:74
static AVFrame * frame
reference-counted frame API
AVHWFrameTransferDirection
Definition hwcontext.h:421
AVHWDeviceType
Definition hwcontext.h:27
const HWContextType ff_hwcontext_type_amf
const HWContextType ff_hwcontext_type_cuda
const HWContextType ff_hwcontext_type_d3d11va
const HWContextType ff_hwcontext_type_d3d12va
const HWContextType ff_hwcontext_type_drm
const HWContextType ff_hwcontext_type_dxva2
const HWContextType ff_hwcontext_type_opencl
static FFHWFramesContext * ffhwframesctx(AVHWFramesContext *ctx)
const HWContextType ff_hwcontext_type_vaapi
const HWContextType ff_hwcontext_type_vdpau
const HWContextType ff_hwcontext_type_qsv
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
Definition hwcontext.c:799
const HWContextType ff_hwcontext_type_oh
const HWContextType ff_hwcontext_type_videotoolbox
const HWContextType ff_hwcontext_type_vulkan
const HWContextType ff_hwcontext_type_mediacodec
int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src)
Replace the current hwmap of dst with the one from src, used for indirect mappings like VAAPI->(DRM)-...
Definition hwcontext.c:1006
#define AVMutex
Definition thread.h:184
pixel format definitions
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
formats
Definition signature.h:47
The buffer pool.
A reference to a data buffer.
Definition buffer.h:82
This structure describes decoded (raw) audio or video data.
Definition frame.h:479
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition hwcontext.h:63
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Definition hwcontext.h:459
This struct describes a set or pool of "hardware" frames (i.e.
Definition hwcontext.h:118
const HWContextType * hw_type
AVBufferPool * transfer_pool
Buffers of transfer_pool_size bytes for av_hwframe_get_transfer_buffer(), both guarded by transfer_po...
int source_allocation_map_flags
Flags to apply to the mapping from the source to the derived frame context when trying to allocate in...
AVHWFramesContext p
The public AVHWFramesContext.
AVBufferPool * pool_internal
AVBufferRef * source_frames
For a derived context, a reference to the original frames context it was derived from.
size_t frames_hwctx_size
size of the public frame pool hardware-specific context, i.e.
int(* transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
int(* map_from)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
int(* frames_get_constraints)(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
int(* device_create)(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
int(* transfer_data_to)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
int(* transfer_get_formats)(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
int(* map_to)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
int(* frames_get_buffer)(AVHWFramesContext *ctx, AVFrame *frame)
enum AVHWDeviceType type
size_t device_hwctx_size
size of the public hardware-specific context, i.e.
int(* device_init)(AVHWDeviceContext *ctx)
int(* frames_derive_to)(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
void(* frames_uninit)(AVHWFramesContext *ctx)
int(* frames_derive_from)(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
size_t device_hwconfig_size
Size of the hardware-specific device configuration.
const char * name
void(* device_uninit)(AVHWDeviceContext *ctx)
int(* device_derive)(AVHWDeviceContext *dst_ctx, AVHWDeviceContext *src_ctx, AVDictionary *opts, int flags)
int(* frames_init)(AVHWFramesContext *ctx)
enum AVPixelFormat * pix_fmts
An array of pixel formats supported by the AVHWFramesContext instances Terminated by AV_PIX_FMT_NONE.
void * priv
Hardware-specific private data associated with the mapping.
void(* unmap)(AVHWFramesContext *ctx, struct HWMapDescriptor *hwmap)
Unmap function.
AVFrame * source
A reference to the original source of the mapping.
AVBufferRef * hw_frames_ctx
A reference to the hardware frames context in which this mapping was made.
#define src
Definition vp8dsp.c:248
int size