21 #include <vdpau/vdpau.h>
22 #include <vdpau/vdpau_x11.h>
28 #include "libavcodec/vdpau.h"
30 #include "libavutil/avassert.h"
31 #include "libavutil/buffer.h"
32 #include "libavutil/frame.h"
33 #include "libavutil/pixfmt.h"
76 XCloseDisplay(ctx->
dpy);
86 VdpVideoSurface surface = *(VdpVideoSurface*)data;
97 VdpVideoSurface *surface;
109 if (!frame->
buf[0]) {
119 if (err != VDP_STATUS_OK) {
133 VdpVideoSurface surface = (VdpVideoSurface)(uintptr_t)frame->
data[3];
137 int ret, chroma_type;
142 if (err != VDP_STATUS_OK) {
159 if (err != VDP_STATUS_OK) {
195 const char *display, *vendor;
214 av_log(
NULL, loglevel,
"Cannot open the X11 display %s.\n",
218 display = XDisplayString(ctx->
dpy);
220 err = vdp_device_create_x11(ctx->
dpy, XDefaultScreen(ctx->
dpy), &ctx->
device,
222 if (err != VDP_STATUS_OK) {
223 av_log(
NULL, loglevel,
"VDPAU device creation on X11 display %s failed.\n",
228 #define GET_CALLBACK(id, result) \
231 err = ctx->get_proc_address(ctx->device, id, &tmp); \
232 if (err != VDP_STATUS_OK) { \
233 av_log(NULL, loglevel, "Error getting the " #id " callback.\n"); \
239 GET_CALLBACK(VDP_FUNC_ID_GET_ERROR_STRING, get_error_string);
240 GET_CALLBACK(VDP_FUNC_ID_GET_INFORMATION_STRING, get_information_string);
241 GET_CALLBACK(VDP_FUNC_ID_DEVICE_DESTROY, device_destroy);
242 GET_CALLBACK(VDP_FUNC_ID_DECODER_CREATE, decoder_create);
243 GET_CALLBACK(VDP_FUNC_ID_DECODER_DESTROY, decoder_destroy);
244 GET_CALLBACK(VDP_FUNC_ID_DECODER_RENDER, decoder_render);
245 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_CREATE, video_surface_create);
246 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, video_surface_destroy);
247 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR, video_surface_get_bits);
248 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, video_surface_get_parameters);
249 GET_CALLBACK(VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES,
250 video_surface_query);
256 if (err != VDP_STATUS_OK) {
258 "Error querying VDPAU surface capabilities: %s\n",
267 "No supported VDPAU format for retrieving the data.\n");
282 "to decode input stream #%d:%d.\n", vendor,
288 av_log(
NULL, loglevel,
"VDPAU init failed for stream #%d:%d.\n",
313 av_log(
NULL, loglevel,
"No known VDPAU decoder profile for this stream.\n");
323 if (err != VDP_STATUS_OK) {
324 av_log(
NULL, loglevel,
"Error creating the VDPAU decoder: %s\n",
VdpDecoderRender * render
VDPAU decoder render callback.
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.
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
int coded_width
Bitstream width / height, may be different from width/height e.g.
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
#define GET_CALLBACK(id, result)
int index
stream index in AVFormatContext
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everythnig contained in src to dst and reset src.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
VdpVideoSurfaceCreate * video_surface_create
VdpDecoderDestroy * decoder_destroy
VdpGetProcAddress * get_proc_address
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.
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.
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.
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
static const int vdpau_formats[][2]
static int vdpau_get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
AVPixelFormat
Pixel format.
VdpDecoderRender * decoder_render
void * opaque
Private data of the user, can be used to carry app specific stuff.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define FF_ARRAY_ELEMS(a)
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile)
Get a decoder profile that should be used for initializing a VDPAU decoder.
int vdpau_init(AVCodecContext *s)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
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
void * hwaccel_context
Hardware accelerator context.
static int vdpau_alloc(AVCodecContext *s)
main external API structure.
enum AVPixelFormat pix_fmt
VdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities * video_surface_query
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static void vdpau_release_buffer(void *opaque, uint8_t *data)
static void vdpau_uninit(AVCodecContext *s)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
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.
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
VdpYCbCrFormat vdpau_format
VdpVideoSurfaceDestroy * video_surface_destroy
#define FFSWAP(type, a, b)
AVVDPAUContext * av_vdpau_alloc_context(void)
Allocate an AVVDPAUContext.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static int vdpau_retrieve_data(AVCodecContext *s, AVFrame *frame)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
VdpDeviceDestroy * device_destroy
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...