24#include <vdpau/vdpau.h>
43#ifdef VDP_YCBCR_FORMAT_P016
59#ifdef VDP_YCBCR_FORMAT_Y_U_V_444
62#ifdef VDP_YCBCR_FORMAT_P016
76#ifdef VDP_YCBCR_FORMAT_P016
140 map->vdpau_fmt, &supported);
141 if (err == VDP_STATUS_OK && supported)
152#define GET_CALLBACK(id, result) \
155 err = hwctx->get_proc_address(hwctx->device, id, &tmp); \
156 if (err != VDP_STATUS_OK) { \
157 av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \
158 return AVERROR_UNKNOWN; \
170 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
196 const void *hwconfig,
200 int nb_sw_formats = 0;
228 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
data;
241 VdpVideoSurface surf;
245 ctx->width,
ctx->height, &surf);
246 if (err != VDP_STATUS_OK) {
321 "No target formats are supported for this chroma type\n");
339 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
src->data[3];
342 uint32_t linesize[3];
345 VdpYCbCrFormat vdpau_format;
351 if (
dst->linesize[
i] < 0 ||
dst->linesize[
i] > UINT32_MAX) {
353 "The linesize %d cannot be represented as uint32\n",
357 linesize[
i] =
dst->linesize[
i];
363 vdpau_format =
map[
i].vdpau_fmt;
369 "Unsupported target pixel format: %s\n",
374 if ((vdpau_format == VDP_YCBCR_FORMAT_YV12)
375#ifdef VDP_YCBCR_FORMAT_Y_U_V_444
376 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444)
378#ifdef VDP_YCBCR_FORMAT_P016
379 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444_16)
384 err = priv->
get_data(surf, vdpau_format,
data, linesize);
385 if (err != VDP_STATUS_OK) {
397 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
dst->data[3];
400 uint32_t linesize[3];
403 VdpYCbCrFormat vdpau_format;
409 if (
src->linesize[
i] < 0 ||
src->linesize[
i] > UINT32_MAX) {
411 "The linesize %d cannot be represented as uint32\n",
415 linesize[
i] =
src->linesize[
i];
421 vdpau_format =
map[
i].vdpau_fmt;
427 "Unsupported source pixel format: %s\n",
432 if ((vdpau_format == VDP_YCBCR_FORMAT_YV12)
433#ifdef VDP_YCBCR_FORMAT_Y_U_V_444
434 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444)
439 err = priv->
put_data(surf, vdpau_format,
data, linesize);
440 if (err != VDP_STATUS_OK) {
449#include <vdpau/vdpau_x11.h>
452typedef struct VDPAUDevicePriv {
453 VdpDeviceDestroy *device_destroy;
460 VDPAUDevicePriv *priv =
ctx->user_opaque;
462 if (priv->device_destroy)
463 priv->device_destroy(hwctx->
device);
465 XCloseDisplay(priv->dpy);
474 VDPAUDevicePriv *priv;
476 VdpGetInformationString *get_information_string;
477 const char *display, *vendor;
483 ctx->user_opaque = priv;
484 ctx->free = vdpau_device_free;
486 priv->dpy = XOpenDisplay(device);
489 XDisplayName(device));
492 display = XDisplayString(priv->dpy);
494 err = vdp_device_create_x11(priv->dpy, XDefaultScreen(priv->dpy),
496 if (err != VDP_STATUS_OK) {
502 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
503 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, priv->device_destroy);
505 get_information_string(&vendor);
507 "X11 display %s\n", vendor, display);
521 .device_create = vdpau_device_create,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static AVFormatContext * ctx
static AVDictionary * opts
refcounted data buffer API
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
common internal and external API header
static enum AVPixelFormat pix_fmt
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
AVBufferPool * av_buffer_pool_init2(size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, size_t size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVHWFrameTransferDirection
static FFHWFramesContext * ffhwframesctx(AVHWFramesContext *ctx)
const HWContextType ff_hwcontext_type_vdpau
#define GET_CALLBACK(id, result)
static void vdpau_buffer_free(void *opaque, uint8_t *data)
const VDPAUPixFmtMap * map
static const VDPAUPixFmtMap pix_fmts_420[]
static int count_pixfmts(const VDPAUPixFmtMap *map)
static int vdpau_frames_get_constraints(AVHWDeviceContext *ctx, const void *hwconfig, AVHWFramesConstraints *constraints)
static int vdpau_frames_init(AVHWFramesContext *ctx)
static void vdpau_device_uninit(AVHWDeviceContext *ctx)
static AVBufferRef * vdpau_pool_alloc(void *opaque, size_t size)
enum AVPixelFormat frames_sw_format
static int vdpau_init_pixmfts(AVHWDeviceContext *ctx)
static int vdpau_device_init(AVHWDeviceContext *ctx)
static const struct @151233163203151337314173014117214063023366371057 vdpau_pix_fmts[]
static int vdpau_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats)
static const VDPAUPixFmtMap pix_fmts_444[]
static int vdpau_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
static int vdpau_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
static const VDPAUPixFmtMap pix_fmts_422[]
VdpChromaType chroma_type
static int vdpau_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src)
An API-specific header for AV_HWDEVICE_TYPE_VDPAU.
#define FFSWAP(type, a, b)
Memory handling functions.
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.
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P10
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
This structure describes decoded (raw) audio or video data.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
enum AVPixelFormat * valid_hw_formats
A list of possible values for format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
This struct describes a set or pool of "hardware" frames (i.e.
This struct is allocated as AVHWDeviceContext.hwctx.
VdpGetProcAddress * get_proc_address
AVBufferPool * pool_internal
VdpVideoSurfacePutBitsYCbCr * put_data
enum AVPixelFormat * pix_fmts[FF_ARRAY_ELEMS(vdpau_pix_fmts)]
VdpVideoSurfaceCreate * surf_create
int nb_pix_fmts[FF_ARRAY_ELEMS(vdpau_pix_fmts)]
VdpVideoSurfaceGetBitsYCbCr * get_data
VdpVideoSurfaceDestroy * surf_destroy
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities * get_transfer_caps
AVVDPAUDeviceContext p
The public AVVDPAUDeviceContext.
enum AVPixelFormat * pix_fmts
VdpChromaType chroma_type
VdpVideoSurfacePutBitsYCbCr * put_data
VdpVideoSurfaceGetBitsYCbCr * get_data
enum AVPixelFormat pix_fmt
#define av_malloc_array(a, b)