[MPlayer-dev-eng] [PATCH]Support packed YUV422 in vo vdpau
Carl Eugen Hoyos
cehoyos at rainbow.studorg.tuwien.ac.at
Sat Mar 28 18:44:55 CET 2009
Hi!
Attached patch adds support for yuy2 and uyvy for vo vdpau.
NV12 does not work, I will try to find out why or remove.
Please comment, Carl Eugen
-------------- next part --------------
Index: libvo/vo_vdpau.c
===================================================================
--- libvo/vo_vdpau.c (revision 29081)
+++ libvo/vo_vdpau.c (working copy)
@@ -174,7 +174,6 @@
static int vid_surface_num;
static uint32_t vid_width, vid_height;
static uint32_t image_format;
-static const VdpChromaType vdp_chroma_type = VDP_CHROMA_TYPE_420;
/* draw_osd */
static unsigned char *index_data;
@@ -534,6 +533,7 @@
uint32_t d_height, uint32_t flags, char *title,
uint32_t format)
{
+ VdpChromaType chroma_type;
XVisualInfo vinfo;
XSetWindowAttributes xswa;
XWindowAttributes attribs;
@@ -598,7 +598,11 @@
if (vdp_flip_queue == VDP_INVALID_HANDLE && win_x11_init_vdpau_flip_queue())
return -1;
- if (create_vdp_mixer(vdp_chroma_type))
+ chroma_type = image_format == IMGFMT_YUY2 || image_format == IMGFMT_UYVY ?
+ VDP_CHROMA_TYPE_422 :
+ VDP_CHROMA_TYPE_420;
+
+ if (create_vdp_mixer(chroma_type))
return -1;
surface_num = 0;
@@ -851,13 +855,14 @@
return VO_ERROR;
}
-static struct vdpau_render_state *get_surface(int number)
+static struct vdpau_render_state *get_surface(int number,
+ VdpChromaType chroma_type)
{
if (number > MAX_VIDEO_SURFACES)
return NULL;
if (surface_render[number].surface == VDP_INVALID_HANDLE) {
VdpStatus vdp_st;
- vdp_st = vdp_video_surface_create(vdp_device, vdp_chroma_type,
+ vdp_st = vdp_video_surface_create(vdp_device, chroma_type,
vid_width, vid_height,
&surface_render[number].surface);
CHECK_ST_WARNING("Error when calling vdp_video_surface_create")
@@ -882,12 +887,32 @@
}
} else if (!(mpi->flags & MP_IMGFLAG_DRAW_CALLBACK)) {
VdpStatus vdp_st;
+ VdpYCbCrFormat pixel_format;
+ VdpChromaType chroma_type;
void *destdata[3] = {mpi->planes[0], mpi->planes[2], mpi->planes[1]};
- struct vdpau_render_state *rndr = get_surface(deint_counter);
+ struct vdpau_render_state *rndr;
+ switch (image_format) {
+ case IMGFMT_YV12:
+ pixel_format = VDP_YCBCR_FORMAT_YV12;
+ chroma_type = VDP_CHROMA_TYPE_420;
+ break;
+ case IMGFMT_NV12:
+ pixel_format = VDP_YCBCR_FORMAT_NV12;
+ chroma_type = VDP_CHROMA_TYPE_420;
+ break;
+ case IMGFMT_YUY2:
+ pixel_format = VDP_YCBCR_FORMAT_YUYV;
+ chroma_type = VDP_CHROMA_TYPE_422;
+ break;
+ case IMGFMT_UYVY:
+ pixel_format = VDP_YCBCR_FORMAT_UYVY;
+ chroma_type = VDP_CHROMA_TYPE_422;
+ }
+ rndr = get_surface(deint_counter, chroma_type);
deint_counter = (deint_counter + 1) % 3;
vid_surface_num = rndr - surface_render;
vdp_st = vdp_video_surface_put_bits_y_cb_cr(rndr->surface,
- VDP_YCBCR_FORMAT_YV12,
+ pixel_format,
(const void *const*)destdata,
mpi->stride); // pitch
CHECK_ST_ERROR("Error when calling vdp_video_surface_put_bits_y_cb_cr")
@@ -906,7 +931,7 @@
if (!IMGFMT_IS_VDPAU(image_format)) return VO_FALSE;
if (mpi->type != MP_IMGTYPE_NUMBERED) return VO_FALSE;
- rndr = get_surface(mpi->number);
+ rndr = get_surface(mpi->number, VDP_CHROMA_TYPE_420);
if (!rndr) {
mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] no surfaces available in get_image\n");
// TODO: this probably breaks things forever, provide a dummy buffer?
@@ -927,6 +952,9 @@
int default_flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_EOSD | VFCAP_EOSD_UNSCALED;
switch (format) {
case IMGFMT_YV12:
+ case IMGFMT_NV12:
+ case IMGFMT_YUY2:
+ case IMGFMT_UYVY:
return default_flags | VOCAP_NOSLICES;
case IMGFMT_VDPAU_MPEG1:
case IMGFMT_VDPAU_MPEG2:
More information about the MPlayer-dev-eng
mailing list