Mesa (master): st/xorg: stop overflowing yuv buffers

Zack Rusin zack at kemper.freedesktop.org
Mon Oct 26 12:09:31 UTC 2009


Module: Mesa
Branch: master
Commit: 0b069d648b787636cc57149f47a06fb16f7629ab
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b069d648b787636cc57149f47a06fb16f7629ab

Author: Zack Rusin <zackr at vmware.com>
Date:   Sat Oct 24 01:29:27 2009 -0400

st/xorg: stop overflowing yuv buffers

---

 src/gallium/state_trackers/xorg/xorg_exa_tgsi.c |    2 +-
 src/gallium/state_trackers/xorg/xorg_xv.c       |   55 +++++++++++++++--------
 2 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
index 7cb11dc..30fcff8 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c
@@ -247,7 +247,7 @@ create_vs(struct pipe_context *pipe,
    const1 = ureg_DECL_constant(ureg, 1);
 
    /* it has to be either a fill or a composite op */
-   debug_assert(is_fill ^ is_composite);
+   debug_assert((is_fill ^ is_composite) ^ is_yuv);
 
    src = ureg_DECL_vs_input(ureg, input_slot++);
    dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0);
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index 983310f..b054ba8 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -216,6 +216,7 @@ copy_packed_data(ScrnInfoPtr pScrn,
    char *ymap, *vmap, *umap;
    unsigned char y1, y2, u, v;
    int yidx, uidx, vidx;
+   int y_array_size = w * h;
 
    src = buf + (top * srcPitch) + (left << 1);
 
@@ -232,13 +233,12 @@ copy_packed_data(ScrnInfoPtr pScrn,
                                      PIPE_TRANSFER_WRITE,
                                      left, top, w, h);
 
-   ymap = screen->transfer_map(screen, ytrans);
-   umap = screen->transfer_map(screen, utrans);
-   vmap = screen->transfer_map(screen, vtrans);
+   ymap = (char*)screen->transfer_map(screen, ytrans);
+   umap = (char*)screen->transfer_map(screen, utrans);
+   vmap = (char*)screen->transfer_map(screen, vtrans);
 
    switch (id) {
    case FOURCC_YV12: {
-      int y_array_size = w * h;
       for (i = 0; i < w; ++i) {
          for (j = 0; i < h; ++j) {
             /*XXX use src? */
@@ -252,22 +252,39 @@ copy_packed_data(ScrnInfoPtr pScrn,
       }
    }
       break;
+   case FOURCC_UYVY:
+      for (i = 0; i < y_array_size; i +=2 ) {
+         /* extracting two pixels */
+         u  = buf[0];
+         y1 = buf[1];
+         v  = buf[2];
+         y2 = buf[3];
+         buf += 4;
+
+         ymap[yidx++] = y1;
+         ymap[yidx++] = y2;
+         umap[uidx++] = u;
+         umap[uidx++] = u;
+         vmap[vidx++] = v;
+         vmap[vidx++] = v;
+      }
+      break;
    case FOURCC_YUY2:
-      for (j = 0; j < h; ++j) {
-         for (i = 0; i < w; ++i) {
-            /* extracting two pixels */
-            y1 = buf[0];
-            u  = buf[1];
-            y2 = buf[2];
-            v  = buf[3];
-
-            ymap[yidx++] = y1;
-            ymap[yidx++] = y2;
-            umap[uidx++] = u;
-            umap[uidx++] = u;
-            vmap[vidx++] = v;
-            vmap[vidx++] = v;
-         }
+      for (i = 0; i < y_array_size; i +=2 ) {
+         /* extracting two pixels */
+         y1 = buf[0];
+         u  = buf[1];
+         y2 = buf[2];
+         v  = buf[3];
+
+         buf += 4;
+
+         ymap[yidx++] = y1;
+         ymap[yidx++] = y2;
+         umap[uidx++] = u;
+         umap[uidx++] = u;
+         vmap[vidx++] = v;
+         vmap[vidx++] = v;
       }
       break;
    default:




More information about the mesa-commit mailing list