summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-11-09 10:15:11 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-11-09 10:26:49 +0000
commitf62b9f94f64f402e731463205635d386386e274e (patch)
tree90eab48d449b52c88f6c5ada765fa6dad898036c /src
parent5809b1ad934d6e19dbcf00f1b59e156761ec16b6 (diff)
sna/video: Pass cropped source dimensions along with frame data
So pack all the relevant details into the same structure. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/sna/sna_video.c60
-rw-r--r--src/sna/sna_video.h12
-rw-r--r--src/sna/sna_video_overlay.c13
-rw-r--r--src/sna/sna_video_textured.c16
4 files changed, 46 insertions, 55 deletions
diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c
index 063aca9d..fd5f3f19 100644
--- a/src/sna/sna_video.c
+++ b/src/sna/sna_video.c
@@ -114,15 +114,14 @@ void sna_video_frame_fini(struct sna *sna,
Bool
sna_video_clip_helper(ScrnInfoPtr scrn,
struct sna_video *video,
+ struct sna_video_frame *frame,
xf86CrtcPtr * crtc_ret,
BoxPtr dst,
short src_x, short src_y,
short drw_x, short drw_y,
short src_w, short src_h,
short drw_w, short drw_h,
- int id,
- int *top, int* left, int* npixels, int *nlines,
- RegionPtr reg, INT32 width, INT32 height)
+ RegionPtr reg)
{
Bool ret;
RegionRec crtc_region_local;
@@ -156,18 +155,18 @@ sna_video_clip_helper(ScrnInfoPtr scrn,
*crtc_ret = crtc;
ret = xf86XVClipVideoHelper(dst, &x1, &x2, &y1, &y2,
- crtc_region, width, height);
+ crtc_region, frame->width, frame->height);
if (crtc_region != reg)
RegionUninit(&crtc_region_local);
- *top = y1 >> 16;
- *left = (x1 >> 16) & ~1;
- *npixels = ALIGN(((x2 + 0xffff) >> 16), 2) - *left;
- if (is_planar_fourcc(id)) {
- *top &= ~1;
- *nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - *top;
+ frame->top = y1 >> 16;
+ frame->left = (x1 >> 16) & ~1;
+ frame->npixels = ALIGN(((x2 + 0xffff) >> 16), 2) - frame->left;
+ if (is_planar_fourcc(frame->id)) {
+ frame->top &= ~1;
+ frame->nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - frame->top;
} else
- *nlines = ((y2 + 0xffff) >> 16) - *top;
+ frame->nlines = ((y2 + 0xffff) >> 16) - frame->top;
return ret;
}
@@ -314,22 +313,22 @@ static void sna_memcpy_plane(uint8_t *dst, const uint8_t *src,
static void
sna_copy_planar_data(struct sna_video *video,
const struct sna_video_frame *frame,
- const uint8_t *src, uint8_t *dst,
- int top, int left, int h, int w)
+ const uint8_t *src, uint8_t *dst)
{
- int pitch;
uint8_t *d;
+ int w = frame->npixels;
+ int h = frame->nlines;
+ int pitch;
pitch = ALIGN(frame->width, 4);
- sna_memcpy_plane(dst, src + top * pitch + left,
- h, w, frame->pitch[1], pitch,
- video->rotation);
+ sna_memcpy_plane(dst, src + frame->top * pitch + frame->left,
+ h, w, frame->pitch[1], pitch, video->rotation);
src += frame->height * pitch; /* move over Luma plane */
/* align to beginning of chroma planes */
pitch = ALIGN((frame->width >> 1), 0x4);
- src += (top >> 1) * pitch + (left >> 1);
+ src += (frame->top >> 1) * pitch + (frame->left >> 1);
w >>= 1;
h >>= 1;
@@ -353,14 +352,15 @@ static void
sna_copy_packed_data(struct sna_video *video,
const struct sna_video_frame *frame,
const uint8_t *buf,
- uint8_t *dst,
- int top, int left, int h, int w)
+ uint8_t *dst)
{
int pitch = frame->width << 1;
const uint8_t *src, *s;
+ int w = frame->npixels;
+ int h = frame->nlines;
int i, j;
- src = buf + (top * pitch) + (left << 1);
+ src = buf + (frame->top * pitch) + (frame->left << 1);
switch (video->rotation) {
case RR_Rotate_0:
@@ -383,7 +383,7 @@ sna_copy_packed_data(struct sna_video *video,
src += pitch;
}
h >>= 1;
- src = buf + (top * pitch) + (left << 1);
+ src = buf + (frame->top * pitch) + (frame->left << 1);
for (i = 0; i < h; i += 2) {
for (j = 0; j < w; j += 2) {
/* Copy U */
@@ -419,7 +419,7 @@ sna_copy_packed_data(struct sna_video *video,
src += pitch;
}
h >>= 1;
- src = buf + (top * pitch) + (left << 1);
+ src = buf + (frame->top * pitch) + (frame->left << 1);
for (i = 0; i < h; i += 2) {
for (j = 0; j < w; j += 2) {
/* Copy U */
@@ -438,8 +438,6 @@ Bool
sna_video_copy_data(struct sna *sna,
struct sna_video *video,
struct sna_video_frame *frame,
- int top, int left,
- int npixels, int nlines,
const uint8_t *buf)
{
uint8_t *dst;
@@ -457,7 +455,7 @@ sna_video_copy_data(struct sna *sna,
};
if (pitch[0] == frame->pitch[0] &&
pitch[1] == frame->pitch[1] &&
- top == 0 && left == 0) {
+ frame->top == 0 && frame->left == 0) {
kgem_bo_write(&sna->kgem, frame->bo,
buf,
pitch[1]*frame->height +
@@ -473,8 +471,8 @@ sna_video_copy_data(struct sna *sna,
} else {
if (frame->width*2 == frame->pitch[0]) {
kgem_bo_write(&sna->kgem, frame->bo,
- buf + (top * frame->width*2) + (left << 1),
- frame->height*frame->width*2);
+ buf + (frame->top * frame->width*2) + (frame->left << 1),
+ frame->nlines*frame->width*2);
return TRUE;
}
}
@@ -486,11 +484,9 @@ sna_video_copy_data(struct sna *sna,
return FALSE;
if (is_planar_fourcc(frame->id))
- sna_copy_planar_data(video, frame, buf, dst,
- top, left, nlines, npixels);
+ sna_copy_planar_data(video, frame, buf, dst);
else
- sna_copy_packed_data(video, frame, buf, dst,
- top, left, nlines, npixels);
+ sna_copy_packed_data(video, frame, buf, dst);
munmap(dst, video->buf->size);
return TRUE;
diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h
index 41874b94..ab8289b6 100644
--- a/src/sna/sna_video.h
+++ b/src/sna/sna_video.h
@@ -68,8 +68,13 @@ struct sna_video_frame {
uint32_t size;
uint32_t UBufOffset;
uint32_t VBufOffset;
+
uint16_t width, height;
uint16_t pitch[2];
+
+ /* extents */
+ uint16_t top, left;
+ uint16_t npixels, nlines;
};
void sna_video_init(struct sna *sna, ScreenPtr screen);
@@ -97,15 +102,14 @@ static inline int is_planar_fourcc(int id)
Bool
sna_video_clip_helper(ScrnInfoPtr scrn,
struct sna_video *adaptor_priv,
+ struct sna_video_frame *frame,
xf86CrtcPtr * crtc_ret,
BoxPtr dst,
short src_x, short src_y,
short drw_x, short drw_y,
short src_w, short src_h,
short drw_w, short drw_h,
- int id,
- int *top, int* left, int* npixels, int *nlines,
- RegionPtr reg, INT32 width, INT32 height);
+ RegionPtr reg);
void
sna_video_frame_init(struct sna *sna,
@@ -117,8 +121,6 @@ Bool
sna_video_copy_data(struct sna *sna,
struct sna_video *video,
struct sna_video_frame *frame,
- int top, int left,
- int npixels, int nlines,
const uint8_t *buf);
void sna_video_frame_fini(struct sna *sna,
diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c
index a20c1112..491baa87 100644
--- a/src/sna/sna_video_overlay.c
+++ b/src/sna/sna_video_overlay.c
@@ -467,7 +467,6 @@ sna_video_overlay_put_image(ScrnInfoPtr scrn,
struct sna_video_frame frame;
BoxRec dstBox;
xf86CrtcPtr crtc;
- int top, left, npixels, nlines;
DBG(("%s: src: (%d,%d)(%d,%d), dst: (%d,%d)(%d,%d), width %d, height %d\n",
__FUNCTION__,
@@ -483,15 +482,16 @@ sna_video_overlay_put_image(ScrnInfoPtr scrn,
if (src_h >= (drw_h * 8))
drw_h = src_h / 7;
+ sna_video_frame_init(sna, video, id, width, height, &frame);
+
if (!sna_video_clip_helper(scrn,
video,
+ &frame,
&crtc,
&dstBox,
src_x, src_y, drw_x, drw_y,
src_w, src_h, drw_w, drw_h,
- id,
- &top, &left, &npixels, &nlines, clip,
- width, height))
+ clip))
return Success;
if (!crtc) {
@@ -502,12 +502,9 @@ sna_video_overlay_put_image(ScrnInfoPtr scrn,
return Success;
}
- sna_video_frame_init(sna, video, id, width, height, &frame);
-
/* overlay can't handle rotation natively, store it for the copy func */
video->rotation = crtc->rotation;
- if (!sna_video_copy_data(sna, video, &frame,
- top, left, npixels, nlines, buf)) {
+ if (!sna_video_copy_data(sna, video, &frame, buf)) {
DBG(("%s: failed to copy video data\n", __FUNCTION__));
return BadAlloc;
}
diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c
index 64d54ec9..3461dc54 100644
--- a/src/sna/sna_video_textured.c
+++ b/src/sna/sna_video_textured.c
@@ -237,22 +237,20 @@ sna_video_textured_put_image(ScrnInfoPtr scrn,
PixmapPtr pixmap = get_drawable_pixmap(drawable);
BoxRec dstBox;
xf86CrtcPtr crtc;
- int top, left, npixels, nlines;
Bool flush = false;
if (!sna_pixmap(pixmap))
return BadAlloc;
- if (!sna_video_clip_helper(scrn, video, &crtc, &dstBox,
+ sna_video_frame_init(sna, video, id, width, height, &frame);
+
+ if (!sna_video_clip_helper(scrn, video, &frame,
+ &crtc, &dstBox,
src_x, src_y, drw_x, drw_y,
src_w, src_h, drw_w, drw_h,
- id,
- &top, &left, &npixels, &nlines,
- clip, width, height))
+ clip))
return Success;
- sna_video_frame_init(sna, video, id, width, height, &frame);
-
if (xvmc_passthrough(id)) {
if (IS_I915G(sna) || IS_I915GM(sna)) {
/* XXX: i915 is not support and needs some
@@ -264,9 +262,7 @@ sna_video_textured_put_image(ScrnInfoPtr scrn,
if (frame.bo == NULL)
return BadAlloc;
} else {
- if (!sna_video_copy_data(sna, video, &frame,
- top, left, npixels, nlines,
- buf))
+ if (!sna_video_copy_data(sna, video, &frame, buf))
return BadAlloc;
}