• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/libva


Commit MetaInfo

修订版16ab532f97d035000e6c7453068c8585a16d21f9 (tree)
时间2007-09-07 20:29:54
作者root <root@mobi...>
Commiterroot

Log Message

Include sub-picture support (va 0.22)

更改概述

差异

--- a/src/va.c
+++ b/src/va.c
@@ -36,7 +36,7 @@
3636
3737 #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
3838 #define DRIVER_EXTENSION "_drv_video.so"
39-#define DRIVER_INIT_FUNC "__vaDriverInit_0_20"
39+#define DRIVER_INIT_FUNC "__vaDriverInit_0_22"
4040
4141 #define CTX(dpy) ((VADriverContextP) dpy );
4242 #define ASSERT_CONTEXT(dpy) assert( vaDbgContextIsValid(dpy) )
@@ -252,6 +252,8 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
252252 CHECK_MAXIMUM(vaStatus, ctx, profiles);
253253 CHECK_MAXIMUM(vaStatus, ctx, entrypoints);
254254 CHECK_MAXIMUM(vaStatus, ctx, attributes);
255+ CHECK_MAXIMUM(vaStatus, ctx, image_formats);
256+ CHECK_MAXIMUM(vaStatus, ctx, subpic_formats);
255257 CHECK_VTABLE(vaStatus, ctx, Terminate);
256258 CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles);
257259 CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints);
@@ -274,6 +276,18 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name)
274276 CHECK_VTABLE(vaStatus, ctx, SyncSurface);
275277 CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus);
276278 CHECK_VTABLE(vaStatus, ctx, PutSurface);
279+ CHECK_VTABLE(vaStatus, ctx, QueryImageFormats);
280+ CHECK_VTABLE(vaStatus, ctx, CreateImage);
281+ CHECK_VTABLE(vaStatus, ctx, DestroyImage);
282+ CHECK_VTABLE(vaStatus, ctx, GetImage);
283+ CHECK_VTABLE(vaStatus, ctx, PutImage);
284+ CHECK_VTABLE(vaStatus, ctx, QuerySubpictureFormats);
285+ CHECK_VTABLE(vaStatus, ctx, CreateSubpicture);
286+ CHECK_VTABLE(vaStatus, ctx, DestroySubpicture);
287+ CHECK_VTABLE(vaStatus, ctx, SetSubpicturePalette);
288+ CHECK_VTABLE(vaStatus, ctx, SetSubpictureChromakey);
289+ CHECK_VTABLE(vaStatus, ctx, SetSubpictureGlobalAlpha);
290+ CHECK_VTABLE(vaStatus, ctx, AssociateSubpicture);
277291 CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer);
278292 }
279293 if (VA_STATUS_SUCCESS != vaStatus)
@@ -334,7 +348,7 @@ const char *vaErrorStr(VAStatus error_status)
334348 case VA_STATUS_ERROR_UNKNOWN:
335349 return "unknown libva error";
336350 }
337- return "unknwon libva error / description missing";
351+ return "unknown libva error / description missing";
338352 }
339353
340354 VAStatus vaInitialize (
@@ -431,6 +445,7 @@ int vaMaxNumEntrypoints (
431445 return ctx->max_entrypoints;
432446 }
433447
448+
434449 /* Get maximum number of attributs supported by the implementation */
435450 int vaMaxNumConfigAttributes (
436451 VADisplay dpy
@@ -442,7 +457,6 @@ int vaMaxNumConfigAttributes (
442457 return ctx->max_attributes;
443458 }
444459
445-
446460 VAStatus vaQueryConfigEntrypoints (
447461 VADisplay dpy,
448462 VAProfile profile,
@@ -734,6 +748,8 @@ VAStatus vaPutSurface (
734748 short desty,
735749 unsigned short destw,
736750 unsigned short desth,
751+ VARectangle *cliprects, /* client supplied clip list */
752+ unsigned int number_cliprects, /* number of clip rects in the clip list */
737753 int flags /* de-interlacing flags */
738754 )
739755 {
@@ -742,9 +758,266 @@ VAStatus vaPutSurface (
742758
743759 TRACE(vaPutSurface);
744760 return ctx->vtable.vaPutSurface( ctx, surface, draw, srcx, srcy, srcw, srch,
745- destx, desty, destw, desth, flags );
761+ destx, desty, destw, desth,
762+ cliprects, number_cliprects, flags );
763+}
764+
765+/* Get maximum number of image formats supported by the implementation */
766+int vaMaxNumImageFormats (
767+ VADisplay dpy
768+)
769+{
770+ VADriverContextP ctx = CTX(dpy);
771+ ASSERT_CONTEXT(ctx);
772+
773+ return ctx->max_image_formats;
774+}
775+
776+VAStatus vaQueryImageFormats (
777+ VADisplay dpy,
778+ VAImageFormat *format_list, /* out */
779+ int *num_formats /* out */
780+)
781+{
782+ VADriverContextP ctx = CTX(dpy);
783+ ASSERT_CONTEXT(ctx);
784+
785+ TRACE(vaQueryImageFormats);
786+ return ctx->vtable.vaQueryImageFormats ( ctx, format_list, num_formats);
787+}
788+
789+/*
790+ * The width and height fields returned in the VAImage structure may get
791+ * enlarged for some YUV formats. The size of the data buffer that needs
792+ * to be allocated will be given in the "data_size" field in VAImage.
793+ * Image data is not allocated by this function. The client should
794+ * allocate the memory and fill in the VAImage structure's data field
795+ * after looking at "data_size" returned from the library.
796+ */
797+VAStatus vaCreateImage (
798+ VADisplay dpy,
799+ VAImageFormat *format,
800+ int width,
801+ int height,
802+ VAImage *image /* out */
803+)
804+{
805+ VADriverContextP ctx = CTX(dpy);
806+ ASSERT_CONTEXT(ctx);
807+
808+ TRACE(vaCreateImage);
809+ return ctx->vtable.vaCreateImage ( ctx, format, width, height, image);
810+}
811+
812+/*
813+ * Should call DestroyImage before destroying the surface it is bound to
814+ */
815+VAStatus vaDestroyImage (
816+ VADisplay dpy,
817+ VAImage *image
818+)
819+{
820+ VADriverContextP ctx = CTX(dpy);
821+ ASSERT_CONTEXT(ctx);
822+
823+ TRACE(vaDestroyImage);
824+ return ctx->vtable.vaDestroyImage ( ctx, image);
825+}
826+
827+/*
828+ * Retrieve surface data into a VAImage
829+ * Image must be in a format supported by the implementation
830+ */
831+VAStatus vaGetImage (
832+ VADisplay dpy,
833+ VASurface *surface,
834+ int x, /* coordinates of the upper left source pixel */
835+ int y,
836+ unsigned int width, /* width and height of the region */
837+ unsigned int height,
838+ VAImage *image
839+)
840+{
841+ VADriverContextP ctx = CTX(dpy);
842+ ASSERT_CONTEXT(ctx);
843+
844+ TRACE(vaGetImage);
845+ return ctx->vtable.vaGetImage ( ctx, surface, x, y, width, height, image);
846+}
847+
848+/*
849+ * Copy data from a VAImage to a surface
850+ * Image must be in a format supported by the implementation
851+ */
852+VAStatus vaPutImage (
853+ VADisplay dpy,
854+ VASurface *surface,
855+ VAImage *image,
856+ int src_x,
857+ int src_y,
858+ unsigned int width,
859+ unsigned int height,
860+ int dest_x,
861+ int dest_y
862+)
863+{
864+ VADriverContextP ctx = CTX(dpy);
865+ ASSERT_CONTEXT(ctx);
866+
867+ TRACE(vaPutImage);
868+ return ctx->vtable.vaPutImage ( ctx, surface, image, src_x, src_y, width, height, dest_x, dest_y );
869+}
870+
871+/* Get maximum number of subpicture formats supported by the implementation */
872+int vaMaxNumSubpictureFormats (
873+ VADisplay dpy
874+)
875+{
876+ VADriverContextP ctx = CTX(dpy);
877+ ASSERT_CONTEXT(ctx);
878+
879+ return ctx->max_subpic_formats;
880+}
881+
882+/*
883+ * Query supported subpicture formats
884+ * The caller must provide a "format_list" array that can hold at
885+ * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
886+ * for each format to indicate additional capabilities for that format. The actual
887+ * number of formats returned in "format_list" is returned in "num_formats".
888+ */
889+VAStatus vaQuerySubpictureFormats (
890+ VADisplay dpy,
891+ VAImageFormat *format_list, /* out */
892+ unsigned int *flags, /* out */
893+ unsigned int *num_formats /* out */
894+)
895+{
896+ VADriverContextP ctx = CTX(dpy);
897+ ASSERT_CONTEXT(ctx);
898+
899+ TRACE(vaQuerySubpictureFormats);
900+ return ctx->vtable.vaQuerySubpictureFormats ( ctx, format_list, flags, num_formats);
901+}
902+
903+/*
904+ * Subpictures are created with an image associated.
905+ */
906+VAStatus vaCreateSubpicture (
907+ VADisplay dpy,
908+ VAImage *image,
909+ VASubpicture *subpicture /* out */
910+)
911+{
912+ VADriverContextP ctx = CTX(dpy);
913+ ASSERT_CONTEXT(ctx);
914+
915+ TRACE(vaCreateSubpicture);
916+ return ctx->vtable.vaCreateSubpicture ( ctx, image, subpicture );
917+}
918+
919+/*
920+ * Destroy the subpicture before destroying the image it is assocated to
921+ */
922+VAStatus vaDestroySubpicture (
923+ VADisplay dpy,
924+ VASubpicture *subpicture
925+)
926+{
927+ VADriverContextP ctx = CTX(dpy);
928+ ASSERT_CONTEXT(ctx);
929+
930+ TRACE(vaDestroySubpicture);
931+ return ctx->vtable.vaDestroySubpicture ( ctx, subpicture);
932+}
933+
934+VAStatus vaSetSubpicturePalette (
935+ VADisplay dpy,
936+ VASubpicture *subpicture,
937+ /*
938+ * pointer to an array holding the palette data. The size of the array is
939+ * num_palette_entries * entry_bytes in size. The order of the components
940+ * in the palette is described by the component_order in VASubpicture struct
941+ */
942+ unsigned char *palette
943+)
944+{
945+ VADriverContextP ctx = CTX(dpy);
946+ ASSERT_CONTEXT(ctx);
947+
948+ TRACE(vaSetSubpicturePalette);
949+ return ctx->vtable.vaSetSubpicturePalette ( ctx, subpicture, palette);
950+}
951+
952+/*
953+ * If chromakey is enabled, then the area where the source value falls within
954+ * the chromakey [min, max] range is transparent
955+ */
956+VAStatus vaSetSubpictureChromakey (
957+ VADisplay dpy,
958+ VASubpicture *subpicture,
959+ unsigned int chromakey_min,
960+ unsigned int chromakey_max
961+)
962+{
963+ VADriverContextP ctx = CTX(dpy);
964+ ASSERT_CONTEXT(ctx);
965+
966+ TRACE(vaSetSubpictureChromakey);
967+ return ctx->vtable.vaSetSubpictureChromakey ( ctx, subpicture, chromakey_min, chromakey_max );
968+}
969+
970+
971+/*
972+ * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
973+ * a value of 0 means fully transparent. If per-pixel alpha is also specified then
974+ * the overall alpha is per-pixel alpha multiplied by the global alpha
975+ */
976+VAStatus vaSetSubpictureGlobalAlpha (
977+ VADisplay dpy,
978+ VASubpicture *subpicture,
979+ float global_alpha
980+)
981+{
982+ VADriverContextP ctx = CTX(dpy);
983+ ASSERT_CONTEXT(ctx);
984+
985+ TRACE(vaSetSubpictureGlobalAlpha);
986+ return ctx->vtable.vaSetSubpictureGlobalAlpha ( ctx, subpicture, global_alpha );
746987 }
747988
989+/*
990+ vaAssociateSubpicture associates the subpicture with the target_surface.
991+ It defines the region mapping between the subpicture and the target
992+ surface through source and destination rectangles (with the same width and height).
993+ Both will be displayed at the next call to vaPutSurface. Additional
994+ associations before the call to vaPutSurface simply overrides the association.
995+*/
996+VAStatus vaAssociateSubpicture (
997+ VADisplay dpy,
998+ VASurface *target_surface,
999+ VASubpicture *subpicture,
1000+ short src_x, /* upper left offset in subpicture */
1001+ short src_y,
1002+ short dest_x, /* upper left offset in surface */
1003+ short dest_y,
1004+ unsigned short width,
1005+ unsigned short height,
1006+ /*
1007+ * whether to enable chroma-keying or global-alpha
1008+ * see VA_SUBPICTURE_XXX values
1009+ */
1010+ unsigned int flags
1011+)
1012+{
1013+ VADriverContextP ctx = CTX(dpy);
1014+ ASSERT_CONTEXT(ctx);
1015+
1016+ TRACE(vaAssociateSubpicture);
1017+ return ctx->vtable.vaAssociateSubpicture ( ctx, target_surface, subpicture, src_x, src_y, dest_x, dest_y, width, height, flags );
1018+}
1019+
1020+
7481021 VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
7491022 VASurface *surface,
7501023 void **buffer, /* out */
--- a/src/va.h
+++ b/src/va.h
@@ -24,7 +24,7 @@
2424 /*
2525 * Video Decode Acceleration API Specification
2626 *
27- * Rev. 0.20
27+ * Rev. 0.22
2828 * <jonathan.bian@intel.com>
2929 *
3030 * Revision History:
@@ -40,8 +40,11 @@
4040 * and MPEG-2 motion compensation.
4141 * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data.
4242 * rev 0.20 (08/08/2007 Jonathan Bian) - Added missing fields to VC-1 PictureParameter structure.
43+ * rev 0.21 (08/20/2007 Jonathan Bian) - Added image and subpicture support.
44+ * rev 0.22 (08/27/2007 Jonathan Bian) - Added support for chroma-keying and global alpha.
4345 *
4446 * Acknowledgements:
47+ * Some concepts borrowed from XvMC and XvImage.
4548 * Thanks to Waldo Bastian for many valuable feedbacks.
4649 */
4750 #ifndef _VA_H_
@@ -54,7 +57,9 @@ extern "C" {
5457 /*
5558 Overview
5659
57-This is a decode only interface currently. The basic steps are:
60+This is currently a decode only interface (with some rendering support).
61+
62+The basic operation steps are:
5863
5964 - Negotiate a mutually acceptable configuration with the server to lock
6065 down profile, entrypoints, and other attributes that will not change on
@@ -139,7 +144,9 @@ typedef enum
139144 VAProfileVC1Advanced = 10,
140145 } VAProfile;
141146
142-/* Currently defined entrypoints */
147+/*
148+ * Currently defined entrypoints
149+ */
143150 typedef enum
144151 {
145152 VAEntrypointVLD = 1,
@@ -781,7 +788,6 @@ typedef struct _VAPictureH264
781788 #define VA_PICTURE_H264_BOTTOM_FIELD 0x00000004
782789 #define VA_PICTURE_H264_SHORT_TERM_REFERENCE 0x00000008
783790 #define VA_PICTURE_H264_LONG_TERM_REFERENCE 0x00000010
784-#define VA_PICTURE_H264_USED_AS_REFERENCE 0x00000020
785791
786792 /* H.264 Picture Parameter Buffer */
787793 /*
@@ -1007,8 +1013,11 @@ VAStatus vaSyncSurface (
10071013
10081014 typedef enum
10091015 {
1010- VASurfaceRendering = 0,
1011- VASurfaceReady = 1,
1016+ VASurfaceRendering = 0, /* Rendering in progress */
1017+ VASurfaceDisplaying = 1, /* Displaying in progress (not safe to render into it) */
1018+ /* this status is useful if surface is used as the source */
1019+ /* of an overlay */
1020+ VASurfaceReady = 2 /* not being rendered or displayed */
10121021 } VASurfaceStatus;
10131022
10141023 /*
@@ -1032,6 +1041,274 @@ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy,
10321041 unsigned int *stride /* out */
10331042 );
10341043
1044+/*
1045+ * Images and Subpictures
1046+ * VAImage is used to either get the surface data to client memory, or
1047+ * to copy image data in client memory to a surface.
1048+ * Both images, subpictures and surfaces follow the same 2D coordinate system where origin
1049+ * is at the upper left corner with positive X to the right and positive Y down
1050+ */
1051+#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
1052+ ((unsigned long)(unsigned char) (ch0) | ((unsigned long)(unsigned char) (ch1) << 8) | \
1053+ ((unsigned long)(unsigned char) (ch2) << 16) | ((unsigned long)(unsigned char) (ch3) << 24 ))
1054+
1055+/* a few common FourCCs */
1056+#define VA_FOURCC_NV12 0x3231564E
1057+#define VA_FOURCC_AI44 0x34344149
1058+#define VA_FOURCC_RGBA 0x41424752
1059+
1060+typedef struct _VAImageFormat
1061+{
1062+ unsigned int fourcc;
1063+ unsigned int byte_order; /* VA_LSB_FIRST, VA_MSB_FIRST */
1064+ unsigned int bits_per_pixel;
1065+ /* for RGB formats */
1066+ unsigned int depth; /* significant bits per pixel */
1067+ unsigned int red_mask;
1068+ unsigned int green_mask;
1069+ unsigned int blue_mask;
1070+ unsigned int alpha_mask;
1071+} VAImageFormat;
1072+
1073+typedef int VAImageID;
1074+
1075+typedef struct _VAImage
1076+{
1077+ VAImageID image_id; /* uniquely identify this image */
1078+ VASurfaceID surface_id; /* which surface will this image be associated with */
1079+ VAImageFormat format;
1080+ unsigned char *data; /* image data pointer */
1081+ /* The following fields are set by the library */
1082+ unsigned short width;
1083+ unsigned short height;
1084+ unsigned int data_size;
1085+ unsigned int num_planes;
1086+ /*
1087+ * An array of size num_planes indicating the scanline pitch in bytes.
1088+ * Each plane may have a different pitch.
1089+ */
1090+ unsigned int *pitches;
1091+ /*
1092+ * An array of size num_planes indicating the byte offset from
1093+ * "data" t the start of each plane.
1094+ */
1095+ unsigned int *offsets;
1096+} VAImage;
1097+
1098+/* Get maximum number of image formats supported by the implementation */
1099+int vaMaxNumImageFormats (
1100+ VADisplay dpy
1101+);
1102+
1103+/*
1104+ * Query supported image formats
1105+ * The caller must provide a "format_list" array that can hold at
1106+ * least vaMaxNumImageFormats() entries. The actual number of formats
1107+ * returned in "format_list" is returned in "num_formats".
1108+ */
1109+VAStatus vaQueryImageFormats (
1110+ VADisplay dpy,
1111+ VAImageFormat *format_list, /* out */
1112+ int *num_formats /* out */
1113+);
1114+
1115+/*
1116+ * The width and height fields returned in the VAImage structure may get
1117+ * enlarged for some YUV formats. The size of the data buffer that needs
1118+ * to be allocated will be given in the "data_size" field in VAImage.
1119+ * Image data is not allocated by this function. The client should
1120+ * allocate the memory and fill in the VAImage structure's data field
1121+ * after looking at "data_size" returned from the library.
1122+ */
1123+VAStatus vaCreateImage (
1124+ VADisplay dpy,
1125+ VAImageFormat *format,
1126+ int width,
1127+ int height,
1128+ VAImage *image /* out */
1129+);
1130+
1131+/*
1132+ * Should call DestroyImage before destroying the surface it is bound to
1133+ */
1134+VAStatus vaDestroyImage (
1135+ VADisplay dpy,
1136+ VAImage *image
1137+);
1138+
1139+/*
1140+ * Retrive surface data into a VAImage
1141+ * Image must be in a format supported by the implementation
1142+ */
1143+VAStatus vaGetImage (
1144+ VADisplay dpy,
1145+ VASurface *surface,
1146+ int x, /* coordinates of the upper left source pixel */
1147+ int y,
1148+ unsigned int width, /* width and height of the region */
1149+ unsigned int height,
1150+ VAImage *image
1151+);
1152+
1153+/*
1154+ * Copy data from a VAImage to a surface
1155+ * Image must be in a format supported by the implementation
1156+ */
1157+VAStatus vaPutImage (
1158+ VADisplay dpy,
1159+ VASurface *surface,
1160+ VAImage *image,
1161+ int src_x,
1162+ int src_y,
1163+ unsigned int width,
1164+ unsigned int height,
1165+ int dest_x,
1166+ int dest_y
1167+);
1168+
1169+/*
1170+ * Subpictures
1171+ * Subpicture is a special type of image that can be blended
1172+ * with a surface during vaPutSurface(). Subpicture can be used to render
1173+ * DVD sub-titles or closed captioning text etc.
1174+ */
1175+
1176+typedef int VASubpictureID;
1177+
1178+typedef struct _VASubpicture
1179+{
1180+ VASubpictureID subpicture_id; /* uniquely identify this subpicture */
1181+ VASurfaceID surface_id; /* which surface does this subpicture associate with */
1182+ VAImageID image_id;
1183+ /* The following fields are set by the library */
1184+ int num_palette_entries; /* paletted formats only. set to zero for image without palettes */
1185+ /*
1186+ * Each component is one byte and entry_bytes indicates the number of components in
1187+ * each entry (eg. 3 for YUV palette entries). set to zero for image without palettes
1188+ */
1189+ int entry_bytes;
1190+ /*
1191+ * An array of ascii characters describing teh order of the components within the bytes.
1192+ * Only entry_bytes characters of the string are used.
1193+ */
1194+ char component_order[4];
1195+
1196+ /* chromakey range */
1197+ unsigned int chromakey_min;
1198+ unsigned int chromakey_max;
1199+
1200+ /* global alpha */
1201+ unsigned int global_alpha;
1202+
1203+ /* flags */
1204+ unsigned int flags; /* see below */
1205+} VASubpicture;
1206+
1207+/* flags for subpictures */
1208+#define VA_SUBPICTURE_CHROMA_KEYING 0x0001
1209+#define VA_SUBPICTURE_GLOBAL_ALPHA 0x0002
1210+
1211+/* Get maximum number of subpicture formats supported by the implementation */
1212+int vaMaxNumSubpictureFormats (
1213+ VADisplay dpy
1214+);
1215+
1216+/*
1217+ * Query supported subpicture formats
1218+ * The caller must provide a "format_list" array that can hold at
1219+ * least vaMaxNumSubpictureFormats() entries. The flags arrary holds the flag
1220+ * for each format to indicate additional capabilities for that format. The actual
1221+ * number of formats returned in "format_list" is returned in "num_formats".
1222+ */
1223+VAStatus vaQuerySubpictureFormats (
1224+ VADisplay dpy,
1225+ VAImageFormat *format_list, /* out */
1226+ unsigned int *flags, /* out */
1227+ unsigned int *num_formats /* out */
1228+);
1229+
1230+/*
1231+ * Subpictures are created with an image associated.
1232+ */
1233+VAStatus vaCreateSubpicture (
1234+ VADisplay dpy,
1235+ VAImage *image,
1236+ VASubpicture *subpicture /* out */
1237+);
1238+
1239+/*
1240+ * Destroy the subpicture before destroying the image it is assocated to
1241+ */
1242+VAStatus vaDestroySubpicture (
1243+ VADisplay dpy,
1244+ VASubpicture *subpicture
1245+);
1246+
1247+VAStatus vaSetSubpicturePalette (
1248+ VADisplay dpy,
1249+ VASubpicture *subpicture,
1250+ /*
1251+ * pointer to an array holding the palette data. The size of the array is
1252+ * num_palette_entries * entry_bytes in size. The order of the components
1253+ * in the palette is described by the component_order in VASubpicture struct
1254+ */
1255+ unsigned char *palette
1256+);
1257+
1258+/*
1259+ * If chromakey is enabled, then the area where the source value falls within
1260+ * the chromakey [min, max] range is transparent
1261+ */
1262+VAStatus vaSetSubpictureChromakey (
1263+ VADisplay dpy,
1264+ VASubpicture *subpicture,
1265+ unsigned int chromakey_min,
1266+ unsigned int chromakey_max
1267+);
1268+
1269+/*
1270+ * Global alpha value is between 0 and 1. A value of 1 means fully opaque and
1271+ * a value of 0 means fully transparent. If per-pixel alpha is also specified then
1272+ * the overall alpha is per-pixel alpha multiplied by the global alpha
1273+ */
1274+VAStatus vaSetSubpictureGlobalAlpha (
1275+ VADisplay dpy,
1276+ VASubpicture *subpicture,
1277+ float global_alpha
1278+);
1279+
1280+/*
1281+ vaAssociateSubpicture associates the subpicture with the target_surface.
1282+ It defines the region mapping between the subpicture and the target
1283+ surface through source and destination rectangles (with the same width and height).
1284+ Both will be displayed at the next call to vaPutSurface. Additional
1285+ associations before the call to vaPutSurface simply overrides the association.
1286+*/
1287+VAStatus vaAssociateSubpicture (
1288+ VADisplay dpy,
1289+ VASurface *target_surface,
1290+ VASubpicture *subpicture,
1291+ short src_x, /* upper left offset in subpicture */
1292+ short src_y,
1293+ short dest_x, /* upper left offset in surface */
1294+ short dest_y,
1295+ unsigned short width,
1296+ unsigned short height,
1297+ /*
1298+ * whether to enable chroma-keying or global-alpha
1299+ * see VA_SUBPICTURE_XXX values
1300+ */
1301+ unsigned int flags
1302+);
1303+
1304+typedef struct _VARectangle
1305+{
1306+ short x;
1307+ short y;
1308+ unsigned short width;
1309+ unsigned short height;
1310+} VARectangle;
1311+
10351312 #ifdef __cplusplus
10361313 }
10371314 #endif
@@ -1165,4 +1442,22 @@ Mostly to demonstrate program flow with no error handling ...
11651442
11661443 /* all slices have been sent, mark the end for this frame */
11671444 vaEndPicture(dpy, context);
1445+
1446+ /* The following code demonstrates rendering a sub-title with the target surface */
1447+ /* Find out supported Subpicture formats */
1448+ VAImageFormat sub_formats[4];
1449+ int num_formats;
1450+ vaQuerySubpictureFormats(dpy, sub_formats, &num_formats);
1451+ /* Assume that we find AI44 as a subpicture format in sub_formats[0] */
1452+ VAImage sub_image;
1453+ VASubpicture subpicture;
1454+ unsigned char sub_data[128][16];
1455+ /* fill sub_data with subtitle in AI44 */
1456+ vaCreateImage(dpy, surfaces, sub_formats, 128, 16, sub_data, &sub_image);
1457+ vaCreateSubpicture(dpy, &sub_image, &subpicture);
1458+ unsigned char palette[3][16];
1459+ /* fill the palette data */
1460+ vaSetSubpicturePalette(dpy, &subpicture, palette);
1461+ vaAssociateSubpicture(dpy, surfaces, &subpicture, 0, 0, 296, 400, 128, 16);
1462+ vaPutSurface(dpy, surfaces, win, 0, 0, 720, 480, 100, 100, 640, 480, NULL, 0, 0);
11681463 #endif
--- a/src/va_backend.h
+++ b/src/va_backend.h
@@ -46,19 +46,21 @@ struct VADriverContext
4646 int max_profiles;
4747 int max_entrypoints;
4848 int max_attributes;
49+ int max_image_formats;
50+ int max_subpic_formats;
4951 void *handle; /* dlopen handle */
5052 void *pDriverData;
5153 struct
5254 {
53- VAStatus (*vaTerminate) ( VADriverContextP ctx );
55+ VAStatus (*vaTerminate) ( VADriverContextP ctx );
5456
55- VAStatus (*vaQueryConfigProfiles) (
57+ VAStatus (*vaQueryConfigProfiles) (
5658 VADriverContextP ctx,
5759 VAProfile *profile_list, /* out */
5860 int *num_profiles /* out */
5961 );
6062
61- VAStatus (*vaQueryConfigEntrypoints) (
63+ VAStatus (*vaQueryConfigEntrypoints) (
6264 VADriverContextP ctx,
6365 VAProfile profile,
6466 VAEntrypoint *entrypoint_list, /* out */
@@ -201,9 +203,111 @@ struct VADriverContext
201203 short desty,
202204 unsigned short destw,
203205 unsigned short desth,
206+ VARectangle *cliprects, /* client supplied clip list */
207+ unsigned int number_cliprects, /* number of clip rects in the clip list */
204208 int flags /* de-interlacing flags */
205209 );
206210
211+ VAStatus (*vaQueryImageFormats) (
212+ VADriverContextP ctx,
213+ VAImageFormat *format_list, /* out */
214+ int *num_formats /* out */
215+ );
216+
217+ VAStatus (*vaCreateImage) (
218+ VADriverContextP ctx,
219+ VAImageFormat *format,
220+ int width,
221+ int height,
222+ VAImage *image /* out */
223+ );
224+
225+ VAStatus (*vaDestroyImage) (
226+ VADriverContextP ctx,
227+ VAImage *image
228+ );
229+
230+ VAStatus (*vaGetImage) (
231+ VADriverContextP ctx,
232+ VASurface *surface,
233+ int x, /* coordinates of the upper left source pixel */
234+ int y,
235+ unsigned int width, /* width and height of the region */
236+ unsigned int height,
237+ VAImage *image
238+ );
239+
240+ VAStatus (*vaPutImage) (
241+ VADriverContextP ctx,
242+ VASurface *surface,
243+ VAImage *image,
244+ int src_x,
245+ int src_y,
246+ unsigned int width,
247+ unsigned int height,
248+ int dest_x,
249+ int dest_y
250+ );
251+
252+ VAStatus (*vaQuerySubpictureFormats) (
253+ VADriverContextP ctx,
254+ VAImageFormat *format_list, /* out */
255+ unsigned int *flags, /* out */
256+ unsigned int *num_formats /* out */
257+ );
258+
259+ VAStatus (*vaCreateSubpicture) (
260+ VADriverContextP ctx,
261+ VAImage *image,
262+ VASubpicture *subpicture /* out */
263+ );
264+
265+ VAStatus (*vaDestroySubpicture) (
266+ VADriverContextP ctx,
267+ VASubpicture *subpicture
268+ );
269+
270+ VAStatus (*vaSetSubpicturePalette) (
271+ VADriverContextP ctx,
272+ VASubpicture *subpicture,
273+ /*
274+ * pointer to an array holding the palette data. The size of the array is
275+ * num_palette_entries * entry_bytes in size. The order of the components
276+ * in the palette is described by the component_order in VASubpicture struct
277+ */
278+ unsigned char *palette
279+ );
280+
281+ VAStatus (*vaSetSubpictureChromakey) (
282+ VADriverContextP ctx,
283+ VASubpicture *subpicture,
284+ unsigned int chromakey_min,
285+ unsigned int chromakey_max
286+ );
287+
288+ VAStatus (*vaSetSubpictureGlobalAlpha) (
289+ VADriverContextP ctx,
290+ VASubpicture *subpicture,
291+ float global_alpha
292+ );
293+
294+ VAStatus (*vaAssociateSubpicture) (
295+ VADriverContextP ctx,
296+ VASurface *target_surface,
297+ VASubpicture *subpicture,
298+ short src_x, /* upper left offset in subpicture */
299+ short src_y,
300+ short dest_x, /* upper left offset in surface */
301+ short dest_y,
302+ unsigned short width,
303+ unsigned short height,
304+ /*
305+ * whether to enable chroma-keying or global-alpha
306+ * see VA_SUBPICTURE_XXX values
307+ */
308+ unsigned int flags
309+ );
310+
207311 VAStatus (*vaDbgCopySurfaceToBuffer) (
208312 VADriverContextP ctx,
209313 VASurface *surface,
--- a/src/va_x11.h
+++ b/src/va_x11.h
@@ -44,6 +44,8 @@ VAStatus vaPutSurface (
4444 short desty,
4545 unsigned short destw,
4646 unsigned short desth,
47+ VARectangle *cliprects, /* client supplied clip list */
48+ unsigned int number_cliprects, /* number of clip rects in the clip list */
4749 int flags /* de-interlacing flags */
4850 );
4951