FFmpeg
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 "frame.h"
27 #include "pixfmt.h"
28 
29 typedef struct HWContextType {
31  const char *name;
32 
33  /**
34  * An array of pixel formats supported by the AVHWFramesContext instances
35  * Terminated by AV_PIX_FMT_NONE.
36  */
37  const enum AVPixelFormat *pix_fmts;
38 
39  /**
40  * size of the public hardware-specific context,
41  * i.e. AVHWDeviceContext.hwctx
42  */
44 
45  /**
46  * Size of the hardware-specific device configuration.
47  * (Used to query hwframe constraints.)
48  */
50 
51  /**
52  * size of the public frame pool hardware-specific context,
53  * i.e. AVHWFramesContext.hwctx
54  */
56 
57  int (*device_create)(AVHWDeviceContext *ctx, const char *device,
58  AVDictionary *opts, int flags);
60  AVHWDeviceContext *src_ctx,
61  AVDictionary *opts, int flags);
62 
65 
67  const void *hwconfig,
68  AVHWFramesConstraints *constraints);
69 
72 
76  enum AVPixelFormat **formats);
78  const AVFrame *src);
80  const AVFrame *src);
81 
83  const AVFrame *src, int flags);
85  const AVFrame *src, int flags);
86 
88  AVHWFramesContext *src_ctx, int flags);
90  AVHWFramesContext *src_ctx, int flags);
92 
93 typedef struct FFHWFramesContext {
94  /**
95  * The public AVHWFramesContext. See hwcontext.h for it.
96  */
98 
100 
102 
103  /**
104  * For a derived context, a reference to the original frames
105  * context it was derived from.
106  */
108  /**
109  * Flags to apply to the mapping from the source to the derived
110  * frame context when trying to allocate in the derived context.
111  */
114 
116 {
117  return (FFHWFramesContext*)ctx;
118 }
119 
120 typedef struct HWMapDescriptor {
121  /**
122  * A reference to the original source of the mapping.
123  */
125  /**
126  * A reference to the hardware frames context in which this
127  * mapping was made. May be the same as source->hw_frames_ctx,
128  * but need not be.
129  */
131  /**
132  * Unmap function.
133  */
135  struct HWMapDescriptor *hwmap);
136  /**
137  * Hardware-specific private data associated with the mapping.
138  */
139  void *priv;
141 
142 int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
143  AVFrame *dst, const AVFrame *src,
144  void (*unmap)(AVHWFramesContext *ctx,
145  HWMapDescriptor *hwmap),
146  void *priv);
147 
148 /**
149  * Replace the current hwmap of dst with the one from src, used for indirect
150  * mappings like VAAPI->(DRM)->OpenCL/Vulkan where a direct interop is missing
151  */
152 int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src);
153 
166 
167 #endif /* AVUTIL_HWCONTEXT_INTERNAL_H */
formats
formats
Definition: signature.h:48
FFHWFramesContext::pool_internal
AVBufferPool * pool_internal
Definition: hwcontext_internal.h:101
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
HWContextType::device_uninit
void(* device_uninit)(AVHWDeviceContext *ctx)
Definition: hwcontext_internal.h:64
HWContextType::frames_get_buffer
int(* frames_get_buffer)(AVHWFramesContext *ctx, AVFrame *frame)
Definition: hwcontext_internal.h:73
HWMapDescriptor::source
AVFrame * source
A reference to the original source of the mapping.
Definition: hwcontext_internal.h:124
AVBufferPool
The buffer pool.
Definition: buffer_internal.h:88
HWContextType::transfer_data_to
int(* transfer_data_to)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_internal.h:77
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
FFHWFramesContext
Definition: hwcontext_internal.h:93
ff_hwcontext_type_qsv
const HWContextType ff_hwcontext_type_qsv
Definition: hwcontext_qsv.c:2604
HWContextType::map_to
int(* map_to)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_internal.h:82
ff_hwcontext_type_vdpau
const HWContextType ff_hwcontext_type_vdpau
Definition: hwcontext_vdpau.c:513
HWContextType::frames_init
int(* frames_init)(AVHWFramesContext *ctx)
Definition: hwcontext_internal.h:70
ff_hwcontext_type_vaapi
const HWContextType ff_hwcontext_type_vaapi
Definition: hwcontext_vaapi.c:2028
HWContextType::map_from
int(* map_from)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, int flags)
Definition: hwcontext_internal.h:84
HWContextType::device_hwconfig_size
size_t device_hwconfig_size
Size of the hardware-specific device configuration.
Definition: hwcontext_internal.h:49
AVDictionary
Definition: dict.c:34
HWMapDescriptor::hw_frames_ctx
AVBufferRef * hw_frames_ctx
A reference to the hardware frames context in which this mapping was made.
Definition: hwcontext_internal.h:130
HWMapDescriptor::priv
void * priv
Hardware-specific private data associated with the mapping.
Definition: hwcontext_internal.h:139
AVHWFramesConstraints
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Definition: hwcontext.h:441
HWContextType::device_derive
int(* device_derive)(AVHWDeviceContext *dst_ctx, AVHWDeviceContext *src_ctx, AVDictionary *opts, int flags)
Definition: hwcontext_internal.h:59
HWContextType::frames_get_constraints
int(* frames_get_constraints)(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
Definition: hwcontext_internal.h:66
ff_hwcontext_type_mediacodec
const HWContextType ff_hwcontext_type_mediacodec
Definition: hwcontext_mediacodec.c:107
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
ff_hwcontext_type_d3d12va
const HWContextType ff_hwcontext_type_d3d12va
Definition: hwcontext_d3d12va.c:679
ffhwframesctx
static FFHWFramesContext * ffhwframesctx(AVHWFramesContext *ctx)
Definition: hwcontext_internal.h:115
HWContextType::type
enum AVHWDeviceType type
Definition: hwcontext_internal.h:30
HWContextType::frames_uninit
void(* frames_uninit)(AVHWFramesContext *ctx)
Definition: hwcontext_internal.h:71
FFHWFramesContext::source_allocation_map_flags
int source_allocation_map_flags
Flags to apply to the mapping from the source to the derived frame context when trying to allocate in...
Definition: hwcontext_internal.h:112
ff_hwframe_map_replace
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:933
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
ctx
AVFormatContext * ctx
Definition: movenc.c:49
HWContextType::device_create
int(* device_create)(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags)
Definition: hwcontext_internal.h:57
FFHWFramesContext::p
AVHWFramesContext p
The public AVHWFramesContext.
Definition: hwcontext_internal.h:97
ff_hwcontext_type_videotoolbox
const HWContextType ff_hwcontext_type_videotoolbox
Definition: hwcontext_videotoolbox.c:766
opts
AVDictionary * opts
Definition: movenc.c:51
HWContextType::transfer_get_formats
int(* transfer_get_formats)(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
Definition: hwcontext_internal.h:74
ff_hwframe_map_create
int ff_hwframe_map_create(AVBufferRef *hwframe_ref, AVFrame *dst, const AVFrame *src, void(*unmap)(AVHWFramesContext *ctx, HWMapDescriptor *hwmap), void *priv)
Definition: hwcontext.c:726
HWContextType::frames_derive_to
int(* frames_derive_to)(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
Definition: hwcontext_internal.h:87
FFHWFramesContext::hw_type
const HWContextType * hw_type
Definition: hwcontext_internal.h:99
FFHWFramesContext::source_frames
AVBufferRef * source_frames
For a derived context, a reference to the original frames context it was derived from.
Definition: hwcontext_internal.h:107
frame.h
buffer.h
HWContextType::frames_derive_from
int(* frames_derive_from)(AVHWFramesContext *dst_ctx, AVHWFramesContext *src_ctx, int flags)
Definition: hwcontext_internal.h:89
HWContextType::frames_hwctx_size
size_t frames_hwctx_size
size of the public frame pool hardware-specific context, i.e.
Definition: hwcontext_internal.h:55
ff_hwcontext_type_vulkan
const HWContextType ff_hwcontext_type_vulkan
Definition: hwcontext_vulkan.c:3741
HWContextType::device_hwctx_size
size_t device_hwctx_size
size of the public hardware-specific context, i.e.
Definition: hwcontext_internal.h:43
ff_hwcontext_type_drm
const HWContextType ff_hwcontext_type_drm
Definition: hwcontext_drm.c:305
HWContextType::name
const char * name
Definition: hwcontext_internal.h:31
HWMapDescriptor::unmap
void(* unmap)(AVHWFramesContext *ctx, struct HWMapDescriptor *hwmap)
Unmap function.
Definition: hwcontext_internal.h:134
ff_hwcontext_type_d3d11va
const HWContextType ff_hwcontext_type_d3d11va
Definition: hwcontext_d3d11va.c:707
AVHWFrameTransferDirection
AVHWFrameTransferDirection
Definition: hwcontext.h:403
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:115
pixfmt.h
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
HWContextType::device_init
int(* device_init)(AVHWDeviceContext *ctx)
Definition: hwcontext_internal.h:63
HWContextType::pix_fmts
enum AVPixelFormat * pix_fmts
An array of pixel formats supported by the AVHWFramesContext instances Terminated by AV_PIX_FMT_NONE.
Definition: hwcontext_internal.h:37
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
ff_hwcontext_type_cuda
const HWContextType ff_hwcontext_type_cuda
Definition: hwcontext_cuda.c:563
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
hwcontext.h
HWContextType::transfer_data_from
int(* transfer_data_from)(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
Definition: hwcontext_internal.h:79
HWContextType
Definition: hwcontext_internal.h:29
int
int
Definition: ffmpeg_filter.c:424
HWMapDescriptor
Definition: hwcontext_internal.h:120
ff_hwcontext_type_opencl
const HWContextType ff_hwcontext_type_opencl
Definition: hwcontext_opencl.c:3039
ff_hwcontext_type_dxva2
const HWContextType ff_hwcontext_type_dxva2
Definition: hwcontext_dxva2.c:591