[MPlayer-dev-eng] [PATCH v2 5/5] vo_xv: Support NV12/21

Alexander Strasser eclipse7 at gmx.net
Mon Jul 10 00:30:59 EEST 2017


Based-on-a-patch-by: Ville Syrjälä >syrjala sci fi<
Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 libvo/vo_xv.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 3aaf12417..0fc55130d 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -413,6 +413,18 @@ static int draw_slice(uint8_t * image[], int stride[], int w, int h,
         memcpy_pic(dst, image[idx_p2], w, h, xvimage[current_buf]->pitches[2],
             stride[idx_p2]);
         break;
+    case IMGFMT_NV12:
+    case IMGFMT_NV21:
+        x &= ~1;
+        y /= 2;
+        w &= ~1;
+        h /= 2;
+
+        dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
+            xvimage[current_buf]->pitches[1] * y + x;
+            memcpy_pic(dst, image[idx_p1], w, h, xvimage[current_buf]->pitches[1],
+                       stride[idx_p1]);
+        break;
     }
 
     return 0;
@@ -496,6 +508,13 @@ static uint32_t get_image(mp_image_t * mpi)
             mpi->stride[1] = xvimage[current_buf]->pitches[idx_p1];
             mpi->stride[2] = xvimage[current_buf]->pitches[idx_p2];
             break;
+        case IMGFMT_NV12:
+        case IMGFMT_NV21:
+            mpi->planes[1] =
+                xvimage[current_buf]->data +
+                xvimage[current_buf]->offsets[1];
+            mpi->stride[1] = xvimage[current_buf]->pitches[1];
+            break;
         }
         mpi->flags |= MP_IMGFLAG_DIRECT;
         mpi->priv = (void *)(intptr_t)current_buf;
@@ -511,6 +530,8 @@ static int is_supported_format(uint32_t format)
     case IMGFMT_YV12:
     case IMGFMT_I420:
     case IMGFMT_IYUV:
+    case IMGFMT_NV12:
+    case IMGFMT_NV21:
         return 1;
     default:
         return !mp_get_chroma_shift(image_format, NULL, NULL, NULL);
-- 
2.13.2


  Alexander


More information about the MPlayer-dev-eng mailing list