24 #include <vdpau/vdpau.h>
84 { VDP_CHROMA_TYPE_420, pix_fmts_420 },
85 { VDP_CHROMA_TYPE_422, pix_fmts_422 },
86 { VDP_CHROMA_TYPE_444, pix_fmts_444 },
119 if (err == VDP_STATUS_OK && supported)
137 #define GET_CALLBACK(id, result) \
140 err = hwctx->get_proc_address(hwctx->device, id, &tmp); \
141 if (err != VDP_STATUS_OK) { \
142 av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \
143 return AVERROR_UNKNOWN; \
145 priv->result = tmp; \
148 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
150 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, get_data);
151 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, put_data);
152 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_CREATE, surf_create);
153 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, surf_destroy);
177 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
data;
190 VdpVideoSurface surf;
195 if (err != VDP_STATUS_OK) {
277 "No target formats are supported for this chroma type\n");
295 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)src->
data[3];
298 uint32_t linesize[3];
301 VdpYCbCrFormat vdpau_format;
306 data[i] = dst->
data[i];
309 "The linesize %d cannot be represented as uint32\n",
325 "Unsupported target pixel format: %s\n",
330 if (vdpau_format == VDP_YCBCR_FORMAT_YV12)
331 FFSWAP(
void*, data[1], data[2]);
333 err = priv->
get_data(surf, vdpau_format, data, linesize);
334 if (err != VDP_STATUS_OK) {
346 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)dst->
data[3];
349 uint32_t linesize[3];
352 VdpYCbCrFormat vdpau_format;
357 data[i] = src->
data[i];
360 "The linesize %d cannot be represented as uint32\n",
376 "Unsupported source pixel format: %s\n",
381 if (vdpau_format == VDP_YCBCR_FORMAT_YV12)
382 FFSWAP(
const void*, data[1], data[2]);
384 err = priv->
put_data(surf, vdpau_format, data, linesize);
385 if (err != VDP_STATUS_OK) {
394 #include <vdpau/vdpau_x11.h>
395 #include <X11/Xlib.h>
397 typedef struct VDPAUDevicePriv {
398 VdpDeviceDestroy *device_destroy;
407 if (priv->device_destroy)
408 priv->device_destroy(hwctx->
device);
410 XCloseDisplay(priv->dpy);
419 VDPAUDevicePriv *priv;
421 VdpGetInformationString *get_information_string;
422 const char *display, *vendor;
429 ctx->
free = vdpau_device_free;
431 priv->dpy = XOpenDisplay(device);
434 XDisplayName(device));
437 display = XDisplayString(priv->dpy);
439 err = vdp_device_create_x11(priv->dpy, XDefaultScreen(priv->dpy),
441 if (err != VDP_STATUS_OK) {
447 #define GET_CALLBACK(id, result) \
450 err = hwctx->get_proc_address(hwctx->device, id, &tmp); \
451 if (err != VDP_STATUS_OK) { \
452 av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \
453 return AVERROR_UNKNOWN; \
458 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
459 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, priv->device_destroy);
461 get_information_string(&vendor);
463 "X11 display %s\n", vendor, display);
478 .device_create = vdpau_device_create,
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
This struct is allocated as AVHWDeviceContext.hwctx.
static enum AVPixelFormat pix_fmt
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
#define GET_CALLBACK(id, result)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static int device_init(AVFormatContext *ctx, int *width, int *height, uint32_t pixelformat)
memory handling functions
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
VdpGetProcAddress * get_proc_address
static int vdpau_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
VdpVideoSurfacePutBitsYCbCr * put_data
VdpVideoSurfacePutBitsYCbCr * put_data
static enum AVSampleFormat formats[]
int width
The allocated dimensions of the frames in this pool.
VdpChromaType chroma_type
static int vdpau_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
const HWContextType ff_hwcontext_type_vdpau
VdpVideoSurfaceGetBitsYCbCr * get_data
static int vdpau_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
An API-specific header for AV_HWDEVICE_TYPE_VDPAU.
enum AVPixelFormat * pix_fmts
AVBufferPool * pool_internal
VdpChromaType chroma_type
static int vdpau_init_pixmfts(AVHWDeviceContext *ctx)
static int vdpau_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
enum AVPixelFormat * pix_fmts[3]
static const VDPAUPixFmtMap pix_fmts_422[]
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void vdpau_buffer_free(void *opaque, uint8_t *data)
void(* free)(struct AVHWDeviceContext *ctx)
This field may be set by the caller before calling av_hwdevice_ctx_init().
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static int vdpau_device_init(AVHWDeviceContext *ctx)
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
static const VDPAUPixFmtMap pix_fmts_444[]
static int vdpau_frames_init(AVHWFramesContext *ctx)
AVBufferPool * av_buffer_pool_init2(int size, void *opaque, AVBufferRef *(*alloc)(void *opaque, int size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
#define FF_ARRAY_ELEMS(a)
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities * get_transfer_caps
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
VdpVideoSurfaceCreate * surf_create
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
uint8_t * data
The data buffer.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
This struct describes a set or pool of "hardware" frames (i.e.
refcounted data buffer API
const VDPAUPixFmtMap * map
AVHWFramesInternal * internal
Private data used internally by libavutil.
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * user_opaque
Arbitrary user data, to be used e.g.
A reference to a data buffer.
static void vdpau_device_uninit(AVHWDeviceContext *ctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
static int count_pixfmts(const VDPAUPixFmtMap *map)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
enum AVPixelFormat pix_fmt
static const VDPAUPixFmtMap pix_fmts_420[]
VdpVideoSurfaceDestroy * surf_destroy
AVHWFrameTransferDirection
AVBufferPool * pool
A pool from which the frames are allocated by av_hwframe_get_buffer().
static AVBufferRef * vdpau_pool_alloc(void *opaque, int size)
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define av_malloc_array(a, b)
#define FFSWAP(type, a, b)
AVHWDeviceInternal * internal
Private data used internally by libavutil.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
VdpVideoSurfaceGetBitsYCbCr * get_data
static const struct @220 vdpau_pix_fmts[]