21 #include <vdpau/vdpau.h>
22 #include <vdpau/vdpau_x11.h>
45 #if 1 // for ffmpegs older vdpau API, not the oldest though
80 XCloseDisplay(ctx->
dpy);
90 VdpVideoSurface surface = *(VdpVideoSurface*)data;
101 VdpVideoSurface *surface;
103 VdpChromaType chroma;
118 if (!frame->
buf[0]) {
128 if (err != VDP_STATUS_OK) {
142 VdpVideoSurface surface = (VdpVideoSurface)(uintptr_t)frame->
data[3];
146 int ret, chroma_type;
151 if (err != VDP_STATUS_OK) {
168 if (err != VDP_STATUS_OK) {
204 const char *display, *vendor;
223 av_log(
NULL, loglevel,
"Cannot open the X11 display %s.\n",
227 display = XDisplayString(ctx->
dpy);
229 err = vdp_device_create_x11(ctx->
dpy, XDefaultScreen(ctx->
dpy), &ctx->
device,
231 if (err != VDP_STATUS_OK) {
232 av_log(
NULL, loglevel,
"VDPAU device creation on X11 display %s failed.\n",
237 #define GET_CALLBACK(id, result) \
240 err = ctx->get_proc_address(ctx->device, id, &tmp); \
241 if (err != VDP_STATUS_OK) { \
242 av_log(NULL, loglevel, "Error getting the " #id " callback.\n"); \
248 GET_CALLBACK(VDP_FUNC_ID_GET_ERROR_STRING, get_error_string);
249 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
250 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, device_destroy);
252 GET_CALLBACK(VDP_FUNC_ID_DECODER_CREATE, decoder_create);
254 GET_CALLBACK(VDP_FUNC_ID_DECODER_RENDER, decoder_render);
256 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_CREATE, video_surface_create);
257 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, video_surface_destroy);
258 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, video_surface_get_bits);
259 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, video_surface_get_parameters);
260 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
261 video_surface_query);
267 if (err != VDP_STATUS_OK) {
269 "Error querying VDPAU surface capabilities: %s\n",
278 "No supported VDPAU format for retrieving the data.\n");
297 "to decode input stream #%d:%d.\n", vendor,
303 av_log(
NULL, loglevel,
"VDPAU init failed for stream #%d:%d.\n",
328 av_log(
NULL, loglevel,
"No known VDPAU decoder profile for this stream.\n");
338 if (err != VDP_STATUS_OK) {
339 av_log(
NULL, loglevel,
"Error creating the VDPAU decoder: %s\n",
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int index
stream index in AVFormatContext
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
#define FF_ARRAY_ELEMS(a)
Public libavcodec VDPAU header.
AVVDPAUContext * av_vdpau_alloc_context(void)
Allocate an AVVDPAUContext.
int vdpau_init(AVCodecContext *s)
int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, uint32_t *width, uint32_t *height)
Gets the parameters to create an adequate VDPAU video surface for the codec context using VDPAU hardw...
VdpVideoSurfaceCreate * video_surface_create
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
void * hwaccel_context
Hardware accelerator context.
VdpDecoderDestroy * decoder_destroy
VdpGetProcAddress * get_proc_address
VdpDecoder decoder
VDPAU decoder handle.
#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.
int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile)
Get a decoder profile that should be used for initializing a VDPAU decoder.
VdpGetErrorString * get_error_string
VdpDecoderCreate * decoder_create
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int vdpau_alloc(AVCodecContext *s)
This structure is used to share data between the libavcodec library and the client video application...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
VdpGetInformationString * get_information_string
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
simple assert() macros that are a bit more flexible than ISO C assert().
static int vdpau_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
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.
reference-counted frame API
static void decoder_destroy(Decoder *d)
VdpDecoderRender * decoder_render
#define GET_CALLBACK(id, result)
static int vdpau_old_init(AVCodecContext *s)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
VdpVideoSurfaceGetParameters * video_surface_get_parameters
VdpVideoSurfaceGetBitsYCbCr * video_surface_get_bits
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
enum AVPixelFormat pix_fmt
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities * video_surface_query
BYTE int const BYTE int int int height
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
VdpDecoderRender * render
VDPAU decoder render callback.
refcounted data buffer API
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, VdpGetProcAddress *get_proc, unsigned flags)
Associate a VDPAU device with a codec context for hardware acceleration.
VdpYCbCrFormat vdpau_format
static const int vdpau_formats[][2]
VdpVideoSurfaceDestroy * video_surface_destroy
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void vdpau_release_buffer(void *opaque, uint8_t *data)
static int vdpau_retrieve_data(AVCodecContext *s, AVFrame *frame)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static void vdpau_uninit(AVCodecContext *s)
VdpDeviceDestroy * device_destroy
#define FFSWAP(type, a, b)
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 ...
void * opaque
Private data of the user, can be used to carry app specific stuff.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.