From patchwork Tue Aug 11 14:06:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 40670 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7BE6wJD022269 for ; Tue, 11 Aug 2009 14:06:58 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A0049EE0D; Tue, 11 Aug 2009 07:06:58 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.ffwll.ch (cable-static-49-187.intergga.ch [157.161.49.187]) by gabe.freedesktop.org (Postfix) with ESMTP id 57D979EE01 for ; Tue, 11 Aug 2009 07:06:53 -0700 (PDT) Received: by mail.ffwll.ch (Postfix, from userid 1000) id B20D620C218; Wed, 12 Aug 2009 00:00:21 +0200 (CEST) X-Spam-ASN: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on orange.ffwll.ch X-Spam-Level: X-Spam-Hammy: 0.000-+--signedoffby, 0.000-+--signed-off-by, 0.000-+--100644 X-Spam-Status: No, score=-4.4 required=6.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Spammy: 0.973-+--H*m:ffwll, 0.971-+--H*Ad:U*daniel.vetter, 0.947-+--H*Ad:D*ffwll.ch Received: from biene (unknown [192.168.23.129]) by mail.ffwll.ch (Postfix) with ESMTP id 9DD6920C223; Wed, 12 Aug 2009 00:00:07 +0200 (CEST) Received: from daniel by biene with local (Exim 4.69) (envelope-from ) id 1Mas0A-0003eJ-Pj; Tue, 11 Aug 2009 16:06:58 +0200 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Aug 2009 16:06:34 +0200 Message-Id: X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <10614c7dd4ecbb1b4d3dd6a15b949cb389053f1f.1249999028.git.daniel.vetter@ffwll.ch> References: <0328734a90544a6cd72d9eaf64015db9d3462921.1249999028.git.daniel.vetter@ffwll.ch> <10614c7dd4ecbb1b4d3dd6a15b949cb389053f1f.1249999028.git.daniel.vetter@ffwll.ch> In-Reply-To: References: Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 04/18] Xv: introduce planar memcpy helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Reduced 3 copies of the same code to one. Signed-off-by: Daniel Vetter --- src/i830_video.c | 176 +++++++++++++++++------------------------------------- 1 files changed, 54 insertions(+), 122 deletions(-) diff --git a/src/i830_video.c b/src/i830_video.c index 1f17ae1..c27a8ba 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -1349,6 +1349,55 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, drm_intel_bo_unmap(pPriv->buf); } +static void i830_memcpy_plane(unsigned char *dst, unsigned char *src, + int height, int width, + int dstPitch, int srcPitch, Rotation rotation) +{ + int i, j = 0; + unsigned char *s; + + switch (rotation) { + case RR_Rotate_0: + /* optimise for the case of no clipping */ + if (srcPitch == dstPitch && srcPitch == width) + memcpy (dst, src, srcPitch * height); + else + for (i = 0; i < height; i++) { + memcpy(dst, src, width); + src += srcPitch; + dst += dstPitch; + } + break; + case RR_Rotate_90: + for (i = 0; i < height; i++) { + s = src; + for (j = 0; j < width; j++) { + dst[(i) + ((width - j - 1) * dstPitch)] = *s++; + } + src += srcPitch; + } + break; + case RR_Rotate_180: + for (i = 0; i < height; i++) { + s = src; + for (j = 0; j < width; j++) { + dst[(width - j - 1) + ((height - i - 1) * dstPitch)] = *s++; + } + src += srcPitch; + } + break; + case RR_Rotate_270: + for (i = 0; i < height; i++) { + s = src; + for (j = 0; j < width; j++) { + dst[(height - i - 1) + (j * dstPitch)] = *s++; + } + src += srcPitch; + } + break; + } +} + static void I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, unsigned char *buf, int srcPitch, @@ -1356,9 +1405,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int h, int w, int id) { I830Ptr pI830 = I830PTR(pScrn); - int i, j = 0; unsigned char *src1, *src2, *src3, *dst_base, *dst1, *dst2, *dst3; - unsigned char *s; int dstPitch2 = dstPitch << 1; #if 0 @@ -1388,46 +1435,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, else dst1 = dst_base + pPriv->YBuf1offset; - switch (pPriv->rotation) { - case RR_Rotate_0: - /* optimise for the case of no clipping */ - if (srcPitch == dstPitch2 && srcPitch == w) - memcpy (dst1, src1, srcPitch * h); - else - for (i = 0; i < h; i++) { - memcpy(dst1, src1, w); - src1 += srcPitch; - dst1 += dstPitch2; - } - break; - case RR_Rotate_90: - for (i = 0; i < h; i++) { - s = src1; - for (j = 0; j < w; j++) { - dst1[(i) + ((w - j - 1) * dstPitch2)] = *s++; - } - src1 += srcPitch; - } - break; - case RR_Rotate_180: - for (i = 0; i < h; i++) { - s = src1; - for (j = 0; j < w; j++) { - dst1[(w - j - 1) + ((h - i - 1) * dstPitch2)] = *s++; - } - src1 += srcPitch; - } - break; - case RR_Rotate_270: - for (i = 0; i < h; i++) { - s = src1; - for (j = 0; j < w; j++) { - dst1[(h - i - 1) + (j * dstPitch2)] = *s++; - } - src1 += srcPitch; - } - break; - } + i830_memcpy_plane(dst1, src1, h, w, dstPitch2, srcPitch, pPriv->rotation); /* Copy V data for YV12, or U data for I420 */ src2 = buf + /* start of YUV data */ @@ -1451,46 +1459,8 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, dst2 = dst_base + pPriv->VBuf1offset; } - switch (pPriv->rotation) { - case RR_Rotate_0: - /* optimise for the case of no clipping */ - if (srcPitch2 == dstPitch && srcPitch2 == (w/2)) - memcpy (dst2, src2, h/2 * srcPitch2); - else - for (i = 0; i < h / 2; i++) { - memcpy(dst2, src2, w / 2); - src2 += srcPitch2; - dst2 += dstPitch; - } - break; - case RR_Rotate_90: - for (i = 0; i < (h/2); i++) { - s = src2; - for (j = 0; j < (w/2); j++) { - dst2[(i) + (((w/2) - j - 1) * (dstPitch))] = *s++; - } - src2 += srcPitch2; - } - break; - case RR_Rotate_180: - for (i = 0; i < (h/2); i++) { - s = src2; - for (j = 0; j < (w/2); j++) { - dst2[((w/2) - j - 1) + (((h/2) - i - 1) * dstPitch)] = *s++; - } - src2 += srcPitch2; - } - break; - case RR_Rotate_270: - for (i = 0; i < (h/2); i++) { - s = src2; - for (j = 0; j < (w/2); j++) { - dst2[((h/2) - i - 1) + (j * dstPitch)] = *s++; - } - src2 += srcPitch2; - } - break; - } + i830_memcpy_plane(dst2, src2, h/2, w/2, + dstPitch, srcPitch2, pPriv->rotation); /* Copy U data for YV12, or V data for I420 */ src3 = buf + /* start of YUV data */ @@ -1514,46 +1484,8 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, dst3 = dst_base + pPriv->UBuf1offset; } - switch (pPriv->rotation) { - case RR_Rotate_0: - /* optimise for the case of no clipping */ - if (srcPitch2 == dstPitch && srcPitch2 == (w/2)) - memcpy (dst3, src3, srcPitch2 * h/2); - else - for (i = 0; i < h / 2; i++) { - memcpy(dst3, src3, w / 2); - src3 += srcPitch2; - dst3 += dstPitch; - } - break; - case RR_Rotate_90: - for (i = 0; i < (h/2); i++) { - s = src3; - for (j = 0; j < (w/2); j++) { - dst3[(i) + (((w/2) - j - 1) * (dstPitch))] = *s++; - } - src3 += srcPitch2; - } - break; - case RR_Rotate_180: - for (i = 0; i < (h/2); i++) { - s = src3; - for (j = 0; j < (w/2); j++) { - dst3[((w/2) - j - 1) + (((h/2) - i - 1) * dstPitch)] = *s++; - } - src3 += srcPitch2; - } - break; - case RR_Rotate_270: - for (i = 0; i < (h/2); i++) { - s = src3; - for (j = 0; j < (w/2); j++) { - dst3[((h/2) - i - 1) + (j * dstPitch)] = *s++; - } - src3 += srcPitch2; - } - break; - } + i830_memcpy_plane(dst3, src3, h/2, w/2, + dstPitch, srcPitch2, pPriv->rotation); if (pPriv->textured) drm_intel_bo_unmap(pPriv->buf);