|
|
|
@ -86,7 +86,7 @@ bool KXv::haveXv()
|
|
|
|
|
return false;
|
|
|
|
|
#else
|
|
|
|
|
unsigned int tmp;
|
|
|
|
|
if (Success != XvQueryExtension(qt_xdisplay(),
|
|
|
|
|
if (Success != XvQueryExtension(tqt_xdisplay(),
|
|
|
|
|
&tmp,
|
|
|
|
|
&tmp,
|
|
|
|
|
&tmp,
|
|
|
|
@ -120,7 +120,7 @@ bool KXv::init(Drawable d)
|
|
|
|
|
#ifndef HAVE_LIBXV
|
|
|
|
|
return false;
|
|
|
|
|
#else
|
|
|
|
|
if (Success != XvQueryExtension(qt_xdisplay(),
|
|
|
|
|
if (Success != XvQueryExtension(tqt_xdisplay(),
|
|
|
|
|
&xv_version,
|
|
|
|
|
&xv_release,
|
|
|
|
|
&xv_request,
|
|
|
|
@ -132,12 +132,12 @@ bool KXv::init(Drawable d)
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXVMC
|
|
|
|
|
// Causes crashes for some people.
|
|
|
|
|
// if (Success == XvMCQueryExtension(qt_xdisplay(),0,0)) {
|
|
|
|
|
// if (Success == XvMCQueryExtension(tqt_xdisplay(),0,0)) {
|
|
|
|
|
// kdDebug() << "Found XvMC!" << endl;
|
|
|
|
|
// }
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (Success != XvQueryAdaptors(qt_xdisplay(),
|
|
|
|
|
if (Success != XvQueryAdaptors(tqt_xdisplay(),
|
|
|
|
|
d,
|
|
|
|
|
&xv_adaptors,
|
|
|
|
|
(XvAdaptorInfo **)&xv_adaptor_info)) {
|
|
|
|
@ -225,13 +225,13 @@ int KXvDevice::displayImage(Window win, const unsigned char *const data, int w,
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (win != xv_last_win && xv_gc) {
|
|
|
|
|
XFreeGC(qt_xdisplay(), xv_gc);
|
|
|
|
|
XFreeGC(tqt_xdisplay(), xv_gc);
|
|
|
|
|
xv_gc = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!xv_gc) {
|
|
|
|
|
xv_last_win = win;
|
|
|
|
|
xv_gc = XCreateGC(qt_xdisplay(), win, 0, NULL);
|
|
|
|
|
xv_gc = XCreateGC(tqt_xdisplay(), win, 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rc = 0;
|
|
|
|
@ -239,17 +239,17 @@ int KXvDevice::displayImage(Window win, const unsigned char *const data, int w,
|
|
|
|
|
if (!_shm) {
|
|
|
|
|
static_cast<XvImage*>(xv_image)->data =
|
|
|
|
|
(char *)const_cast<unsigned char*>(data);
|
|
|
|
|
rc = XvPutImage(qt_xdisplay(), xv_port, win, xv_gc,
|
|
|
|
|
rc = XvPutImage(tqt_xdisplay(), xv_port, win, xv_gc,
|
|
|
|
|
static_cast<XvImage*>(xv_image), x, y, sw, sh, 0, 0, dw, dh);
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
|
memcpy(static_cast<XvImage*>(xv_image)->data, data, static_cast<XvImage*>(xv_image)->data_size);
|
|
|
|
|
rc = XvShmPutImage(qt_xdisplay(), xv_port, win, xv_gc,
|
|
|
|
|
rc = XvShmPutImage(tqt_xdisplay(), xv_port, win, xv_gc,
|
|
|
|
|
static_cast<XvImage*>(xv_image), x, y, sw, sh, 0, 0, dw, dh, 0);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XSync(qt_xdisplay(), False);
|
|
|
|
|
XSync(tqt_xdisplay(), False);
|
|
|
|
|
return rc;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@ -283,13 +283,13 @@ bool KXvDevice::startVideo(Window w, int dw, int dh)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (w != xv_last_win && xv_gc) {
|
|
|
|
|
XFreeGC(qt_xdisplay(), xv_gc);
|
|
|
|
|
XFreeGC(tqt_xdisplay(), xv_gc);
|
|
|
|
|
xv_gc = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!xv_gc) {
|
|
|
|
|
xv_last_win = w;
|
|
|
|
|
xv_gc = XCreateGC(qt_xdisplay(), w, 0, NULL);
|
|
|
|
|
xv_gc = XCreateGC(tqt_xdisplay(), w, 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (-1 != xv_encoding) {
|
|
|
|
@ -300,11 +300,11 @@ bool KXvDevice::startVideo(Window w, int dw, int dh)
|
|
|
|
|
// xawtv does this here:
|
|
|
|
|
// ng_ratio_fixup(&dw, &dh, &dx, &dy);
|
|
|
|
|
|
|
|
|
|
kdDebug() << "XvPutVideo: " << qt_xdisplay()
|
|
|
|
|
kdDebug() << "XvPutVideo: " << tqt_xdisplay()
|
|
|
|
|
<< " " << xv_port << " " << w << " " << xv_gc
|
|
|
|
|
<< " " << sx << " " << sy << " " << sw << " " << sh
|
|
|
|
|
<< " " << dx << " " << dy << " " << dw << " " << dh << endl;
|
|
|
|
|
XvPutVideo(qt_xdisplay(), xv_port, w, xv_gc, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
|
|
|
XvPutVideo(tqt_xdisplay(), xv_port, w, xv_gc, sx, sy, sw, sh, dx, dy, dw, dh);
|
|
|
|
|
|
|
|
|
|
videoStarted = true;
|
|
|
|
|
videoWindow = w;
|
|
|
|
@ -324,7 +324,7 @@ bool KXvDevice::stopVideo()
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XvStopVideo(qt_xdisplay(), xv_port, videoWindow);
|
|
|
|
|
XvStopVideo(tqt_xdisplay(), xv_port, videoWindow);
|
|
|
|
|
videoStarted = false;
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
@ -345,7 +345,7 @@ KXvDevice::KXvDevice()
|
|
|
|
|
#ifdef HAVE_LIBXV
|
|
|
|
|
xv_imageformat = 0x32595559; // FIXME (YUY2)
|
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
|
if (!XShmQueryExtension(qt_xdisplay())) {
|
|
|
|
|
if (!XShmQueryExtension(tqt_xdisplay())) {
|
|
|
|
|
_haveShm = false;
|
|
|
|
|
} else {
|
|
|
|
|
_shm = true;
|
|
|
|
@ -381,11 +381,11 @@ KXvDevice::~KXvDevice()
|
|
|
|
|
destroyImage();
|
|
|
|
|
#endif
|
|
|
|
|
if (xv_gc)
|
|
|
|
|
XFreeGC(qt_xdisplay(), xv_gc);
|
|
|
|
|
XFreeGC(tqt_xdisplay(), xv_gc);
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXV
|
|
|
|
|
if (xv_port != -1)
|
|
|
|
|
XvUngrabPort(qt_xdisplay(), xv_port, CurrentTime);
|
|
|
|
|
XvUngrabPort(tqt_xdisplay(), xv_port, CurrentTime);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -397,12 +397,12 @@ bool KXvDevice::init()
|
|
|
|
|
#else
|
|
|
|
|
assert(xv_port != -1); // make sure we were prepped by KXv already.
|
|
|
|
|
|
|
|
|
|
if (XvGrabPort(qt_xdisplay(), xv_port, CurrentTime)) {
|
|
|
|
|
if (XvGrabPort(tqt_xdisplay(), xv_port, CurrentTime)) {
|
|
|
|
|
kdWarning() << "KXvDevice::init(): Unable to grab Xv port." << endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Success != XvQueryEncodings(qt_xdisplay(),
|
|
|
|
|
if (Success != XvQueryEncodings(tqt_xdisplay(),
|
|
|
|
|
xv_port,
|
|
|
|
|
&xv_encodings,
|
|
|
|
|
(XvEncodingInfo **)&xv_encoding_info)) {
|
|
|
|
@ -416,7 +416,7 @@ bool KXvDevice::init()
|
|
|
|
|
_encodingList << ((XvEncodingInfo *)xv_encoding_info)[i].name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xv_attr = XvQueryPortAttributes(qt_xdisplay(),
|
|
|
|
|
xv_attr = XvQueryPortAttributes(tqt_xdisplay(),
|
|
|
|
|
xv_port,
|
|
|
|
|
&xv_encoding_attributes);
|
|
|
|
|
XvAttribute *xvattr = (XvAttribute *)xv_attr;
|
|
|
|
@ -438,7 +438,7 @@ bool KXvDevice::init()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XvImageFormatValues *fo;
|
|
|
|
|
fo = XvListImageFormats(qt_xdisplay(), xv_port, &xv_formats);
|
|
|
|
|
fo = XvListImageFormats(tqt_xdisplay(), xv_port, &xv_formats);
|
|
|
|
|
xv_formatvalues = (void *)fo;
|
|
|
|
|
kdDebug() << "Image formats for port " << xv_port << endl;
|
|
|
|
|
for (int i = 0; i < xv_formats; i++) {
|
|
|
|
@ -530,7 +530,7 @@ bool KXvDevice::getAttribute(const TQString& attribute, int *val)
|
|
|
|
|
for (KXvDeviceAttribute *at = _attrs.first(); at != NULL; at = _attrs.next()) {
|
|
|
|
|
if (at->name == attribute) {
|
|
|
|
|
if (val)
|
|
|
|
|
XvGetPortAttribute(qt_xdisplay(), xv_port, at->atom(), val);
|
|
|
|
|
XvGetPortAttribute(tqt_xdisplay(), xv_port, at->atom(), val);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -546,8 +546,8 @@ bool KXvDevice::setAttribute(const TQString& attribute, int val)
|
|
|
|
|
#else
|
|
|
|
|
for (KXvDeviceAttribute *at = _attrs.first(); at != NULL; at = _attrs.next()) {
|
|
|
|
|
if (at->name == attribute) {
|
|
|
|
|
XvSetPortAttribute(qt_xdisplay(), xv_port, at->atom(), val);
|
|
|
|
|
XSync(qt_xdisplay(), False);
|
|
|
|
|
XvSetPortAttribute(tqt_xdisplay(), xv_port, at->atom(), val);
|
|
|
|
|
XSync(tqt_xdisplay(), False);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -581,7 +581,7 @@ bool KXvDevice::encoding(TQString& encoding)
|
|
|
|
|
|
|
|
|
|
for (KXvDeviceAttribute *at = _attrs.first(); at != 0L; at = _attrs.next()) {
|
|
|
|
|
if (at->name == "XV_ENCODING") {
|
|
|
|
|
XvGetPortAttribute(qt_xdisplay(), xv_port, at->atom(), (int*)&enc);
|
|
|
|
|
XvGetPortAttribute(tqt_xdisplay(), xv_port, at->atom(), (int*)&enc);
|
|
|
|
|
kdDebug() << "KXvDevice: encoding: " << enc << endl;
|
|
|
|
|
encoding = enc;
|
|
|
|
|
return true;
|
|
|
|
@ -643,7 +643,7 @@ void KXvDevice::rebuildImage(int w, int h, bool shm)
|
|
|
|
|
}
|
|
|
|
|
#ifdef HAVE_LIBXV
|
|
|
|
|
if (!shm) {
|
|
|
|
|
xv_image = (void*)XvCreateImage(qt_xdisplay(), xv_port, xv_imageformat,
|
|
|
|
|
xv_image = (void*)XvCreateImage(tqt_xdisplay(), xv_port, xv_imageformat,
|
|
|
|
|
0, w, h);
|
|
|
|
|
if (!xv_image) {
|
|
|
|
|
kdWarning() << "KXvDevice::rebuildImage: XvCreateImage failed." << endl;
|
|
|
|
@ -651,13 +651,13 @@ void KXvDevice::rebuildImage(int w, int h, bool shm)
|
|
|
|
|
} else {
|
|
|
|
|
#ifdef HAVE_XSHM
|
|
|
|
|
memset(xv_shminfo, 0, sizeof(XShmSegmentInfo));
|
|
|
|
|
xv_image = (void*)XvShmCreateImage(qt_xdisplay(), xv_port, xv_imageformat,
|
|
|
|
|
xv_image = (void*)XvShmCreateImage(tqt_xdisplay(), xv_port, xv_imageformat,
|
|
|
|
|
0, w, h, static_cast<XShmSegmentInfo*>(xv_shminfo));
|
|
|
|
|
if (!xv_image) {
|
|
|
|
|
kdWarning() << "KXvDevice::rebuildImage: Error using SHM with Xv! Disabling SHM..." << endl;
|
|
|
|
|
_haveShm = false;
|
|
|
|
|
_shm = false;
|
|
|
|
|
xv_image = (void*)XvCreateImage(qt_xdisplay(), xv_port, xv_imageformat,
|
|
|
|
|
xv_image = (void*)XvCreateImage(tqt_xdisplay(), xv_port, xv_imageformat,
|
|
|
|
|
0, w, h);
|
|
|
|
|
if (!xv_image) {
|
|
|
|
|
kdWarning() << "KXvDevice::rebuildImage: XvCreateImage failed." << endl;
|
|
|
|
@ -672,8 +672,8 @@ void KXvDevice::rebuildImage(int w, int h, bool shm)
|
|
|
|
|
static_cast<XShmSegmentInfo*>(xv_shminfo)->readOnly = True;
|
|
|
|
|
static_cast<XvImage*>(xv_image)->data =
|
|
|
|
|
static_cast<XShmSegmentInfo*>(xv_shminfo)->shmaddr;
|
|
|
|
|
XShmAttach(qt_xdisplay(), static_cast<XShmSegmentInfo*>(xv_shminfo));
|
|
|
|
|
XSync(qt_xdisplay(), False);
|
|
|
|
|
XShmAttach(tqt_xdisplay(), static_cast<XShmSegmentInfo*>(xv_shminfo));
|
|
|
|
|
XSync(tqt_xdisplay(), False);
|
|
|
|
|
shmctl(static_cast<XShmSegmentInfo*>(xv_shminfo)->shmid, IPC_RMID, 0);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
@ -707,5 +707,5 @@ void KXvDevice::destroyImage()
|
|
|
|
|
|
|
|
|
|
Atom KXvDeviceAttribute::atom()
|
|
|
|
|
{
|
|
|
|
|
return XInternAtom(qt_xdisplay(), name.latin1(), False);
|
|
|
|
|
return XInternAtom(tqt_xdisplay(), name.latin1(), False);
|
|
|
|
|
}
|
|
|
|
|