summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-12-29 18:35:22 -0200
committerPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-12-29 18:35:22 -0200
commitdeb2f845dd370ba819d02cb21b8a481827497af6 (patch)
tree6749e76df87f59496ac4496707b428b89b721cd4 /src
parent46741589529809c17aa1e9719492a4b623de6ddf (diff)
Simplification and redundancy removal in video code.
FOURCC_YV12 and FOURCC_I420 handling also was buggy. First it was doing a noop by swapping offset2 and offset3 values twice, and second, swap is not required when using smi 501/502 CSC video. Changed SMI_DisplayVideo0501_CSC() to not set static values to registers in a possible loop, if there is clipping.
Diffstat (limited to 'src')
-rw-r--r--src/smi_video.c88
1 files changed, 39 insertions, 49 deletions
diff --git a/src/smi_video.c b/src/smi_video.c
index 18cb0c2..3ae30f4 100644
--- a/src/smi_video.c
+++ b/src/smi_video.c
@@ -1530,6 +1530,7 @@ SMI_PutImage(
switch (id) {
case FOURCC_YV12:
+ case FOURCC_I420:
srcPitch = (width + 3) & ~3;
offset2 = srcPitch * height;
srcPitch2 = ((width >> 1) + 3) & ~3;
@@ -1539,16 +1540,6 @@ SMI_PutImage(
else
dstPitch = ((width << 1) + 15) & ~15;
break;
- case FOURCC_I420:
- srcPitch = (width + 3) & ~3;
- offset3 = srcPitch * height;
- srcPitch2 = ((width >> 1) + 3) & ~3;
- offset2 = offset3 + (srcPitch2 * (height >> 1));
- if (pSmi->CSCVideo)
- dstPitch = (((width >> 1) + 15) & ~15) << 1;
- else
- dstPitch = ((width << 1) + 15) & ~15;
- break;
case FOURCC_RV24:
bpp = 3;
srcPitch = width * bpp;
@@ -1589,19 +1580,17 @@ SMI_PutImage(
tmp = ((top >> 1) * srcPitch2) + (left >> 2);
offset2 += tmp;
offset3 += tmp;
-
- if (id == FOURCC_I420) {
- tmp = offset2;
- offset2 = offset3;
- offset3 = tmp;
- }
-
if (pSmi->CSCVideo)
CopyYV12ToVideoMem(buf,
buf + offset2, buf + offset3,
dstStart, srcPitch, srcPitch2, dstPitch,
height, width);
else {
+ if (id == FOURCC_I420) {
+ tmp = offset2;
+ offset2 = offset3;
+ offset3 = tmp;
+ }
nLines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
xf86XVCopyYUV12ToPacked(buf + (top * srcPitch) + (left >> 1),
buf + offset2, buf + offset3, dstStart,
@@ -1849,8 +1838,39 @@ SMI_DisplayVideo0501_CSC(ScrnInfoPtr pScrn, int id, int offset,
csc = (1 << 31) | (1 << 25);
if (pSmi->Bpp > 2)
csc |= 1 << 26;
- if (id == FOURCC_YV12 || id == FOURCC_I420)
- csc |= 2 << 28;
+
+ switch (id) {
+ case FOURCC_YV12:
+ SrcUVPitch = SrcYPitch / 2;
+ SrcVBase = SrcYBase + SrcYPitch * height;
+ SrcUBase = SrcVBase + SrcUVPitch * height / 2;
+ csc |= 2 << 28;
+ break;
+
+ case FOURCC_I420:
+ SrcUVPitch = SrcYPitch / 2;
+ SrcUBase = SrcYBase + SrcYPitch * height;
+ SrcVBase = SrcUBase + SrcUVPitch * height / 2;
+ csc |= 2 << 28;
+ break;
+
+ case FOURCC_YUY2:
+ case FOURCC_RV16:
+ case FOURCC_RV32:
+ SrcUBase = SrcVBase = SrcYBase;
+ SrcUVPitch = SrcYPitch;
+ break;
+
+ default:
+ LEAVE();
+ }
+
+ WRITE_DPR(pSmi, 0xE4, ((SrcYPitch >> 4) << 16) | (SrcUVPitch >> 4));
+ WRITE_DPR(pSmi, 0xC8, SrcYBase);
+ WRITE_DPR(pSmi, 0xD8, SrcUBase);
+ WRITE_DPR(pSmi, 0xDC, SrcVBase);
+ WRITE_DPR(pSmi, 0xF4, (((ScaleXn << 13) | ScaleXd) << 16) |
+ (ScaleYn << 13 | ScaleYd));
for (i = 0; i < nbox; i++, pbox++) {
rect_x = pbox->x1;
@@ -1858,30 +1878,6 @@ SMI_DisplayVideo0501_CSC(ScrnInfoPtr pScrn, int id, int offset,
rect_w = pbox->x2 - pbox->x1;
rect_h = pbox->y2 - pbox->y1;
- switch (id) {
- case FOURCC_YV12:
- SrcUVPitch = SrcYPitch / 2;
- SrcVBase = SrcYBase + SrcYPitch * height;
- SrcUBase = SrcVBase + SrcUVPitch * height / 2;
- break;
-
- case FOURCC_I420:
- SrcUVPitch = SrcYPitch / 2;
- SrcUBase = SrcYBase + SrcYPitch * height;
- SrcVBase = SrcUBase + SrcUVPitch * height / 2;
- break;
-
- case FOURCC_YUY2:
- case FOURCC_RV16:
- case FOURCC_RV32:
- SrcUBase = SrcVBase = SrcYBase;
- SrcUVPitch = SrcYPitch;
- break;
-
- default:
- return;
- }
-
SrcLn = (rect_x - dstBox->x1) * Hscale;
SrcLd = ((rect_x - dstBox->x1) << 13) * Hscale - (SrcLn << 13);
SrcRn = (rect_x + rect_w - dstBox->x1) * Hscale;
@@ -1896,15 +1892,9 @@ SMI_DisplayVideo0501_CSC(ScrnInfoPtr pScrn, int id, int offset,
WRITE_DPR(pSmi, 0xD0, (SrcLn << 16) | SrcLd);
WRITE_DPR(pSmi, 0xD4, (SrcTn << 16) | SrcTd);
WRITE_DPR(pSmi, 0xE0, (SrcDimX << 16) | SrcDimY);
- WRITE_DPR(pSmi, 0xE4, ((SrcYPitch >> 4) << 16) | (SrcUVPitch >> 4));
WRITE_DPR(pSmi, 0xE8, (rect_x << 16) | rect_y);
WRITE_DPR(pSmi, 0xEC, (rect_w << 16) | rect_h);
WRITE_DPR(pSmi, 0xF0, ((DestPitch >> 4) << 16) | rect_h);
- WRITE_DPR(pSmi, 0xF4, (((ScaleXn << 13) | ScaleXd) << 16) |
- (ScaleYn << 13 | ScaleYd));
- WRITE_DPR(pSmi, 0xC8, SrcYBase);
- WRITE_DPR(pSmi, 0xD8, SrcUBase);
- WRITE_DPR(pSmi, 0xDC, SrcVBase);
while (READ_DPR(pSmi, 0xfc) & (1 << 31))
;