hardware/intel/libva
Revision | 16ab532f97d035000e6c7453068c8585a16d21f9 (tree) |
---|---|
Time | 2007-09-07 20:29:54 |
Author | root <root@mobi...> |
Commiter | root |
Include sub-picture support (va 0.22)
@@ -36,7 +36,7 @@ | ||
36 | 36 | |
37 | 37 | #define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri" |
38 | 38 | #define DRIVER_EXTENSION "_drv_video.so" |
39 | -#define DRIVER_INIT_FUNC "__vaDriverInit_0_20" | |
39 | +#define DRIVER_INIT_FUNC "__vaDriverInit_0_22" | |
40 | 40 | |
41 | 41 | #define CTX(dpy) ((VADriverContextP) dpy ); |
42 | 42 | #define ASSERT_CONTEXT(dpy) assert( vaDbgContextIsValid(dpy) ) |
@@ -252,6 +252,8 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) | ||
252 | 252 | CHECK_MAXIMUM(vaStatus, ctx, profiles); |
253 | 253 | CHECK_MAXIMUM(vaStatus, ctx, entrypoints); |
254 | 254 | CHECK_MAXIMUM(vaStatus, ctx, attributes); |
255 | + CHECK_MAXIMUM(vaStatus, ctx, image_formats); | |
256 | + CHECK_MAXIMUM(vaStatus, ctx, subpic_formats); | |
255 | 257 | CHECK_VTABLE(vaStatus, ctx, Terminate); |
256 | 258 | CHECK_VTABLE(vaStatus, ctx, QueryConfigProfiles); |
257 | 259 | CHECK_VTABLE(vaStatus, ctx, QueryConfigEntrypoints); |
@@ -274,6 +276,18 @@ static VAStatus va_openDriver(VADriverContextP ctx, char *driver_name) | ||
274 | 276 | CHECK_VTABLE(vaStatus, ctx, SyncSurface); |
275 | 277 | CHECK_VTABLE(vaStatus, ctx, QuerySurfaceStatus); |
276 | 278 | 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); | |
277 | 291 | CHECK_VTABLE(vaStatus, ctx, DbgCopySurfaceToBuffer); |
278 | 292 | } |
279 | 293 | if (VA_STATUS_SUCCESS != vaStatus) |
@@ -334,7 +348,7 @@ const char *vaErrorStr(VAStatus error_status) | ||
334 | 348 | case VA_STATUS_ERROR_UNKNOWN: |
335 | 349 | return "unknown libva error"; |
336 | 350 | } |
337 | - return "unknwon libva error / description missing"; | |
351 | + return "unknown libva error / description missing"; | |
338 | 352 | } |
339 | 353 | |
340 | 354 | VAStatus vaInitialize ( |
@@ -431,6 +445,7 @@ int vaMaxNumEntrypoints ( | ||
431 | 445 | return ctx->max_entrypoints; |
432 | 446 | } |
433 | 447 | |
448 | + | |
434 | 449 | /* Get maximum number of attributs supported by the implementation */ |
435 | 450 | int vaMaxNumConfigAttributes ( |
436 | 451 | VADisplay dpy |
@@ -442,7 +457,6 @@ int vaMaxNumConfigAttributes ( | ||
442 | 457 | return ctx->max_attributes; |
443 | 458 | } |
444 | 459 | |
445 | - | |
446 | 460 | VAStatus vaQueryConfigEntrypoints ( |
447 | 461 | VADisplay dpy, |
448 | 462 | VAProfile profile, |
@@ -734,6 +748,8 @@ VAStatus vaPutSurface ( | ||
734 | 748 | short desty, |
735 | 749 | unsigned short destw, |
736 | 750 | unsigned short desth, |
751 | + VARectangle *cliprects, /* client supplied clip list */ | |
752 | + unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
737 | 753 | int flags /* de-interlacing flags */ |
738 | 754 | ) |
739 | 755 | { |
@@ -742,9 +758,266 @@ VAStatus vaPutSurface ( | ||
742 | 758 | |
743 | 759 | TRACE(vaPutSurface); |
744 | 760 | 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 ); | |
746 | 987 | } |
747 | 988 | |
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 | + | |
748 | 1021 | VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, |
749 | 1022 | VASurface *surface, |
750 | 1023 | void **buffer, /* out */ |
@@ -24,7 +24,7 @@ | ||
24 | 24 | /* |
25 | 25 | * Video Decode Acceleration API Specification |
26 | 26 | * |
27 | - * Rev. 0.20 | |
27 | + * Rev. 0.22 | |
28 | 28 | * <jonathan.bian@intel.com> |
29 | 29 | * |
30 | 30 | * Revision History: |
@@ -40,8 +40,11 @@ | ||
40 | 40 | * and MPEG-2 motion compensation. |
41 | 41 | * rev 0.19 (08/06/2007 Jonathan Bian) - Removed extra type for bitplane data. |
42 | 42 | * 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. | |
43 | 45 | * |
44 | 46 | * Acknowledgements: |
47 | + * Some concepts borrowed from XvMC and XvImage. | |
45 | 48 | * Thanks to Waldo Bastian for many valuable feedbacks. |
46 | 49 | */ |
47 | 50 | #ifndef _VA_H_ |
@@ -54,7 +57,9 @@ extern "C" { | ||
54 | 57 | /* |
55 | 58 | Overview |
56 | 59 | |
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: | |
58 | 63 | |
59 | 64 | - Negotiate a mutually acceptable configuration with the server to lock |
60 | 65 | down profile, entrypoints, and other attributes that will not change on |
@@ -139,7 +144,9 @@ typedef enum | ||
139 | 144 | VAProfileVC1Advanced = 10, |
140 | 145 | } VAProfile; |
141 | 146 | |
142 | -/* Currently defined entrypoints */ | |
147 | +/* | |
148 | + * Currently defined entrypoints | |
149 | + */ | |
143 | 150 | typedef enum |
144 | 151 | { |
145 | 152 | VAEntrypointVLD = 1, |
@@ -781,7 +788,6 @@ typedef struct _VAPictureH264 | ||
781 | 788 | #define VA_PICTURE_H264_BOTTOM_FIELD 0x00000004 |
782 | 789 | #define VA_PICTURE_H264_SHORT_TERM_REFERENCE 0x00000008 |
783 | 790 | #define VA_PICTURE_H264_LONG_TERM_REFERENCE 0x00000010 |
784 | -#define VA_PICTURE_H264_USED_AS_REFERENCE 0x00000020 | |
785 | 791 | |
786 | 792 | /* H.264 Picture Parameter Buffer */ |
787 | 793 | /* |
@@ -1007,8 +1013,11 @@ VAStatus vaSyncSurface ( | ||
1007 | 1013 | |
1008 | 1014 | typedef enum |
1009 | 1015 | { |
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 */ | |
1012 | 1021 | } VASurfaceStatus; |
1013 | 1022 | |
1014 | 1023 | /* |
@@ -1032,6 +1041,274 @@ VAStatus vaDbgCopySurfaceToBuffer(VADisplay dpy, | ||
1032 | 1041 | unsigned int *stride /* out */ |
1033 | 1042 | ); |
1034 | 1043 | |
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 | + | |
1035 | 1312 | #ifdef __cplusplus |
1036 | 1313 | } |
1037 | 1314 | #endif |
@@ -1165,4 +1442,22 @@ Mostly to demonstrate program flow with no error handling ... | ||
1165 | 1442 | |
1166 | 1443 | /* all slices have been sent, mark the end for this frame */ |
1167 | 1444 | 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); | |
1168 | 1463 | #endif |
@@ -46,19 +46,21 @@ struct VADriverContext | ||
46 | 46 | int max_profiles; |
47 | 47 | int max_entrypoints; |
48 | 48 | int max_attributes; |
49 | + int max_image_formats; | |
50 | + int max_subpic_formats; | |
49 | 51 | void *handle; /* dlopen handle */ |
50 | 52 | void *pDriverData; |
51 | 53 | struct |
52 | 54 | { |
53 | - VAStatus (*vaTerminate) ( VADriverContextP ctx ); | |
55 | + VAStatus (*vaTerminate) ( VADriverContextP ctx ); | |
54 | 56 | |
55 | - VAStatus (*vaQueryConfigProfiles) ( | |
57 | + VAStatus (*vaQueryConfigProfiles) ( | |
56 | 58 | VADriverContextP ctx, |
57 | 59 | VAProfile *profile_list, /* out */ |
58 | 60 | int *num_profiles /* out */ |
59 | 61 | ); |
60 | 62 | |
61 | - VAStatus (*vaQueryConfigEntrypoints) ( | |
63 | + VAStatus (*vaQueryConfigEntrypoints) ( | |
62 | 64 | VADriverContextP ctx, |
63 | 65 | VAProfile profile, |
64 | 66 | VAEntrypoint *entrypoint_list, /* out */ |
@@ -201,9 +203,111 @@ struct VADriverContext | ||
201 | 203 | short desty, |
202 | 204 | unsigned short destw, |
203 | 205 | unsigned short desth, |
206 | + VARectangle *cliprects, /* client supplied clip list */ | |
207 | + unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
204 | 208 | int flags /* de-interlacing flags */ |
205 | 209 | ); |
206 | 210 | |
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 | + | |
207 | 311 | VAStatus (*vaDbgCopySurfaceToBuffer) ( |
208 | 312 | VADriverContextP ctx, |
209 | 313 | VASurface *surface, |
@@ -44,6 +44,8 @@ VAStatus vaPutSurface ( | ||
44 | 44 | short desty, |
45 | 45 | unsigned short destw, |
46 | 46 | unsigned short desth, |
47 | + VARectangle *cliprects, /* client supplied clip list */ | |
48 | + unsigned int number_cliprects, /* number of clip rects in the clip list */ | |
47 | 49 | int flags /* de-interlacing flags */ |
48 | 50 | ); |
49 | 51 |