summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/va/Makefile28
-rw-r--r--src/gallium/state_trackers/va/ftab.c136
-rw-r--r--src/gallium/state_trackers/va/htab.c99
-rw-r--r--src/gallium/state_trackers/va/va_buffer.c96
-rw-r--r--src/gallium/state_trackers/va/va_config.c131
-rw-r--r--src/gallium/state_trackers/va/va_context.c107
-rw-r--r--src/gallium/state_trackers/va/va_display.c70
-rw-r--r--src/gallium/state_trackers/va/va_image.c178
-rw-r--r--src/gallium/state_trackers/va/va_picture.c61
-rw-r--r--src/gallium/state_trackers/va/va_private.h159
-rw-r--r--src/gallium/state_trackers/va/va_subpicture.c157
-rw-r--r--src/gallium/state_trackers/va/va_surface.c167
-rw-r--r--src/gallium/state_trackers/vdpau/Makefile16
-rw-r--r--src/gallium/state_trackers/vdpau/bitmap.c75
-rw-r--r--src/gallium/state_trackers/vdpau/color.c0
-rw-r--r--src/gallium/state_trackers/vdpau/decode.c309
-rw-r--r--src/gallium/state_trackers/vdpau/device.c114
-rw-r--r--src/gallium/state_trackers/vdpau/ftab.c108
-rw-r--r--src/gallium/state_trackers/vdpau/mixer.c140
-rw-r--r--src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c149
-rw-r--r--src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h65
-rw-r--r--src/gallium/state_trackers/vdpau/output.c64
-rw-r--r--src/gallium/state_trackers/vdpau/preemption.c39
-rw-r--r--src/gallium/state_trackers/vdpau/presentation.c149
-rw-r--r--src/gallium/state_trackers/vdpau/query.c121
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c193
-rw-r--r--src/gallium/state_trackers/vdpau/vdpau_private.h223
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/subpicture.c13
28 files changed, 3096 insertions, 71 deletions
diff --git a/src/gallium/state_trackers/va/Makefile b/src/gallium/state_trackers/va/Makefile
new file mode 100644
index 00000000000..dd303ebace9
--- /dev/null
+++ b/src/gallium/state_trackers/va/Makefile
@@ -0,0 +1,28 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = vatracker
+
+VA_MAJOR = 0
+VA_MINOR = 3
+LIBRARY_DEFINES = -DVER_MAJOR=$(VA_MAJOR) -DVER_MINOR=$(VA_MINOR) $(STATE_TRACKER_DEFINES)
+
+LIBRARY_INCLUDES = \
+ $(shell pkg-config --cflags-only-I va) \
+ -I$(TOP)/src/gallium/winsys/g3dvl
+
+C_SOURCES = htab.c \
+ ftab.c \
+ va_context.c \
+ va_image.c \
+ va_subpicture.c \
+ va_buffer.c \
+ va_config.c \
+ va_picture.c \
+ va_surface.c \
+ va_display.c
+
+
+
+include ../../Makefile.template
+
diff --git a/src/gallium/state_trackers/va/ftab.c b/src/gallium/state_trackers/va/ftab.c
new file mode 100644
index 00000000000..999287e7a7e
--- /dev/null
+++ b/src/gallium/state_trackers/va/ftab.c
@@ -0,0 +1,136 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <assert.h>
+#include <va/va.h>
+#include <va/va_backend.h>
+#include "va_private.h"
+
+struct VADriverVTable vlVaGetVtable();
+
+static struct VADriverVTable vtable =
+{
+ &vlVaTerminate, /* VAStatus (*vaTerminate) ( VADriverContextP ctx ); */
+ &vlVaQueryConfigProfiles, /* VAStatus (*vaQueryConfigProfiles) ( VADriverContextP ctx, VAProfile *profile_list,int *num_profiles); */
+ &vlVaQueryConfigEntrypoints, /* VAStatus (*vaQueryConfigEntrypoints) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints ); */
+ &vlVaGetConfigAttributes, /* VAStatus (*vaGetConfigAttributes) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs ); */
+ &vlVaCreateConfig, /* VAStatus (*vaCreateConfig) ( VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id); */
+ &vlVaDestroyConfig, /* VAStatus (*vaDestroyConfig) ( VADriverContextP ctx, VAConfigID config_id); */
+ &vlVaQueryConfigAttributes, /* VAStatus (*vaQueryConfigAttributes) ( VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs); */
+ &vlVaCreateSurfaces, /* VAStatus (*vaCreateSurfaces) ( VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces); */
+ &vlVaDestroySurfaces, /* VAStatus (*vaDestroySurfaces) ( VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces ); */
+ &vlVaCreateContext, /* VAStatus (*vaCreateContext) (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context); */
+ &vlVaDestroyContext, /* VAStatus (*vaDestroyContext) (VADriverContextP ctx,VAContextID context); */
+ &vlVaCreateBuffer, /* VAStatus (*vaCreateBuffer) (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id); */
+ &vlVaBufferSetNumElements, /* VAStatus (*vaBufferSetNumElements) (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements); */
+ &vlVaMapBuffer, /* VAStatus (*vaMapBuffer) (VADriverContextP ctx,VABufferID buf_id,void **pbuf); */
+ &vlVaUnmapBuffer, /* VAStatus (*vaUnmapBuffer) (VADriverContextP ctx,VABufferID buf_id); */
+ &vlVaDestroyBuffer, /* VAStatus (*vaDestroyBuffer) (VADriverContextP ctx,VABufferID buffer_id); */
+ &vlVaBeginPicture, /* VAStatus (*vaBeginPicture) (VADriverContextP ctx,VAContextID context,VASurfaceID render_target); */
+ &vlVaRenderPicture, /* VAStatus (*vaRenderPicture) (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers); */
+ &vlVaEndPicture, /* VAStatus (*vaEndPicture) (VADriverContextP ctx,VAContextID context); */
+ &vlVaSyncSurface, /* VAStatus (*vaSyncSurface) (VADriverContextP ctx,VASurfaceID render_target); */
+ &vlVaQuerySurfaceStatus, /* VAStatus (*vaQuerySurfaceStatus) (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status); */
+ &vlVaPutSurface, /* VAStatus (*vaPutSurface) (
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ void* draw,
+ short srcx,
+ short srcy,
+ unsigned short srcw,
+ unsigned short srch,
+ short destx,
+ short desty,
+ unsigned short destw,
+ unsigned short desth,
+ VARectangle *cliprects,
+ unsigned int number_cliprects,
+ unsigned int flags); */
+ &vlVaQueryImageFormats, /* VAStatus (*vaQueryImageFormats) ( VADriverContextP ctx, VAImageFormat *format_list,int *num_formats); */
+ &vlVaCreateImage, /* VAStatus (*vaCreateImage) (VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image); */
+ &vlVaDeriveImage, /* VAStatus (*vaDeriveImage) (VADriverContextP ctx,VASurfaceID surface,VAImage *image); */
+ &vlVaDestroyImage, /* VAStatus (*vaDestroyImage) (VADriverContextP ctx,VAImageID image); */
+ &vlVaSetImagePalette, /* VAStatus (*vaSetImagePalette) (VADriverContextP ctx,VAImageID image, unsigned char *palette); */
+ &vlVaGetImage, /* VAStatus (*vaGetImage) (VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image); */
+ &vlVaPutImage, /* VAStatus (*vaPutImage) (
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ VAImageID image,
+ int src_x,
+ int src_y,
+ unsigned int src_width,
+ unsigned int src_height,
+ int dest_x,
+ int dest_y,
+ unsigned int dest_width,
+ unsigned int dest_height
+ ); */
+ &vlVaQuerySubpictureFormats, /* VAStatus (*vaQuerySubpictureFormats) (VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats); */
+ &vlVaCreateSubpicture, /* VAStatus (*vaCreateSubpicture) (VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture); */
+ &vlVaDestroySubpicture, /* VAStatus (*vaDestroySubpicture) (VADriverContextP ctx,VASubpictureID subpicture); */
+ &vlVaSubpictureImage, /* VAStatus (*vaSetSubpictureImage) (VADriverContextP ctx,VASubpictureID subpicture,VAImageID image); */
+ &vlVaSetSubpictureChromakey, /* VAStatus (*vaSetSubpictureChromakey) (VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask); */
+ &vlVaSetSubpictureGlobalAlpha, /* VAStatus (*vaSetSubpictureGlobalAlpha) (VADriverContextP ctx,VASubpictureID subpicture,float global_alpha); */
+ &vlVaAssociateSubpicture, /* VAStatus (*vaAssociateSubpicture) (
+ VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
+ short src_x,
+ short src_y,
+ unsigned short src_width,
+ unsigned short src_height,
+ short dest_x,
+ short dest_y,
+ unsigned short dest_width,
+ unsigned short dest_height,
+ unsigned int flags); */
+ &vlVaDeassociateSubpicture, /* VAStatus (*vaDeassociateSubpicture) (VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces); */
+ &vlVaQueryDisplayAttributes, /* VAStatus (*vaQueryDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes); */
+ &vlVaGetDisplayAttributes, /* VAStatus (*vaGetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */
+ &vlVaSetDisplayAttributes, /* VAStatus (*vaSetDisplayAttributes) (VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes); */
+ &vlVaBufferInfo, /* VAStatus (*vaBufferInfo) (VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements); */
+ &vlVaLockSurface, /* VAStatus (*vaLockSurface) (
+ VADriverContextP ctx,
+ VASurfaceID surface,
+ unsigned int *fourcc,
+ unsigned int *luma_stride,
+ unsigned int *chroma_u_stride,
+ unsigned int *chroma_v_stride,
+ unsigned int *luma_offset,
+ unsigned int *chroma_u_offset,
+ unsigned int *chroma_v_offset,
+ unsigned int *buffer_name,
+ void **buffer); */
+ &vlVaUnlockSurface, /* VAStatus (*vaUnlockSurface) (VADriverContextP ctx,VASurfaceID surface); */
+ NULL /* struct VADriverVTableGLX *glx; "Optional" */
+};
+
+struct VADriverVTable vlVaGetVtable()
+{
+ return vtable;
+}
diff --git a/src/gallium/state_trackers/va/htab.c b/src/gallium/state_trackers/va/htab.c
new file mode 100644
index 00000000000..2187507c6a4
--- /dev/null
+++ b/src/gallium/state_trackers/va/htab.c
@@ -0,0 +1,99 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Younes Manton.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <util/u_handle_table.h>
+#include <os/os_thread.h>
+#include "va_private.h"
+
+boolean vlCreateHTAB(void);
+void vlDestroyHTAB(void);
+vlHandle vlAddDataHTAB(void *data);
+void* vlGetDataHTAB(vlHandle handle);
+
+#ifdef VL_HANDLES
+static struct handle_table *htab = NULL;
+pipe_static_mutex(htab_lock);
+#endif
+
+boolean vlCreateHTAB(void)
+{
+#ifdef VL_HANDLES
+ boolean ret;
+ /* Make sure handle table handles match VDPAU handles. */
+ assert(sizeof(unsigned) <= sizeof(vlHandle));
+ pipe_mutex_lock(htab_lock);
+ if (!htab)
+ htab = handle_table_create();
+ ret = htab != NULL;
+ pipe_mutex_unlock(htab_lock);
+ return ret;
+#else
+ return TRUE;
+#endif
+}
+
+void vlDestroyHTAB(void)
+{
+#ifdef VL_HANDLES
+ pipe_mutex_lock(htab_lock);
+ if (htab) {
+ handle_table_destroy(htab);
+ htab = NULL;
+ }
+ pipe_mutex_unlock(htab_lock);
+#endif
+}
+
+vlHandle vlAddDataHTAB(void *data)
+{
+ assert(data);
+#ifdef VL_HANDLES
+ vlHandle handle = 0;
+ pipe_mutex_lock(htab_lock);
+ if (htab)
+ handle = handle_table_add(htab, data);
+ pipe_mutex_unlock(htab_lock);
+ return handle;
+#else
+ return (vlHandle)data;
+#endif
+}
+
+void* vlGetDataHTAB(vlHandle handle)
+{
+ assert(handle);
+#ifdef VL_HANDLES
+ void *data = NULL;
+ pipe_mutex_lock(htab_lock);
+ if (htab)
+ data = handle_table_get(htab, handle);
+ pipe_mutex_unlock(htab_lock);
+ return data;
+#else
+ return (void*)handle;
+#endif
+}
diff --git a/src/gallium/state_trackers/va/va_buffer.c b/src/gallium/state_trackers/va/va_buffer.c
new file mode 100644
index 00000000000..7608a4264ff
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_buffer.c
@@ -0,0 +1,96 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <va/va.h>
+#include <va/va_backend.h>
+#include "va_private.h"
+
+
+VAStatus vlVaCreateBuffer( VADriverContextP ctx,
+ VAContextID context,
+ VABufferType type,
+ unsigned int size,
+ unsigned int num_elements,
+ void *data,
+ VABufferID *buf_id)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaBufferSetNumElements( VADriverContextP ctx,
+ VABufferID buf_id,
+ unsigned int num_elements)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaMapBuffer( VADriverContextP ctx,
+ VABufferID buf_id,
+ void **pbuff)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaUnmapBuffer( VADriverContextP ctx,
+ VABufferID buf_id)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaDestroyBuffer( VADriverContextP ctx,
+ VABufferID buffer_id)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaBufferInfo( VADriverContextP ctx,
+ VAContextID context,
+ VABufferID buf_id,
+ VABufferType *type,
+ unsigned int *size,
+ unsigned int *num_elements)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_config.c b/src/gallium/state_trackers/va/va_config.c
new file mode 100644
index 00000000000..1589abf7cfa
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_config.c
@@ -0,0 +1,131 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <va/va.h>
+#include <va/va_backend.h>
+#include <util/u_debug.h>
+#include "va_private.h"
+
+VAStatus vlVaQueryConfigProfiles( VADriverContextP ctx,
+ VAProfile *profile_list,
+ int *num_profiles)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ int i = 0;
+
+ profile_list[i++] = VAProfileMPEG2Simple;
+ *num_profiles = i;
+
+ return VA_STATUS_SUCCESS;
+}
+
+
+VAStatus vlVaQueryConfigEntrypoints( VADriverContextP ctx,
+ VAProfile profile,
+ VAEntrypoint *entrypoint_list,
+ int *num_entrypoints)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ VAStatus vaStatus = VA_STATUS_SUCCESS;
+
+ switch (profile) {
+ case VAProfileMPEG2Simple:
+ case VAProfileMPEG2Main:
+ VA_INFO("Using profile %08x\n",profile);
+ *num_entrypoints = 1;
+ entrypoint_list[0] = VAEntrypointMoComp;
+ break;
+
+ case VAProfileH264Baseline:
+ case VAProfileH264Main:
+ case VAProfileH264High:
+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ *num_entrypoints = 0;
+ break;
+
+ default:
+ VA_ERROR("Unsupported profile %08x\n",profile);
+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_PROFILE;
+ *num_entrypoints = 0;
+ break;
+ }
+
+ return vaStatus;
+}
+
+
+VAStatus vlVaGetConfigAttributes( VADriverContextP ctx,
+ VAProfile profile,
+ VAEntrypoint entrypoint,
+ VAConfigAttrib *attrib_list,
+ int num_attribs)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaCreateConfig( VADriverContextP ctx,
+ VAProfile profile,
+ VAEntrypoint entrypoint,
+ VAConfigAttrib *attrib_list,
+ int num_attribs,
+ VAConfigID *config_id)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaDestroyConfig( VADriverContextP ctx,
+ VAConfigID config_id)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaQueryConfigAttributes( VADriverContextP ctx,
+ VAConfigID config_id,
+ VAProfile *profile,
+ VAEntrypoint *entrypoint,
+ VAConfigAttrib *attrib_list,
+ int *num_attribs)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
diff --git a/src/gallium/state_trackers/va/va_context.c b/src/gallium/state_trackers/va/va_context.c
new file mode 100644
index 00000000000..cdb20cc0eb2
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_context.c
@@ -0,0 +1,107 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <pipe/p_compiler.h>
+#include <pipe/p_video_context.h>
+#include <pipe/p_screen.h>
+#include <vl_winsys.h>
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+#include <va/va.h>
+#include <va/va_backend.h>
+#include "va_private.h"
+
+//struct VADriverVTable vlVaGetVtable();
+
+PUBLIC
+VAStatus __vaDriverInit_0_31 (VADriverContextP ctx)
+{
+ vlVaDriverContextPriv *driver_context = NULL;
+
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ /* Create private driver context */
+ driver_context = CALLOC(1,sizeof(vlVaDriverContextPriv));
+ if (!driver_context)
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+ driver_context->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
+ if (!driver_context->vscreen)
+ {
+ FREE(driver_context);
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+
+ ctx->str_vendor = "mesa gallium vaapi";
+ ctx->vtable = vlVaGetVtable();
+ ctx->max_attributes = 1;
+ ctx->max_display_attributes = 1;
+ ctx->max_entrypoints = VA_MAX_ENTRYPOINTS;
+ ctx->max_image_formats = VA_MAX_IMAGE_FORMATS_SUPPORTED;
+ ctx->max_profiles = 1;
+ ctx->max_subpic_formats = VA_MAX_SUBPIC_FORMATS_SUPPORTED;
+ ctx->version_major = 3;
+ ctx->version_minor = 1;
+ ctx->pDriverData = (void *)driver_context;
+
+ VA_INFO("vl_screen_pointer %p\n",ctx->native_dpy);
+
+ return VA_STATUS_SUCCESS;
+}
+
+VAStatus vlVaCreateContext( VADriverContextP ctx,
+ VAConfigID config_id,
+ int picture_width,
+ int picture_height,
+ int flag,
+ VASurfaceID *render_targets,
+ int num_render_targets,
+ VAContextID *conext)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaDestroyContext( VADriverContextP ctx,
+ VAContextID context)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaTerminate( VADriverContextP ctx)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_display.c b/src/gallium/state_trackers/va/va_display.c
new file mode 100644
index 00000000000..1aaaf7ccc53
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_display.c
@@ -0,0 +1,70 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ #include <va/va.h>
+ #include <va/va_backend.h>
+ #include "va_private.h"
+
+
+VAStatus vlVaQueryDisplayAttributes( VADriverContextP ctx,
+ VADisplayAttribute *attr_list,
+ int *num_attributes)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ if (!(attr_list && num_attributes))
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ *num_attributes = 0;
+
+ return VA_STATUS_SUCCESS;
+}
+
+VAStatus vlVaGetDisplayAttributes( VADriverContextP ctx,
+ VADisplayAttribute *attr_list,
+ int num_attributes)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaSetDisplayAttributes( VADriverContextP ctx,
+ VADisplayAttribute *attr_list,
+ int num_attributes)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+
diff --git a/src/gallium/state_trackers/va/va_image.c b/src/gallium/state_trackers/va/va_image.c
new file mode 100644
index 00000000000..8d20bfa9174
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_image.c
@@ -0,0 +1,178 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <util/u_memory.h>
+#include <util/u_format.h>
+#include <util/u_debug.h>
+#include <pipe/p_format.h>
+#include <va/va.h>
+#include <va/va_backend.h>
+#include "va_private.h"
+
+typedef struct {
+ enum pipe_format pipe_format;
+ VAImageFormat va_format;
+} va_image_formats_supported_t;
+
+static const va_image_formats_supported_t va_image_formats_supported[VA_MAX_IMAGE_FORMATS_SUPPORTED] =
+{
+ { PIPE_FORMAT_B8G8R8A8_UNORM,
+ { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }},
+ { PIPE_FORMAT_R8G8B8A8_UNORM,
+ { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }}
+};
+
+boolean vlCreateHTAB(void);
+void vlDestroyHTAB(void);
+vlHandle vlAddDataHTAB(void *data);
+void* vlGetDataHTAB(vlHandle handle);
+
+VAStatus
+vlVaQueryImageFormats ( VADriverContextP ctx,
+ VAImageFormat *format_list,
+ int *num_formats)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ if (!(format_list && num_formats))
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ int n = 0;
+
+ num_formats[0] = VA_MAX_IMAGE_FORMATS_SUPPORTED;
+
+ /* Query supported formats */
+ for (n = 0; n < VA_MAX_IMAGE_FORMATS_SUPPORTED; n++)
+ {
+ format_list[n] = va_image_formats_supported[n].va_format;
+ }
+
+ return VA_STATUS_SUCCESS;
+}
+
+VAStatus vlVaCreateImage( VADriverContextP ctx,
+ VAImageFormat *format,
+ int width,
+ int height,
+ VAImage *image)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ if(!format)
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ if (!(width && height))
+ return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
+
+ if (!vlCreateHTAB())
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ switch (format->fourcc) {
+ case VA_FOURCC('B','G','R','A'):
+ VA_INFO("Creating BGRA image of size %dx%d\n",width,height);
+ break;
+ case VA_FOURCC_RGBA:
+ VA_INFO("Creating RGBA image of size %dx%d\n",width,height);
+ break;
+ default:
+ VA_ERROR("Couldn't create image of type %0x08\n",format->fourcc);
+ return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+ break;
+ }
+
+ VA_INFO("Image %p created successfully\n",format);
+
+ return VA_STATUS_SUCCESS;
+}
+
+VAStatus vlVaDeriveImage( VADriverContextP ctx,
+ VASurfaceID surface,
+ VAImage *image)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaDestroyImage( VADriverContextP ctx,
+ VAImageID image)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaSetImagePalette( VADriverContextP ctx,
+ VAImageID image,
+ unsigned char *palette)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaGetImage( VADriverContextP ctx,
+ VASurfaceID surface,
+ int x,
+ int y,
+ unsigned int width,
+ unsigned int height,
+ VAImageID image)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaPutImage( VADriverContextP ctx,
+ VASurfaceID surface,
+ VAImageID image,
+ int src_x,
+ int src_y,
+ unsigned int src_width,
+ unsigned int src_height,
+ int dest_x,
+ int dest_y,
+ unsigned int dest_width,
+ unsigned int dest_height)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_picture.c b/src/gallium/state_trackers/va/va_picture.c
new file mode 100644
index 00000000000..3603dfb6fed
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_picture.c
@@ -0,0 +1,61 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <va/va.h>
+#include <va/va_backend.h>
+#include <util/u_debug.h>
+#include "va_private.h"
+
+VAStatus vlVaBeginPicture( VADriverContextP ctx,
+ VAContextID context,
+ VASurfaceID render_target)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaRenderPicture( VADriverContextP ctx,
+ VAContextID context,
+ VABufferID *buffers,
+ int num_buffers)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaEndPicture( VADriverContextP ctx,
+ VAContextID context)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
new file mode 100644
index 00000000000..625c6cdbe1b
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -0,0 +1,159 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef VA_PRIVATE_H
+#define VA_PRIVATE_H
+
+#include <va/va.h>
+#include <va/va_backend.h>
+#include <pipe/p_format.h>
+#include <pipe/p_state.h>
+
+#define VA_DEBUG(_str,...) debug_printf("[Gallium VA backend]: " _str,__VA_ARGS__)
+#define VA_INFO(_str,...) VA_DEBUG("INFO: " _str,__VA_ARGS__)
+#define VA_WARNING(_str,...) VA_DEBUG("WARNING: " _str,__VA_ARGS__)
+#define VA_ERROR(_str,...) VA_DEBUG("ERROR: " _str,__VA_ARGS__)
+
+#define VA_MAX_IMAGE_FORMATS_SUPPORTED 2
+#define VA_MAX_SUBPIC_FORMATS_SUPPORTED 2
+#define VA_MAX_ENTRYPOINTS 1
+
+#define VL_HANDLES
+
+typedef unsigned int vlHandle;
+
+typedef struct {
+ struct vl_screen *vscreen;
+ struct pipe_surface *backbuffer;
+} vlVaDriverContextPriv;
+
+typedef struct {
+ unsigned int width;
+ unsigned int height;
+ enum pipe_video_chroma_format format;
+ VADriverContextP ctx;
+} vlVaSurfacePriv;
+
+// Public functions:
+VAStatus __vaDriverInit_0_31 (VADriverContextP ctx);
+
+// Private functions:
+struct VADriverVTable vlVaGetVtable();
+
+
+// Vtable functions:
+VAStatus vlVaTerminate (VADriverContextP ctx);
+VAStatus vlVaQueryConfigProfiles (VADriverContextP ctx, VAProfile *profile_list,int *num_profiles);
+VAStatus vlVaQueryConfigEntrypoints (VADriverContextP ctx, VAProfile profile, VAEntrypoint *entrypoint_list, int *num_entrypoints);
+VAStatus vlVaGetConfigAttributes (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs);
+VAStatus vlVaCreateConfig (VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoint, VAConfigAttrib *attrib_list, int num_attribs, VAConfigID *config_id);
+VAStatus vlVaDestroyConfig (VADriverContextP ctx, VAConfigID config_id);
+VAStatus vlVaQueryConfigAttributes (VADriverContextP ctx, VAConfigID config_id, VAProfile *profile, VAEntrypoint *entrypoint, VAConfigAttrib *attrib_list, int *num_attribs);
+VAStatus vlVaCreateSurfaces (VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID *surfaces);
+VAStatus vlVaDestroySurfaces (VADriverContextP ctx, VASurfaceID *surface_list, int num_surfaces);
+VAStatus vlVaCreateContext (VADriverContextP ctx,VAConfigID config_id,int picture_width,int picture_height,int flag,VASurfaceID *render_targets,int num_render_targets,VAContextID *context);
+VAStatus vlVaDestroyContext (VADriverContextP ctx,VAContextID context);
+VAStatus vlVaCreateBuffer (VADriverContextP ctx,VAContextID context,VABufferType type,unsigned int size,unsigned int num_elements,void *data,VABufferID *buf_id);
+VAStatus vlVaBufferSetNumElements (VADriverContextP ctx,VABufferID buf_id,unsigned int num_elements);
+VAStatus vlVaMapBuffer (VADriverContextP ctx,VABufferID buf_id,void **pbuf);
+VAStatus vlVaUnmapBuffer (VADriverContextP ctx,VABufferID buf_id);
+VAStatus vlVaDestroyBuffer (VADriverContextP ctx,VABufferID buffer_id);
+VAStatus vlVaBeginPicture (VADriverContextP ctx,VAContextID context,VASurfaceID render_target);
+VAStatus vlVaRenderPicture (VADriverContextP ctx,VAContextID context,VABufferID *buffers,int num_buffers);
+VAStatus vlVaEndPicture (VADriverContextP ctx,VAContextID context);
+VAStatus vlVaSyncSurface (VADriverContextP ctx,VASurfaceID render_target);
+VAStatus vlVaQuerySurfaceStatus (VADriverContextP ctx,VASurfaceID render_target,VASurfaceStatus *status);
+VAStatus vlVaPutSurface (VADriverContextP ctx,
+ VASurfaceID surface,
+ void* draw,
+ short srcx,
+ short srcy,
+ unsigned short srcw,
+ unsigned short srch,
+ short destx,
+ short desty,
+ unsigned short destw,
+ unsigned short desth,
+ VARectangle *cliprects,
+ unsigned int number_cliprects,
+ unsigned int flags);
+VAStatus vlVaQueryImageFormats (VADriverContextP ctx,VAImageFormat *format_list,int *num_formats);
+VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats);
+VAStatus vlVaCreateImage(VADriverContextP ctx,VAImageFormat *format,int width,int height,VAImage *image);
+VAStatus vlVaDeriveImage(VADriverContextP ctx,VASurfaceID surface,VAImage *image);
+VAStatus vlVaDestroyImage(VADriverContextP ctx,VAImageID image);
+VAStatus vlVaSetImagePalette(VADriverContextP ctx,VAImageID image, unsigned char *palette);
+VAStatus vlVaGetImage(VADriverContextP ctx,VASurfaceID surface,int x,int y,unsigned int width,unsigned int height,VAImageID image);
+VAStatus vlVaPutImage(VADriverContextP ctx,
+ VASurfaceID surface,
+ VAImageID image,
+ int src_x,
+ int src_y,
+ unsigned int src_width,
+ unsigned int src_height,
+ int dest_x,
+ int dest_y,
+ unsigned int dest_width,
+ unsigned int dest_height);
+VAStatus vlVaQuerySubpictureFormats(VADriverContextP ctx,VAImageFormat *format_list,unsigned int *flags,unsigned int *num_formats);
+VAStatus vlVaCreateSubpicture(VADriverContextP ctx,VAImageID image,VASubpictureID *subpicture);
+VAStatus vlVaDestroySubpicture(VADriverContextP ctx,VASubpictureID subpicture);
+VAStatus vlVaSubpictureImage(VADriverContextP ctx,VASubpictureID subpicture,VAImageID image);
+VAStatus vlVaSetSubpictureChromakey(VADriverContextP ctx,VASubpictureID subpicture,unsigned int chromakey_min,unsigned int chromakey_max,unsigned int chromakey_mask);
+VAStatus vlVaSetSubpictureGlobalAlpha(VADriverContextP ctx,VASubpictureID subpicture,float global_alpha);
+VAStatus vlVaAssociateSubpicture(VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
+ short src_x,
+ short src_y,
+ unsigned short src_width,
+ unsigned short src_height,
+ short dest_x,
+ short dest_y,
+ unsigned short dest_width,
+ unsigned short dest_height,
+ unsigned int flags);
+VAStatus vlVaDeassociateSubpicture(VADriverContextP ctx,VASubpictureID subpicture,VASurfaceID *target_surfaces,int num_surfaces);
+VAStatus vlVaQueryDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int *num_attributes);
+VAStatus vlVaGetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes);
+VAStatus vlVaSetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute *attr_list,int num_attributes);
+VAStatus vlVaBufferInfo(VADriverContextP ctx,VAContextID context,VABufferID buf_id,VABufferType *type,unsigned int *size,unsigned int *num_elements);
+VAStatus vlVaLockSurface(VADriverContextP ctx,
+ VASurfaceID surface,
+ unsigned int *fourcc,
+ unsigned int *luma_stride,
+ unsigned int *chroma_u_stride,
+ unsigned int *chroma_v_stride,
+ unsigned int *luma_offset,
+ unsigned int *chroma_u_offset,
+ unsigned int *chroma_v_offset,
+ unsigned int *buffer_name,
+ void **buffer);
+VAStatus vlVaUnlockSurface(VADriverContextP ctx,VASurfaceID surface);
+
+#endif //VA_PRIVATE_H
diff --git a/src/gallium/state_trackers/va/va_subpicture.c b/src/gallium/state_trackers/va/va_subpicture.c
new file mode 100644
index 00000000000..910e5bd7b70
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_subpicture.c
@@ -0,0 +1,157 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <va/va.h>
+#include <va/va_backend.h>
+#include <pipe/p_format.h>
+#include "va_private.h"
+
+
+typedef struct {
+ enum pipe_format pipe_format;
+ VAImageFormat va_format;
+ unsigned int va_flags;
+} va_subpicture_formats_supported_t;
+
+static const va_subpicture_formats_supported_t va_subpicture_formats_supported[VA_MAX_SUBPIC_FORMATS_SUPPORTED + 1] =
+{
+ { PIPE_FORMAT_B8G8R8A8_UNORM,
+ { VA_FOURCC('B','G','R','A'), VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 },
+ 0 },
+ { PIPE_FORMAT_R8G8B8A8_UNORM,
+ { VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 },
+ 0 }
+};
+
+VAStatus
+vlVaQuerySubpictureFormats( VADriverContextP ctx,
+ VAImageFormat *format_list,
+ unsigned int *flags,
+ unsigned int *num_formats)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ if (!(format_list && flags && num_formats))
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ num_formats[0] = VA_MAX_SUBPIC_FORMATS_SUPPORTED;
+
+ int n = 0;
+ /* Query supported formats */
+ for (n = 0; n < VA_MAX_SUBPIC_FORMATS_SUPPORTED ; n++)
+ {
+ const va_subpicture_formats_supported_t * const format_map = &va_subpicture_formats_supported[n];
+ flags[n] = format_map->va_flags;
+ format_list[n] = format_map->va_format;
+ }
+
+ return VA_STATUS_SUCCESS;
+}
+
+
+VAStatus vlVaCreateSubpicture( VADriverContextP ctx,
+ VAImageID image,
+ VASubpictureID *subpicture)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaDestroySubpicture( VADriverContextP ctx,
+ VASubpictureID subpicture)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaSubpictureImage( VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VAImageID image)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaSetSubpictureChromakey( VADriverContextP ctx,
+ VASubpictureID subpicture,
+ unsigned int chromakey_min,
+ unsigned int chromakey_max,
+ unsigned int chromakey_mask)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaSetSubpictureGlobalAlpha( VADriverContextP ctx,
+ VASubpictureID subpicture,
+ float global_alpha)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaAssociateSubpicture( VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces,
+ short src_x,
+ short src_y,
+ unsigned short src_width,
+ unsigned short src_height,
+ short dest_x,
+ short dest_y,
+ unsigned short dest_width,
+ unsigned short dest_height,
+ unsigned int flags)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaDeassociateSubpicture( VADriverContextP ctx,
+ VASubpictureID subpicture,
+ VASurfaceID *target_surfaces,
+ int num_surfaces)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/va/va_surface.c b/src/gallium/state_trackers/va/va_surface.c
new file mode 100644
index 00000000000..a86c806248a
--- /dev/null
+++ b/src/gallium/state_trackers/va/va_surface.c
@@ -0,0 +1,167 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <va/va.h>
+#include <va/va_backend.h>
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+#include "va_private.h"
+
+boolean vlCreateHTAB(void);
+void vlDestroyHTAB(void);
+vlHandle vlAddDataHTAB(void *data);
+void* vlGetDataHTAB(vlHandle handle);
+
+static enum pipe_video_chroma_format VaRTFormatToPipe(unsigned int va_type)
+{
+ switch (va_type) {
+ case VA_RT_FORMAT_YUV420:
+ return PIPE_VIDEO_CHROMA_FORMAT_420;
+ case VA_RT_FORMAT_YUV422:
+ return PIPE_VIDEO_CHROMA_FORMAT_422;
+ case VA_RT_FORMAT_YUV444:
+ return PIPE_VIDEO_CHROMA_FORMAT_444;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+VAStatus vlVaCreateSurfaces( VADriverContextP ctx,
+ int width,
+ int height,
+ int format,
+ int num_surfaces,
+ VASurfaceID *surfaces)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ /* We only support one format */
+ if (VA_RT_FORMAT_YUV420 != format)
+ return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
+
+ if (!(width && height))
+ return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
+
+ if (!vlCreateHTAB())
+ return VA_STATUS_ERROR_UNKNOWN;
+
+ vlVaSurfacePriv *va_surface = (vlVaSurfacePriv *)CALLOC(num_surfaces,sizeof(vlVaSurfacePriv));
+ if (!va_surface)
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+
+ int n = 0;
+ for (n = 0; n < num_surfaces; n++)
+ {
+ va_surface[n].width = width;
+ va_surface[n].height = height;
+ va_surface[n].format = VaRTFormatToPipe(format);
+ va_surface[n].ctx = ctx;
+ surfaces[n] = (VASurfaceID *)vlAddDataHTAB((void *)(va_surface + n));
+ }
+
+ return VA_STATUS_SUCCESS;
+}
+
+VAStatus vlVaDestroySurfaces( VADriverContextP ctx,
+ VASurfaceID *surface_list,
+ int num_surfaces)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaSyncSurface( VADriverContextP ctx,
+ VASurfaceID render_target)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaQuerySurfaceStatus( VADriverContextP ctx,
+ VASurfaceID render_target,
+ VASurfaceStatus *status)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaPutSurface( VADriverContextP ctx,
+ VASurfaceID surface,
+ void* draw,
+ short srcx,
+ short srcy,
+ unsigned short srcw,
+ unsigned short srch,
+ short destx,
+ short desty,
+ unsigned short destw,
+ unsigned short desth,
+ VARectangle *cliprects,
+ unsigned int number_cliprects,
+ unsigned int flags)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaLockSurface( VADriverContextP ctx,
+ VASurfaceID surface,
+ unsigned int *fourcc,
+ unsigned int *luma_stride,
+ unsigned int *chroma_u_stride,
+ unsigned int *chroma_v_stride,
+ unsigned int *luma_offset,
+ unsigned int *chroma_u_offset,
+ unsigned int *chroma_v_offset,
+ unsigned int *buffer_name,
+ void **buffer)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
+
+VAStatus vlVaUnlockSurface( VADriverContextP ctx,
+ VASurfaceID surface)
+{
+ if (!ctx)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
+ return VA_STATUS_ERROR_UNIMPLEMENTED;
+}
diff --git a/src/gallium/state_trackers/vdpau/Makefile b/src/gallium/state_trackers/vdpau/Makefile
index 346cce9d43b..0e68d4fe007 100644
--- a/src/gallium/state_trackers/vdpau/Makefile
+++ b/src/gallium/state_trackers/vdpau/Makefile
@@ -3,6 +3,10 @@ include $(TOP)/configs/current
LIBNAME = vdpautracker
+VDPAU_MAJOR = 1
+VDPAU_MINOR = 0
+LIBRARY_DEFINES = -DVER_MAJOR=$(VDPAU_MAJOR) -DVER_MINOR=$(VDPAU_MINOR) $(STATE_TRACKER_DEFINES)
+
LIBRARY_INCLUDES = \
$(shell pkg-config --cflags-only-I vdpau) \
-I$(TOP)/src/gallium/winsys/g3dvl
@@ -10,6 +14,16 @@ LIBRARY_INCLUDES = \
C_SOURCES = htab.c \
ftab.c \
device.c \
- query.c
+ query.c \
+ surface.c \
+ decode.c \
+ presentation.c \
+ bitmap.c \
+ mpeg2_bitstream_parser.c \
+ output.c \
+ preemption.c \
+ mixer.c
+
include ../../Makefile.template
+
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
new file mode 100644
index 00000000000..f1a9d9a6828
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -0,0 +1,75 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include <vdpau/vdpau.h>
+#include "vdpau_private.h"
+#include <util/u_debug.h>
+
+VdpStatus
+vlVdpBitmapSurfaceCreate( VdpDevice device,
+ VdpRGBAFormat rgba_format,
+ uint32_t width, uint32_t height,
+ VdpBool frequently_accessed,
+ VdpBitmapSurface *surface)
+{
+ debug_printf("[VDPAU] Creating a bitmap surface\n");
+ if (!surface)
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfaceDestroy ( VdpBitmapSurface surface )
+{
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfaceGetParameters ( VdpBitmapSurface surface,
+ VdpRGBAFormat *rgba_format,
+ uint32_t *width, uint32_t *height,
+ VdpBool *frequently_accessed)
+{
+ if (!(rgba_format && width && height && frequently_accessed))
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpBitmapSurfacePutBitsNative ( VdpBitmapSurface surface,
+ void const *const *source_data,
+ uint32_t const *source_pitches,
+ VdpRect const *destination_rect )
+{
+ if (!(source_data && source_pitches && destination_rect))
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+} \ No newline at end of file
diff --git a/src/gallium/state_trackers/vdpau/color.c b/src/gallium/state_trackers/vdpau/color.c
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/color.c
diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
new file mode 100644
index 00000000000..5d3674c5eb2
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -0,0 +1,309 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vdpau_private.h"
+#include "mpeg2_bitstream_parser.h"
+#include <util/u_memory.h>
+#include <util/u_math.h>
+#include <pipe/p_video_context.h>
+#include <util/u_debug.h>
+
+VdpStatus
+vlVdpDecoderCreate ( VdpDevice device,
+ VdpDecoderProfile profile,
+ uint32_t width, uint32_t height,
+ uint32_t max_references,
+ VdpDecoder *decoder
+)
+{
+ enum pipe_video_profile p_profile = PIPE_VIDEO_PROFILE_UNKNOWN;
+ VdpStatus ret = VDP_STATUS_OK;
+ vlVdpDecoder *vldecoder = NULL;
+
+ debug_printf("[VDPAU] Creating decoder\n");
+
+ if (!decoder)
+ return VDP_STATUS_INVALID_POINTER;
+
+ if (!(width && height))
+ return VDP_STATUS_INVALID_VALUE;
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev) {
+ ret = VDP_STATUS_INVALID_HANDLE;
+ goto inv_device;
+ }
+
+ vldecoder = CALLOC(1,sizeof(vlVdpDecoder));
+ if (!vldecoder) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_decoder;
+ }
+
+ p_profile = ProfileToPipe(profile);
+ if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
+ ret = VDP_STATUS_INVALID_DECODER_PROFILE;
+ goto inv_profile;
+ }
+
+ // TODO: Define max_references. Used mainly for H264
+
+ vldecoder->profile = p_profile;
+ vldecoder->height = height;
+ vldecoder->width = width;
+ vldecoder->device = dev;
+ vldecoder->vctx = NULL;
+
+ *decoder = vlAddDataHTAB(vldecoder);
+ if (*decoder == 0) {
+ ret = VDP_STATUS_ERROR;
+ goto no_handle;
+ }
+ debug_printf("[VDPAU] Decoder created succesfully\n");
+
+ return VDP_STATUS_OK;
+
+ no_handle:
+ FREE(vldecoder);
+ inv_profile:
+ no_screen:
+ no_decoder:
+ inv_device:
+ return ret;
+}
+
+VdpStatus
+vlVdpDecoderDestroy (VdpDecoder decoder
+)
+{
+ debug_printf("[VDPAU] Destroying decoder\n");
+ vlVdpDecoder *vldecoder;
+
+ vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
+ if (!vldecoder) {
+ return VDP_STATUS_INVALID_HANDLE;
+ }
+
+ if (vldecoder->vctx)
+ {
+ if (vldecoder->vctx->vscreen)
+ vl_screen_destroy(vldecoder->vctx->vscreen);
+ }
+
+ if (vldecoder->vctx)
+ vl_video_destroy(vldecoder->vctx);
+
+ FREE(vldecoder);
+
+ return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpCreateSurfaceTarget (vlVdpDecoder *vldecoder,
+ vlVdpSurface *vlsurf
+)
+{
+ struct pipe_resource tmplt;
+ struct pipe_resource *surf_tex;
+ struct pipe_video_context *vctx;
+
+ debug_printf("[VDPAU] Creating surface\n");
+
+ if(!(vldecoder && vlsurf))
+ return VDP_STATUS_INVALID_POINTER;
+
+ vctx = vldecoder->vctx->vpipe;
+
+ memset(&tmplt, 0, sizeof(struct pipe_resource));
+ tmplt.target = PIPE_TEXTURE_2D;
+ tmplt.format = vctx->get_param(vctx,PIPE_CAP_DECODE_TARGET_PREFERRED_FORMAT);
+ tmplt.last_level = 0;
+
+ if (vctx->is_format_supported(vctx, tmplt.format,
+ PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET,
+ PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO)) {
+ tmplt.width0 = vlsurf->width;
+ tmplt.height0 = vlsurf->height;
+ }
+ else {
+ assert(vctx->is_format_supported(vctx, tmplt.format,
+ PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET,
+ PIPE_TEXTURE_GEOM_NON_SQUARE));
+ tmplt.width0 = util_next_power_of_two(vlsurf->width);
+ tmplt.height0 = util_next_power_of_two(vlsurf->height);
+ }
+
+ tmplt.depth0 = 1;
+ tmplt.usage = PIPE_USAGE_DEFAULT;
+ tmplt.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+ tmplt.flags = 0;
+
+ surf_tex = vctx->screen->resource_create(vctx->screen, &tmplt);
+
+ vlsurf->psurface = vctx->screen->get_tex_surface(vctx->screen, surf_tex, 0, 0, 0,
+ PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET);
+
+ pipe_resource_reference(&surf_tex, NULL);
+
+ if (!vlsurf->psurface)
+ return VDP_STATUS_RESOURCES;
+ debug_printf("[VDPAU] Done creating surface\n");
+
+ return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpDecoderRenderMpeg2 (vlVdpDecoder *vldecoder,
+ vlVdpSurface *vlsurf,
+ VdpPictureInfoMPEG1Or2 *picture_info,
+ uint32_t bitstream_buffer_count,
+ VdpBitstreamBuffer const *bitstream_buffers
+ )
+{
+ struct pipe_video_context *vpipe;
+ vlVdpSurface *t_vdp_surf;
+ vlVdpSurface *p_vdp_surf;
+ vlVdpSurface *f_vdp_surf;
+ struct pipe_surface *t_surf;
+ struct pipe_surface *p_surf;
+ struct pipe_surface *f_surf;
+ uint32_t num_macroblocks;
+ struct pipe_mpeg12_macroblock *pipe_macroblocks;
+ VdpStatus ret;
+
+ debug_printf("[VDPAU] Decoding MPEG2\n");
+
+ t_vdp_surf = vlsurf;
+
+ /* if surfaces equals VDP_STATUS_INVALID_HANDLE, they are not used */
+ if (picture_info->backward_reference == VDP_INVALID_HANDLE)
+ p_vdp_surf = NULL;
+ else {
+ p_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->backward_reference);
+ if (!p_vdp_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+ }
+
+ if (picture_info->forward_reference == VDP_INVALID_HANDLE)
+ f_vdp_surf = NULL;
+ else {
+ f_vdp_surf = (vlVdpSurface *)vlGetDataHTAB(picture_info->forward_reference);
+ if (!f_vdp_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+ }
+
+
+ if (f_vdp_surf == VDP_INVALID_HANDLE) f_vdp_surf = NULL;
+
+ ret = vlVdpCreateSurfaceTarget(vldecoder,t_vdp_surf);
+
+ vpipe = vldecoder->vctx->vpipe;
+
+ if (vlVdpMPEG2BitstreamToMacroblock(vpipe->screen, bitstream_buffers, bitstream_buffer_count,
+ &num_macroblocks, &pipe_macroblocks))
+ {
+ debug_printf("[VDPAU] Error in frame-header. Skipping.\n");
+
+ ret = VDP_STATUS_OK;
+ goto skip_frame;
+ }
+
+ vpipe->set_decode_target(vpipe,t_surf);
+ vpipe->decode_macroblocks(vpipe, p_surf, f_surf, num_macroblocks, (struct pipe_macroblock *)pipe_macroblocks, NULL);
+
+ skip_frame:
+ return ret;
+}
+
+VdpStatus
+vlVdpDecoderRender (VdpDecoder decoder,
+ VdpVideoSurface target,
+ VdpPictureInfo const *picture_info,
+ uint32_t bitstream_buffer_count,
+ VdpBitstreamBuffer const *bitstream_buffers
+)
+{
+ vlVdpDecoder *vldecoder;
+ vlVdpSurface *vlsurf;
+ struct vl_screen *vscreen;
+ VdpStatus ret;
+ debug_printf("[VDPAU] Decoding\n");
+
+ if (!(picture_info && bitstream_buffers))
+ return VDP_STATUS_INVALID_POINTER;
+
+
+ vldecoder = (vlVdpDecoder *)vlGetDataHTAB(decoder);
+ if (!vldecoder)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlsurf = (vlVdpSurface *)vlGetDataHTAB(target);
+ if (!vlsurf)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (vlsurf->device != vldecoder->device)
+ return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
+
+ /* Test doesn't make sence */
+ /*if (vlsurf->chroma_format != vldecoder->chroma_format)
+ return VDP_STATUS_INVALID_CHROMA_TYPE;*/
+
+ vscreen = vl_screen_create(vldecoder->device->display, vldecoder->device->screen);
+ if (!vscreen)
+ return VDP_STATUS_RESOURCES;
+
+ vldecoder->vctx = vl_video_create(vscreen, vldecoder->profile, vlsurf->chroma_format, vldecoder->width, vldecoder->height);
+ if (!vldecoder->vctx)
+ return VDP_STATUS_RESOURCES;
+
+ // TODO: Right now only mpeg2 is supported.
+ switch (vldecoder->vctx->vpipe->profile) {
+ case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
+ case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
+ ret = vlVdpDecoderRenderMpeg2(vldecoder,vlsurf,(VdpPictureInfoMPEG1Or2 *)picture_info,
+ bitstream_buffer_count,bitstream_buffers);
+ break;
+ default:
+ return VDP_STATUS_INVALID_DECODER_PROFILE;
+ }
+ assert(0);
+
+ return ret;
+}
+
+VdpStatus
+vlVdpGenerateCSCMatrix(
+ VdpProcamp *procamp,
+ VdpColorStandard standard,
+ VdpCSCMatrix *csc_matrix)
+{
+ debug_printf("[VDPAU] Generating CSCMatrix\n");
+ if (!(csc_matrix && procamp))
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_OK;
+} \ No newline at end of file
diff --git a/src/gallium/state_trackers/vdpau/device.c b/src/gallium/state_trackers/vdpau/device.c
index 83fcaff0282..496e2b8def0 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2010 Younes Manton.
+ * Copyright 2010 Younes Manton og Thomas Balling Sørensen.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,19 +25,19 @@
*
**************************************************************************/
-#include <vdpau/vdpau_x11.h>
#include <pipe/p_compiler.h>
+#include <pipe/p_video_context.h>
#include <vl_winsys.h>
#include <util/u_memory.h>
+#include <util/u_debug.h>
#include "vdpau_private.h"
-VdpDeviceCreateX11 vdp_imp_device_create_x11;
PUBLIC VdpStatus
vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGetProcAddress **get_proc_address)
{
VdpStatus ret;
- vlVdpDevice *dev;
+ vlVdpDevice *dev = NULL;
if (!(display && device && get_proc_address))
return VDP_STATUS_INVALID_POINTER;
@@ -53,17 +53,29 @@ vdp_imp_device_create_x11(Display *display, int screen, VdpDevice *device, VdpGe
goto no_dev;
}
+ dev->display = display;
+ dev->screen = screen;
+ dev->vscreen = vl_screen_create(display, screen);
+ if (!dev->vscreen)
+ {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_vscreen;
+ }
+
*device = vlAddDataHTAB(dev);
if (*device == 0) {
ret = VDP_STATUS_ERROR;
goto no_handle;
}
-
+
*get_proc_address = &vlVdpGetProcAddress;
+ debug_printf("[VDPAU] Device created succesfully\n");
return VDP_STATUS_OK;
no_handle:
+ /* Destroy vscreen */
+no_vscreen:
FREE(dev);
no_dev:
vlDestroyHTAB();
@@ -71,18 +83,59 @@ no_htab:
return ret;
}
-VdpStatus vlVdpDeviceDestroy(VdpDevice device)
+PUBLIC VdpStatus
+vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,VdpPresentationQueueTarget *target)
+{
+ VdpStatus ret;
+ vlVdpPresentationQueueTarget *pqt = NULL;
+
+ debug_printf("[VDPAU] Creating PresentationQueueTarget\n");
+
+ if (!drawable)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ pqt = CALLOC(1, sizeof(vlVdpPresentationQueue));
+ if (!pqt)
+ return VDP_STATUS_RESOURCES;
+
+ pqt->device = dev;
+ pqt->drawable = drawable;
+
+ *target = vlAddDataHTAB(pqt);
+ if (*target == 0) {
+ ret = VDP_STATUS_ERROR;
+ goto no_handle;
+ }
+
+
+ return VDP_STATUS_OK;
+ no_handle:
+ FREE(dev);
+ return ret;
+}
+
+VdpStatus
+vlVdpDeviceDestroy(VdpDevice device)
{
+ debug_printf("[VDPAU] Destroying destroy\n");
+
vlVdpDevice *dev = vlGetDataHTAB(device);
if (!dev)
return VDP_STATUS_INVALID_HANDLE;
FREE(dev);
vlDestroyHTAB();
+ debug_printf("[VDPAU] Device destroyed succesfully\n");
+
return VDP_STATUS_OK;
}
-VdpStatus vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer)
+VdpStatus
+vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **function_pointer)
{
vlVdpDevice *dev = vlGetDataHTAB(device);
if (!dev)
@@ -96,3 +149,50 @@ VdpStatus vlVdpGetProcAddress(VdpDevice device, VdpFuncId function_id, void **fu
return VDP_STATUS_OK;
}
+
+#define _ERROR_TYPE(TYPE,STRING) \
+ case TYPE: \
+ return STRING; \
+ break
+
+char const *
+vlVdpGetErrorString (
+VdpStatus status)
+{
+ switch (status)
+ {
+ _ERROR_TYPE(VDP_STATUS_OK,"The operation completed successfully; no error.");
+ _ERROR_TYPE(VDP_STATUS_NO_IMPLEMENTATION,"No backend implementation could be loaded.");
+ _ERROR_TYPE(VDP_STATUS_DISPLAY_PREEMPTED,"The display was preempted, or a fatal error occurred. The application must re-initialize VDPAU.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_HANDLE,"An invalid handle value was provided. Either the handle does not exist at all, or refers to an object of an incorrect type.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_POINTER ,"An invalid pointer was provided. Typically, this means that a NULL pointer was provided for an 'output' parameter.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_CHROMA_TYPE ,"An invalid/unsupported VdpChromaType value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_Y_CB_CR_FORMAT,"An invalid/unsupported VdpYCbCrFormat value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_RGBA_FORMAT,"An invalid/unsupported VdpRGBAFormat value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_INDEXED_FORMAT,"An invalid/unsupported VdpIndexedFormat value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_STANDARD,"An invalid/unsupported VdpColorStandard value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_COLOR_TABLE_FORMAT,"An invalid/unsupported VdpColorTableFormat value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_FACTOR,"An invalid/unsupported VdpOutputSurfaceRenderBlendFactor value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_BLEND_EQUATION,"An invalid/unsupported VdpOutputSurfaceRenderBlendEquation value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_FLAG,"An invalid/unsupported flag value/combination was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_DECODER_PROFILE,"An invalid/unsupported VdpDecoderProfile value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_FEATURE,"An invalid/unsupported VdpVideoMixerFeature value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PARAMETER ,"An invalid/unsupported VdpVideoMixerParameter value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_ATTRIBUTE,"An invalid/unsupported VdpVideoMixerAttribute value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_VIDEO_MIXER_PICTURE_STRUCTURE,"An invalid/unsupported VdpVideoMixerPictureStructure value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_FUNC_ID,"An invalid/unsupported VdpFuncId value was supplied.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_SIZE,"The size of a supplied object does not match the object it is being used with.\
+ For example, a VdpVideoMixer is configured to process VdpVideoSurface objects of a specific size.\
+ If presented with a VdpVideoSurface of a different size, this error will be raised.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_VALUE,"An invalid/unsupported value was supplied.\
+ This is a catch-all error code for values of type other than those with a specific error code.");
+ _ERROR_TYPE(VDP_STATUS_INVALID_STRUCT_VERSION,"An invalid/unsupported structure version was specified in a versioned structure. \
+ This implies that the implementation is older than the header file the application was built against.");
+ _ERROR_TYPE(VDP_STATUS_RESOURCES,"The system does not have enough resources to complete the requested operation at this time.");
+ _ERROR_TYPE(VDP_STATUS_HANDLE_DEVICE_MISMATCH,"The set of handles supplied are not all related to the same VdpDevice.When performing operations \
+ that operate on multiple surfaces, such as VdpOutputSurfaceRenderOutputSurface or VdpVideoMixerRender, \
+ all supplied surfaces must have been created within the context of the same VdpDevice object. \
+ This error is raised if they were not.");
+ _ERROR_TYPE(VDP_STATUS_ERROR,"A catch-all error, used when no other error code applies.");
+ }
+}
diff --git a/src/gallium/state_trackers/vdpau/ftab.c b/src/gallium/state_trackers/vdpau/ftab.c
index a8a29857df7..de08b810268 100644
--- a/src/gallium/state_trackers/vdpau/ftab.c
+++ b/src/gallium/state_trackers/vdpau/ftab.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2010 Younes Manton.
+ * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -30,78 +30,78 @@
static void* ftab[67] =
{
- 0, /* VDP_FUNC_ID_GET_ERROR_STRING */
- 0, /* VDP_FUNC_ID_GET_PROC_ADDRESS */
+ &vlVdpGetErrorString, /* VDP_FUNC_ID_GET_ERROR_STRING */
+ &vlVdpGetProcAddress, /* VDP_FUNC_ID_GET_PROC_ADDRESS */
&vlVdpGetApiVersion, /* VDP_FUNC_ID_GET_API_VERSION */
- 0,
+ 0x55, /* DUMMY */
&vlVdpGetInformationString, /* VDP_FUNC_ID_GET_INFORMATION_STRING */
&vlVdpDeviceDestroy, /* VDP_FUNC_ID_DEVICE_DESTROY */
- 0, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */
+ &vlVdpGenerateCSCMatrix, /* VDP_FUNC_ID_GENERATE_CSC_MATRIX */
&vlVdpVideoSurfaceQueryCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES */
&vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_VIDEO_SURFACE_QUERY_GET_PUT_BITS_Y_CB_CR_CAPABILITIES */
- 0, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
- 0, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */
- 0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */
- 0, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */
- 0, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */
+ &vlVdpVideoSurfaceCreate, /* VDP_FUNC_ID_VIDEO_SURFACE_CREATE */
+ &vlVdpVideoSurfaceDestroy, /* VDP_FUNC_ID_VIDEO_SURFACE_DESTROY */
+ &vlVdpVideoSurfaceGetParameters, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS */
+ &vlVdpVideoSurfaceGetBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR */
+ &vlVdpVideoSurfacePutBitsYCbCr, /* VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR */
&vlVdpOutputSurfaceQueryCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_CAPABILITIES */
&vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_GET_PUT_BITS_NATIVE_CAPABILITIES */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */
+ 0x2, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_INDEXED_CAPABILITIES */
&vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities, /* VDP_FUNC_ID_OUTPUT_SURFACE_QUERY_PUT_BITS_Y_CB_CR_CAPABILITIES */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */
+ &vlVdpOutputSurfaceCreate, /* VDP_FUNC_ID_OUTPUT_SURFACE_CREATE */
+ 0x3, /* VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY */
+ 0x4, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS */
+ 0x5, /* VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE */
+ 0x6, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE */
+ 0x7, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED */
+ 0x8, /* VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR */
&vlVdpBitmapSurfaceQueryCapabilities, /* VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES */
- 0, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */
- 0, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */
- 0, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */
- 0, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */
- 0,
- 0,
- 0,
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */
- 0, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */
+ &vlVdpBitmapSurfaceCreate, /* VDP_FUNC_ID_BITMAP_SURFACE_CREATE */
+ &vlVdpBitmapSurfaceDestroy, /* VDP_FUNC_ID_BITMAP_SURFACE_DESTROY */
+ &vlVdpBitmapSurfaceGetParameters, /* VDP_FUNC_ID_BITMAP_SURFACE_GET_PARAMETERS */
+ &vlVdpBitmapSurfacePutBitsNative, /* VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE */
+ 0x55, /* DUMMY */
+ 0x55, /* DUMMY */
+ 0x55, /* DUMMY */
+ 0x9, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE */
+ 0x10, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE */
+ 0x11, /* VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_VIDEO_SURFACE_LUMA */
&vlVdpDecoderQueryCapabilities, /* VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES */
- 0, /* VDP_FUNC_ID_DECODER_CREATE */
- 0, /* VDP_FUNC_ID_DECODER_DESTROY */
- 0, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */
- 0, /* VDP_FUNC_ID_DECODER_RENDER */
+ &vlVdpDecoderCreate, /* VDP_FUNC_ID_DECODER_CREATE */
+ &vlVdpDecoderDestroy, /* VDP_FUNC_ID_DECODER_DESTROY */
+ 0x12, /* VDP_FUNC_ID_DECODER_GET_PARAMETERS */
+ &vlVdpDecoderRender, /* VDP_FUNC_ID_DECODER_RENDER */
&vlVdpVideoMixerQueryFeatureSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT */
&vlVdpVideoMixerQueryParameterSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT */
&vlVdpVideoMixerQueryAttributeSupport, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_SUPPORT */
&vlVdpVideoMixerQueryParameterValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_VALUE_RANGE */
&vlVdpVideoMixerQueryAttributeValueRange, /* VDP_FUNC_ID_VIDEO_MIXER_QUERY_ATTRIBUTE_VALUE_RANGE */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */
- 0, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */
- 0,
- 0,
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */
- 0, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */
- 0 /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */
+ &vlVdpVideoMixerCreate, /* VDP_FUNC_ID_VIDEO_MIXER_CREATE */
+ &vlVdpVideoMixerSetFeatureEnables, /* VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES */
+ &vlVdpVideoMixerSetAttributeValues, /* VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES */
+ 0x16, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_SUPPORT */
+ 0x17, /* VDP_FUNC_ID_VIDEO_MIXER_GET_FEATURE_ENABLES */
+ 0x18, /* VDP_FUNC_ID_VIDEO_MIXER_GET_PARAMETER_VALUES */
+ 0x19, /* VDP_FUNC_ID_VIDEO_MIXER_GET_ATTRIBUTE_VALUES */
+ 0x20, /* VDP_FUNC_ID_VIDEO_MIXER_DESTROY */
+ &vlVdpVideoMixerRender, /* VDP_FUNC_ID_VIDEO_MIXER_RENDER */
+ &vlVdpPresentationQueueTargetDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY */
+ &vlVdpPresentationQueueCreate, /* VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE */
+ &vlVdpPresentationQueueDestroy, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY */
+ &vlVdpPresentationQueueSetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR */
+ &vlVdpPresentationQueueGetBackgroundColor, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_BACKGROUND_COLOR */
+ 0x55, /* DUMMY */
+ 0x55, /* DUMMY */
+ &vlVdpPresentationQueueGetTime, /* VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME */
+ &vlVdpPresentationQueueDisplay, /* VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY */
+ &vlVdpPresentationQueueBlockUntilSurfaceIdle, /* VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE */
+ &vlVdpPresentationQueueQuerySurfaceStatus, /* VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS */
+ &vlVdpPreemptionCallbackRegister /* VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER */
};
static void* ftab_winsys[1] =
{
- 0 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
+ &vlVdpPresentationQueueTargetCreateX11 /* VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 */
};
boolean vlGetFuncFTAB(VdpFuncId function_id, void **func)
diff --git a/src/gallium/state_trackers/vdpau/mixer.c b/src/gallium/state_trackers/vdpau/mixer.c
new file mode 100644
index 00000000000..124125ebaad
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/mixer.c
@@ -0,0 +1,140 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ #include <vdpau/vdpau.h>
+ #include <util/u_memory.h>
+ #include <util/u_debug.h>
+ #include "vdpau_private.h"
+
+
+ VdpStatus
+ vlVdpVideoMixerCreate (VdpDevice device,
+ uint32_t feature_count,
+ VdpVideoMixerFeature const *features,
+ uint32_t parameter_count,
+ VdpVideoMixerParameter const *parameters,
+ void const *const *parameter_values,
+ VdpVideoMixer *mixer)
+{
+ VdpStatus ret;
+ vlVdpVideoMixer *vmixer = NULL;
+
+ debug_printf("[VDPAU] Creating VideoMixer\n");
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vmixer = CALLOC(1, sizeof(vlVdpVideoMixer));
+ if (!vmixer)
+ return VDP_STATUS_RESOURCES;
+
+ vmixer->device = dev;
+ /*
+ * TODO: Handle features and parameters
+ * */
+
+ *mixer = vlAddDataHTAB(vmixer);
+ if (*mixer == 0) {
+ ret = VDP_STATUS_ERROR;
+ goto no_handle;
+ }
+
+
+ return VDP_STATUS_OK;
+ no_handle:
+ return ret;
+}
+
+VdpStatus
+vlVdpVideoMixerSetFeatureEnables (
+ VdpVideoMixer mixer,
+ uint32_t feature_count,
+ VdpVideoMixerFeature const *features,
+ VdpBool const *feature_enables)
+{
+ debug_printf("[VDPAU] Setting VideoMixer features\n");
+
+ if (!(features && feature_enables))
+ return VDP_STATUS_INVALID_POINTER;
+
+ vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
+ if (!vmixer)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ /*
+ * TODO: Set features
+ * */
+
+
+ return VDP_STATUS_OK;
+}
+
+VdpStatus vlVdpVideoMixerRender (
+ VdpVideoMixer mixer,
+ VdpOutputSurface background_surface,
+ VdpRect const *background_source_rect,
+ VdpVideoMixerPictureStructure current_picture_structure,
+ uint32_t video_surface_past_count,
+ VdpVideoSurface const *video_surface_past,
+ VdpVideoSurface video_surface_current,
+ uint32_t video_surface_future_count,
+ VdpVideoSurface const *video_surface_future,
+ VdpRect const *video_source_rect,
+ VdpOutputSurface destination_surface,
+ VdpRect const *destination_rect,
+ VdpRect const *destination_video_rect,
+ uint32_t layer_count,
+ VdpLayer const *layers)
+{
+ if (!(background_source_rect && video_surface_past && video_surface_future && video_source_rect && destination_rect && destination_video_rect && layers))
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpVideoMixerSetAttributeValues (
+ VdpVideoMixer mixer,
+ uint32_t attribute_count,
+ VdpVideoMixerAttribute const *attributes,
+ void const *const *attribute_values)
+{
+ if (!(attributes && attribute_values))
+ return VDP_STATUS_INVALID_POINTER;
+
+ vlVdpVideoMixer *vmixer = vlGetDataHTAB(mixer);
+ if (!vmixer)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ /*
+ * TODO: Implement the function
+ *
+ * */
+
+ return VDP_STATUS_OK;
+} \ No newline at end of file
diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c
new file mode 100644
index 00000000000..90936584893
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.c
@@ -0,0 +1,149 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include "mpeg2_bitstream_parser.h"
+
+int
+vlVdpMPEG2NextStartCode(struct vdpMPEG2BitstreamParser *parser)
+{
+ uint32_t integer = 0xffffff00;
+ uint8_t * ptr_read = parser->ptr_bitstream;
+ int8_t * bytes_to_end;
+
+ bytes_to_end = parser->ptr_bitstream_end - parser->ptr_bitstream;
+
+ /* Read byte after byte, until startcode is found */
+ while(integer != 0x00000100)
+ {
+ if (bytes_to_end <= 0)
+ {
+ parser->state = MPEG2_BITSTREAM_DONE;
+ parser->code = 0;
+ return 0;
+ }
+ integer = ( integer | *ptr_read++ ) << 8;
+ bytes_to_end--;
+ }
+ parser->ptr_bitstream = ptr_read;
+ parser->code = parser->ptr_bitstream;
+ /* start_code found. rewind cursor a byte */
+ //parser->cursor -= 8;
+
+ return 0;
+}
+
+int
+vlVdpMPEG2BitstreamToMacroblock (
+ struct pipe_screen *screen,
+ VdpBitstreamBuffer const *bitstream_buffers,
+ uint32_t bitstream_buffer_count,
+ unsigned int *num_macroblocks,
+ struct pipe_mpeg12_macroblock **pipe_macroblocks)
+{
+ bool b_header_done = false;
+ struct vdpMPEG2BitstreamParser parser;
+
+ #if(1)
+ FILE *fp;
+
+ if ((fp = fopen("binout", "w"))==NULL) {
+ printf("Cannot open file.\n");
+ exit(1);
+ }
+ fwrite(bitstream_buffers[0].bitstream, 1, bitstream_buffers[0].bitstream_bytes, fp);
+ fclose(fp);
+
+ #endif
+
+
+ debug_printf("[VDPAU] Starting decoding MPEG2 stream\n");
+
+ num_macroblocks[0] = 0;
+
+ memset(&parser,0,sizeof(parser));
+ parser.state = MPEG2_HEADER_START_CODE;
+ parser.ptr_bitstream = (unsigned char *)bitstream_buffers[0].bitstream;
+ parser.ptr_bitstream_end = parser.ptr_bitstream + bitstream_buffers[0].bitstream_bytes;
+
+ /* Main header parser loop */
+ while(!b_header_done)
+ {
+ switch (parser.state)
+ {
+ case MPEG2_SEEK_HEADER:
+ if (vlVdpMPEG2NextStartCode(&parser))
+ exit(1);
+ break;
+ /* Start_code found */
+ switch (parser.code)
+ {
+ /* sequence_header_code */
+ case 0xB3:
+ debug_printf("[VDPAU][Bitstream parser] Sequence header code found\n");
+
+ /* We dont need to read this, because we already have this information */
+ break;
+ case 0xB5:
+ debug_printf("[VDPAU][Bitstream parser] Extension start code found\n");
+ //exit(1);
+ break;
+
+ case 0xB8:
+ debug_printf("[VDPAU][Bitstream parser] Extension start code found\n");
+ //exit(1);
+ break;
+
+ }
+
+ break;
+ case MPEG2_BITSTREAM_DONE:
+ if (parser.cur_bitstream < bitstream_buffer_count - 1)
+ {
+ debug_printf("[VDPAU][Bitstream parser] Done parsing current bitstream. Moving to the next\n");
+ parser.cur_bitstream++;
+ parser.ptr_bitstream = (unsigned char *)bitstream_buffers[parser.cur_bitstream].bitstream;
+ parser.ptr_bitstream_end = parser.ptr_bitstream + bitstream_buffers[parser.cur_bitstream].bitstream_bytes;
+ parser.state = MPEG2_HEADER_START_CODE;
+ }
+ else
+ {
+ debug_printf("[VDPAU][Bitstream parser] Done with frame\n");
+ exit(0);
+ // return 0;
+ }
+ break;
+
+ }
+
+
+ }
+
+
+ return 0;
+}
+
diff --git a/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h
new file mode 100644
index 00000000000..25f3516f821
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/mpeg2_bitstream_parser.h
@@ -0,0 +1,65 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef MPEG2_BITSTREAM_PARSER_H
+#define MPEG2_BITSTREAM_PARSER_H
+
+#include <vdpau/vdpau.h>
+#include <pipe/p_video_state.h>
+#include "vdpau_private.h"
+
+enum vdpMPEG2States
+{
+ MPEG2_SEEK_HEADER,
+ MPEG2_HEADER_DONE,
+ MPEG2_BITSTREAM_DONE,
+ MPEG2_HEADER_START_CODE
+};
+
+
+struct vdpMPEG2BitstreamParser
+{
+ enum vdpMPEG2States state;
+ uint32_t cur_bitstream;
+ const uint8_t *ptr_bitstream_end;
+ const uint8_t *ptr_bitstream;
+ uint8_t code;
+
+ /* The decoded bitstream goes here: */
+ /* Sequence_header_info */
+ uint32_t horizontal_size_value;
+};
+
+int
+vlVdpMPEG2BitstreamToMacroblock(struct pipe_screen *screen,
+ VdpBitstreamBuffer const *bitstream_buffers,
+ uint32_t bitstream_buffer_count,
+ unsigned int *num_macroblocks,
+ struct pipe_mpeg12_macroblock **pipe_macroblocks);
+
+
+#endif // MPEG2_BITSTREAM_PARSER_H
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
new file mode 100644
index 00000000000..20097eaf98c
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -0,0 +1,64 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vdpau_private.h"
+#include <vdpau/vdpau.h>
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+
+VdpStatus
+vlVdpOutputSurfaceCreate ( VdpDevice device,
+ VdpRGBAFormat rgba_format,
+ uint32_t width, uint32_t height,
+ VdpOutputSurface *surface)
+{
+ vlVdpOutputSurface *vlsurface = NULL;
+
+ debug_printf("[VDPAU] Creating output surface\n");
+ if (!(width && height))
+ return VDP_STATUS_INVALID_SIZE;
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlsurface = CALLOC(1, sizeof(vlVdpOutputSurface));
+ if (!vlsurface)
+ return VDP_STATUS_RESOURCES;
+
+ vlsurface->width = width;
+ vlsurface->height = height;
+ vlsurface->format = FormatRGBAToPipe(rgba_format);
+
+ *surface = vlAddDataHTAB(vlsurface);
+ if (*surface == 0) {
+ FREE(dev);
+ return VDP_STATUS_ERROR;
+ }
+
+ return VDP_STATUS_OK;
+} \ No newline at end of file
diff --git a/src/gallium/state_trackers/vdpau/preemption.c b/src/gallium/state_trackers/vdpau/preemption.c
new file mode 100644
index 00000000000..4572bdcfe6d
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/preemption.c
@@ -0,0 +1,39 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ #include <vdpau/vdpau.h>
+
+ void vlVdpPreemptionCallback (VdpDevice device, void *context)
+ {
+ /* TODO: Implement preemption */
+ }
+
+ VdpStatus vlVdpPreemptionCallbackRegister (VdpDevice device, VdpPreemptionCallback callback, void *context)
+ {
+
+ return VDP_STATUS_OK;
+ } \ No newline at end of file
diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c
new file mode 100644
index 00000000000..5f545d0bb27
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -0,0 +1,149 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vdpau_private.h"
+#include <vdpau/vdpau.h>
+#include <util/u_debug.h>
+#include <util/u_memory.h>
+
+VdpStatus
+vlVdpPresentationQueueTargetDestroy (VdpPresentationQueueTarget presentation_queue_target)
+{
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueCreate ( VdpDevice device,
+ VdpPresentationQueueTarget presentation_queue_target,
+ VdpPresentationQueue *presentation_queue)
+{
+ debug_printf("[VDPAU] Creating PresentationQueue\n");
+ VdpStatus ret;
+ vlVdpPresentationQueue *pq = NULL;
+
+ if (!presentation_queue)
+ return VDP_STATUS_INVALID_POINTER;
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlVdpPresentationQueueTarget *pqt = vlGetDataHTAB(presentation_queue_target);
+ if (!pqt)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (dev != pqt->device)
+ return VDP_STATUS_HANDLE_DEVICE_MISMATCH;
+
+ pq = CALLOC(1, sizeof(vlVdpPresentationQueue));
+ if (!pq)
+ return VDP_STATUS_RESOURCES;
+
+ *presentation_queue = vlAddDataHTAB(pq);
+ if (*presentation_queue == 0) {
+ ret = VDP_STATUS_ERROR;
+ goto no_handle;
+ }
+
+
+ return VDP_STATUS_OK;
+ no_handle:
+ FREE(pq);
+ return ret;
+}
+
+VdpStatus
+vlVdpPresentationQueueDestroy (VdpPresentationQueue presentation_queue)
+{
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueSetBackgroundColor ( VdpPresentationQueue presentation_queue,
+ VdpColor *const background_color)
+{
+ if (!background_color)
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueGetBackgroundColor ( VdpPresentationQueue presentation_queue,
+ VdpColor *const background_color)
+{
+ if (!background_color)
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueGetTime ( VdpPresentationQueue presentation_queue,
+ VdpTime *current_time)
+{
+ if (!current_time)
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueDisplay ( VdpPresentationQueue presentation_queue,
+ VdpOutputSurface surface,
+ uint32_t clip_width,
+ uint32_t clip_height,
+ VdpTime earliest_presentation_time)
+{
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueBlockUntilSurfaceIdle ( VdpPresentationQueue presentation_queue,
+ VdpOutputSurface surface,
+ VdpTime *first_presentation_time)
+{
+ if (!first_presentation_time)
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+}
+
+VdpStatus
+vlVdpPresentationQueueQuerySurfaceStatus ( VdpPresentationQueue presentation_queue,
+ VdpOutputSurface surface,
+ VdpPresentationQueueStatus *status,
+ VdpTime *first_presentation_time)
+{
+ if (!(status && first_presentation_time))
+ return VDP_STATUS_INVALID_POINTER;
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+} \ No newline at end of file
diff --git a/src/gallium/state_trackers/vdpau/query.c b/src/gallium/state_trackers/vdpau/query.c
index 57bd7fb7526..a3a8500a6f7 100644
--- a/src/gallium/state_trackers/vdpau/query.c
+++ b/src/gallium/state_trackers/vdpau/query.c
@@ -26,6 +26,13 @@
**************************************************************************/
#include "vdpau_private.h"
+#include <vl_winsys.h>
+#include <assert.h>
+#include <pipe/p_screen.h>
+#include <pipe/p_defines.h>
+#include <math.h>
+#include <util/u_debug.h>
+
VdpStatus
vlVdpGetApiVersion(uint32_t *api_version)
@@ -43,7 +50,7 @@ vlVdpGetInformationString(char const **information_string)
if (!information_string)
return VDP_STATUS_INVALID_POINTER;
- *information_string = "VDPAU-G3DVL";
+ *information_string = INFORMATION_STRING;
return VDP_STATUS_OK;
}
@@ -51,10 +58,44 @@ VdpStatus
vlVdpVideoSurfaceQueryCapabilities(VdpDevice device, VdpChromaType surface_chroma_type,
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
{
+ struct vl_screen *vlscreen;
+ uint32_t max_2d_texture_level;
+ VdpStatus ret;
+
+ debug_printf("[VDPAU] Querying video surfaces\n");
+
if (!(is_supported && max_width && max_height))
return VDP_STATUS_INVALID_POINTER;
- return VDP_STATUS_NO_IMPLEMENTATION;
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlscreen = vl_screen_create(dev->display, dev->screen);
+ if (!vlscreen)
+ return VDP_STATUS_RESOURCES;
+
+ /* XXX: Current limits */
+ *is_supported = true;
+ if (surface_chroma_type != VDP_CHROMA_TYPE_420) {
+ *is_supported = false;
+ goto no_sup;
+ }
+
+ max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS );
+ if (!max_2d_texture_level) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_sup;
+ }
+
+ /* I am not quite sure if it is max_2d_texture_level-1 or just max_2d_texture_level */
+ *max_width = *max_height = pow(2,max_2d_texture_level-1);
+
+ vl_screen_destroy(vlscreen);
+
+ return VDP_STATUS_OK;
+ no_sup:
+ return ret;
}
VdpStatus
@@ -62,10 +103,32 @@ vlVdpVideoSurfaceQueryGetPutBitsYCbCrCapabilities(VdpDevice device, VdpChromaTyp
VdpYCbCrFormat bits_ycbcr_format,
VdpBool *is_supported)
{
+ struct vl_screen *vlscreen;
+
+ debug_printf("[VDPAU] Querying get put video surfaces\n");
+
if (!is_supported)
return VDP_STATUS_INVALID_POINTER;
- return VDP_STATUS_NO_IMPLEMENTATION;
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlscreen = vl_screen_create(dev->display, dev->screen);
+ if (!vlscreen)
+ return VDP_STATUS_RESOURCES;
+
+ if (bits_ycbcr_format != VDP_YCBCR_FORMAT_Y8U8V8A8 && bits_ycbcr_format != VDP_YCBCR_FORMAT_V8U8Y8A8)
+ *is_supported = vlscreen->pscreen->is_format_supported(vlscreen->pscreen,
+ FormatToPipe(bits_ycbcr_format),
+ PIPE_TEXTURE_2D,
+ 1,
+ PIPE_BIND_RENDER_TARGET,
+ PIPE_TEXTURE_GEOM_NON_SQUARE );
+
+ vl_screen_destroy(vlscreen);
+
+ return VDP_STATUS_OK;
}
VdpStatus
@@ -73,18 +136,61 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
VdpBool *is_supported, uint32_t *max_level, uint32_t *max_macroblocks,
uint32_t *max_width, uint32_t *max_height)
{
+ enum pipe_video_profile p_profile;
+ uint32_t max_decode_width;
+ uint32_t max_decode_height;
+ uint32_t max_2d_texture_level;
+ struct vl_screen *vlscreen;
+
+ debug_printf("[VDPAU] Querying decoder\n");
+
if (!(is_supported && max_level && max_macroblocks && max_width && max_height))
return VDP_STATUS_INVALID_POINTER;
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ vlscreen = vl_screen_create(dev->display, dev->screen);
+ if (!vlscreen)
+ return VDP_STATUS_RESOURCES;
- return VDP_STATUS_NO_IMPLEMENTATION;
+ p_profile = ProfileToPipe(profile);
+ if (p_profile == PIPE_VIDEO_PROFILE_UNKNOWN) {
+ *is_supported = false;
+ return VDP_STATUS_OK;
+ }
+
+ if (p_profile != PIPE_VIDEO_PROFILE_MPEG2_SIMPLE && p_profile != PIPE_VIDEO_PROFILE_MPEG2_MAIN) {
+ *is_supported = false;
+ return VDP_STATUS_OK;
+ }
+
+ /* XXX hack, need to implement something more sane when the decoders have been implemented */
+ max_2d_texture_level = vlscreen->pscreen->get_param( vlscreen->pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS );
+ max_decode_width = max_decode_height = pow(2,max_2d_texture_level-2);
+ if (!(max_decode_width && max_decode_height))
+ return VDP_STATUS_RESOURCES;
+
+ *is_supported = true;
+ *max_width = max_decode_width;
+ *max_height = max_decode_height;
+ *max_level = 16;
+ *max_macroblocks = (max_decode_width/16) * (max_decode_height/16);
+
+ vl_screen_destroy(vlscreen);
+
+ return VDP_STATUS_OK;
}
VdpStatus
vlVdpOutputSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
-{
+{
if (!(is_supported && max_width && max_height))
return VDP_STATUS_INVALID_POINTER;
+
+ debug_printf("[VDPAU] Querying ouput surfaces\n");
return VDP_STATUS_NO_IMPLEMENTATION;
}
@@ -93,6 +199,8 @@ VdpStatus
vlVdpOutputSurfaceQueryGetPutBitsNativeCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
VdpBool *is_supported)
{
+ debug_printf("[VDPAU] Querying output surfaces get put native cap\n");
+
if (!is_supported)
return VDP_STATUS_INVALID_POINTER;
@@ -104,6 +212,7 @@ vlVdpOutputSurfaceQueryPutBitsYCbCrCapabilities(VdpDevice device, VdpRGBAFormat
VdpYCbCrFormat bits_ycbcr_format,
VdpBool *is_supported)
{
+ debug_printf("[VDPAU] Querying output surfaces put ycrcb cap\n");
if (!is_supported)
return VDP_STATUS_INVALID_POINTER;
@@ -114,6 +223,7 @@ VdpStatus
vlVdpBitmapSurfaceQueryCapabilities(VdpDevice device, VdpRGBAFormat surface_rgba_format,
VdpBool *is_supported, uint32_t *max_width, uint32_t *max_height)
{
+ debug_printf("[VDPAU] Querying bitmap surfaces\n");
if (!(is_supported && max_width && max_height))
return VDP_STATUS_INVALID_POINTER;
@@ -124,6 +234,7 @@ VdpStatus
vlVdpVideoMixerQueryFeatureSupport(VdpDevice device, VdpVideoMixerFeature feature,
VdpBool *is_supported)
{
+ debug_printf("[VDPAU] Querying mixer feature support\n");
if (!is_supported)
return VDP_STATUS_INVALID_POINTER;
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
new file mode 100644
index 00000000000..9b6dac9c3f4
--- /dev/null
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -0,0 +1,193 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Thomas Balling Sørensen.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "vdpau_private.h"
+#include <pipe/p_screen.h>
+#include <pipe/p_state.h>
+#include <util/u_memory.h>
+#include <util/u_format.h>
+
+VdpStatus
+vlVdpVideoSurfaceCreate(VdpDevice device,
+ VdpChromaType chroma_type,
+ uint32_t width,
+ uint32_t height,
+ VdpVideoSurface *surface)
+{
+ printf("[VDPAU] Creating a surface\n");
+
+ vlVdpSurface *p_surf;
+ VdpStatus ret;
+
+ if (!(width && height))
+ {
+ ret = VDP_STATUS_INVALID_SIZE;
+ goto inv_size;
+ }
+
+
+ if (!vlCreateHTAB()) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_htab;
+ }
+
+ p_surf = CALLOC(1, sizeof(p_surf));
+ if (!p_surf) {
+ ret = VDP_STATUS_RESOURCES;
+ goto no_res;
+ }
+
+ vlVdpDevice *dev = vlGetDataHTAB(device);
+ if (!dev) {
+ ret = VDP_STATUS_INVALID_HANDLE;
+ goto inv_device;
+ }
+
+ p_surf->chroma_format = TypeToPipe(chroma_type);
+ p_surf->device = dev;
+ p_surf->width = width;
+ p_surf->height = height;
+
+ *surface = vlAddDataHTAB(p_surf);
+ if (*surface == 0) {
+ ret = VDP_STATUS_ERROR;
+ goto no_handle;
+ }
+
+ return VDP_STATUS_OK;
+
+no_handle:
+ FREE(p_surf->psurface);
+inv_device:
+no_surf:
+ FREE(p_surf);
+no_res:
+ // vlDestroyHTAB(); XXX: Do not destroy this tab, I think.
+no_htab:
+inv_size:
+ return ret;
+}
+
+VdpStatus
+vlVdpVideoSurfaceDestroy ( VdpVideoSurface surface )
+{
+ vlVdpSurface *p_surf;
+
+ p_surf = (vlVdpSurface *)vlGetDataHTAB((vlHandle)surface);
+ if (!p_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (p_surf->psurface) {
+ if (p_surf->psurface->texture) {
+ if (p_surf->psurface->texture->screen)
+ p_surf->psurface->texture->screen->tex_surface_destroy(p_surf->psurface);
+ }
+ }
+ FREE(p_surf);
+ return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfaceGetParameters ( VdpVideoSurface surface,
+ VdpChromaType *chroma_type,
+ uint32_t *width,
+ uint32_t *height
+)
+{
+ if (!(width && height && chroma_type))
+ return VDP_STATUS_INVALID_POINTER;
+
+
+ vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+ if (!p_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+
+
+ if (!(p_surf->chroma_format > 0 && p_surf->chroma_format < 3))
+ return VDP_STATUS_INVALID_CHROMA_TYPE;
+
+ *width = p_surf->width;
+ *height = p_surf->height;
+ *chroma_type = PipeToType(p_surf->chroma_format);
+
+ return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfaceGetBitsYCbCr ( VdpVideoSurface surface,
+ VdpYCbCrFormat destination_ycbcr_format,
+ void *const *destination_data,
+ uint32_t const *destination_pitches
+)
+{
+ if (!vlCreateHTAB())
+ return VDP_STATUS_RESOURCES;
+
+
+ vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+ if (!p_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+
+ if (!p_surf->psurface)
+ return VDP_STATUS_RESOURCES;
+
+
+ return VDP_STATUS_OK;
+}
+
+VdpStatus
+vlVdpVideoSurfacePutBitsYCbCr ( VdpVideoSurface surface,
+ VdpYCbCrFormat source_ycbcr_format,
+ void const *const *source_data,
+ uint32_t const *source_pitches
+)
+{
+ uint32_t size_surface_bytes;
+ const struct util_format_description *format_desc;
+ enum pipe_format pformat = FormatToPipe(source_ycbcr_format);
+
+ if (!vlCreateHTAB())
+ return VDP_STATUS_RESOURCES;
+
+
+ vlVdpSurface *p_surf = vlGetDataHTAB(surface);
+ if (!p_surf)
+ return VDP_STATUS_INVALID_HANDLE;
+
+
+ //size_surface_bytes = ( source_pitches[0] * p_surf->height util_format_get_blockheight(pformat) );
+ /*util_format_translate(enum pipe_format dst_format,
+ void *dst, unsigned dst_stride,
+ unsigned dst_x, unsigned dst_y,
+ enum pipe_format src_format,
+ const void *src, unsigned src_stride,
+ unsigned src_x, unsigned src_y,
+ unsigned width, unsigned height);*/
+
+ return VDP_STATUS_NO_IMPLEMENTATION;
+
+}
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 8f54ae657ce..1deea3a67d3 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2010 Younes Manton.
+ * Copyright 2010 Younes Manton & Thomas Balling Sørensen.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,14 +25,195 @@
*
**************************************************************************/
+#ifndef VDPAU_PRIVATE_H
+#define VDPAU_PRIVATE_H
+
+
#include <vdpau/vdpau.h>
+#include <vdpau/vdpau_x11.h>
#include <pipe/p_compiler.h>
+#include <pipe/p_video_context.h>
+#include <vl_winsys.h>
+#include <assert.h>
+
+#define INFORMATION G3DVL VDPAU Driver Shared Library version VER_MAJOR.VER_MINOR
+#define QUOTEME(x) #x
+#define TOSTRING(x) QUOTEME(x)
+#define INFORMATION_STRING TOSTRING(INFORMATION)
+#define VL_HANDLES
+
+static enum pipe_video_chroma_format TypeToPipe(VdpChromaType vdpau_type)
+{
+ switch (vdpau_type) {
+ case VDP_CHROMA_TYPE_420:
+ return PIPE_VIDEO_CHROMA_FORMAT_420;
+ case VDP_CHROMA_TYPE_422:
+ return PIPE_VIDEO_CHROMA_FORMAT_422;
+ case VDP_CHROMA_TYPE_444:
+ return PIPE_VIDEO_CHROMA_FORMAT_444;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static VdpChromaType PipeToType(enum pipe_video_chroma_format pipe_type)
+{
+ switch (pipe_type) {
+ case PIPE_VIDEO_CHROMA_FORMAT_420:
+ return VDP_CHROMA_TYPE_420;
+ case PIPE_VIDEO_CHROMA_FORMAT_422:
+ return VDP_CHROMA_TYPE_422;
+ case PIPE_VIDEO_CHROMA_FORMAT_444:
+ return VDP_CHROMA_TYPE_444;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+
+static enum pipe_format FormatToPipe(VdpYCbCrFormat vdpau_format)
+{
+ switch (vdpau_format) {
+ case VDP_YCBCR_FORMAT_NV12:
+ return PIPE_FORMAT_NV12;
+ case VDP_YCBCR_FORMAT_YV12:
+ return PIPE_FORMAT_YV12;
+ case VDP_YCBCR_FORMAT_UYVY:
+ return PIPE_FORMAT_UYVY;
+ case VDP_YCBCR_FORMAT_YUYV:
+ return PIPE_FORMAT_YUYV;
+ case VDP_YCBCR_FORMAT_Y8U8V8A8: /* Not defined in p_format.h */
+ return 0;
+ case VDP_YCBCR_FORMAT_V8U8Y8A8:
+ return PIPE_FORMAT_VUYA;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static enum pipe_format FormatRGBAToPipe(VdpRGBAFormat vdpau_format)
+{
+ switch (vdpau_format) {
+ case VDP_RGBA_FORMAT_A8:
+ return PIPE_FORMAT_A8_UNORM;
+ case VDP_RGBA_FORMAT_B10G10R10A2:
+ return PIPE_FORMAT_B10G10R10A2_UNORM;
+ case VDP_RGBA_FORMAT_B8G8R8A8:
+ return PIPE_FORMAT_B8G8R8A8_UNORM;
+ case VDP_RGBA_FORMAT_R10G10B10A2:
+ return PIPE_FORMAT_R10G10B10A2_UNORM;
+ case VDP_RGBA_FORMAT_R8G8B8A8:
+ return PIPE_FORMAT_R8G8B8A8_UNORM;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static VdpYCbCrFormat PipeToFormat(enum pipe_format p_format)
+{
+ switch (p_format) {
+ case PIPE_FORMAT_NV12:
+ return VDP_YCBCR_FORMAT_NV12;
+ case PIPE_FORMAT_YV12:
+ return VDP_YCBCR_FORMAT_YV12;
+ case PIPE_FORMAT_UYVY:
+ return VDP_YCBCR_FORMAT_UYVY;
+ case PIPE_FORMAT_YUYV:
+ return VDP_YCBCR_FORMAT_YUYV;
+ //case PIPE_FORMAT_YUVA:
+ // return VDP_YCBCR_FORMAT_Y8U8V8A8;
+ case PIPE_FORMAT_VUYA:
+ return VDP_YCBCR_FORMAT_V8U8Y8A8;
+ default:
+ assert(0);
+ }
+
+ return -1;
+}
+
+static enum pipe_video_profile ProfileToPipe(VdpDecoderProfile vdpau_profile)
+{
+ switch (vdpau_profile) {
+ case VDP_DECODER_PROFILE_MPEG1:
+ return PIPE_VIDEO_PROFILE_MPEG1;
+ case VDP_DECODER_PROFILE_MPEG2_SIMPLE:
+ return PIPE_VIDEO_PROFILE_MPEG2_SIMPLE;
+ case VDP_DECODER_PROFILE_MPEG2_MAIN:
+ return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
+ case VDP_DECODER_PROFILE_H264_BASELINE:
+ return PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE;
+ case VDP_DECODER_PROFILE_H264_MAIN: /* Not defined in p_format.h */
+ return PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN;
+ case VDP_DECODER_PROFILE_H264_HIGH:
+ return PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH;
+ default:
+ PIPE_VIDEO_PROFILE_UNKNOWN;
+ }
+
+ return -1;
+}
typedef struct
{
- int dummy;
+ Display *display;
+ int screen;
+ struct vl_screen *vscreen;
} vlVdpDevice;
+typedef struct
+{
+ vlVdpDevice *device;
+ Drawable drawable;
+} vlVdpPresentationQueueTarget;
+
+typedef struct
+{
+ vlVdpDevice *device;
+ Drawable drawable;
+} vlVdpPresentationQueue;
+
+typedef struct
+{
+ vlVdpDevice *device;
+} vlVdpVideoMixer;
+
+typedef struct
+{
+ vlVdpDevice *device;
+ uint32_t width;
+ uint32_t height;
+ uint32_t pitch;
+ struct pipe_surface *psurface;
+ enum pipe_video_chroma_format chroma_format;
+ uint8_t *data;
+} vlVdpSurface;
+
+typedef struct
+{
+ vlVdpDevice *device;
+ uint32_t width;
+ uint32_t height;
+ enum pipe_format format;
+} vlVdpOutputSurface;
+
+typedef struct
+{
+ vlVdpDevice *device;
+ struct vl_context *vctx;
+ enum pipe_video_chroma_format chroma_format;
+ enum pipe_video_profile profile;
+ uint32_t width;
+ uint32_t height;
+} vlVdpDecoder;
+
typedef uint32_t vlHandle;
boolean vlCreateHTAB(void);
@@ -41,6 +222,12 @@ vlHandle vlAddDataHTAB(void *data);
void* vlGetDataHTAB(vlHandle handle);
boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
+/* Public functions */
+VdpDeviceCreateX11 vdp_imp_device_create_x11;
+VdpPresentationQueueTargetCreateX11 vlVdpPresentationQueueTargetCreateX11;
+
+/* Internal function pointers */
+VdpGetErrorString vlVdpGetErrorString;
VdpDeviceDestroy vlVdpDeviceDestroy;
VdpGetProcAddress vlVdpGetProcAddress;
VdpGetApiVersion vlVdpGetApiVersion;
@@ -57,3 +244,35 @@ VdpVideoMixerQueryParameterSupport vlVdpVideoMixerQueryParameterSupport;
VdpVideoMixerQueryParameterValueRange vlVdpVideoMixerQueryParameterValueRange;
VdpVideoMixerQueryAttributeSupport vlVdpVideoMixerQueryAttributeSupport;
VdpVideoMixerQueryAttributeValueRange vlVdpVideoMixerQueryAttributeValueRange;
+VdpVideoSurfaceCreate vlVdpVideoSurfaceCreate;
+VdpVideoSurfaceDestroy vlVdpVideoSurfaceDestroy;
+VdpVideoSurfaceGetParameters vlVdpVideoSurfaceGetParameters;
+VdpVideoSurfaceGetBitsYCbCr vlVdpVideoSurfaceGetBitsYCbCr;
+VdpVideoSurfacePutBitsYCbCr vlVdpVideoSurfacePutBitsYCbCr;
+VdpDecoderCreate vlVdpDecoderCreate;
+VdpDecoderDestroy vlVdpDecoderDestroy;
+VdpDecoderRender vlVdpDecoderRender;
+VdpOutputSurfaceCreate vlVdpOutputSurfaceCreate;
+VdpBitmapSurfaceCreate vlVdpBitmapSurfaceCreate;
+VdpBitmapSurfaceDestroy vlVdpBitmapSurfaceDestroy;
+VdpBitmapSurfaceGetParameters vlVdpBitmapSurfaceGetParameters;
+VdpBitmapSurfacePutBitsNative vlVdpBitmapSurfacePutBitsNative;
+VdpPresentationQueueTargetDestroy vlVdpPresentationQueueTargetDestroy;
+VdpPresentationQueueCreate vlVdpPresentationQueueCreate;
+VdpPresentationQueueDestroy vlVdpPresentationQueueDestroy;
+VdpPresentationQueueSetBackgroundColor vlVdpPresentationQueueSetBackgroundColor;
+VdpPresentationQueueGetBackgroundColor vlVdpPresentationQueueGetBackgroundColor;
+VdpPresentationQueueGetTime vlVdpPresentationQueueGetTime;
+VdpPresentationQueueDisplay vlVdpPresentationQueueDisplay;
+VdpPresentationQueueBlockUntilSurfaceIdle vlVdpPresentationQueueBlockUntilSurfaceIdle;
+VdpPresentationQueueQuerySurfaceStatus vlVdpPresentationQueueQuerySurfaceStatus;
+VdpPreemptionCallback vlVdpPreemptionCallback;
+VdpPreemptionCallbackRegister vlVdpPreemptionCallbackRegister;
+VdpVideoMixerSetFeatureEnables vlVdpVideoMixerSetFeatureEnables;
+VdpVideoMixerCreate vlVdpVideoMixerCreate;
+VdpVideoMixerRender vlVdpVideoMixerRender;
+VdpVideoMixerSetAttributeValues vlVdpVideoMixerSetAttributeValues;
+VdpGenerateCSCMatrix vlVdpGenerateCSCMatrix;
+
+
+#endif // VDPAU_PRIVATE_H
diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c
index 1c70d1deb66..4a835c04d8a 100644
--- a/src/gallium/state_trackers/xorg/xvmc/subpicture.c
+++ b/src/gallium/state_trackers/xorg/xvmc/subpicture.c
@@ -215,18 +215,27 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh
{
XvMCSubpicturePrivate *subpicture_priv;
XvMCContextPrivate *context_priv;
+ unsigned int tmp_color;
+ float color_f[4];
assert(dpy);
if (!subpicture)
return XvMCBadSubpicture;
+
+ /* Convert color to float */
+ util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM,
+ color_f, 1,
+ &color, 4,
+ 0, 0, 1, 1);
subpicture_priv = subpicture->privData;
context_priv = subpicture_priv->context->privData;
/* TODO: Assert clear rect is within bounds? Or clip? */
- context_priv->vctx->vpipe->surface_fill(context_priv->vctx->vpipe,
+ context_priv->vctx->vpipe->clear_render_target(context_priv->vctx->vpipe,
subpicture_priv->sfc, x, y,
- width, height, color);
+ color_f,
+ width, height);
return Success;
}