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);
178 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
data;
191 VdpVideoSurface surf;
196 if (err != VDP_STATUS_OK) {
278 "No target formats are supported for this chroma type\n");
296 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)src->
data[3];
299 uint32_t linesize[3];
302 VdpYCbCrFormat vdpau_format;
307 data[i] = dst->
data[i];
310 "The linesize %d cannot be represented as uint32\n",
326 "Unsupported target pixel format: %s\n",
331 if (vdpau_format == VDP_YCBCR_FORMAT_YV12)
332 FFSWAP(
void*, data[1], data[2]);
334 err = priv->
get_data(surf, vdpau_format, data, linesize);
335 if (err != VDP_STATUS_OK) {
347 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)dst->
data[3];
350 uint32_t linesize[3];
353 VdpYCbCrFormat vdpau_format;
358 data[i] = src->
data[i];
361 "The linesize %d cannot be represented as uint32\n",
377 "Unsupported source pixel format: %s\n",
382 if (vdpau_format == VDP_YCBCR_FORMAT_YV12)
383 FFSWAP(
const void*, data[1], data[2]);
385 err = priv->
put_data(surf, vdpau_format, data, linesize);
386 if (err != VDP_STATUS_OK) {
395 #include <vdpau/vdpau_x11.h>
396 #include <X11/Xlib.h>
398 typedef struct VDPAUDevicePriv {
399 VdpDeviceDestroy *device_destroy;
408 if (priv->device_destroy)
409 priv->device_destroy(hwctx->
device);
411 XCloseDisplay(priv->dpy);
420 VDPAUDevicePriv *priv;
422 VdpGetInformationString *get_information_string;
423 const char *display, *vendor;
430 ctx->
free = vdpau_device_free;
432 priv->dpy = XOpenDisplay(device);
435 XDisplayName(device));
438 display = XDisplayString(priv->dpy);
440 err = vdp_device_create_x11(priv->dpy, XDefaultScreen(priv->dpy),
442 if (err != VDP_STATUS_OK) {
448 #define GET_CALLBACK(id, result) \
451 err = hwctx->get_proc_address(hwctx->device, id, &tmp); \
452 if (err != VDP_STATUS_OK) { \
453 av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \
454 return AVERROR_UNKNOWN; \
459 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
460 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, priv->device_destroy);
462 get_information_string(&vendor);
464 "X11 display %s\n", vendor, display);
479 .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
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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().
static const struct @238 vdpau_pix_fmts[]
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.
VdpVideoSurfaceGetBitsYCbCr * get_data