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
136 if (err == VDP_STATUS_OK && supported)
147 #define GET_CALLBACK(id, result) \
150 err = hwctx->get_proc_address(hwctx->device, id, &tmp); \
151 if (err != VDP_STATUS_OK) { \
152 av_log(ctx, AV_LOG_ERROR, "Error getting the " #id " callback.\n"); \
153 return AVERROR_UNKNOWN; \
165 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
191 const void *hwconfig,
195 int nb_sw_formats = 0;
223 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
data;
236 VdpVideoSurface surf;
240 ctx->width,
ctx->height, &surf);
241 if (err != VDP_STATUS_OK) {
315 "No target formats are supported for this chroma type\n");
333 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)
src->data[3];
336 uint32_t linesize[3];
339 VdpYCbCrFormat vdpau_format;
347 "The linesize %d cannot be represented as uint32\n",
363 "Unsupported target pixel format: %s\n",
368 if ((vdpau_format == VDP_YCBCR_FORMAT_YV12)
369 #ifdef VDP_YCBCR_FORMAT_Y_U_V_444
370 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444)
372 #ifdef VDP_YCBCR_FORMAT_P016
373 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444_16)
378 err = priv->
get_data(surf, vdpau_format,
data, linesize);
379 if (err != VDP_STATUS_OK) {
391 VdpVideoSurface surf = (VdpVideoSurface)(uintptr_t)dst->
data[3];
394 uint32_t linesize[3];
397 VdpYCbCrFormat vdpau_format;
403 if (
src->linesize[
i] < 0 ||
src->linesize[
i] > UINT32_MAX) {
405 "The linesize %d cannot be represented as uint32\n",
409 linesize[
i] =
src->linesize[
i];
421 "Unsupported source pixel format: %s\n",
426 if ((vdpau_format == VDP_YCBCR_FORMAT_YV12)
427 #ifdef VDP_YCBCR_FORMAT_Y_U_V_444
428 || (vdpau_format == VDP_YCBCR_FORMAT_Y_U_V_444)
433 err = priv->
put_data(surf, vdpau_format,
data, linesize);
434 if (err != VDP_STATUS_OK) {
443 #include <vdpau/vdpau_x11.h>
444 #include <X11/Xlib.h>
446 typedef struct VDPAUDevicePriv {
447 VdpDeviceDestroy *device_destroy;
454 VDPAUDevicePriv *priv =
ctx->user_opaque;
456 if (priv->device_destroy)
457 priv->device_destroy(hwctx->
device);
459 XCloseDisplay(priv->dpy);
468 VDPAUDevicePriv *priv;
470 VdpGetInformationString *get_information_string;
471 const char *display, *vendor;
477 ctx->user_opaque = priv;
478 ctx->free = vdpau_device_free;
480 priv->dpy = XOpenDisplay(device);
483 XDisplayName(device));
486 display = XDisplayString(priv->dpy);
488 err = vdp_device_create_x11(priv->dpy, XDefaultScreen(priv->dpy),
490 if (err != VDP_STATUS_OK) {
496 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
497 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, priv->device_destroy);
499 get_information_string(&vendor);
501 "X11 display %s\n", vendor, display);
516 .device_create = vdpau_device_create,
refcounted data buffer API
#define flags(name, subs,...)
common internal and external API header
#define FFSWAP(type, a, b)
static enum AVPixelFormat pix_fmt
AVBufferRef * av_buffer_create(uint8_t *data, buffer_size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
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(buffer_size_t size, void *opaque, AVBufferRef *(*alloc)(void *opaque, buffer_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.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVHWFrameTransferDirection
#define GET_CALLBACK(id, result)
static AVBufferRef * vdpau_pool_alloc(void *opaque, buffer_size_t size)
const HWContextType ff_hwcontext_type_vdpau
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)
enum AVPixelFormat frames_sw_format
static int vdpau_init_pixmfts(AVHWDeviceContext *ctx)
static int vdpau_device_init(AVHWDeviceContext *ctx)
static const struct @308 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.
static enum AVPixelFormat pix_fmts[]
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.
uint8_t * data
The data buffer.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
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
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
enum AVPixelFormat * pix_fmts
VdpChromaType chroma_type
VdpVideoSurfacePutBitsYCbCr * put_data
VdpVideoSurfaceGetBitsYCbCr * get_data
enum AVPixelFormat pix_fmt
#define av_malloc_array(a, b)
static int device_init(AVFormatContext *ctx, int *width, int *height, uint32_t pixelformat)