Commit 1d44071b authored by Waldo Bastian's avatar Waldo Bastian

rev 0.29 (02/07/2007 Jonathan Bian) - VC1 parameter fixes,

                                      added VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED
rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture
                                      to enable scaling
rev 0.27 (11/19/2007 Matt Sottek)   - Added DeriveImage
parent 563092b8
......@@ -21,7 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AC_PREREQ(2.57)
AC_INIT([libva], 0.26, [waldo.bastian@intel.com], libva)
AC_INIT([libva], 0.29, [waldo.bastian@intel.com], libva)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
......
......@@ -451,6 +451,18 @@ VAStatus dummy_CreateImage(
return VA_STATUS_SUCCESS;
}
VAStatus dummy_DeriveImage(
VADriverContextP ctx,
VASurfaceID surface,
VAImage *image /* out */
)
{
INIT_DRIVER_DATA
/* TODO */
return VA_STATUS_SUCCESS;
}
VAStatus dummy_DestroyImage(
VADriverContextP ctx,
VAImageID image
......@@ -508,6 +520,26 @@ VAStatus dummy_PutImage(
return VA_STATUS_SUCCESS;
}
VAStatus dummy_PutImage2(
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
)
{
INIT_DRIVER_DATA
/* TODO */
return VA_STATUS_SUCCESS;
}
VAStatus dummy_QuerySubpictureFormats(
VADriverContextP ctx,
VAImageFormat *format_list, /* out */
......@@ -623,6 +655,32 @@ VAStatus dummy_AssociateSubpicture(
return VA_STATUS_SUCCESS;
}
VAStatus dummy_AssociateSubpicture2(
VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
unsigned short src_width,
unsigned short src_height,
short dest_x, /* upper left offset in surface */
short dest_y,
unsigned short dest_width,
unsigned short dest_height,
/*
* whether to enable chroma-keying or global-alpha
* see VA_SUBPICTURE_XXX values
*/
unsigned int flags
)
{
INIT_DRIVER_DATA
/* TODO */
return VA_STATUS_SUCCESS;
}
VAStatus dummy_DeassociateSubpicture(
VADriverContextP ctx,
VASubpictureID subpicture,
......@@ -1141,7 +1199,7 @@ VAStatus dummy_Terminate( VADriverContextP ctx )
return VA_STATUS_SUCCESS;
}
VAStatus __vaDriverInit_0_26( VADriverContextP ctx )
VAStatus __vaDriverInit_0_28( VADriverContextP ctx )
{
object_base_p obj;
int result;
......@@ -1149,7 +1207,7 @@ VAStatus __vaDriverInit_0_26( VADriverContextP ctx )
int i;
ctx->version_major = 0;
ctx->version_minor = 26;
ctx->version_minor = 28;
ctx->max_profiles = DUMMY_MAX_PROFILES;
ctx->max_entrypoints = DUMMY_MAX_ENTRYPOINTS;
ctx->max_attributes = DUMMY_MAX_CONFIG_ATTRIBUTES;
......@@ -1183,10 +1241,12 @@ VAStatus __vaDriverInit_0_26( VADriverContextP ctx )
ctx->vtable.vaPutSurface = dummy_PutSurface;
ctx->vtable.vaQueryImageFormats = dummy_QueryImageFormats;
ctx->vtable.vaCreateImage = dummy_CreateImage;
ctx->vtable.vaDeriveImage = dummy_DeriveImage;
ctx->vtable.vaDestroyImage = dummy_DestroyImage;
ctx->vtable.vaSetImagePalette = dummy_SetImagePalette;
ctx->vtable.vaGetImage = dummy_GetImage;
ctx->vtable.vaPutImage = dummy_PutImage;
ctx->vtable.vaPutImage2 = dummy_PutImage2;
ctx->vtable.vaQuerySubpictureFormats = dummy_QuerySubpictureFormats;
ctx->vtable.vaCreateSubpicture = dummy_CreateSubpicture;
ctx->vtable.vaDestroySubpicture = dummy_DestroySubpicture;
......@@ -1195,6 +1255,7 @@ VAStatus __vaDriverInit_0_26( VADriverContextP ctx )
ctx->vtable.vaSetSubpictureChromakey = dummy_SetSubpictureChromakey;
ctx->vtable.vaSetSubpictureGlobalAlpha = dummy_SetSubpictureGlobalAlpha;
ctx->vtable.vaAssociateSubpicture = dummy_AssociateSubpicture;
ctx->vtable.vaAssociateSubpicture2 = dummy_AssociateSubpicture2;
ctx->vtable.vaDeassociateSubpicture = dummy_DeassociateSubpicture;
ctx->vtable.vaQueryDisplayAttributes = dummy_QueryDisplayAttributes;
ctx->vtable.vaGetDisplayAttributes = dummy_GetDisplayAttributes;
......
......@@ -34,7 +34,7 @@
#define DUMMY_MAX_IMAGE_FORMATS 10
#define DUMMY_MAX_SUBPIC_FORMATS 4
#define DUMMY_MAX_DISPLAY_ATTRIBUTES 4
#define DUMMY_STR_VENDOR "Dummy-dummy-1.0-dummy"
#define DUMMY_STR_VENDOR "Dummy Driver 1.0"
struct dummy_driver_data {
struct object_heap config_heap;
......
......@@ -22,8 +22,8 @@
libva_la_LTLIBRARIES = libva.la
libva_ladir = $(libdir)
libva_la_LDFLAGS = -version-number 0:26:0 -no-undefined
libva_la_LIBADD = -ldl -lX11 -lXext
libva_la_LDFLAGS = -version-number 0:29:0 -no-undefined
libva_la_LIBADD = -ldl -lX11 -lXext -lXfixes -lXdamage
libva_la_SOURCES = va_dri.c va.c va_dristr.h
......
......@@ -35,8 +35,8 @@
#include "va_dri.h"
#define VA_MAJOR_VERSION 0
#define VA_MINOR_VERSION 26
#define DRIVER_INIT_FUNC "__vaDriverInit_0_26"
#define VA_MINOR_VERSION 29
#define DRIVER_INIT_FUNC "__vaDriverInit_0_29"
#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
#define DRIVER_EXTENSION "_drv_video.so"
......@@ -211,7 +211,7 @@ static VAStatus va_getDriverName(VADriverContextP ctx, char **driver_name)
static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
{
VAStatus vaStatus = VA_STATUS_ERROR_UNKNOWN;
char *search_path;
char *search_path = NULL;
char *saveptr;
char *driver_dir;
......@@ -299,10 +299,12 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, PutSurface);
CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
CHECK_VTABLE(vaStatus, ctx, CreateImage);
CHECK_VTABLE(vaStatus, ctx, DeriveImage);
CHECK_VTABLE(vaStatus, ctx, DestroyImage);
CHECK_VTABLE(vaStatus, ctx, SetImagePalette);
CHECK_VTABLE(vaStatus, ctx, GetImage);
CHECK_VTABLE(vaStatus, ctx, PutImage);
CHECK_VTABLE(vaStatus, ctx, PutImage2);
CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
......@@ -311,6 +313,7 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture2);
CHECK_VTABLE(vaStatus, ctx, DeassociateSubpicture);
CHECK_VTABLE(vaStatus, ctx, QueryDisplayAttributes);
CHECK_VTABLE(vaStatus, ctx, GetDisplayAttributes);
......@@ -340,6 +343,18 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
return vaStatus;
}
VAPrivFunc vaGetLibFunc(VADisplay dpy, const char *func)
{
VADriverContextP ctx = CTX(dpy);
if( !vaContextIsValid(ctx) )
return NULL;
if (NULL == ctx->handle)
return NULL;
return (VAPrivFunc) dlsym(ctx->handle, func);
}
/*
* Returns a short english description of error_status
......@@ -350,8 +365,12 @@ const char *vaErrorStr(VAStatus error_status)
{
case VA_STATUS_SUCCESS:
return "success (no error)";
case VA_STATUS_ERROR_OPERATION_FAILED:
return "operation failed";
case VA_STATUS_ERROR_ALLOCATION_FAILED:
return "resource allocation failed";
case VA_STATUS_ERROR_INVALID_DISPLAY:
return "invalid VADisplay";
case VA_STATUS_ERROR_INVALID_CONFIG:
return "invalid VAConfigID";
case VA_STATUS_ERROR_INVALID_CONTEXT:
......@@ -360,6 +379,10 @@ const char *vaErrorStr(VAStatus error_status)
return "invalid VASurfaceID";
case VA_STATUS_ERROR_INVALID_BUFFER:
return "invalid VABufferID";
case VA_STATUS_ERROR_INVALID_IMAGE:
return "invalid VAImageID";
case VA_STATUS_ERROR_INVALID_SUBPICTURE:
return "invalid VASubpictureID";
case VA_STATUS_ERROR_ATTR_NOT_SUPPORTED:
return "attribute not supported";
case VA_STATUS_ERROR_MAX_NUM_EXCEEDED:
......@@ -372,6 +395,14 @@ const char *vaErrorStr(VAStatus error_status)
return "the requested RT Format is not supported";
case VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE:
return "the requested VABufferType is not supported";
case VA_STATUS_ERROR_SURFACE_BUSY:
return "surface is in use";
case VA_STATUS_ERROR_FLAG_NOT_SUPPORTED:
return "flag not supported";
case VA_STATUS_ERROR_INVALID_PARAMETER:
return "invalid parameter";
case VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED:
return "resolution not supported";
case VA_STATUS_ERROR_UNKNOWN:
return "unknown libva error";
}
......@@ -942,6 +973,76 @@ VAStatus vaPutImage (
return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
}
/*
* Similar to vaPutImage but with additional destination width
* and height arguments to enable scaling
*/
VAStatus vaPutImage2 (
VADisplay dpy,
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
)
{
VADriverContextP ctx = CTX(dpy);
CHECK_CONTEXT(ctx);
TRACE(vaPutImage2);
return ctx->vtable.vaPutImage2 ( ctx, surface, image, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height );
}
/*
* Derive an VAImage from an existing surface.
* This interface will derive a VAImage and corresponding image buffer from
* an existing VA Surface. The image buffer can then be mapped/unmapped for
* direct CPU access. This operation is only possible on implementations with
* direct rendering capabilities and internal surface formats that can be
* represented with a VAImage. When the operation is not possible this interface
* will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
* to using vaCreateImage + vaPutImage to accomplish the same task in an
* indirect manner.
*
* Implementations should only return success when the resulting image buffer
* would be useable with vaMap/Unmap.
*
* When directly accessing a surface special care must be taken to insure
* proper synchronization with the graphics hardware. Clients should call
* vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
* rendering or currently being displayed by an overlay.
*
* Additionally nothing about the contents of a surface should be assumed
* following a vaPutSurface. Implementations are free to modify the surface for
* scaling or subpicture blending within a call to vaPutImage.
*
* Calls to vaPutImage or vaGetImage using the same surface from which the image
* has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
* vaGetImage with other surfaces is supported.
*
* An image created with vaDeriveImage should be freed with vaDestroyImage. The
* image and image buffer structures will be destroyed; however, the underlying
* surface will remain unchanged until freed with vaDestroySurfaces.
*/
VAStatus vaDeriveImage (
VADisplay dpy,
VASurfaceID surface,
VAImage *image /* out */
)
{
VADriverContextP ctx = CTX(dpy);
CHECK_CONTEXT(ctx);
TRACE(vaDeriveImage);
return ctx->vtable.vaDeriveImage ( ctx, surface, image );
}
/* Get maximum number of subpicture formats supported by the implementation */
int vaMaxNumSubpictureFormats (
VADisplay dpy
......@@ -1021,7 +1122,7 @@ VAStatus vaSetSubpictureImage (
return ctx->vtable.vaSetSubpictureImage ( ctx, subpicture, image);
}
#warning TODO: Remove vaSetSubpicturePalette in rev 0.29
VAStatus vaSetSubpicturePalette (
VADisplay dpy,
VASubpictureID subpicture,
......@@ -1110,6 +1211,33 @@ VAStatus vaAssociateSubpicture (
return ctx->vtable.vaAssociateSubpicture ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, dest_x, dest_y, width, height, flags );
}
VAStatus vaAssociateSubpicture2 (
VADisplay dpy,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
unsigned short src_width,
unsigned short src_height,
short dest_x, /* upper left offset in surface */
short dest_y,
unsigned short dest_width,
unsigned short dest_height,
/*
* whether to enable chroma-keying or global-alpha
* see VA_SUBPICTURE_XXX values
*/
unsigned int flags
)
{
VADriverContextP ctx = CTX(dpy);
CHECK_CONTEXT(ctx);
TRACE(vaAssociateSubpicture2);
return ctx->vtable.vaAssociateSubpicture2 ( ctx, subpicture, target_surfaces, num_surfaces, src_x, src_y, src_width, src_height, dest_x, dest_y, dest_width, dest_height, flags );
}
/*
* vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
*/
......@@ -1200,7 +1328,7 @@ VAStatus vaSetDisplayAttributes (
}
#warning TODO: Remove vaDbgCopySurfaceToBuffer in rev 0.29
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
VASurfaceID surface,
void **buffer, /* out */
......
......@@ -24,7 +24,7 @@
/*
* Video Decode Acceleration API Specification
*
* Rev. 0.25
* Rev. 0.29
* <jonathan.bian@intel.com>
*
* Revision History:
......@@ -46,6 +46,11 @@
* rev 0.24 (09/18/2007 Jonathan Bian) - Added display attributes.
* rev 0.25 (10/18/2007 Jonathan Bian) - Changed to use IDs only for some types.
* rev 0.26 (11/07/2007 Waldo Bastian) - Change vaCreateBuffer semantics
* rev 0.27 (11/19/2007 Matt Sottek) - Added DeriveImage
* rev 0.28 (12/06/2007 Jonathan Bian) - Added new versions of PutImage and AssociateSubpicture
* to enable scaling
* rev 0.29 (02/07/2007 Jonathan Bian) - VC1 parameter fixes,
* added VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED
*
* Acknowledgements:
* Some concepts borrowed from XvMC and XvImage.
......@@ -108,6 +113,9 @@ typedef int VAStatus; /* Return status type from functions */
#define VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT 0x0000000e
#define VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE 0x0000000f
#define VA_STATUS_ERROR_SURFACE_BUSY 0x00000010
#define VA_STATUS_ERROR_FLAG_NOT_SUPPORTED 0x00000011
#define VA_STATUS_ERROR_INVALID_PARAMETER 0x00000012
#define VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED 0x00000013
#define VA_STATUS_ERROR_UNKNOWN 0xFFFFFFFF
/*
......@@ -147,15 +155,26 @@ VAStatus vaTerminate (
/*
* vaQueryVendorString returns a pointer to a zero-terminated string
* describing some aspects of the VA implemenation on a specific
* hardware accelerator. The format of the returned string is:
* <vendorname>-<major_version>-<minor_version>-<addtional_info>
* hardware accelerator. The format of the returned string is vendor
* specific and at the discretion of the implementer.
* e.g. for the Intel GMA500 implementation, an example would be:
* "IntelGMA500-1.0-0.2-patch3
* "Intel GMA500 - 2.0.0.32L.0005"
*/
const char *vaQueryVendorString (
VADisplay dpy
);
typedef int (*VAPrivFunc)();
/*
* Return a function pointer given a function name in the library.
* This allows private interfaces into the library
*/
VAPrivFunc vaGetLibFunc (
VADisplay dpy,
const char *func
);
/* Currently defined profiles */
typedef enum
{
......@@ -741,7 +760,7 @@ typedef struct _VAPictureParameterBufferVC1
union {
struct {
unsigned char reference_distance_flag : 1;/* PICTURE_LAYER::REFDIST_FLAG */
unsigned char reference_distance : 1;/* PICTURE_LAYER::REFDIST */
unsigned char reference_distance : 5;/* PICTURE_LAYER::REFDIST */
unsigned char num_reference_pictures: 1;/* PICTURE_LAYER::NUMREF */
unsigned char reference_field_pic_indicator : 1;/* PICTURE_LAYER::REFFIELD */
};
......@@ -765,6 +784,7 @@ typedef struct _VAPictureParameterBufferVC1
union {
struct {
unsigned char dquant : 2; /* ENTRY_POINT_LAYER::DQUANT */
unsigned char quantizer : 2; /* ENTRY_POINT_LAYER::QUANTIZER */
unsigned char half_qp : 1; /* PICTURE_LAYER::HALFQP */
unsigned char pic_quantizer_scale : 5;/* PICTURE_LAYER::PQUANT */
unsigned char pic_quantizer_type : 1;/* PICTURE_LAYER::PQUANTIZER */
......@@ -906,9 +926,9 @@ typedef struct _VAIQMatrixBufferH264
typedef struct _VASliceParameterBufferH264
{
unsigned int slice_data_size;/* number of bytes in the slice data buffer for this slice */
unsigned int slice_data_offset;/* the offset to first byte of slice data */
unsigned int slice_data_offset;/* the offset to the NAL start code for this slice */
unsigned int slice_data_flag; /* see VA_SLICE_DATA_FLAG_XXX defintions */
unsigned short slice_data_bit_offset; /* bit offset in the first byte of valid data */
unsigned short slice_data_bit_offset; /* bit offset from NAL start code to the beginning of slice data */
unsigned short first_mb_in_slice;
unsigned char slice_type;
unsigned char direct_spatial_mv_pred_flag;
......@@ -1079,18 +1099,6 @@ VAStatus vaQuerySurfaceStatus (
VASurfaceStatus *status /* out */
);
/*
* Copies the surface to a buffer
* The stride of the surface will be stored in *stride
* Caller should free the returned buffer with free() when done.
*/
VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
VASurfaceID surface,
void **buffer, /* out */
unsigned int *stride /* out */
);
/*
* Images and Subpictures
* VAImage is used to either get the surface data to client memory, or
......@@ -1252,6 +1260,63 @@ VAStatus vaPutImage (
int dest_y
);
/*
* Similar to vaPutImage but with additional destination width
* and height arguments to enable scaling
*/
VAStatus vaPutImage2 (
VADisplay dpy,
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
);
/*
* Derive an VAImage from an existing surface.
* This interface will derive a VAImage and corresponding image buffer from
* an existing VA Surface. The image buffer can then be mapped/unmapped for
* direct CPU access. This operation is only possible on implementations with
* direct rendering capabilities and internal surface formats that can be
* represented with a VAImage. When the operation is not possible this interface
* will return VA_STATUS_ERROR_OPERATION_FAILED. Clients should then fall back
* to using vaCreateImage + vaPutImage to accomplish the same task in an
* indirect manner.
*
* Implementations should only return success when the resulting image buffer
* would be useable with vaMap/Unmap.
*
* When directly accessing a surface special care must be taken to insure
* proper synchronization with the graphics hardware. Clients should call
* vaQuerySurfaceStatus to insure that a surface is not the target of concurrent
* rendering or currently being displayed by an overlay.
*
* Additionally nothing about the contents of a surface should be assumed
* following a vaPutSurface. Implementations are free to modify the surface for
* scaling or subpicture blending within a call to vaPutImage.
*
* Calls to vaPutImage or vaGetImage using the same surface from which the image
* has been derived will return VA_STATUS_ERROR_SURFACE_BUSY. vaPutImage or
* vaGetImage with other surfaces is supported.
*
* An image created with vaDeriveImage should be freed with vaDestroyImage. The
* image and image buffer structures will be destroyed; however, the underlying
* surface will remain unchanged until freed with vaDestroySurfaces.
*/
VAStatus vaDeriveImage (
VADisplay dpy,
VASurfaceID surface,
VAImage *image /* out */
);
/*
* Subpictures
* Subpicture is a special type of image that can be blended
......@@ -1313,17 +1378,6 @@ VAStatus vaSetSubpictureImage (
VAImageID image
);
VAStatus vaSetSubpicturePalette (
VADisplay dpy,
VASubpictureID subpicture,
/*
* pointer to an array holding the palette data. The size of the array is
* num_palette_entries * entry_bytes in size. The order of the components
* in the palette is described by the component_order in VAImage struct
*/
unsigned char *palette
);
/*
* If chromakey is enabled, then the area where the source value falls within
* the chromakey [min, max] range is transparent
......@@ -1377,6 +1431,30 @@ VAStatus vaAssociateSubpicture (
unsigned int flags
);
/*
* Similar to vaAssociateSubpicture but with additional destination width
* and height to enable scaling
*/
VAStatus vaAssociateSubpicture2 (
VADisplay dpy,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
unsigned short src_width,
unsigned short src_height,
short dest_x, /* upper left offset in surface */
short dest_y,
unsigned short dest_width,
unsigned short dest_height,
/*
* whether to enable chroma-keying or global-alpha
* see VA_SUBPICTURE_XXX values
*/
unsigned int flags
);
/*
* vaDeassociateSubpicture removes the association of the subpicture with target_surfaces.
*/
......@@ -1501,8 +1579,8 @@ Mostly to demonstrate program flow with no error handling ...
int max_num_profiles, max_num_entrypoints, max_num_attribs;
max_num_profiles = vaMaxNumProfiles(dpy);
max_num_entrypoints = vaMaxNumProfiles(dpy);
max_num_attribs = vaMaxNumProfiles(dpy);
max_num_entrypoints = vaMaxNumEntrypoints(dpy);
max_num_attribs = vaMaxNumAttributes(dpy);
/* find out whether MPEG2 MP is supported */
VAProfile *profiles = malloc(sizeof(VAProfile)*max_num_profiles);
......
......@@ -209,6 +209,12 @@ struct VADriverVTable
VAImage *image /* out */
);
VAStatus (*vaDeriveImage) (
VADriverContextP ctx,
VASurfaceID surface,
VAImage *image /* out */
);
VAStatus (*vaDestroyImage) (
VADriverContextP ctx,
VAImageID image
......@@ -247,6 +253,20 @@ struct VADriverVTable
int dest_y
);
VAStatus (*vaPutImage2) (
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 (*vaQuerySubpictureFormats) (
VADriverContextP ctx,
VAImageFormat *format_list, /* out */
......@@ -314,6 +334,26 @@ struct VADriverVTable
unsigned int flags
);
VAStatus (*vaAssociateSubpicture2) (
VADriverContextP ctx,
VASubpictureID subpicture,
VASurfaceID *target_surfaces,
int num_surfaces,
short src_x, /* upper left offset in subpicture */
short src_y,
unsigned short src_width,
unsigned short src_height,
short dest_x, /* upper left offset in surface */
short dest_y,
unsigned short dest_width,
unsigned short dest_height,
/*
* whether to enable chroma-keying or global-alpha
* see VA_SUBPICTURE_XXX values
*/
unsigned int flags
);
VAStatus (*vaDeassociateSubpicture) (
VADriverContextP ctx,
VASubpictureID subpicture,
......
......@@ -33,9 +33,9 @@ extern "C" {
*/
/* de-interlace flags for vaPutSurface */
#define VA_FRAME_PICTURE 0x00000000
#define VA_TOP_FIELD 0x00000001
#define VA_BOTTOM_FIELD 0x00000002
#define VA_FRAME_PICTURE 0x00000004 /* weave */
/*
* clears the drawable with background color.
* for hardware overlay based implementation this flag
......
......@@ -21,7 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
check_PROGRAMS = test_01 test_02 test_03 test_04 test_05 test_06 \
test_07 test_08 test_09 test_10 test_11
test_07 test_08 test_09 test_10 test_11 test_12
bin_PROGRAMS = vainfo
......@@ -69,6 +69,9 @@ test_10_SOURCES = test_10.c
test_11_LDADD = $(TEST_LIBS)
test_11_SOURCES = test_11.c
test_12_LDADD = $(TEST_LIBS)
test_12_SOURCES = test_12.c
valgrind: $(check_PROGRAMS)
for a in $(check_PROGRAMS); do \
......
/*
* Copyright (c) 2007 Intel Corporation. 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 PRECISION INSIGHT 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.
*/
#define TEST_DESCRIPTION "Sample MPEG2 VLD Decoding"
#include "test_common.c"
#include <X11/Xlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "va_x11.h"
void pre()
{
test_init();
}
/* Data dump of a 16x16 MPEG2 video clip,it has one I frame
*/
static unsigned char mpeg2_clip[]={
0x00,0x00,0x01,0xb3,0x01,0x00,0x10,0x13,0xff,0xff,0xe0,0x18,0x00,0x00,0x01,0xb5,
0x14,0x8a,0x00,0x01,0x00,0x00,0x00,0x00,0x01,0xb8,0x00,0x08,0x00,0x00,0x00,0x00,
0x01,0x00,0x00,0x0f,0xff,0xf8,0x00,0x00,0x01,0xb5,0x8f,0xff,0xf3,0x41,0x80,0x00,
0x00,0x01,0x01,0x13,0xe1,0x00,0x15,0x81,0x54,0xe0,0x2a,0x05,0x43,0x00,0x2d,0x60,
0x18,0x01,0x4e,0x82,0xb9,0x58,0xb1,0x83,0x49,0xa4,0xa0,0x2e,0x05,0x80,0x4b,0x7a,
0x00,0x01,0x38,0x20,0x80,0xe8,0x05,0xff,0x60,0x18,0xe0,0x1d,0x80,0x98,0x01,0xf8,
0x06,0x00,0x54,0x02,0xc0,0x18,0x14,0x03,0xb2,0x92,0x80,0xc0,0x18,0x94,0x42,0x2c,
0xb2,0x11,0x64,0xa0,0x12,0x5e,0x78,0x03,0x3c,0x01,0x80,0x0e,0x80,0x18,0x80,0x6b,
0xca,0x4e,0x01,0x0f,0xe4,0x32,0xc9,0xbf,0x01,0x42,0x69,0x43,0x50,0x4b,0x01,0xc9,
0x45,0x80,0x50,0x01,0x38,0x65,0xe8,0x01,0x03,0xf3,0xc0,0x76,0x00,0xe0,0x03,0x20,
0x28,0x18,0x01,0xa9,0x34,0x04,0xc5,0xe0,0x0b,0x0b,0x04,0x20,0x06,0xc0,0x89,0xff,
0x60,0x12,0x12,0x8a,0x2c,0x34,0x11,0xff,0xf6,0xe2,0x40,0xc0,0x30,0x1b,0x7a,0x01,
0xa9,0x0d,0x00,0xac,0x64
};
/* hardcoded here without a bitstream parser helper
* please see picture mpeg2-I.jpg for bitstream details
*/
static VAPictureParameterBufferMPEG2 pic_param={
horizontal_size:16,
vertical_size:16,
forward_reference_picture:0xffffffff,
backward_reference_picture:0xffffffff,
picture_coding_type:1,
f_code:0xffff,
{
{
intra_dc_precision:0,
picture_structure:3,
top_field_first:0,
frame_pred_frame_dct:1,
concealment_motion_vectors:0,
q_scale_type:0,
intra_vlc_format:0,
alternate_scan:0,
repeat_first_field:0,
progressive_frame:1 ,
is_first_field:1
},
}
};
/* see MPEG2 spec65 for the defines of matrix */
static VAIQMatrixBufferMPEG2 iq_matrix = {
load_intra_quantiser_matrix:1,
load_non_intra_quantiser_matrix:1,
load_chroma_intra_quantiser_matrix:0,
load_chroma_non_intra_quantiser_matrix:0,
intra_quantiser_matrix:{
8, 16, 16, 19, 16, 19, 22, 22,
22, 22, 22, 22, 26, 24, 26, 27,
27, 27, 26, 26, 26, 26, 27, 27,
27, 29, 29, 29, 34, 34, 34, 29,
29, 29, 27, 27, 29, 29, 32, 32,
34, 34, 37, 38, 37, 35, 35, 34,
35, 38, 38, 40, 40, 40, 48, 48,
46, 46, 56, 56, 58, 69, 69, 83
},
non_intra_quantiser_matrix:{16},
chroma_intra_quantiser_matrix:{0},
chroma_non_intra_quantiser_matrix:{0}
};
static VASliceParameterBufferMPEG2 slice_param={
slice_data_size:150,
slice_data_offset:0,
slice_data_flag:0,
macroblock_offset:38,/* 4byte + 6bits=38bits */
slice_vertical_position:0,
quantiser_scale_code:2,
intra_slice_flag:0
};
#define CLIP_WIDTH 16
#define CLIP_HEIGHT 16
int surf_width=CLIP_WIDTH,surf_height=CLIP_HEIGHT;
int win_width=CLIP_WIDTH<<1,win_height=CLIP_HEIGHT<<1;
void test()
{
VAEntrypoint entrypoints[5];
int num_entrypoints,vld_entrypoint;
VAConfigAttrib attrib;
VAConfigID config_id;
VASurfaceID vaSurface;
VAContextID vaContext;
VABufferID vaPicParamBuf,vaIQMatrixBuf,vaSliceParamBuf,vaSliceDataBuf;
Window win = 0;
va_status = vaQueryConfigEntrypoints(va_dpy, VAProfileMPEG2Main, entrypoints,
&num_entrypoints);
ASSERT( VA_STATUS_SUCCESS == va_status );
for (vld_entrypoint = 0; vld_entrypoint < num_entrypoints; vld_entrypoint++) {
if (entrypoints[vld_entrypoint] == VAEntrypointVLD)
break;
}
if (vld_entrypoint == num_entrypoints) {
/* not find VLD entry point */
ASSERT(0);
}
/* Assuming finding VLD, find out the format for the render target */
attrib.type = VAConfigAttribRTFormat;
va_status = vaGetConfigAttributes(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
&attrib, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
if ((attrib.value & VA_RT_FORMAT_YUV420) == 0) {
/* not find desired YUV420 RT format */
ASSERT(0);
}
va_status = vaCreateConfig(va_dpy, VAProfileMPEG2Main, VAEntrypointVLD,
&attrib, 1,&config_id);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaCreateSurfaces(va_dpy,surf_width,surf_height,
VA_RT_FORMAT_YUV420, 1, &vaSurface);
ASSERT( VA_STATUS_SUCCESS == va_status );
/* Create a context for this decode pipe */
va_status = vaCreateContext(va_dpy, config_id,
CLIP_WIDTH,
((CLIP_HEIGHT+15)/16)*16,
VA_PROGRESSIVE,
&vaSurface,
1,
&vaContext);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaCreateBuffer(va_dpy, vaContext,
VAPictureParameterBufferType,
sizeof(VAPictureParameterBufferMPEG2),
1, &pic_param,
&vaPicParamBuf);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaCreateBuffer(va_dpy, vaContext,
VAIQMatrixBufferType,
sizeof(VAIQMatrixBufferMPEG2),
1, &iq_matrix,
&vaIQMatrixBuf );
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaCreateBuffer(va_dpy, vaContext,
VASliceParameterBufferType,
sizeof(VASliceParameterBufferMPEG2),
1,
&slice_param, &vaSliceParamBuf);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaCreateBuffer(va_dpy, vaContext,
VASliceDataBufferType,
0xc4-0x2f+1,
1,
mpeg2_clip+0x2f,
&vaSliceDataBuf);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaBeginPicture(va_dpy, vaContext, vaSurface);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaPicParamBuf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaIQMatrixBuf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaSliceParamBuf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaRenderPicture(va_dpy,vaContext, &vaSliceDataBuf, 1);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaEndPicture(va_dpy,vaContext);
ASSERT( VA_STATUS_SUCCESS == va_status );
va_status = vaSyncSurface(va_dpy, vaContext, vaSurface);
ASSERT( VA_STATUS_SUCCESS == va_status );
win = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 0, 0,
win_width,win_height, 0, 0, WhitePixel(dpy, 0));
XMapWindow(dpy, win);
XSync(dpy, False);
#if 0
va_status = vaPutSurface(va_dpy, vaSurface, win,
0,0,surf_width,surf_height,
0,0,win_width,win_height,
NULL,0,0);
#endif
ASSERT( VA_STATUS_SUCCESS == va_status );
printf("press any key to exit\n");
getchar();
vaDestroySurfaces(va_dpy,&vaSurface,1);
vaDestroyConfig(va_dpy,config_id);
vaDestroyContext(va_dpy,vaContext);
}
void post()
{
test_terminate();
}
......@@ -28,6 +28,7 @@
#include "assert.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <dlfcn.h>
......
......@@ -28,7 +28,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char* argv[])
{
......@@ -64,8 +64,10 @@ int main(int argc, const char* argv[])
{
fprintf(stderr, "%s: vaInitialize failed with error code %d (%s)\n",
name, va_status, vaErrorStr(va_status));
return 3;
}
printf("%s: VA API version: %d.%d\n", name, major_version, minor_version);
driver = vaQueryVendorString(va_dpy);
printf("%s: Driver version: %s\n", name, driver ? driver : "<unknown>");
vaTerminate(va_dpy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment