[PATCH 1/5] vo_xv: Simplify plane swapping

Alexander Strasser <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Message-ID <33ed4a3cec69f0a2c5015630eb52b678c50845b1.1497479932.git.eclipse7@gmx.net>
Signed-off-by: Alexander Strasser <[email protected]>
---
 libvo/vo_xv.c | 54 +++++++++++++++++++++---------------------------------
 1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 95600fc85..a39c8d504 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -386,12 +386,17 @@ static int draw_slice(uint8_t * image[], int stride[], int w, int h,
                            int x, int y)
 {
     uint8_t *dst;
+    int idx_p1 = 1, idx_p2 = 2;
 
     dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[0] +
         xvimage[current_buf]->pitches[0] * y + x;
     memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0],
                stride[0]);
 
+    switch (image_format) {
+    case IMGFMT_YV12:
+        idx_p1 = 2; idx_p2 = 1;
+    default:
     x /= 2;
     y /= 2;
     w /= 2;
@@ -399,21 +404,15 @@ static int draw_slice(uint8_t * image[], int stride[], int w, int h,
 
     dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
         xvimage[current_buf]->pitches[1] * y + x;
-    if (image_format != IMGFMT_YV12)
-        memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
-                   stride[1]);
-    else
-        memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
-                   stride[2]);
+        memcpy_pic(dst, image[idx_p1], w, h, xvimage[current_buf]->pitches[1],
+                   stride[idx_p1]);
 
     dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] +
         xvimage[current_buf]->pitches[2] * y + x;
-    if (image_format == IMGFMT_YV12)
-        memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
-                   stride[1]);
-    else
-        memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
-                   stride[2]);
+        memcpy_pic(dst, image[idx_p2], w, h, xvimage[current_buf]->pitches[1],
+                   stride[idx_p2]);
+        break;
+    }
 
     return 0;
 }
@@ -476,36 +475,25 @@ static uint32_t get_image(mp_image_t * mpi)
     if ((mpi->flags & (MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_ACCEPT_WIDTH))
         || (mpi->width * (mpi->bpp / 8) == xvimage[buf]->pitches[0]))
     {
+        int idx_p1 = 1, idx_p2 = 2;
         current_buf = buf;
         mpi->planes[0] =
             xvimage[current_buf]->data + xvimage[current_buf]->offsets[0];
         mpi->stride[0] = xvimage[current_buf]->pitches[0];
         mpi->width = mpi->stride[0] / (mpi->bpp / 8);
-        if (mpi->flags & MP_IMGFLAG_PLANAR)
-        {
-            if (mpi->flags & MP_IMGFLAG_SWAPPED)
-            {
-                // I420
+        switch (image_format) {
+        case IMGFMT_YV12:
+            idx_p1 = 2; idx_p2 = 1;
+        default:
                 mpi->planes[1] =
                     xvimage[current_buf]->data +
-                    xvimage[current_buf]->offsets[1];
+                    xvimage[current_buf]->offsets[idx_p1];
                 mpi->planes[2] =
                     xvimage[current_buf]->data +
-                    xvimage[current_buf]->offsets[2];
-                mpi->stride[1] = xvimage[current_buf]->pitches[1];
-                mpi->stride[2] = xvimage[current_buf]->pitches[2];
-            } else
-            {
-                // YV12
-                mpi->planes[1] =
-                    xvimage[current_buf]->data +
-                    xvimage[current_buf]->offsets[2];
-                mpi->planes[2] =
-                    xvimage[current_buf]->data +
-                    xvimage[current_buf]->offsets[1];
-                mpi->stride[1] = xvimage[current_buf]->pitches[2];
-                mpi->stride[2] = xvimage[current_buf]->pitches[1];
-            }
+                    xvimage[current_buf]->offsets[idx_p2];
+                mpi->stride[1] = xvimage[current_buf]->pitches[idx_p1];
+                mpi->stride[2] = xvimage[current_buf]->pitches[idx_p2];
+            break;
         }
         mpi->flags |= MP_IMGFLAG_DIRECT;
         mpi->priv = (void *)(intptr_t)current_buf;
-- 
_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.