Libav
hwcontext.h
Go to the documentation of this file.
1 /*
2  * This file is part of Libav.
3  *
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.
8  *
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.
13  *
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
17  */
18 
19 #ifndef AVUTIL_HWCONTEXT_H
20 #define AVUTIL_HWCONTEXT_H
21 
22 #include "buffer.h"
23 #include "frame.h"
24 #include "log.h"
25 #include "pixfmt.h"
26 
33 };
34 
36 
54 typedef struct AVHWDeviceContext {
58  const AVClass *av_class;
59 
64  AVHWDeviceInternal *internal;
65 
73 
85  void *hwctx;
86 
98 
102  void *user_opaque;
104 
106 
117 typedef struct AVHWFramesContext {
122 
128 
135 
143 
155  void *hwctx;
156 
164 
168  void *user_opaque;
169 
184 
193 
203 
216 
222  int width, height;
224 
234 
244 
271  const char *device, AVDictionary *opts, int flags);
272 
283 
293 
303 int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags);
304 
334 int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags);
335 
341 
346 };
347 
365  enum AVPixelFormat **formats, int flags);
366 
367 
374 typedef struct AVHWFramesConstraints {
380 
387 
394 
402 
413 void *av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx);
414 
428  const void *hwconfig);
429 
436 
437 #endif /* AVUTIL_HWCONTEXT_H */
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:54
This structure describes decoded (raw) audio or video data.
Definition: frame.h:140
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
Definition: hwcontext.c:454
static enum AVSampleFormat formats[]
Definition: avresample.c:163
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:222
void * user_opaque
Arbitrary user data, to be used e.g.
Definition: hwcontext.h:168
int max_width
The maximum size of frames in this hw_frames_ctx.
Definition: hwcontext.h:399
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ctx)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:177
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
Definition: hwcontext.c:368
AVHWFramesConstraints * av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, const void *hwconfig)
Get the constraints on HW frames given a device and the HW-specific configuration to be used with tha...
Definition: hwcontext.c:429
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:85
static int flags
Definition: log.c:50
int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats, int flags)
Get a list of possible source or target formats usable in av_hwframe_transfer_data().
Definition: hwcontext.c:310
The buffer pool.
const AVClass * av_class
A class for logging.
Definition: hwcontext.h:121
#define src
Definition: vp8dsp.c:254
AVBufferRef * av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
Allocate an AVHWDeviceContext for a given pixel format.
Definition: hwcontext.c:74
int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition: hwcontext.c:394
enum AVHWDeviceType type
This field identifies the underlying API used for hardware access.
Definition: hwcontext.h:72
reference-counted frame API
int initial_pool_size
Initial size of the frame pool.
Definition: hwcontext.h:192
AVDictionary * opts
Definition: movenc.c:50
Transfer the data from the queried hw frame.
Definition: hwcontext.h:340
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:142
AVFormatContext * ctx
Definition: movenc.c:48
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:263
int min_width
The minimum size of frames in this hw_frames_ctx.
Definition: hwcontext.h:392
Transfer the data to the queried hw frame.
Definition: hwcontext.h:345
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Definition: hwcontext.h:374
int av_hwdevice_ctx_init(AVBufferRef *ref)
Finalize the device context before use.
Definition: hwcontext.c:132
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:155
const AVClass * av_class
A class for logging.
Definition: hwcontext.h:58
const char * format
Definition: movenc.c:47
Describe the class of an AVClass context structure.
Definition: log.h:34
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:117
refcounted data buffer API
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
Definition: hwcontext.h:379
void * user_opaque
Arbitrary user data, to be used e.g.
Definition: hwcontext.h:102
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:134
int height
Definition: gxfenc.c:72
A reference to a data buffer.
Definition: buffer.h:81
AVHWFrameTransferDirection
Definition: hwcontext.h:336
pixel format definitions
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
Definition: hwcontext.h:183
AVHWDeviceType
Definition: hwcontext.h:27
int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
Definition: hwcontext.c:463
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
Definition: hwcontext.h:386
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
Definition: hwcontext.h:97
void * av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx)
Allocate a HW-specific configuration structure for a given HW device.
Definition: hwcontext.c:418
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:215
AVPixelFormat
Pixel format.
Definition: pixfmt.h:57