[MPlayer-cvslog] r37947 - trunk/libvo/vo_xv.c

al subversion at mplayerhq.hu
Sat Aug 26 23:34:41 EEST 2017


Author: al
Date: Sat Aug 26 23:34:40 2017
New Revision: 37947

Log:
vo_xv: Simplify plane swapping

Modified:
   trunk/libvo/vo_xv.c

Modified: trunk/libvo/vo_xv.c
==============================================================================
--- trunk/libvo/vo_xv.c	Mon Jul  3 22:00:43 2017	(r37946)
+++ trunk/libvo/vo_xv.c	Sat Aug 26 23:34:40 2017	(r37947)
@@ -386,12 +386,17 @@ static int draw_slice(uint8_t * image[],
                            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[],
 
     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 * m
     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
-                mpi->planes[1] =
-                    xvimage[current_buf]->data +
-                    xvimage[current_buf]->offsets[1];
-                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
+        switch (image_format) {
+        case IMGFMT_YV12:
+            idx_p1 = 2; idx_p2 = 1;
+        default:
                 mpi->planes[1] =
                     xvimage[current_buf]->data +
-                    xvimage[current_buf]->offsets[2];
+                    xvimage[current_buf]->offsets[idx_p1];
                 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;


More information about the MPlayer-cvslog mailing list