desktop/python2-v4l2capture/YUV420_out_1.4.patch
2012-06-05 22:48:15 +00:00

143 lines
5.1 KiB
Diff

=== modified file 'README'
--- README 2010-07-20 23:46:35 +0000
+++ README 2011-03-18 15:51:36 +0000
@@ -1,7 +1,7 @@
python-v4l2capture 1.1
Python extension to capture video with video4linux2
-2009, 2010 Fredrik Portstrom
+2009, 2010, 2011 Fredrik Portstrom
I, the copyright holder of this file, hereby release it into the
public domain. This applies worldwide. In case this is not legally
@@ -13,20 +13,19 @@
python-v4l2capture is a slim and easy to use Python extension for
capturing video with video4linux2. It supports libv4l to convert any
-image format to RGB.
+image format to RGB or YUV420.
python-v4l2capture: http://fredrik.jemla.eu/v4l2capture
-libv4l: http://hansdegoede.livejournal.com/3636.html
+libv4l: http://freshmeat.net/projects/libv4l
Installation
============
v4l2capture requires libv4l by default. You can compile v4l2capture
-without libv4l if you only want it to support video devices supporting
-the YUYV pixel format. You can do so by erasing ', libraries =
-["v4l2"]' in setup.py and erasing '#define USE_LIBV4L' in
-v4l2capture.c.
+without libv4l, but that reduces image format support to YUYV input
+and RGB output only. You can do so by erasing ', libraries = ["v4l2"]'
+in setup.py and erasing '#define USE_LIBV4L' in v4l2capture.c.
python-v4l2capture uses distutils.
To build: ./setup.py build
@@ -40,6 +39,8 @@
Change log
==========
+1.4 (2011-03-18) - Added support for YUV420 output.
+
1.3 (2010-07-21) - Added set of capabilities to the return value of
get_info. Updated list_devices.py.
=== modified file 'setup.py'
--- setup.py 2010-04-01 08:09:53 +0000
+++ setup.py 2011-03-18 15:51:36 +0000
@@ -2,7 +2,7 @@
#
# python-v4l2capture
#
-# 2009, 2010 Fredrik Portstrom
+# 2009, 2010, 2011 Fredrik Portstrom
#
# I, the copyright holder of this file, hereby release it into the
# public domain. This applies worldwide. In case this is not legally
@@ -13,7 +13,7 @@
from distutils.core import Extension, setup
setup(
name = "v4l2capture",
- version = "1.3",
+ version = "1.4",
author = "Fredrik Portstrom",
author_email = "fredrik@jemla.se",
url = "http://fredrik.jemla.eu/v4l2capture",
=== modified file 'v4l2capture.c'
--- v4l2capture.c 2010-07-20 23:46:35 +0000
+++ v4l2capture.c 2011-03-18 15:51:36 +0000
@@ -1,7 +1,7 @@
// python-v4l2capture
// Python extension to capture video with video4linux2
//
-// 2009, 2010 Fredrik Portstrom
+// 2009, 2010, 2011 Fredrik Portstrom
//
// I, the copyright holder of this file, hereby release it into the
// public domain. This applies worldwide. In case this is not legally
@@ -180,7 +180,7 @@
struct capability *capability = capabilities;
- while(capability < (void *)capabilities + sizeof(capabilities))
+ while((void *)capability < (void *)capabilities + sizeof(capabilities))
{
if(caps.capabilities & capability->id)
{
@@ -205,8 +205,9 @@
{
int size_x;
int size_y;
+ int yuv420 = 0;
- if(!PyArg_ParseTuple(args, "ii", &size_x, &size_y))
+ if(!PyArg_ParseTuple(args, "ii|i", &size_x, &size_y, &yuv420))
{
return NULL;
}
@@ -216,7 +217,8 @@
format.fmt.pix.width = size_x;
format.fmt.pix.height = size_y;
#ifdef USE_LIBV4L
- format.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
+ format.fmt.pix.pixelformat =
+ yuv420 ? V4L2_PIX_FMT_YUV420 : V4L2_PIX_FMT_RGB24;
#else
format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
#endif
@@ -462,9 +464,11 @@
"set containing strings identifying the capabilities of the video "
"device."},
{"set_format", (PyCFunction)Video_device_set_format, METH_VARARGS,
- "set_format(size_x, size_y) -> size_x, size_y\n\n"
- "Request the video device to set image size. The device may choose "
- "another size than requested and will return its choice."},
+ "set_format(size_x, size_y, yuv420 = 0) -> size_x, size_y\n\n"
+ "Request the video device to set image size and format. The device may "
+ "choose another size than requested and will return its choice. The "
+ "image format will be RGB24 if yuv420 is false (default) or YUV420 if "
+ "yuv420 is true."},
{"start", (PyCFunction)Video_device_start, METH_NOARGS,
"start()\n\n"
"Start video capture."},
@@ -481,9 +485,10 @@
"Let the video device fill all buffers created."},
{"read", (PyCFunction)Video_device_read, METH_NOARGS,
"read() -> string\n\n"
- "Reads RGB image data from a buffer that has been filled by the video "
- "device. The buffer is removed from the queue. Fails if no buffer is "
- "filled. Use select.select to check for filled buffers."},
+ "Reads image data from a buffer that has been filled by the video "
+ "device. The image data is in RGB och YUV420 format as decided by "
+ "'set_format'. The buffer is removed from the queue. Fails if no buffer "
+ "is filled. Use select.select to check for filled buffers."},
{"read_and_queue", (PyCFunction)Video_device_read_and_queue, METH_NOARGS,
"read_and_queue()\n\n"
"Same as 'read', but adds the buffer back to the queue so the video "