[MPlayer-dev-eng] [PATCH v2 4/5] vo xv: Limit output formats to what the vo actually supports

Alexander Strasser eclipse7 at gmx.net
Mon Jul 10 00:28:41 EEST 2017


Assumes the format IDs (FourCCs in this case) are the same in MPlayer
and Xvideo.

That assumption is nothing new, but it was never checked if in case
of a match, we actually supported that image format in vo xv.

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 libvo/vo_xv.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index a607f8517..3aaf12417 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -396,7 +396,8 @@ static int draw_slice(uint8_t * image[], int stride[], int w, int h,
     switch (image_format) {
     case IMGFMT_YV12:
         idx_p1 = 2; idx_p2 = 1;
-    default:
+    case IMGFMT_I420:
+    case IMGFMT_IYUV:
         x /= 2;
         y /= 2;
         w /= 2;
@@ -484,7 +485,8 @@ static uint32_t get_image(mp_image_t * mpi)
         switch (image_format) {
         case IMGFMT_YV12:
             idx_p1 = 2; idx_p2 = 1;
-        default:
+        case IMGFMT_I420:
+        case IMGFMT_IYUV:
             mpi->planes[1] =
                 xvimage[current_buf]->data +
                 xvimage[current_buf]->offsets[idx_p1];
@@ -503,10 +505,25 @@ static uint32_t get_image(mp_image_t * mpi)
     return VO_FALSE;
 }
 
+static int is_supported_format(uint32_t format)
+{
+    switch (format) {
+    case IMGFMT_YV12:
+    case IMGFMT_I420:
+    case IMGFMT_IYUV:
+        return 1;
+    default:
+        return !mp_get_chroma_shift(image_format, NULL, NULL, NULL);
+    }
+}
+
 static int query_format(uint32_t format)
 {
     uint32_t i;
     int flag = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN | VFCAP_OSD | VFCAP_ACCEPT_STRIDE;       // FIXME! check for DOWN
+    if (!is_supported_format(format)) {
+        return 0;
+    }
 
     /* check image formats */
     for (i = 0; i < formats; i++)
-- 
2.13.2


  Alexander


More information about the MPlayer-dev-eng mailing list