[MPlayer-dev-eng] [PATCH] v4l formats + planar u, y swapped

kirin_e at users.sourceforge.net kirin_e at users.sourceforge.net
Mon Apr 7 16:56:15 CEST 2008


3 other patches i did, separate from the v4lw update in my last mail.
First one is a bug fix i guess?

planar_swapped.patch:
444p/422p/411p doesn't have u & y planes in same order as yv12

v4l_autoformat.patch:
actually check if format is supported so we don't always try to use yv12

tv_format.patch:
adds bgr24/32 and 422p as supported in v4l

/kirin
-------------- next part --------------
diff -Naur ../uu/mplayer-export-2008-04-05/libmpcodecs/mp_image.h ./libmpcodecs/mp_image.h
--- ../uu/mplayer-export-2008-04-05/libmpcodecs/mp_image.h	Thu Mar  6 09:34:50 2008
+++ ./libmpcodecs/mp_image.h	Sun Apr  6 07:28:35 2008
@@ -158,6 +158,7 @@
 	mpi->chroma_y_shift=2;
 	return;
     case IMGFMT_444P:
+	mpi->flags|=MP_IMGFLAG_SWAPPED;
 	mpi->flags|=MP_IMGFLAG_PLANAR;
 	mpi->bpp=24;
 	mpi->chroma_width=(mpi->width);
@@ -166,6 +167,7 @@
 	mpi->chroma_y_shift=0;
 	return;
     case IMGFMT_422P:
+	mpi->flags|=MP_IMGFLAG_SWAPPED;
 	mpi->flags|=MP_IMGFLAG_PLANAR;
 	mpi->bpp=16;
 	mpi->chroma_width=(mpi->width>>1);
@@ -174,6 +176,7 @@
 	mpi->chroma_y_shift=0;
 	return;
     case IMGFMT_411P:
+	mpi->flags|=MP_IMGFLAG_SWAPPED;
 	mpi->flags|=MP_IMGFLAG_PLANAR;
 	mpi->bpp=12;
 	mpi->chroma_width=(mpi->width>>2);

-------------- next part --------------
diff -Naur ../uu/mplayer-export-2008-04-05/stream/tvi_v4l.c ./stream/tvi_v4l.c
--- ../uu/mplayer-export-2008-04-05/stream/tvi_v4l.c	Sun Jan 13 13:01:57 2008
+++ ./stream/tvi_v4l.c	Sun Apr  6 07:50:49 2008
@@ -1184,7 +1186,17 @@
             return(TVI_CONTROL_TRUE);
         }
         case TVI_CONTROL_VID_SET_FORMAT:
+        {
+            struct video_picture pict_tmp;
+
             priv->format = *(int *)arg;
+
+            if (ioctl(priv->video_fd, VIDIOCGPICT, &pict_tmp) == -1)
+                return(TVI_CONTROL_FALSE);
+            pict_tmp.palette = format2palette(priv->format);
+            if (ioctl(priv->video_fd, VIDIOCSPICT, &pict_tmp) == -1)
+                return(TVI_CONTROL_FALSE);
+
             // !HACK! v4l uses BGR format instead of RGB
             // and we have to correct this. Fortunately,
             // tv.c reads later the format back so we
@@ -1194,6 +1206,7 @@
                 priv->format |= IMGFMT_BGR;
             }
             return(TVI_CONTROL_TRUE);
+        }
         case TVI_CONTROL_VID_GET_PLANES:
             *(int *)arg = 1; /* FIXME, also not needed at this time */
             return(TVI_CONTROL_TRUE);

-------------- next part --------------
diff -Naur ../uu/mplayer-export-2008-04-05/stream/tv.c ./stream/tv.c
--- ../uu/mplayer-export-2008-04-05/stream/tv.c	Sun Jan 13 13:01:57 2008
+++ ./stream/tv.c	Sun Apr  6 07:28:21 2008
@@ -324,8 +324,11 @@
       IMGFMT_I420,
       IMGFMT_UYVY,
       IMGFMT_YUY2,
+      IMGFMT_422P,
       IMGFMT_RGB32,
       IMGFMT_RGB24,
+      IMGFMT_BGR32,
+      IMGFMT_BGR24,
       IMGFMT_RGB16,
       IMGFMT_RGB15
     };
@@ -352,6 +355,7 @@
 	case IMGFMT_I420:
 	case IMGFMT_UYVY:
 	case IMGFMT_YUY2:
+	case IMGFMT_422P:
 	case IMGFMT_RGB32:
 	case IMGFMT_RGB24:
 	case IMGFMT_BGR32:
diff -Naur ../uu/mplayer-export-2008-04-05/stream/tvi_v4l.c ./stream/tvi_v4l.c
--- ../uu/mplayer-export-2008-04-05/stream/tvi_v4l.c	Sun Jan 13 13:01:57 2008
+++ ./stream/tvi_v4l.c	Sun Apr  6 07:50:49 2008
@@ -260,6 +260,8 @@
         case IMGFMT_YV12:
         case IMGFMT_I420:
             return(VIDEO_PALETTE_YUV420P);
+       case IMGFMT_422P:
+           return(VIDEO_PALETTE_YUV422P);
         case IMGFMT_YUY2:
             return(VIDEO_PALETTE_YUV422);
     case IMGFMT_UYVY:



More information about the MPlayer-dev-eng mailing list