00001
00002 #ifndef XVMC_SURFACE_TYPES_H_
00003 #define XVMC_SURFACE_TYPES_H_
00004
00005 #ifdef USING_XVMC
00006
00007 #include <qwindowdefs.h>
00008 #include "mythcontext.h"
00009 #include <X11/extensions/XvMC.h>
00010 #include "util-x11.h"
00011 #include "fourcc.h"
00012
00013 extern "C" {
00014 #include "../libavcodec/xvmc_render.h"
00015 }
00016
00017 #ifndef XVMC_VLD
00018 #define XVMC_VLD 0x0020000
00019 #endif
00020
00021
00022 #define XVMC_COPY_TO_PBUFFER 0x00000010
00023 extern "C" {
00024 Status
00025 XvMCCopySurfaceToGLXPbuffer (
00026 Display *display,
00027 XvMCSurface *surface,
00028 XID pbuffer_id,
00029 short src_x,
00030 short src_y,
00031 unsigned short width,
00032 unsigned short height,
00033 short dst_x,
00034 short dst_y,
00035 unsigned int gl_buffer,
00036 int flags
00037 );
00038 }
00039
00040 typedef enum { XvVLD, XvIDCT, XvMC } XvMCAccelID;
00041
00042 QString XvImageFormatToString(const XvImageFormatValues &fmt);
00043
00044 class XvMCSurfaceTypes
00045 {
00046 public:
00047 XvMCSurfaceTypes(Display *dpy, XvPortID port) : num(0)
00048 {
00049 X11S(surfaces = XvMCListSurfaceTypes(dpy, port, &num));
00050 }
00051
00052 ~XvMCSurfaceTypes()
00053 {
00054 X11S(XFree(surfaces));
00055 }
00056
00058 inline int find(int pminWidth, int pminHeight, int chroma, bool vld,
00059 bool idct, int mpeg, int pminSubpictureWidth,
00060 int pminSubpictureHeight);
00061
00062 bool hasChroma420(int surface) const
00063 {
00064 return XVMC_CHROMA_FORMAT_420 == surfaces[surface].chroma_format;
00065 }
00066
00067 bool hasChroma422(int surface) const
00068 {
00069 return XVMC_CHROMA_FORMAT_422 == surfaces[surface].chroma_format;
00070 }
00071
00072 bool hasChroma444(int surface) const
00073 {
00074 return XVMC_CHROMA_FORMAT_444 == surfaces[surface].chroma_format;
00075 }
00076
00077 bool hasOverlay(int surface) const
00078 {
00079 return surfaces[surface].flags & XVMC_OVERLAID_SURFACE;
00080 }
00081
00082 bool hasBackendSubpicture(int surface) const
00083 {
00084 return surfaces[surface].flags & XVMC_BACKEND_SUBPICTURE;
00085 }
00086
00087 bool hasSubpictureScaling(int surface) const
00088 {
00089 return surfaces[surface].flags & XVMC_SUBPICTURE_INDEPENDENT_SCALING;
00090 }
00091
00092
00093 bool isIntraUnsigned(int surface) const
00094 {
00095 return surfaces[surface].flags & XVMC_INTRA_UNSIGNED;
00096 }
00097
00098 bool hasCopyToPBuffer(int surface) const
00099 {
00100 #ifdef USING_XVMC_PBUFFER
00101 (void) surface;
00102 return true;
00103 #else
00104 return surfaces[surface].flags & XVMC_COPY_TO_PBUFFER;
00105 #endif
00106 }
00107
00108 bool hasMotionCompensationAcceleration(int surface) const
00109 {
00110
00111
00112 return XVMC_MOCOMP == (surfaces[surface].mc_type & XVMC_IDCT);
00113 }
00114
00115 bool hasIDCTAcceleration(int surface) const
00116 {
00117 return XVMC_IDCT == (surfaces[surface].mc_type & XVMC_IDCT);
00118 }
00119
00120 bool hasVLDAcceleration(int surface) const
00121 {
00122 return XVMC_VLD == (surfaces[surface].mc_type & XVMC_VLD);
00123 }
00124
00125 bool hasMPEG1Support(int surface) const
00126 {
00127 return XVMC_MPEG_1 == (surfaces[surface].mc_type & 0x7);
00128 }
00129
00130 bool hasMPEG2Support(int surface) const
00131 {
00132 return XVMC_MPEG_2 == (surfaces[surface].mc_type & 0x7);
00133 }
00134
00135 bool hasH263Support(int surface) const
00136 {
00137 return XVMC_H263 == (surfaces[surface].mc_type & 0x7);
00138 }
00139
00140 bool hasMPEG4Support(int surface) const
00141 {
00142 return XVMC_MPEG_4 == (surfaces[surface].mc_type & 0x7);
00143 }
00144
00145 int surfaceTypeID(int surface) const
00146 {
00147 return surfaces[surface].surface_type_id;
00148 }
00149
00150 unsigned short maxWidth(int surface) const
00151 {
00152 return surfaces[surface].max_width;
00153 }
00154
00155 unsigned short maxHeight(int surface) const
00156 {
00157 return surfaces[surface].max_height;
00158 }
00159
00160 unsigned short maxSubpictureWidth(int surface) const
00161 {
00162 return surfaces[surface].subpicture_max_width;
00163 }
00164
00165 unsigned short maxSubpictureHeight(int surface) const
00166 {
00167 return surfaces[surface].subpicture_max_height;
00168 }
00169
00170 void set(int surface, XvMCSurfaceInfo* surfinfo) const
00171 {
00172 memcpy(surfinfo, &surfaces[surface], sizeof(XvMCSurfaceInfo));
00173 }
00174
00175 int size() const { return num; }
00176
00178 static void find(int minWidth, int minHeight, int chroma, bool vld,
00179 bool idct, int mpeg, int minSubpictureWidth,
00180 int minSubpictureHeight, Display *dpy,
00181 XvPortID portMin, XvPortID portMax,
00182 XvPortID& port, int& surfNum);
00183
00186 static bool has(Display *pdisp,
00187 XvMCAccelID accel_type, uint stream_type, int chroma,
00188 uint width, uint height, uint osd_width, uint osd_height);
00189
00190 static QString XvMCDescription(Display *pdisp = NULL);
00191 QString toString(Display *pdisp = NULL, XvPortID p = 0) const;
00192 ostream& operator<<(ostream& os) const { return os << toString(); }
00193
00194 private:
00195 int num;
00196 XvMCSurfaceInfo *surfaces;
00197 };
00198
00199 #endif // USING_XVMC
00200
00201 #endif // XVMC_SURFACE_TYPES_H_