[Intel-gfx] [PATCH 2/2] Use ALIGN macro instead of open coding it.
mattst88 at gmail.com
mattst88 at gmail.com
Wed Mar 17 18:26:04 CET 2010
From: Matt Turner <mattst88 at gmail.com>
Also, kill off ROUND_TO, ROUND_DOWN, ROUND_TO_PAGE, and ROUND_TO_MB
macros. ROUND_{TO,DOWN} are only useful if rounding to a non-power of
two, which they always were, and ROUND_TO_PAGE and ROUND_TO_MB
inherently round to a power of two, so just use ALIGN.
Also, kill off i830_pad_drawable_width and UXA_ALIGN{,2} since they're
unused.
v2: fix a i830_pad_drawable_width->ALIGN mistake in I830ScreenInit,
found a few more open coded instances and replaced them with ALIGN.
CC: Eric Anholt <eric at anholt.net>
CC: Carl Worth <cworth at cworth.org>
CC: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
src/common.h | 6 ++----
src/drmmode_display.c | 7 +++----
src/i810_accel.c | 2 +-
src/i810_dga.c | 2 +-
src/i810_dri.c | 7 +++----
src/i810_driver.c | 3 +--
src/i810_video.c | 26 +++++++++++++-------------
src/i830.h | 3 ---
src/i830_driver.c | 14 ++------------
src/i830_memory.c | 4 ++--
src/i830_uxa.c | 4 ++--
src/i830_video.c | 48 ++++++++++++++++++++++--------------------------
src/i915_hwmc.h | 2 +-
src/i965_hwmc.c | 2 +-
src/xvmc/I810XvMC.c | 10 +++++-----
src/xvmc/intel_xvmc.c | 4 ++--
uxa/uxa-priv.h | 6 ------
17 files changed, 61 insertions(+), 89 deletions(-)
diff --git a/src/common.h b/src/common.h
index bc5d722..726292f 100644
--- a/src/common.h
+++ b/src/common.h
@@ -68,6 +68,8 @@ I830DPRINTF_stub(const char *filename, int line, const char *function,
#define KB(x) ((x) * 1024)
#define MB(x) ((x) * KB(1024))
+#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
+
/* Using usleep() makes things noticably slow. */
#if 0
#define DELAY(x) usleep(x)
@@ -395,10 +397,6 @@ extern int I810_DEBUG;
#define SUPPORTS_YTILING(pI810) (IS_I965G(intel))
#define GTT_PAGE_SIZE KB(4)
-#define ROUND_TO(x, y) (((x) + (y) - 1) / (y) * (y))
-#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
-#define ROUND_TO_PAGE(x) ROUND_TO((x), GTT_PAGE_SIZE)
-#define ROUND_TO_MB(x) ROUND_TO((x), MB(1))
#define PRIMARY_RINGBUFFER_SIZE KB(128)
#define MIN_SCRATCH_BUFFER_SIZE KB(16)
#define MAX_SCRATCH_BUFFER_SIZE KB(64)
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index ae200ca..743659f 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -476,7 +476,7 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
int size, ret;
unsigned long rotate_pitch;
- width = i830_pad_drawable_width(width, drmmode->cpp);
+ width = ALIGN(width, 64);
rotate_pitch = width * drmmode->cpp;
size = rotate_pitch * height;
@@ -523,8 +523,7 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
}
}
- rotate_pitch =
- i830_pad_drawable_width(width, drmmode->cpp) * drmmode->cpp;
+ rotate_pitch = ALIGN(width, 64) * drmmode->cpp;
rotate_pixmap = GetScratchPixmapHeader(scrn->pScreen,
width, height,
scrn->depth,
@@ -1261,7 +1260,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
if (scrn->virtualX == width && scrn->virtualY == height)
return TRUE;
- pitch = i830_pad_drawable_width(width, intel->cpp);
+ pitch = ALIGN(width, 64);
i830_tiled_width(intel, &pitch, intel->cpp);
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"Allocate new frame buffer %dx%d stride %d\n",
diff --git a/src/i810_accel.c b/src/i810_accel.c
index ae4a654..9aa3e42 100644
--- a/src/i810_accel.c
+++ b/src/i810_accel.c
@@ -129,7 +129,7 @@ I810AccelInit(ScreenPtr pScreen)
*/
if (pI810->Scratch.Size != 0) {
int i;
- int width = ((pScrn->displayWidth + 31) & ~31) / 8;
+ int width = ALIGN(pScrn->displayWidth, 32) / 8;
int nr_buffers = pI810->Scratch.Size / width;
unsigned char *ptr = pI810->FbBase + pI810->Scratch.Start;
diff --git a/src/i810_dga.c b/src/i810_dga.c
index 3f53057..6a7106d 100644
--- a/src/i810_dga.c
+++ b/src/i810_dga.c
@@ -118,7 +118,7 @@ I810DGAInit(ScreenPtr pScreen)
currentMode->offset = 0;
currentMode->address = pI810->FbBase;
- currentMode->bytesPerScanline = ((pScrn->displayWidth * Bpp) + 3) & ~3L;
+ currentMode->bytesPerScanline = ALIGN(pScrn->displayWidth * Bpp, 4L);
currentMode->imageWidth = pI810->FbMemBox.x2;
currentMode->imageHeight = pI810->FbMemBox.y2;
currentMode->pixmapWidth = currentMode->imageWidth;
diff --git a/src/i810_dri.c b/src/i810_dri.c
index e566acf..ca29924 100644
--- a/src/i810_dri.c
+++ b/src/i810_dri.c
@@ -348,9 +348,8 @@ I810DRIScreenInit(ScreenPtr pScreen)
pDRIInfo->ddxDriverMinorVersion = I810_MINOR_VERSION;
pDRIInfo->ddxDriverPatchVersion = I810_PATCHLEVEL;
pDRIInfo->frameBufferPhysicalAddress = (pointer) pI810->LinearAddr;
- pDRIInfo->frameBufferSize = (((pScrn->displayWidth *
- pScrn->virtualY * pI810->cpp) +
- 4096 - 1) / 4096) * 4096;
+ pDRIInfo->frameBufferSize = ALIGN(pScrn->displayWidth * pScrn->virtualY *
+ pI810->cpp, 4096);
pDRIInfo->frameBufferStride = pScrn->displayWidth * pI810->cpp;
pDRIInfo->ddxDrawableTableEntry = I810_MAX_DRAWABLES;
@@ -537,7 +536,7 @@ I810DRIScreenInit(ScreenPtr pScreen)
* - airlied */
int lines = (pScrn->virtualY + 15) / 16 * 16;
back_size = i810_pitches[pitch_idx] * lines;
- back_size = ((back_size + 4096 - 1) / 4096) * 4096;
+ back_size = ALIGN(back_size, 4096);
}
sysmem_size = pScrn->videoRam * 1024;
diff --git a/src/i810_driver.c b/src/i810_driver.c
index 3109834..34a4413 100644
--- a/src/i810_driver.c
+++ b/src/i810_driver.c
@@ -1838,8 +1838,7 @@ I810AllocateFront(ScrnInfoPtr pScrn)
if (!I810AllocLow(&(pI810->FrontBuffer),
&(pI810->SysMem),
- ((pI810->FbMemBox.x2 *
- pI810->FbMemBox.y2 * pI810->cpp) + 4095) & ~4095)) {
+ ALIGN(pI810->FbMemBox.x2 * pI810->FbMemBox.y2 * pI810->cpp, 4096))) {
xf86DrvMsg(pScrn->scrnIndex,
X_WARNING, "Framebuffer allocation failed\n");
return FALSE;
diff --git a/src/i810_video.c b/src/i810_video.c
index 9bb9870..47347a7 100644
--- a/src/i810_video.c
+++ b/src/i810_video.c
@@ -750,14 +750,14 @@ I810DisplayVideo(
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
- swidth = (width + 7) & ~7;
+ swidth = ALIGN(width, 8);
overlay->SWID = (swidth << 15) | swidth;
overlay->SWIDQW = (swidth << 12) | (swidth >> 3);
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
- swidth = ((width + 3) & ~3) << 1;
+ swidth = ALIGN(width, 4) << 1;
overlay->SWID = swidth;
overlay->SWIDQW = swidth >> 3;
break;
@@ -1013,15 +1013,15 @@ I810PutImage(
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
- srcPitch = (width + 3) & ~3;
- dstPitch = ((width >> 1) + 7) & ~7; /* of chroma */
+ srcPitch = ALIGN(width, 4);
+ dstPitch = ALIGN(width >> 1, 8); /* of chroma */
size = dstPitch * height * 3;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
srcPitch = (width << 1);
- dstPitch = (srcPitch + 7) & ~7;
+ dstPitch = ALIGN(srcPitch, 8);
size = dstPitch * height;
break;
}
@@ -1062,13 +1062,13 @@ I810PutImage(
/* copy data */
top = y1 >> 16;
left = (x1 >> 16) & ~1;
- npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
+ npixels = (ALIGN((x2 + 0xffff) >> 16, 2)) - left;
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
top &= ~1;
- nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
+ nlines = (ALIGN((y2 + 0xffff) >> 16, 2)) - top;
I810CopyPlanarData(pScrn, buf, srcPitch, dstPitch, height, top, left,
nlines, npixels, id);
break;
@@ -1109,7 +1109,7 @@ I810QueryImageAttributes(
if(*w > IMAGE_MAX_WIDTH) *w = IMAGE_MAX_WIDTH;
if(*h > IMAGE_MAX_HEIGHT) *h = IMAGE_MAX_HEIGHT;
- *w = (*w + 1) & ~1;
+ *w = ALIGN(*w, 2);
if(offsets) offsets[0] = 0;
switch(id) {
@@ -1121,12 +1121,12 @@ I810QueryImageAttributes(
break;
case FOURCC_YV12:
case FOURCC_I420:
- *h = (*h + 1) & ~1;
- size = (*w + 3) & ~3;
+ *h = ALIGN(*h, 2);
+ size = ALIGN(*w, 4);
if(pitches) pitches[0] = size;
size *= *h;
if(offsets) offsets[1] = size;
- tmp = ((*w >> 1) + 3) & ~3;
+ tmp = ALIGN(*w >> 1, 4);
if(pitches) pitches[1] = pitches[2] = tmp;
tmp *= (*h >> 1);
size += tmp;
@@ -1213,8 +1213,8 @@ I810AllocateSurface(
if((w > 1024) || (h > 1024))
return BadAlloc;
- w = (w + 1) & ~1;
- pitch = ((w << 1) + 15) & ~15;
+ w = ALIGN(w, 2);
+ pitch = ALIGN((w << 1), 16);
bpp = pScrn->bitsPerPixel >> 3;
size = ((pitch * h) + bpp - 1) / bpp;
diff --git a/src/i830.h b/src/i830.h
index 7593cde..91d318b 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -385,7 +385,6 @@ intel_get_screen_private(ScrnInfoPtr scrn)
}
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
unsigned long intel_get_pixmap_pitch(PixmapPtr pixmap);
@@ -429,8 +428,6 @@ void i830_init_bufmgr(ScrnInfoPtr scrn);
Bool i830_tiled_width(intel_screen_private *intel, int *width, int cpp);
-int i830_pad_drawable_width(int width, int cpp);
-
/* i830_memory.c */
unsigned long i830_get_fence_size(intel_screen_private *intel, unsigned long size);
unsigned long i830_get_fence_pitch(intel_screen_private *intel, unsigned long pitch,
diff --git a/src/i830_driver.c b/src/i830_driver.c
index 53d8663..29c93eb 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -360,8 +360,7 @@ Bool i830_tiled_width(intel_screen_private *intel, int *width, int cpp)
if (intel->tiling) {
if (IS_I965G(intel)) {
int tile_pixels = 512 / cpp;
- *width = (*width + tile_pixels - 1) &
- ~(tile_pixels - 1);
+ *width = ALIGN(*width, tile_pixels);
tiled = TRUE;
} else {
/* Good pitches to allow tiling. Don't care about pitches < 1024
@@ -389,14 +388,6 @@ Bool i830_tiled_width(intel_screen_private *intel, int *width, int cpp)
}
/*
- * Pad to accelerator requirement
- */
-int i830_pad_drawable_width(int width, int cpp)
-{
- return (width + 63) & ~63;
-}
-
-/*
* DRM mode setting Linux only at this point... later on we could
* add a wrapper here.
*/
@@ -1100,8 +1091,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv)
struct pci_device *const device = intel->PciInfo;
int fb_bar = IS_I9XX(intel) ? 2 : 0;
- scrn->displayWidth =
- i830_pad_drawable_width(scrn->virtualX, intel->cpp);
+ scrn->displayWidth = ALIGN(scrn->virtualX, 64);
/*
* The "VideoRam" config file parameter specifies the maximum amount of
diff --git a/src/i830_memory.c b/src/i830_memory.c
index a21f29b..ba47714 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -129,7 +129,7 @@ i830_get_fence_pitch(intel_screen_private *intel, unsigned long pitch,
/* 965 is flexible */
if (IS_I965G(intel))
- return ROUND_TO(pitch, tile_width);
+ return ALIGN(pitch, tile_width);
/* Pre-965 needs power of two tile width */
for (i = tile_width; i < pitch; i <<= 1) ;
@@ -232,7 +232,7 @@ drm_intel_bo *i830_allocate_framebuffer(ScrnInfoPtr scrn)
*/
fb_height = scrn->virtualY;
- size = ROUND_TO_PAGE(pitch * fb_height);
+ size = ALIGN(pitch * fb_height, GTT_PAGE_SIZE);
if (intel->tiling && IsTileable(scrn, pitch))
tiling_mode = I915_TILING_X;
diff --git a/src/i830_uxa.c b/src/i830_uxa.c
index 9904311..8fc9cc9 100644
--- a/src/i830_uxa.c
+++ b/src/i830_uxa.c
@@ -133,7 +133,7 @@ i830_uxa_pixmap_compute_size(PixmapPtr pixmap,
if (*tiling != I915_TILING_NONE) {
/* First check whether tiling is necessary. */
pitch_align = intel->accel_pixmap_pitch_alignment;
- size = ROUND_TO((w * pixmap->drawable.bitsPerPixel + 7) / 8,
+ size = ALIGN((w * pixmap->drawable.bitsPerPixel + 7) / 8,
pitch_align) * ALIGN (h, 2);
if (size < 4096)
*tiling = I915_TILING_NONE;
@@ -146,7 +146,7 @@ i830_uxa_pixmap_compute_size(PixmapPtr pixmap,
pitch_align = 512;
}
- *stride = ROUND_TO((w * pixmap->drawable.bitsPerPixel + 7) / 8,
+ *stride = ALIGN((w * pixmap->drawable.bitsPerPixel + 7) / 8,
pitch_align);
if (*tiling == I915_TILING_NONE) {
diff --git a/src/i830_video.c b/src/i830_video.c
index 4e1b9ce..c7dd57e 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1271,10 +1271,10 @@ i830_clip_video_helper(ScrnInfoPtr scrn,
*top = y1 >> 16;
*left = (x1 >> 16) & ~1;
- *npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - *left;
+ *npixels = ALIGN((x2 + 0xffff) >> 16, 2) - *left;
if (is_planar_fourcc(id)) {
*top &= ~1;
- *nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - *top;
+ *nlines = ALIGN((y2 + 0xffff) >> 16, 2) - *top;
} else
*nlines = ((y2 + 0xffff) >> 16) - *top;
@@ -1351,24 +1351,24 @@ i830_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, sho
int id)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
- int pitchAlignMask;
+ int pitchAlign;
/* Only needs to be DWORD-aligned for textured on i915, but overlay has
* stricter requirements.
*/
if (adaptor_priv->textured) {
- pitchAlignMask = 3;
+ pitchAlign = 4;
} else {
if (IS_I965G(intel))
- pitchAlignMask = 255;
+ pitchAlign = 256;
else
- pitchAlignMask = 63;
+ pitchAlign = 64;
}
#if INTEL_XVMC
/* for i915 xvmc, hw requires 1kb aligned surfaces */
if ((id == FOURCC_XVMC) && IS_I915(intel))
- pitchAlignMask = 0x3ff;
+ pitchAlign = 1024;
#endif
/* Determine the desired destination pitch (representing the chroma's pitch,
@@ -1377,25 +1377,25 @@ i830_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, sho
if (is_planar_fourcc(id)) {
if (adaptor_priv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
*dstPitch =
- ((height / 2) + pitchAlignMask) & ~pitchAlignMask;
+ ALIGN(height / 2, pitchAlign);
*dstPitch2 =
- (height + pitchAlignMask) & ~pitchAlignMask;
+ ALIGN(height, pitchAlign);
*size = *dstPitch * width * 3;
} else {
*dstPitch =
- ((width / 2) + pitchAlignMask) & ~pitchAlignMask;
+ ALIGN(width / 2, pitchAlign);
*dstPitch2 =
- (width + pitchAlignMask) & ~pitchAlignMask;
+ ALIGN(width, pitchAlign);
*size = *dstPitch * height * 3;
}
} else {
if (adaptor_priv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
*dstPitch =
- ((height << 1) + pitchAlignMask) & ~pitchAlignMask;
+ ALIGN(height << 1, pitchAlign);
*size = *dstPitch * width;
} else {
*dstPitch =
- ((width << 1) + pitchAlignMask) & ~pitchAlignMask;
+ ALIGN(width << 1, pitchAlign);
*size = *dstPitch * height;
}
*dstPitch2 = 0;
@@ -1426,16 +1426,9 @@ i830_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
int top, int left, int npixels, int nlines,
int id, unsigned char *buf)
{
- int srcPitch = 0, srcPitch2 = 0;
+ int srcPitch, srcPitch2;
int size;
- if (is_planar_fourcc(id)) {
- srcPitch = (width + 0x3) & ~0x3;
- srcPitch2 = ((width >> 1) + 0x3) & ~0x3;
- } else {
- srcPitch = width << 1;
- }
-
i830_setup_dst_params(scrn, adaptor_priv, width, height, dstPitch,
dstPitch2, &size, id);
@@ -1444,11 +1437,14 @@ i830_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
/* copy data */
if (is_planar_fourcc(id)) {
+ srcPitch = ALIGN(width, 0x4);
+ srcPitch2 = ALIGN(width >> 1, 0x4);
I830CopyPlanarData(adaptor_priv, buf, srcPitch, srcPitch2,
*dstPitch, *dstPitch2,
height, top, left, nlines,
npixels, id);
} else {
+ srcPitch = width << 1;
I830CopyPackedData(adaptor_priv, buf, srcPitch, *dstPitch, top, left,
nlines, npixels);
}
@@ -1650,7 +1646,7 @@ I830QueryImageAttributes(ScrnInfoPtr scrn,
*h = IMAGE_MAX_HEIGHT;
}
- *w = (*w + 1) & ~1;
+ *w = ALIGN(*w, 2);
if (offsets)
offsets[0] = 0;
@@ -1664,14 +1660,14 @@ I830QueryImageAttributes(ScrnInfoPtr scrn,
break;
case FOURCC_YV12:
case FOURCC_I420:
- *h = (*h + 1) & ~1;
- size = (*w + 3) & ~3;
+ *h = ALIGN(*h, 2);
+ size = ALIGN(*w, 4);
if (pitches)
pitches[0] = size;
size *= *h;
if (offsets)
offsets[1] = size;
- tmp = ((*w >> 1) + 3) & ~3;
+ tmp = ALIGN(*w >> 1, 4);
if (pitches)
pitches[1] = pitches[2] = tmp;
tmp *= (*h >> 1);
@@ -1692,7 +1688,7 @@ I830QueryImageAttributes(ScrnInfoPtr scrn,
break;
#ifdef INTEL_XVMC
case FOURCC_XVMC:
- *h = (*h + 1) & ~1;
+ *h = ALIGN(*h, 2);
size = sizeof(struct intel_xvmc_command);
if (pitches)
pitches[0] = size;
diff --git a/src/i915_hwmc.h b/src/i915_hwmc.h
index c036b63..b08dafe 100644
--- a/src/i915_hwmc.h
+++ b/src/i915_hwmc.h
@@ -30,7 +30,7 @@
#include "i830_hwmc.h"
/* i915 hw requires surface to be at least 1KB aligned */
-#define STRIDE(w) (((w) + 0x3ff) & ~0x3ff)
+#define STRIDE(w) ALIGN((w), 0x400)
#define SIZE_Y420(w, h) (h * STRIDE(w))
#define SIZE_UV420(w, h) ((h >> 1) * STRIDE(w >> 1))
#define SIZE_YUV420(w, h) (SIZE_Y420(w,h) + SIZE_UV420(w,h) * 2)
diff --git a/src/i965_hwmc.c b/src/i965_hwmc.c
index 682107a..0f81d54 100644
--- a/src/i965_hwmc.c
+++ b/src/i965_hwmc.c
@@ -58,7 +58,7 @@ static int create_context(ScrnInfoPtr scrn,
unsigned int blocknum =
(((context->width + 15) / 16) * ((context->height + 15) / 16));
unsigned int blocksize = 6 * blocknum * 64 * sizeof(short);
- blocksize = (blocksize + 4095) & (~4095);
+ blocksize = ALIGN(blocksize, 4096);
if ((private_context = Xcalloc(sizeof(*private_context))) == NULL) {
ErrorF("XVMC Can not allocate private context\n");
return BadAlloc;
diff --git a/src/xvmc/I810XvMC.c b/src/xvmc/I810XvMC.c
index 0754ff4..c40a221 100644
--- a/src/xvmc/I810XvMC.c
+++ b/src/xvmc/I810XvMC.c
@@ -2860,8 +2860,8 @@ _X_EXPORT Status XvMCPutSurface(Display *display,XvMCSurface *surface,
switch(surface->surface_type_id) {
case FOURCC_YV12:
case FOURCC_I420:
- yPitch = (srcw + 7) & ~7;
- uvPitch = ((srcw>>1) + 7) & ~7;
+ yPitch = ALIGN(srcw, 8);
+ uvPitch = ALIGN(srcw>>1, 8);
if((flags & XVMC_FRAME_PICTURE) != XVMC_FRAME_PICTURE) {
srch = srch>>1;
}
@@ -2871,7 +2871,7 @@ _X_EXPORT Status XvMCPutSurface(Display *display,XvMCSurface *surface,
default:
/* FIXME: Non Planar not fully implemented. */
return BadValue;
- yPitch = ((srcw + 7) & ~7) << 1;
+ yPitch = ALIGN(srcw, 8) << 1;
break;
}/* switch(surface->surface_type_id) */
@@ -3010,8 +3010,8 @@ _X_EXPORT Status XvMCPutSurface(Display *display,XvMCSurface *surface,
Adjust the source offset width and height according to the clipped
destination window.
*/
- ysrc_offset = ((clipped_srcx + 1) & ~1) +
- ((clipped_srcy + 1) & ~1) * (1<<pI810Surface->pitch);
+ ysrc_offset = ALIGN(clipped_srcx, 2) +
+ ALIGN(clipped_srcy, 2) * (1<<pI810Surface->pitch);
uvsrc_offset = (clipped_srcx>>1) +
(clipped_srcy>>1) * (1<<(pI810Surface->pitch - 1));
diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c
index 328d3c1..0965b84 100644
--- a/src/xvmc/intel_xvmc.c
+++ b/src/xvmc/intel_xvmc.c
@@ -360,8 +360,8 @@ _X_EXPORT Status XvMCCreateContext(Display * display, XvPortID port,
here.
*/
context->surface_type_id = surface_type_id;
- context->width = (unsigned short)((width + 15) & ~15);
- context->height = (unsigned short)((height + 15) & ~15);
+ context->width = (unsigned short)ALIGN(width, 16);
+ context->height = (unsigned short)ALIGN(height, 16);
context->flags = flags;
context->port = port;
diff --git a/uxa/uxa-priv.h b/uxa/uxa-priv.h
index c1f3688..07052b3 100644
--- a/uxa/uxa-priv.h
+++ b/uxa/uxa-priv.h
@@ -194,12 +194,6 @@ static inline uxa_screen_t *uxa_get_screen(ScreenPtr screen)
&uxa_screen_index);
}
-/** Align an offset to an arbitrary alignment */
-#define UXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
- (((offset) + (align) - 1) % (align)))
-/** Align an offset to a power-of-two alignment */
-#define UXA_ALIGN2(offset, align) (((offset) + (align) - 1) & ~((align) - 1))
-
typedef struct {
INT16 xSrc;
INT16 ySrc;
--
1.6.4.4
More information about the Intel-gfx
mailing list