Author: branden Date: 2004-05-05 14:08:23 -0500 (Wed, 05 May 2004) New Revision: 1367
Modified: trunk/debian/changelog trunk/debian/patches/000_stolen_from_HEAD.diff Log: Grab updated XVideo (Xv) server-side implementation from XFree86 CVS as of 2003-04-30. + Initialise v4l's XVideo adaptors last (Marc La France). + Reduce cut&paste effects by adding more helpers to Xv (derived from #5645, Bj?\195?\182rn Augustsson, Marc La France). + XvExtension driver cleanups (Marc La France). + Fix precision problems in xf86XVClipVideoHelper (Marc La France). Modified: trunk/debian/changelog =================================================================== --- trunk/debian/changelog 2004-05-05 18:24:36 UTC (rev 1366) +++ trunk/debian/changelog 2004-05-05 19:08:23 UTC (rev 1367) @@ -27,12 +27,20 @@ * Grab updated XFree86 X server I2C code from XFree86 CVS as of 2003-08-29. Implements and exposes xf86I2CGetScreenBuses() function. + * Grab updated XVideo (Xv) server-side implementation from XFree86 CVS as of + 2003-04-30. + + Initialise v4l's XVideo adaptors last (Marc La France). + + Reduce cut&paste effects by adding more helpers to Xv (derived from + #5645, Björn Augustsson, Marc La France). + + XvExtension driver cleanups (Marc La France). + + Fix precision problems in xf86XVClipVideoHelper (Marc La France). + Changes by Fabio Massimo Di Nitto: * Update xutils's package description to refer to bdftruncate and ucs2any programs by their correct names. - -- Branden Robinson <[EMAIL PROTECTED]> Wed, 5 May 2004 13:15:17 -0500 + -- Branden Robinson <[EMAIL PROTECTED]> Wed, 5 May 2004 14:04:36 -0500 xfree86 (4.3.0.dfsg.1-1) unstable; urgency=low Modified: trunk/debian/patches/000_stolen_from_HEAD.diff =================================================================== --- trunk/debian/patches/000_stolen_from_HEAD.diff 2004-05-05 18:24:36 UTC (rev 1366) +++ trunk/debian/patches/000_stolen_from_HEAD.diff 2004-05-05 19:08:23 UTC (rev 1367) @@ -153,6 +153,19 @@ [This incompatibility is not relevant to Debian as we are "skipping over" the misspelled symbol name.] +xc/programs/Xserver/hw/xfree86/common/fourcc.h @ 1.4 +xc/programs/Xserver/hw/xfree86/common/xf86xv.c @ 1.34 +xc/programs/Xserver/hw/xfree86/common/xf86xv.h @ 1.24 +xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c @ 1.4 +xc/programs/Xserver/hw/xfree86/common/xf86xvpriv.h @ 1.1 + 129. Initialise v4l's XVideo adaptors last (Marc La France). + 128. Reduce cut&paste effects by adding more helpers to Xv + (derived from #5645, Bj?rn Augustsson, Marc La France). + 126. [...] XvExtension driver cleanups (Marc La France). + +xc/programs/Xserver/hw/xfree86/common/xf86xv.c @ 1.35 + 156. Fix precision problems in xf86XVClipVideoHelper [...] (Marc La France). + diff -urN xc.orig/config/imake/imake.c xc/config/imake/imake.c --- xc.orig/config/imake/imake.c 2002-12-17 09:48:27.000000000 +1100 +++ xc/config/imake/imake.c 2003-04-09 01:58:14.000000000 +1000 @@ -2231,3 +2244,1706 @@ /* I2C slave devices */ +Index: xc/programs/Xserver/hw/xfree86/common/xf86xv.c +=================================================================== +RCS file: /cvs/xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v +retrieving revision 1.33 +retrieving revision 1.35 +diff -u -r1.33 -r1.35 +--- xc/programs/Xserver/hw/xfree86/common/xf86xv.c 9 Nov 2002 01:18:11 -0000 1.33 ++++ xc/programs/Xserver/hw/xfree86/common/xf86xv.c 30 Apr 2003 16:56:25 -0000 1.35 +@@ -1,12 +1,12 @@ +-/* ++/* + +- XFree86 Xv DDX written by Mark Vojkovich ([EMAIL PROTECTED]) ++ XFree86 Xv DDX written by Mark Vojkovich ([EMAIL PROTECTED]) + + Copyright (C) 1998, 1999 - The XFree86 Project Inc. + + */ + +-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.33 2002/11/09 01:18:11 keithp Exp $ */ ++/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.35 2003/04/30 16:56:25 tsi Exp $ */ + + #include "misc.h" + #include "xf86.h" +@@ -31,7 +31,7 @@ + #include "xvmodproc.h" + #endif + +-#include "xf86xv.h" ++#include "xf86xvpriv.h" + + + /* XvScreenRec fields */ +@@ -44,29 +44,29 @@ + static int xf86XVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*); + static int xf86XVFreePort(XvPortPtr); + static int xf86XVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, +- INT16, INT16, CARD16, CARD16, ++ INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + static int xf86XVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, +- INT16, INT16, CARD16, CARD16, ++ INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + static int xf86XVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, +- INT16, INT16, CARD16, CARD16, ++ INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + static int xf86XVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr, +- INT16, INT16, CARD16, CARD16, ++ INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16); + static int xf86XVStopVideo(ClientPtr, XvPortPtr, DrawablePtr); + static int xf86XVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32); + static int xf86XVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32*); + static int xf86XVQueryBestSize(ClientPtr, XvPortPtr, CARD8, +- CARD16, CARD16,CARD16, CARD16, ++ CARD16, CARD16,CARD16, CARD16, + unsigned int*, unsigned int*); + static int xf86XVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr, +- INT16, INT16, CARD16, CARD16, ++ INT16, INT16, CARD16, CARD16, + INT16, INT16, CARD16, CARD16, + XvImagePtr, unsigned char*, Bool, + CARD16, CARD16); +-static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr, ++static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr, + CARD16*, CARD16*, int*, int*); + + +@@ -107,7 +107,7 @@ + ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr)) + + #define GET_XF86XV_SCREEN(pScreen) \ +- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) ++ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr)) + + #define GET_XF86XV_WINDOW(pWin) \ + ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr)) +@@ -121,12 +121,12 @@ + ){ + xf86XVInitGenericAdaptorPtr *newdrivers; + +- newdrivers = xrealloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) * ++ newdrivers = xrealloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) * + (1 + NumGenDrivers)); + if (!newdrivers) + return 0; + GenDrivers = newdrivers; +- ++ + GenDrivers[NumGenDrivers++] = InitFunc; + + return 1; +@@ -134,7 +134,7 @@ + + int + xf86XVListGenericAdaptors( +- ScrnInfoPtr pScrn, ++ ScrnInfoPtr pScrn, + XF86VideoAdaptorPtr **adaptors + ){ + int i,j,n,num; +@@ -142,8 +142,13 @@ + + num = 0; + *adaptors = NULL; +- for (i = 0; i < NumGenDrivers; i++) { +- n = GenDrivers[i](pScrn,&DrivAdap); ++ /* ++ * The v4l driver registers itself first, but can use surfaces registered ++ * by other drivers. So, call the v4l driver last. ++ */ ++ for (i = NumGenDrivers; --i >= 0; ) { ++ DrivAdap = NULL; ++ n = (*GenDrivers[i])(pScrn, &DrivAdap); + if (0 == n) + continue; + new = xrealloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num+n)); +@@ -156,6 +161,38 @@ + return num; + } + ++ ++/**************** Offscreen surface stuff *******************/ ++ ++typedef struct { ++ XF86OffscreenImagePtr images; ++ int num; ++} OffscreenImageRec; ++ ++static OffscreenImageRec OffscreenImages[MAXSCREENS]; ++ ++Bool ++xf86XVRegisterOffscreenImages( ++ ScreenPtr pScreen, ++ XF86OffscreenImagePtr images, ++ int num ++){ ++ OffscreenImages[pScreen->myNum].num = num; ++ OffscreenImages[pScreen->myNum].images = images; ++ ++ return TRUE; ++} ++ ++XF86OffscreenImagePtr ++xf86XVQueryOffscreenImages( ++ ScreenPtr pScreen, ++ int *num ++){ ++ *num = OffscreenImages[pScreen->myNum].num; ++ return OffscreenImages[pScreen->myNum].images; ++} ++ ++ + XF86VideoAdaptorPtr + xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn) + { +@@ -171,7 +208,7 @@ + + Bool + xf86XVScreenInit( +- ScreenPtr pScreen, ++ ScreenPtr pScreen, + XF86VideoAdaptorPtr *adaptors, + int num + ){ +@@ -181,7 +218,7 @@ + + if(num <= 0 || + !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc) +- return FALSE; ++ return FALSE; + + if(XF86XVGeneration != serverGeneration) { + if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0) +@@ -190,7 +227,7 @@ + } + + if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0)) +- return FALSE; ++ return FALSE; + + if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; + +@@ -245,31 +282,28 @@ + { + int i; + +- if(pAdaptor->name) +- xfree(pAdaptor->name); ++ xfree(pAdaptor->name); + + if(pAdaptor->pEncodings) { + XvEncodingPtr pEncode = pAdaptor->pEncodings; + +- for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) { +- if(pEncode->name) xfree(pEncode->name); +- } ++ for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) ++ xfree(pEncode->name); + xfree(pAdaptor->pEncodings); + } + +- if(pAdaptor->pFormats) +- xfree(pAdaptor->pFormats); ++ xfree(pAdaptor->pFormats); + + if(pAdaptor->pPorts) { + XvPortPtr pPort = pAdaptor->pPorts; + XvPortRecPrivatePtr pPriv; + + for(i = 0; i < pAdaptor->nPorts; i++, pPort++) { +- pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; ++ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr; + if(pPriv) { +- if(pPriv->clientClip) ++ if(pPriv->clientClip) + REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip); +- if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) ++ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip) + REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip); + xfree(pPriv); + } +@@ -280,23 +314,18 @@ + if(pAdaptor->nAttributes) { + XvAttributePtr pAttribute = pAdaptor->pAttributes; + +- for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) { +- if(pAttribute->name) xfree(pAttribute->name); +- } +- ++ for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) ++ xfree(pAttribute->name); + xfree(pAdaptor->pAttributes); + } + +- if(pAdaptor->nImages) +- xfree(pAdaptor->pImages); +- +- if(pAdaptor->devPriv.ptr) +- xfree(pAdaptor->devPriv.ptr); ++ xfree(pAdaptor->pImages); ++ xfree(pAdaptor->devPriv.ptr); + } + + static Bool + xf86XVInitAdaptors( +- ScreenPtr pScreen, ++ ScreenPtr pScreen, + XF86VideoAdaptorPtr *infoPtr, + int number + ) { +@@ -325,7 +354,7 @@ + pxvs->nAdaptors = 0; + pxvs->pAdaptors = NULL; + +- if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec)))) ++ if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec)))) + return FALSE; + + for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) { +@@ -339,7 +368,7 @@ + if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings) + continue; + +- pa->type = adaptorPtr->type; ++ pa->type = adaptorPtr->type; + + if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo) + pa->type &= ~XvVideoMask; +@@ -350,19 +379,19 @@ + if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes) + pa->type &= ~XvImageMask; + +- if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage && ++ if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage && + !adaptorPtr->PutStill) + pa->type &= ~XvInputMask; + + if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill) + pa->type &= ~XvOutputMask; +- +- if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask))) ++ ++ if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask))) + continue; +- if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask))) ++ if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask))) + continue; + +- pa->pScreen = pScreen; ++ pa->pScreen = pScreen; + pa->ddAllocatePort = xf86XVAllocatePort; + pa->ddFreePort = xf86XVFreePort; + pa->ddPutVideo = xf86XVPutVideo; +@@ -376,33 +405,33 @@ + pa->ddQueryBestSize = xf86XVQueryBestSize; + pa->ddQueryImageAttributes = xf86XVQueryImageAttributes; + if((pa->name = xalloc(strlen(adaptorPtr->name) + 1))) +- strcpy(pa->name, adaptorPtr->name); ++ strcpy(pa->name, adaptorPtr->name); + + if(adaptorPtr->nEncodings && + (pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) { + +- for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0; +- i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) +- { ++ for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0; ++ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++) ++ { + pe->id = encodingPtr->id; + pe->pScreen = pScreen; + if((pe->name = xalloc(strlen(encodingPtr->name) + 1))) +- strcpy(pe->name, encodingPtr->name); ++ strcpy(pe->name, encodingPtr->name); + pe->width = encodingPtr->width; + pe->height = encodingPtr->height; + pe->rate.numerator = encodingPtr->rate.numerator; + pe->rate.denominator = encodingPtr->rate.denominator; + } + pa->nEncodings = adaptorPtr->nEncodings; +- pa->pEncodings = pEncode; +- } ++ pa->pEncodings = pEncode; ++ } + + if(adaptorPtr->nImages && +- (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) { ++ (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) { + +- for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages; +- i < adaptorPtr->nImages; i++, pi++, imagePtr++) +- { ++ for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages; ++ i < adaptorPtr->nImages; i++, pi++, imagePtr++) ++ { + pi->id = imagePtr->id; + pi->type = imagePtr->type; + pi->byte_order = imagePtr->byte_order; +@@ -425,7 +454,7 @@ + pi->vert_v_period = imagePtr->vert_v_period; + memcpy(pi->component_order, imagePtr->component_order, 32); + pi->scanline_order = imagePtr->scanline_order; +- } ++ } + pa->nImages = adaptorPtr->nImages; + pa->pImages = pImage; + } +@@ -433,65 +462,65 @@ + if(adaptorPtr->nAttributes && + (pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec)))) + { +- for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0; +- i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) +- { ++ for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0; ++ i < adaptorPtr->nAttributes; pat++, i++, attributePtr++) ++ { + pat->flags = attributePtr->flags; + pat->min_value = attributePtr->min_value; + pat->max_value = attributePtr->max_value; + if((pat->name = xalloc(strlen(attributePtr->name) + 1))) +- strcpy(pat->name, attributePtr->name); ++ strcpy(pat->name, attributePtr->name); + } + pa->nAttributes = adaptorPtr->nAttributes; +- pa->pAttributes = pAttribute; +- } ++ pa->pAttributes = pAttribute; ++ } + + + totFormat = adaptorPtr->nFormats; + + if(!(pFormat = xcalloc(totFormat, sizeof(XvFormatRec)))) { +- xf86XVFreeAdaptor(pa); +- continue; ++ xf86XVFreeAdaptor(pa); ++ continue; + } +- for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats; +- i < adaptorPtr->nFormats; i++, formatPtr++) ++ for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats; ++ i < adaptorPtr->nFormats; i++, formatPtr++) + { + numVisuals = pScreen->numVisuals; +- pVisual = pScreen->visuals; ++ pVisual = pScreen->visuals; + +- while(numVisuals--) { +- if((pVisual->class == formatPtr->class) && +- (pVisual->nplanes == formatPtr->depth)) { ++ while(numVisuals--) { ++ if((pVisual->class == formatPtr->class) && ++ (pVisual->nplanes == formatPtr->depth)) { + + if(numFormat >= totFormat) { +- void *moreSpace; ++ void *moreSpace; + totFormat *= 2; +- moreSpace = xrealloc(pFormat, ++ moreSpace = xrealloc(pFormat, + totFormat * sizeof(XvFormatRec)); + if(!moreSpace) break; + pFormat = moreSpace; + pf = pFormat + numFormat; + } + +- pf->visual = pVisual->vid; ++ pf->visual = pVisual->vid; + pf->depth = formatPtr->depth; + + pf++; + numFormat++; +- } +- pVisual++; +- } ++ } ++ pVisual++; ++ } + } + pa->nFormats = numFormat; +- pa->pFormats = pFormat; ++ pa->pFormats = pFormat; + if(!numFormat) { +- xf86XVFreeAdaptor(pa); +- continue; ++ xf86XVFreeAdaptor(pa); ++ continue; + } + + if(!(adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate)))) { +- xf86XVFreeAdaptor(pa); +- continue; ++ xf86XVFreeAdaptor(pa); ++ continue; + } + + adaptorPriv->flags = adaptorPtr->flags; +@@ -510,47 +539,47 @@ + pa->devPriv.ptr = (pointer)adaptorPriv; + + if(!(pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) { +- xf86XVFreeAdaptor(pa); +- continue; ++ xf86XVFreeAdaptor(pa); ++ continue; + } +- for(pp = pPort, i = 0, numPort = 0; ++ for(pp = pPort, i = 0, numPort = 0; + i < adaptorPtr->nPorts; i++) { + +- if(!(pp->id = FakeClientID(0))) ++ if(!(pp->id = FakeClientID(0))) + continue; + +- if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate)))) ++ if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate)))) + continue; +- ++ + if(!AddResource(pp->id, PortResource, pp)) { + xfree(portPriv); + continue; + } + +- pp->pAdaptor = pa; +- pp->pNotify = (XvPortNotifyPtr)NULL; +- pp->pDraw = (DrawablePtr)NULL; +- pp->client = (ClientPtr)NULL; +- pp->grab.client = (ClientPtr)NULL; +- pp->time = currentTime; +- pp->devPriv.ptr = portPriv; ++ pp->pAdaptor = pa; ++ pp->pNotify = (XvPortNotifyPtr)NULL; ++ pp->pDraw = (DrawablePtr)NULL; ++ pp->client = (ClientPtr)NULL; ++ pp->grab.client = (ClientPtr)NULL; ++ pp->time = currentTime; ++ pp->devPriv.ptr = portPriv; + + portPriv->pScrn = pScrn; + portPriv->AdaptorRec = adaptorPriv; +- portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr; +- +- pp++; +- numPort++; ++ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr; ++ ++ pp++; ++ numPort++; + } + pa->nPorts = numPort; + pa->pPorts = pPort; + if(!numPort) { +- xf86XVFreeAdaptor(pa); +- continue; ++ xf86XVFreeAdaptor(pa); ++ continue; + } + + pa->base_id = pPort->id; +- ++ + pa++; + numAdaptor++; + } +@@ -576,18 +605,18 @@ + the GC and used it's clip list when they needed to reclip the window, + even if the client clip was different from the one the video was + initialized with. If the original GC was destroyed, they had to stop +- the video. I like the new method better (MArk). ++ the video. I like the new method better (MArk). + + This function only works for windows. Will need to rewrite when + (if) we support pixmap rendering. + */ + +-static void ++static void + xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv) + { + RegionPtr pregWin, pCompositeClip; + WindowPtr pWin; +- Bool freeCompClip = FALSE; ++ Bool freeCompClip = FALSE; + + if(portPriv->pCompositeClip) + return; +@@ -618,8 +647,8 @@ + portPriv->FreeCompositeClip = TRUE; + + if(freeCompClip) { +- REGION_DESTROY(pWin->pScreen, pregWin); +- } ++ REGION_DESTROY(pWin->pScreen, pregWin); ++ } + } + + /* Save the current clientClip and update the CompositeClip whenever +@@ -627,7 +656,7 @@ + + static void + xf86XVCopyClip( +- XvPortRecPrivatePtr portPriv, ++ XvPortRecPrivatePtr portPriv, + GCPtr pGC + ){ + /* copy the new clip if it exists */ +@@ -670,12 +699,12 @@ + WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; + WinBox.x2 = WinBox.x1 + portPriv->drw_w; + WinBox.y2 = WinBox.y1 + portPriv->drw_h; +- ++ + /* clip to the window composite clip */ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_INIT(pScreen, &ClipRegion, NullBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); +- ++ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); ++ + /* that's all if it's totally obscured */ + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; +@@ -686,11 +715,11 @@ + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + +- ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn, +- portPriv->vid_x, portPriv->vid_y, +- WinBox.x1, WinBox.y1, +- portPriv->vid_w, portPriv->vid_h, +- portPriv->drw_w, portPriv->drw_h, ++ ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn, ++ portPriv->vid_x, portPriv->vid_y, ++ WinBox.x1, WinBox.y1, ++ portPriv->vid_w, portPriv->vid_h, ++ portPriv->drw_w, portPriv->drw_h, + &ClipRegion, portPriv->DevPriv.ptr); + + if(ret == Success) +@@ -734,27 +763,27 @@ + WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; + WinBox.x2 = WinBox.x1 + portPriv->drw_w; + WinBox.y2 = WinBox.y1 + portPriv->drw_h; +- ++ + /* clip to the window composite clip */ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_INIT(pScreen, &ClipRegion, NullBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); ++ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); + + /* clip and translate to the viewport */ + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + +- VPBox.x1 = portPriv->pScrn->frameX0; ++ VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; +- VPBox.x2 = portPriv->pScrn->frameX1; ++ VPBox.x2 = portPriv->pScrn->frameX1; + VPBox.y2 = portPriv->pScrn->frameY1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); ++ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } +- ++ + /* that's all if it's totally obscured */ + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; +@@ -765,8 +794,8 @@ + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || +- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || +- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) ++ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || ++ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; +@@ -777,11 +806,11 @@ + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + +- ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn, +- portPriv->vid_x, portPriv->vid_y, ++ ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn, ++ portPriv->vid_x, portPriv->vid_y, + WinBox.x1, WinBox.y1, +- portPriv->vid_w, portPriv->vid_h, +- portPriv->drw_w, portPriv->drw_h, ++ portPriv->vid_w, portPriv->vid_h, ++ portPriv->drw_w, portPriv->drw_h, + &ClipRegion, portPriv->DevPriv.ptr); + + if(ret == Success) portPriv->isOn = XV_ON; +@@ -823,27 +852,27 @@ + WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y; + WinBox.x2 = WinBox.x1 + portPriv->drw_w; + WinBox.y2 = WinBox.y1 + portPriv->drw_h; +- ++ + /* clip to the window composite clip */ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_INIT(pScreen, &ClipRegion, NullBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); ++ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip); + + /* clip and translate to the viewport */ + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + +- VPBox.x1 = portPriv->pScrn->frameX0; ++ VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; +- VPBox.x2 = portPriv->pScrn->frameX1; ++ VPBox.x2 = portPriv->pScrn->frameX1; + VPBox.y2 = portPriv->pScrn->frameY1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); ++ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } +- ++ + /* that's all if it's totally obscured */ + if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) { + clippedAway = TRUE; +@@ -854,8 +883,8 @@ + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || +- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || +- (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) ++ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || ++ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; + goto CLIP_VIDEO_BAILOUT; +@@ -866,7 +895,7 @@ + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + +- ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn, ++ ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn, + WinBox.x1, WinBox.y1, + &ClipRegion, portPriv->DevPriv.ptr); + +@@ -910,7 +939,7 @@ + static int + xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv) + { +- XF86XVWindowPtr winPriv, PrivRoot; ++ XF86XVWindowPtr winPriv, PrivRoot; + + winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin); + +@@ -927,7 +956,7 @@ + winPriv->PortRec = portPriv; + winPriv->next = PrivRoot; + pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv; +- } ++ } + return Success; + } + +@@ -941,15 +970,15 @@ + + while(winPriv) { + if(winPriv->PortRec == portPriv) { +- if(prevPriv) ++ if(prevPriv) + prevPriv->next = winPriv->next; +- else +- pWin->devPrivates[XF86XVWindowIndex].ptr = ++ else ++ pWin->devPrivates[XF86XVWindowIndex].ptr = + (pointer)winPriv->next; + xfree(winPriv); + break; + } +- prevPriv = winPriv; ++ prevPriv = winPriv; + winPriv = winPriv->next; + } + portPriv->pDraw = NULL; +@@ -1008,7 +1037,7 @@ + + /* filter out XClearWindow/Area */ + if (!pWin->valdata) return; +- ++ + pPrev = NULL; + + while(WinPriv) { +@@ -1019,10 +1048,10 @@ + switch(pPriv->type) { + case XvInputMask: + xf86XVReputVideo(pPriv); +- break; ++ break; + case XvOutputMask: +- xf86XVRegetVideo(pPriv); +- break; ++ xf86XVRegetVideo(pPriv); ++ break; + default: /* overlaid still/image*/ + if (pPriv->AdaptorRec->ReputImage) + xf86XVReputImage(pPriv); +@@ -1036,8 +1065,8 @@ + } + pPriv->pDraw = NULL; + +- if(!pPrev) +- pWin->devPrivates[XF86XVWindowIndex].ptr = ++ if(!pPrev) ++ pWin->devPrivates[XF86XVWindowIndex].ptr = + (pointer)(WinPriv->next); + else + pPrev->next = WinPriv->next; +@@ -1054,7 +1083,7 @@ + } + + +-static void ++static void + xf86XVClipNotify(WindowPtr pWin, int dx, int dy) + { + ScreenPtr pScreen = pWin->drawable.pScreen; +@@ -1073,7 +1102,7 @@ + + pPriv->pCompositeClip = NULL; + +- /* Stop everything except images, but stop them too if the ++ /* Stop everything except images, but stop them too if the + window isn't visible. But we only remove the images. */ + + if(pPriv->type || !visible) { +@@ -1086,8 +1115,8 @@ + if(!pPriv->type) { /* overlaid still/image */ + pPriv->pDraw = NULL; + +- if(!pPrev) +- pWin->devPrivates[XF86XVWindowIndex].ptr = ++ if(!pPrev) ++ pWin->devPrivates[XF86XVWindowIndex].ptr = + (pointer)(WinPriv->next); + else + pPrev->next = WinPriv->next; +@@ -1122,6 +1151,9 @@ + XvAdaptorPtr pa; + int c; + ++ /* Clear offscreen images */ ++ (void)memset(&OffscreenImages[pScreen->myNum], 0, sizeof(OffscreenImages[0])); ++ + if(!ScreenPriv) return TRUE; + + if(ScreenPriv->videoGC) { +@@ -1133,20 +1165,16 @@ + pScreen->WindowExposures = ScreenPriv->WindowExposures; + pScreen->ClipNotify = ScreenPriv->ClipNotify; + +- pScrn->EnterVT = ScreenPriv->EnterVT; +- pScrn->LeaveVT = ScreenPriv->LeaveVT; ++ pScrn->EnterVT = ScreenPriv->EnterVT; ++ pScrn->LeaveVT = ScreenPriv->LeaveVT; + pScrn->AdjustFrame = ScreenPriv->AdjustFrame; + +- for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) { ++ for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) { + xf86XVFreeAdaptor(pa); + } + +- if(pxvs->pAdaptors) +- xfree(pxvs->pAdaptors); +- ++ xfree(pxvs->pAdaptors); + xfree(ScreenPriv); +- +- + return TRUE; + } + +@@ -1168,7 +1196,7 @@ + + /**** ScrnInfoRec fields ****/ + +-static Bool ++static Bool + xf86XVEnterVT(int index, int flags) + { + ScreenPtr pScreen = screenInfo.screens[index]; +@@ -1177,12 +1205,12 @@ + + ret = (*ScreenPriv->EnterVT)(index, flags); + +- if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0); +- ++ if(ret) WalkTree(pScreen, xf86XVReputAllVideo, 0); ++ + return ret; + } + +-static void ++static void + xf86XVLeaveVT(int index, int flags) + { + ScreenPtr pScreen = screenInfo.screens[index]; +@@ -1229,14 +1257,14 @@ + WindowPtr pWin; + XvAdaptorPtr pa; + int c, i; +- ++ + if(ScreenPriv->AdjustFrame) { + pScrn->AdjustFrame = ScreenPriv->AdjustFrame; + (*pScrn->AdjustFrame)(index, x, y, flags); + pScrn->AdjustFrame = xf86XVAdjustFrame; + } +- +- for(c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) { ++ ++ for(c = pxvs->nAdaptors, pa = pxvs->pAdaptors; c > 0; c--, pa++) { + XvPortPtr pPort = pa->pPorts; + XvPortRecPrivatePtr pPriv; + +@@ -1254,7 +1282,7 @@ + + if ((pPriv->AdaptorRec->ReputImage) && + ((pWin->visibility == VisibilityUnobscured) || +- (pWin->visibility == VisibilityPartiallyObscured))) ++ (pWin->visibility == VisibilityPartiallyObscured))) + { + xf86XVReputImage(pPriv); + } else { +@@ -1297,8 +1325,8 @@ + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, +- INT16 vid_x, INT16 vid_y, +- CARD16 vid_w, CARD16 vid_h, ++ INT16 vid_x, INT16 vid_y, ++ CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h + ){ +@@ -1310,7 +1338,7 @@ + pPort->pDraw = (DrawablePtr)NULL; + return BadAlloc; + } +- ++ + /* If we are changing windows, unregister our port in the old window */ + if(portPriv->pDraw && (portPriv->pDraw != pDraw)) + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); +@@ -1333,7 +1361,7 @@ + + /* To indicate to the DI layer that we were successful */ + pPort->pDraw = pDraw; +- ++ + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + return(xf86XVReputVideo(portPriv)); +@@ -1345,8 +1373,8 @@ + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, +- INT16 vid_x, INT16 vid_y, +- CARD16 vid_w, CARD16 vid_h, ++ INT16 vid_x, INT16 vid_y, ++ CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h + ){ +@@ -1369,22 +1397,22 @@ + WinBox.y1 = pDraw->y + drw_y; + WinBox.x2 = WinBox.x1 + drw_w; + WinBox.y2 = WinBox.y1 + drw_h; +- ++ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_INIT(pScreen, &ClipRegion, NullBox, 1); +- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); ++ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); + + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + +- VPBox.x1 = portPriv->pScrn->frameX0; ++ VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; +- VPBox.x2 = portPriv->pScrn->frameX1; ++ VPBox.x2 = portPriv->pScrn->frameX1; + VPBox.y2 = portPriv->pScrn->frameY1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); ++ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } + +@@ -1400,11 +1428,11 @@ + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || +- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || ++ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || + (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; +- goto PUT_STILL_BAILOUT; ++ goto PUT_STILL_BAILOUT; + } + } + +@@ -1412,7 +1440,7 @@ + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + +- ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn, ++ ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn, + vid_x, vid_y, WinBox.x1, WinBox.y1, + vid_w, vid_h, drw_w, drw_h, + &ClipRegion, portPriv->DevPriv.ptr); +@@ -1433,9 +1461,9 @@ + PUT_STILL_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { +- (*portPriv->AdaptorRec->StopVideo)( +- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); +- portPriv->isOn = XV_PENDING; ++ (*portPriv->AdaptorRec->StopVideo)( ++ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); ++ portPriv->isOn = XV_PENDING; + } + + REGION_UNINIT(pScreen, &WinRegion); +@@ -1450,8 +1478,8 @@ + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, +- INT16 vid_x, INT16 vid_y, +- CARD16 vid_w, CARD16 vid_h, ++ INT16 vid_x, INT16 vid_y, ++ CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h + ){ +@@ -1463,7 +1491,7 @@ + pPort->pDraw = (DrawablePtr)NULL; + return BadAlloc; + } +- ++ + /* If we are changing windows, unregister our port in the old window */ + if(portPriv->pDraw && (portPriv->pDraw != pDraw)) + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); +@@ -1486,7 +1514,7 @@ + + /* To indicate to the DI layer that we were successful */ + pPort->pDraw = pDraw; +- ++ + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ + + return(xf86XVRegetVideo(portPriv)); +@@ -1498,8 +1526,8 @@ + DrawablePtr pDraw, + XvPortPtr pPort, + GCPtr pGC, +- INT16 vid_x, INT16 vid_y, +- CARD16 vid_w, CARD16 vid_h, ++ INT16 vid_x, INT16 vid_y, ++ CARD16 vid_w, CARD16 vid_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h + ){ +@@ -1522,10 +1550,10 @@ + WinBox.y1 = pDraw->y + drw_y; + WinBox.x2 = WinBox.x1 + drw_w; + WinBox.y2 = WinBox.y1 + drw_h; +- ++ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_INIT(pScreen, &ClipRegion, NullBox, 1); +- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); ++ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); + + if(portPriv->pDraw) { + xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv); +@@ -1548,9 +1576,9 @@ + GET_STILL_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { +- (*portPriv->AdaptorRec->StopVideo)( +- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); +- portPriv->isOn = XV_PENDING; ++ (*portPriv->AdaptorRec->StopVideo)( ++ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); ++ portPriv->isOn = XV_PENDING; + } + + REGION_UNINIT(pScreen, &WinRegion); +@@ -1559,7 +1587,7 @@ + return ret; + } + +- ++ + + static int + xf86XVStopVideo( +@@ -1571,7 +1599,7 @@ + + if(pDraw->type != DRAWABLE_WINDOW) + return BadAlloc; +- ++ + xf86XVRemovePortFromWindow((WindowPtr)pDraw, portPriv); + + if(!portPriv->pScrn->vtSema) return Success; /* Success ? */ +@@ -1595,8 +1623,8 @@ + INT32 value + ){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); +- +- return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn, ++ ++ return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->pScrn, + attribute, value, portPriv->DevPriv.ptr)); + } + +@@ -1609,8 +1637,8 @@ + INT32 *p_value + ){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); +- +- return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn, ++ ++ return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->pScrn, + attribute, p_value, portPriv->DevPriv.ptr)); + } + +@@ -1626,8 +1654,8 @@ + unsigned int *p_w, unsigned int *p_h + ){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); +- +- (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn, ++ ++ (*portPriv->AdaptorRec->QueryBestSize)(portPriv->pScrn, + (Bool)motion, vid_w, vid_h, drw_w, drw_h, + p_w, p_h, portPriv->DevPriv.ptr); + +@@ -1635,14 +1663,14 @@ + } + + +-static int ++static int + xf86XVPutImage( +- ClientPtr client, +- DrawablePtr pDraw, +- XvPortPtr pPort, ++ ClientPtr client, ++ DrawablePtr pDraw, ++ XvPortPtr pPort, + GCPtr pGC, +- INT16 src_x, INT16 src_y, +- CARD16 src_w, CARD16 src_h, ++ INT16 src_x, INT16 src_y, ++ CARD16 src_w, CARD16 src_h, + INT16 drw_x, INT16 drw_y, + CARD16 drw_w, CARD16 drw_h, + XvImagePtr format, +@@ -1669,22 +1697,22 @@ + WinBox.y1 = pDraw->y + drw_y; + WinBox.x2 = WinBox.x1 + drw_w; + WinBox.y2 = WinBox.y1 + drw_h; +- ++ + REGION_INIT(pScreen, &WinRegion, &WinBox, 1); + REGION_INIT(pScreen, &ClipRegion, NullBox, 1); +- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); ++ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip); + + if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) { + RegionRec VPReg; + BoxRec VPBox; + +- VPBox.x1 = portPriv->pScrn->frameX0; ++ VPBox.x1 = portPriv->pScrn->frameX0; + VPBox.y1 = portPriv->pScrn->frameY0; +- VPBox.x2 = portPriv->pScrn->frameX1 + 1; ++ VPBox.x2 = portPriv->pScrn->frameX1 + 1; + VPBox.y2 = portPriv->pScrn->frameY1 + 1; + + REGION_INIT(pScreen, &VPReg, &VPBox, 1); +- REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); ++ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg); + REGION_UNINIT(pScreen, &VPReg); + } + +@@ -1700,11 +1728,11 @@ + if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) { + BoxPtr clipBox = REGION_RECTS(&ClipRegion); + if( (REGION_NUM_RECTS(&ClipRegion) != 1) || +- (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || ++ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) || + (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2)) + { + clippedAway = TRUE; +- goto PUT_IMAGE_BAILOUT; ++ goto PUT_IMAGE_BAILOUT; + } + } + +@@ -1712,7 +1740,7 @@ + REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion); + } + +- ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn, ++ ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn, + src_x, src_y, WinBox.x1, WinBox.y1, + src_w, src_h, drw_w, drw_h, format->id, data, width, height, + sync, &ClipRegion, portPriv->DevPriv.ptr); +@@ -1733,9 +1761,9 @@ + PUT_IMAGE_BAILOUT: + + if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) { +- (*portPriv->AdaptorRec->StopVideo)( +- portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); +- portPriv->isOn = XV_PENDING; ++ (*portPriv->AdaptorRec->StopVideo)( ++ portPriv->pScrn, portPriv->DevPriv.ptr, FALSE); ++ portPriv->isOn = XV_PENDING; + } + + REGION_UNINIT(pScreen, &WinRegion); +@@ -1745,19 +1773,19 @@ + } + + +-static int ++static int + xf86XVQueryImageAttributes( +- ClientPtr client, ++ ClientPtr client, + XvPortPtr pPort, +- XvImagePtr format, +- CARD16 *width, +- CARD16 *height, ++ XvImagePtr format, ++ CARD16 *width, ++ CARD16 *height, + int *pitches, + int *offsets + ){ + XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr); + +- return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn, ++ return (*portPriv->AdaptorRec->QueryImageAttributes)(portPriv->pScrn, + format->id, width, height, pitches, offsets); + } + +@@ -1778,7 +1806,7 @@ + pval[0] = key; + pval[1] = IncludeInferiors; + ScreenPriv->videoGC = CreateGC(root, GCForeground | GCSubwindowMode, +- pval, &status); ++ pval, &status); + if(!ScreenPriv->videoGC) return; + ValidateGC(root, ScreenPriv->videoGC); + } else if (key != ScreenPriv->videoGC->fgPixel){ +@@ -1795,20 +1823,20 @@ + rects[i].width = pbox->x2 - pbox->x1; + rects[i].height = pbox->y2 - pbox->y1; + } +- ++ + (*ScreenPriv->videoGC->ops->PolyFillRect)( +- root, ScreenPriv->videoGC, nbox, rects); ++ root, ScreenPriv->videoGC, nbox, rects); + + DEALLOCATE_LOCAL(rects); + } + +-/* xf86XVClipVideoHelper - ++/* xf86XVClipVideoHelper - + + Takes the dst box in standard X BoxRec form (top and left + edges inclusive, bottom and right exclusive). The new dst +- box is returned. The source boundaries are given (x1, y1 +- inclusive, x2, y2 exclusive) and returned are the new source +- boundaries in 16.16 fixed point. ++ box is returned. The source boundaries are given (x1, y1 ++ inclusive, x2, y2 exclusive) and returned are the new source ++ boundaries in 16.16 fixed point. + */ + + #define DummyScreen screenInfo.screens[0] +@@ -1824,112 +1852,169 @@ + INT32 width, + INT32 height + ){ +- INT32 vscale, hscale, delta; ++ double xsw, xdw, ysw, ydw; ++ INT32 delta; + BoxPtr extents = REGION_EXTENTS(DummyScreen, reg); + int diff; + +- hscale = ((*xb - *xa) << 16) / (dst->x2 - dst->x1); +- vscale = ((*yb - *ya) << 16) / (dst->y2 - dst->y1); ++ xsw = (*xb - *xa) << 16; ++ xdw = dst->x2 - dst->x1; ++ ysw = (*yb - *ya) << 16; ++ ydw = dst->y2 - dst->y1; + + *xa <<= 16; *xb <<= 16; + *ya <<= 16; *yb <<= 16; + + diff = extents->x1 - dst->x1; +- if(diff > 0) { +- dst->x1 = extents->x1; +- *xa += diff * hscale; ++ if (diff > 0) { ++ dst->x1 = extents->x1; ++ *xa += (diff * xsw) / xdw; + } + diff = dst->x2 - extents->x2; +- if(diff > 0) { +- dst->x2 = extents->x2; +- *xb -= diff * hscale; ++ if (diff > 0) { ++ dst->x2 = extents->x2; ++ *xb -= (diff * xsw) / xdw; + } + diff = extents->y1 - dst->y1; +- if(diff > 0) { +- dst->y1 = extents->y1; +- *ya += diff * vscale; ++ if (diff > 0) { ++ dst->y1 = extents->y1; ++ *ya += (diff * ysw) / ydw; + } + diff = dst->y2 - extents->y2; +- if(diff > 0) { +- dst->y2 = extents->y2; +- *yb -= diff * vscale; ++ if (diff > 0) { ++ dst->y2 = extents->y2; ++ *yb -= (diff * ysw) / ydw; + } + +- if(*xa < 0) { +- diff = (- *xa + hscale - 1)/ hscale; +- dst->x1 += diff; +- *xa += diff * hscale; ++ if (*xa < 0) { ++ diff = (((-*xa) * xdw) + xsw - 1) / xsw; ++ dst->x1 += diff; ++ *xa += (diff * xsw) / xdw; + } + delta = *xb - (width << 16); +- if(delta > 0) { +- diff = (delta + hscale - 1)/ hscale; +- dst->x2 -= diff; +- *xb -= diff * hscale; ++ if (delta > 0) { ++ diff = ((delta * xdw) + xsw - 1) / xsw; ++ dst->x2 -= diff; ++ *xb -= (diff * xsw) / xdw; + } +- if(*xa >= *xb) return FALSE; ++ if (*xa >= *xb) return FALSE; + +- if(*ya < 0) { +- diff = (- *ya + vscale - 1)/ vscale; +- dst->y1 += diff; +- *ya += diff * vscale; ++ if (*ya < 0) { ++ diff = (((-*ya) * ydw) + ysw - 1) / ysw; ++ dst->y1 += diff; ++ *ya += (diff * ysw) / ydw; + } + delta = *yb - (height << 16); +- if(delta > 0) { +- diff = (delta + vscale - 1)/ vscale; +- dst->y2 -= diff; +- *yb -= diff * vscale; ++ if (delta > 0) { ++ diff = ((delta * ydw) + ysw - 1) / ysw; ++ dst->y2 -= diff; ++ *yb -= (diff * ysw) / ydw; + } +- if(*ya >= *yb) return FALSE; ++ if (*ya >= *yb) return FALSE; + +- if((dst->x1 != extents->x1) || (dst->x2 != extents->x2) || +- (dst->y1 != extents->y1) || (dst->y2 != extents->y2)) ++ if ((dst->x1 > extents->x1) || (dst->x2 < extents->x2) || ++ (dst->y1 > extents->y1) || (dst->y2 < extents->y2)) + { +- RegionRec clipReg; +- REGION_INIT(DummyScreen, &clipReg, dst, 1); +- REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); +- REGION_UNINIT(DummyScreen, &clipReg); ++ RegionRec clipReg; ++ REGION_INIT(DummyScreen, &clipReg, dst, 1); ++ REGION_INTERSECT(DummyScreen, reg, reg, &clipReg); ++ REGION_UNINIT(DummyScreen, &clipReg); + } + return TRUE; + } + ++void ++xf86XVCopyYUV12ToPacked( ++ const void *srcy, ++ const void *srcv, ++ const void *srcu, ++ void *dst, ++ int srcPitchy, ++ int srcPitchuv, ++ int dstPitch, ++ int h, ++ int w ++){ ++ CARD32 *Dst; ++ const CARD8 *Y, *U, *V; ++ int i, j; + +-/**************** Offscreen surface stuff *******************/ ++ w >>= 1; + +-typedef struct { +- XF86OffscreenImagePtr images; +- int num; +-} OffscreenImageRec; ++ for (j = 0; j < h; j++) { ++ Dst = dst; ++ Y = srcy; V = srcv; U = srcu; ++ i = w; ++ while (i >= 4) { ++#if X_BYTE_ORDER == X_LITTLE_ENDIAN ++ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24); ++ Dst[1] = Y[2] | (Y[3] << 16) | (U[1] << 8) | (V[1] << 24); ++ Dst[2] = Y[4] | (Y[5] << 16) | (U[2] << 8) | (V[2] << 24); ++ Dst[3] = Y[6] | (Y[7] << 16) | (U[3] << 8) | (V[3] << 24); ++#else ++ /* This assumes a little-endian framebuffer */ ++ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | Y[0]; ++ Dst[1] = (Y[2] << 24) | (Y[3] << 8) | (U[1] << 16) | Y[1]; ++ Dst[2] = (Y[4] << 24) | (Y[5] << 8) | (U[2] << 16) | Y[2]; ++ Dst[3] = (Y[6] << 24) | (Y[7] << 8) | (U[3] << 16) | Y[3]; ++#endif ++ Dst += 4; Y += 8; V += 4; U += 4; ++ i -= 4; ++ } + +-static OffscreenImageRec OffscreenImages[MAXSCREENS]; +-static Bool offscreenInited = FALSE; ++ while (i--) { ++#if X_BYTE_ORDER == X_LITTLE_ENDIAN ++ Dst[0] = Y[0] | (Y[1] << 16) | (U[0] << 8) | (V[0] << 24); ++#else ++ /* This assumes a little-endian framebuffer */ ++ Dst[0] = (Y[0] << 24) | (Y[1] << 8) | (U[0] << 16) | Y[0]; ++#endif ++ Dst++; Y += 2; V++; U++; ++ } + +-Bool +-xf86XVRegisterOffscreenImages( +- ScreenPtr pScreen, +- XF86OffscreenImagePtr images, +- int num +-){ +- if(!offscreenInited) { +- bzero(OffscreenImages, sizeof(OffscreenImages[MAXSCREENS])); +- offscreenInited = TRUE; ++ dst = (CARD8 *)dst + dstPitch; ++ srcy = (const CARD8 *)srcy + srcPitchy; ++ if (j & 1) { ++ srcu = (const CARD8 *)srcu + srcPitchuv; ++ srcv = (const CARD8 *)srcv + srcPitchuv; ++ } + } +- +- OffscreenImages[pScreen->myNum].num = num; +- OffscreenImages[pScreen->myNum].images = images; +- +- return TRUE; + } + +-XF86OffscreenImagePtr +-xf86XVQueryOffscreenImages( +- ScreenPtr pScreen, +- int *num ++void ++xf86XVCopyPacked( ++ const void *src, ++ void *dst, ++ int srcPitch, ++ int dstPitch, ++ int h, ++ int w + ){ +- if(!offscreenInited) { +- *num = 0; +- return NULL; +- } ++ const CARD32 *Src; ++ CARD32 *Dst; ++ int i; ++ ++ w >>= 1; ++ while (--h >= 0) { ++ do { ++ Dst = dst; Src = src; ++ i = w; ++ while (i >= 4) { ++ Dst[0] = Src[0]; ++ Dst[1] = Src[1]; ++ Dst[2] = Src[2]; ++ Dst[3] = Src[3]; ++ Dst += 4; Src += 4; i -= 4; ++ } ++ if (!i) break; ++ Dst[0] = Src[0]; ++ if (i == 1) break; ++ Dst[1] = Src[1]; ++ if (i == 2) break; ++ Dst[2] = Src[2]; ++ } while (0); + +- *num = OffscreenImages[pScreen->myNum].num; +- return OffscreenImages[pScreen->myNum].images; ++ src = (const CARD8 *)src + srcPitch; ++ dst = (CARD8 *)dst + dstPitch; ++ } + } +Index: xc/programs/Xserver/hw/xfree86/common/xf86xv.h +=================================================================== +RCS file: /cvs/xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v +retrieving revision 1.23 +retrieving revision 1.24 +diff -u -r1.23 -r1.24 +--- xc/programs/Xserver/hw/xfree86/common/xf86xv.h 9 Nov 2002 01:18:33 -0000 1.23 ++++ xc/programs/Xserver/hw/xfree86/common/xf86xv.h 23 Apr 2003 21:51:25 -0000 1.24 +@@ -1,4 +1,4 @@ +-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.23 2002/11/09 01:18:33 keithp Exp $ */ ++/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.24 2003/04/23 21:51:25 tsi Exp $ */ + + #ifndef _XF86XV_H_ + #define _XF86XV_H_ +@@ -218,55 +218,27 @@ + INT32 height + ); + +-/*** These are DDX layer privates ***/ +- +-extern int XF86XvScreenIndex; +- +-typedef struct { +- DestroyWindowProcPtr DestroyWindow; +- ClipNotifyProcPtr ClipNotify; +- WindowExposuresProcPtr WindowExposures; +- void (*AdjustFrame)(int, int, int, int); +- Bool (*EnterVT)(int, int); +- void (*LeaveVT)(int, int); +- GCPtr videoGC; +-} XF86XVScreenRec, *XF86XVScreenPtr; +- +-typedef struct { +- int flags; +- PutVideoFuncPtr PutVideo; +- PutStillFuncPtr PutStill; +- GetVideoFuncPtr GetVideo; +- GetStillFuncPtr GetStill; +- StopVideoFuncPtr StopVideo; +- SetPortAttributeFuncPtr SetPortAttribute; +- GetPortAttributeFuncPtr GetPortAttribute; +- QueryBestSizeFuncPtr QueryBestSize; +- PutImageFuncPtr PutImage; +- ReputImageFuncPtr ReputImage; +- QueryImageAttributesFuncPtr QueryImageAttributes; +-} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr; ++void ++xf86XVCopyYUV12ToPacked( ++ const void *srcy, ++ const void *srcv, ++ const void *srcu, ++ void *dst, ++ int srcPitchy, ++ int srcPitchuv, ++ int dstPitch, ++ int h, ++ int w ++); + +-typedef struct { +- ScrnInfoPtr pScrn; +- DrawablePtr pDraw; +- unsigned char type; +- unsigned int subWindowMode; +- DDXPointRec clipOrg; +- RegionPtr clientClip; +- RegionPtr pCompositeClip; +- Bool FreeCompositeClip; +- XvAdaptorRecPrivatePtr AdaptorRec; +- XvStatus isOn; +- Bool moved; +- int vid_x, vid_y, vid_w, vid_h; +- int drw_x, drw_y, drw_w, drw_h; +- DevUnion DevPriv; +-} XvPortRecPrivate, *XvPortRecPrivatePtr; +- +-typedef struct _XF86XVWindowRec{ +- XvPortRecPrivatePtr PortRec; +- struct _XF86XVWindowRec *next; +-} XF86XVWindowRec, *XF86XVWindowPtr; ++void ++xf86XVCopyPacked( ++ const void *src, ++ void *dst, ++ int srcPitch, ++ int dstPitch, ++ int h, ++ int w ++); + + #endif /* _XF86XV_H_ */ +Index: xc/programs/Xserver/hw/xfree86/common/xf86xvpriv.h +=================================================================== +RCS file: xf86xvpriv.h +diff -N xf86xvpriv.h +--- xc/programs/Xserver/hw/xfree86/common//dev/null 1 Jan 1970 00:00:00 -0000 ++++ xc/programs/Xserver/hw/xfree86/common/xf86xvpriv.h 23 Apr 2003 21:51:25 -0000 1.1 +@@ -0,0 +1,59 @@ ++/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvpriv.h,v 1.1 2003/04/23 21:51:25 tsi Exp $ */ ++ ++#ifndef _XF86XVPRIV_H_ ++#define _XF86XVPRIV_H_ ++ ++#include "xf86xv.h" ++ ++/*** These are DDX layer privates ***/ ++ ++extern int XF86XvScreenIndex; ++ ++typedef struct { ++ DestroyWindowProcPtr DestroyWindow; ++ ClipNotifyProcPtr ClipNotify; ++ WindowExposuresProcPtr WindowExposures; ++ void (*AdjustFrame)(int, int, int, int); ++ Bool (*EnterVT)(int, int); ++ void (*LeaveVT)(int, int); ++ GCPtr videoGC; ++} XF86XVScreenRec, *XF86XVScreenPtr; ++ ++typedef struct { ++ int flags; ++ PutVideoFuncPtr PutVideo; ++ PutStillFuncPtr PutStill; ++ GetVideoFuncPtr GetVideo; ++ GetStillFuncPtr GetStill; ++ StopVideoFuncPtr StopVideo; ++ SetPortAttributeFuncPtr SetPortAttribute; ++ GetPortAttributeFuncPtr GetPortAttribute; ++ QueryBestSizeFuncPtr QueryBestSize; ++ PutImageFuncPtr PutImage; ++ ReputImageFuncPtr ReputImage; ++ QueryImageAttributesFuncPtr QueryImageAttributes; ++} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr; ++ ++typedef struct { ++ ScrnInfoPtr pScrn; ++ DrawablePtr pDraw; ++ unsigned char type; ++ unsigned int subWindowMode; ++ DDXPointRec clipOrg; ++ RegionPtr clientClip; ++ RegionPtr pCompositeClip; ++ Bool FreeCompositeClip; ++ XvAdaptorRecPrivatePtr AdaptorRec; ++ XvStatus isOn; ++ Bool moved; ++ int vid_x, vid_y, vid_w, vid_h; ++ int drw_x, drw_y, drw_w, drw_h; ++ DevUnion DevPriv; ++} XvPortRecPrivate, *XvPortRecPrivatePtr; ++ ++typedef struct _XF86XVWindowRec{ ++ XvPortRecPrivatePtr PortRec; ++ struct _XF86XVWindowRec *next; ++} XF86XVWindowRec, *XF86XVWindowPtr; ++ ++#endif /* _XF86XVPRIV_H_ */ +Index: xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c +=================================================================== +RCS file: /cvs/xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c,v +retrieving revision 1.3 +retrieving revision 1.4 +diff -u -r1.3 -r1.4 +--- xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c 1 Apr 2001 14:00:08 -0000 1.3 ++++ xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c 23 Apr 2003 21:51:25 -0000 1.4 +@@ -1,4 +1,4 @@ +-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c,v 1.3 2001/04/01 14:00:08 tsi Exp $ */ ++/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xvmc.c,v 1.4 2003/04/23 21:51:25 tsi Exp $ */ + + #include "misc.h" + #include "xf86.h" +@@ -14,6 +14,7 @@ + #include "xvmodproc.h" + #endif + ++#include "xf86xvpriv.h" + #include "xf86xvmc.h" + + #ifdef XFree86LOADER +Index: xc/programs/Xserver/hw/xfree86/common/fourcc.h +=================================================================== +RCS file: /cvs/xc/programs/Xserver/hw/xfree86/common/fourcc.h,v +retrieving revision 1.3 +retrieving revision 1.4 +diff -u -r1.3 -r1.4 +--- xc/programs/Xserver/hw/xfree86/common/fourcc.h 3 Dec 2001 22:13:24 -0000 1.3 ++++ xc/programs/Xserver/hw/xfree86/common/fourcc.h 23 Apr 2003 21:51:24 -0000 1.4 +@@ -1,4 +1,4 @@ +-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/fourcc.h,v 1.3 2001/12/03 22:13:24 mvojkovi Exp $ */ ++/* $XFree86: xc/programs/Xserver/hw/xfree86/common/fourcc.h,v 1.4 2003/04/23 21:51:24 tsi Exp $ */ + + /* + This header file contains listings of STANDARD guids for video formats. +@@ -7,6 +7,9 @@ + For an explanation of fourcc <-> guid mappings see RFC2361. + */ + ++#ifndef _XF86_FOURCC_H_ ++#define _XF86_FOURCC_H_ 1 ++ + #define FOURCC_YUY2 0x32595559 + #define XVIMAGE_YUY2 \ + { \ +@@ -128,3 +131,4 @@ + XvTopToBottom \ + } + ++#endif /* _XF86_FOURCC_H_ */