24 #include <vdpau/vdpau.h>
120 if (err == VDP_STATUS_OK && supported)
131 #define GET_CALLBACK(id, result) \
134 err = hwctx->get_proc_address(hwctx->device, id, &tmp); \
135 if (err != VDP_STATUS_OK) { \
136 av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \
137 return AVERROR_UNKNOWN; \
149 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
175 const void *hwconfig,
179 int nb_sw_formats = 0;
207 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
data;
220 VdpVideoSurface surf;
225 if (err != VDP_STATUS_OK) {
299 "No target formats are supported for this chroma type\n");
317 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)src->
data[3];
320 uint32_t linesize[3];
323 VdpYCbCrFormat vdpau_format;
328 data[i] = dst->
data[i];
331 "The linesize %d cannot be represented as uint32\n",
347 "Unsupported target pixel format: %s\n",
352 if (vdpau_format == VDP_YCBCR_FORMAT_YV12)
353 FFSWAP(
void*, data[1], data[2]);
355 err = priv->
get_data(surf, vdpau_format, data, linesize);
356 if (err != VDP_STATUS_OK) {
368 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)dst->
data[3];
371 uint32_t linesize[3];
374 VdpYCbCrFormat vdpau_format;
379 data[i] = src->
data[i];
382 "The linesize %d cannot be represented as uint32\n",
398 "Unsupported source pixel format: %s\n",
403 if (vdpau_format == VDP_YCBCR_FORMAT_YV12)
404 FFSWAP(
const void*, data[1], data[2]);
406 err = priv->
put_data(surf, vdpau_format, data, linesize);
407 if (err != VDP_STATUS_OK) {
416 #include <vdpau/vdpau_x11.h>
417 #include <X11/Xlib.h>
419 typedef struct VDPAUDevicePriv {
420 VdpDeviceDestroy *device_destroy;
429 if (priv->device_destroy)
430 priv->device_destroy(hwctx->
device);
432 XCloseDisplay(priv->dpy);
441 VDPAUDevicePriv *priv;
443 VdpGetInformationString *get_information_string;
444 const char *display, *vendor;
451 ctx->
free = vdpau_device_free;
453 priv->dpy = XOpenDisplay(device);
456 XDisplayName(device));
459 display = XDisplayString(priv->dpy);
461 err = vdp_device_create_x11(priv->dpy, XDefaultScreen(priv->dpy),
463 if (err != VDP_STATUS_OK) {
469 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
470 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, priv->device_destroy);
472 get_information_string(&vendor);
474 "X11 display %s\n", vendor, display);
489 .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
enum AVPixelFormat frames_sw_format
#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
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[]
#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.
static const struct @292 vdpau_pix_fmts[]
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
static int vdpau_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
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
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
const VDPAUPixFmtMap * map
AVHWFramesInternal * internal
Private data used internally by libavutil.
static enum AVPixelFormat pix_fmts[]
#define flags(name, subs,...)
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().
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
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