diff -Naur a/src/i830_video.c b/src/i830_video.c --- a/src/i830_video.c 2009-08-25 11:15:07.000000000 -0400 +++ b/src/i830_video.c 2009-08-25 11:28:57.000000000 -0400 @@ -2364,6 +2364,35 @@ pitchAlignMask = 63; } + /* Compute destination buffer size */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: + top &= ~1; + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + break; + case FOURCC_UYVY: + case FOURCC_YUY2: + nlines = ((y2 + 0xffff) >> 16) - top; + break; +#ifdef INTEL_XVMC + case FOURCC_XVMC: + if (pPriv->rotation != RR_Rotate_0) { + top &= ~1; + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + } + + break; +#endif + default: + break; + } + + /* Determine the desired destination pitch (representing the chroma's pitch, * in the planar case. */ @@ -2371,28 +2400,28 @@ case FOURCC_YV12: case FOURCC_I420: if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) { - dstPitch = ((height / 2) + pitchAlignMask) & ~pitchAlignMask; - size = dstPitch * width * 3; + dstPitch = ((nlines / 2) + pitchAlignMask) & ~pitchAlignMask; + size = dstPitch * npixels * 3; } else { - dstPitch = ((width / 2) + pitchAlignMask) & ~pitchAlignMask; - size = dstPitch * height * 3; + dstPitch = ((npixels / 2) + pitchAlignMask) & ~pitchAlignMask; + size = dstPitch * nlines * 3; } break; case FOURCC_UYVY: case FOURCC_YUY2: if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) { - dstPitch = ((height << 1) + pitchAlignMask) & ~pitchAlignMask; - size = dstPitch * width; + dstPitch = ((nlines << 1) + pitchAlignMask) & ~pitchAlignMask; + size = dstPitch * npixels; } else { - dstPitch = ((width << 1) + pitchAlignMask) & ~pitchAlignMask; - size = dstPitch * height; + dstPitch = ((npixels << 1) + pitchAlignMask) & ~pitchAlignMask; + size = dstPitch * nlines; } break; #ifdef INTEL_XVMC case FOURCC_XVMC: - dstPitch = ((width / 2) + pitchAlignMask ) & ~pitchAlignMask; - dstPitch2 = (width + pitchAlignMask ) & ~pitchAlignMask; + dstPitch = ((npixels / 2) + pitchAlignMask ) & ~pitchAlignMask; + dstPitch2 = (npixels + pitchAlignMask ) & ~pitchAlignMask; size = 0; break; #endif @@ -2448,8 +2477,8 @@ #ifdef INTEL_XVMC if (id == FOURCC_XVMC && IS_I915(pI830)) { pPriv->YBuf0offset = (uint32_t)((uintptr_t)buf); - pPriv->VBuf0offset = pPriv->YBuf0offset + (dstPitch2 * height); - pPriv->UBuf0offset = pPriv->VBuf0offset + (dstPitch * height / 2); + pPriv->VBuf0offset = pPriv->YBuf0offset + (dstPitch2 * nlines); + pPriv->UBuf0offset = pPriv->VBuf0offset + (dstPitch * nlines / 2); destId = FOURCC_YV12; } else { #endif @@ -2459,20 +2488,20 @@ pPriv->YBuf0offset = pPriv->buf->offset; if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) { - pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width); - pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * width / 2); + pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * npixels); + pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * npixels / 2); if(pPriv->doubleBuffer) { pPriv->YBuf1offset = pPriv->YBuf0offset + size; - pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * width); - pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * width / 2); + pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * npixels); + pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * npixels / 2); } } else { - pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * height); - pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * height / 2); + pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * nlines); + pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * nlines / 2); if(pPriv->doubleBuffer) { pPriv->YBuf1offset = pPriv->YBuf0offset + size; - pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * height); - pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * height / 2); + pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * nlines); + pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * nlines / 2); } } #ifdef INTEL_XVMC @@ -2484,29 +2513,21 @@ pPriv->currentBuf = !((INREG(DOVSTA) & OC_BUF) >> 20); /* copy data */ - top = y1 >> 16; - left = (x1 >> 16) & ~1; - npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; switch (id) { case FOURCC_YV12: case FOURCC_I420: - top &= ~1; - nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; I830CopyPlanarData(pScrn, pPriv, buf, srcPitch, srcPitch2, dstPitch, height, top, left, nlines, npixels, id); break; case FOURCC_UYVY: case FOURCC_YUY2: - nlines = ((y2 + 0xffff) >> 16) - top; I830CopyPackedData(pScrn, pPriv, buf, srcPitch, dstPitch, top, left, nlines, npixels); break; #ifdef INTEL_XVMC case FOURCC_XVMC: if (pPriv->rotation != RR_Rotate_0) { - top &= ~1; - nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; I830CopyPlanarData(pScrn, pPriv, buf, srcPitch, srcPitch2, dstPitch, height, top, left, nlines, npixels, id); } @@ -2518,7 +2539,7 @@ } if (!pPriv->textured) { - i830_display_video(pScrn, crtc, destId, width, height, dstPitch, + i830_display_video(pScrn, crtc, destId, npixels, nlines, dstPitch, x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h); @@ -2574,15 +2595,15 @@ #ifdef INTEL_XVMC if (id == FOURCC_XVMC && pPriv->rotation == RR_Rotate_0) { pPriv->YBuf0offset = buf - pI830->FbBase; - pPriv->UBuf0offset = pPriv->YBuf0offset + height*width; - pPriv->VBuf0offset = pPriv->UBuf0offset + height*width/4; + pPriv->UBuf0offset = pPriv->YBuf0offset + nlines*npixels; + pPriv->VBuf0offset = pPriv->UBuf0offset + nlines*npixels/4; } #endif - I965DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, width, height, + I965DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, npixels, nlines, dstPitch, x1, y1, x2, y2, src_w, src_h, drw_w, drw_h, pPixmap); } else { - I915DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, width, height, + I915DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, npixels, nlines, dstPitch, dstPitch2, x1, y1, x2, y2, src_w, src_h, drw_w, drw_h, pPixmap); }