linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>,
	Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: nasty bug at qv4l2
Date: Fri, 31 Dec 2010 16:02:10 +0100	[thread overview]
Message-ID: <4D1DF072.7080408@redhat.com> (raw)
In-Reply-To: <201012241520.01460.hverkuil@xs4all.nl>

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

Hi,

Hans V. I've tested your patch for avoiding the double
conversion problem, and I can report it fixes the issue seen with
webcameras which need 90 degrees rotation.

While testing I found a bug in gspca, which gets triggered by
qv4l2 which makes it impossible to switch between userptr and
mmap mode. While fixing that I also found some locking issues in
gspca. As these all touch the gscpa core I'll send a patch set
to Jean Francois Moine for this.

With the issues in gspca fixed, I found a bug in qv4l2 when using
read mode in raw mode (not passing the correct src_size to
libv4lconvert_convert).

I've attached 2 patches to qv4l2, fixing the read issue and a similar
issue in mmap / userptr mode. These apply on top of your patch.

Regards,

Hans

[-- Attachment #2: 0001-qv4l2-Check-and-use-result-of-read.patch --]
[-- Type: text/plain, Size: 1808 bytes --]

>From d3393364292441fca894186c406a7e9ee982d243 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 31 Dec 2010 11:50:28 +0100
Subject: [PATCH 1/2] qv4l2: Check and use result of read()

qv4l2 was calling libv4lconvert_convert with a src size of fmt.pix.sizeimage,
rather then using the actual amount of bytes read. This causes decompressors
which check if they have consumed the entire compressed frame (ie pjpg) to
error out, because they were not being passed the actual frame size.

This patch fixes this, and also adds reporting of libv4lconvert_convert
errors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 utils/qv4l2/qv4l2.cpp |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp
index a085f86..1876b3c 100644
--- a/utils/qv4l2/qv4l2.cpp
+++ b/utils/qv4l2/qv4l2.cpp
@@ -178,11 +178,18 @@ void ApplicationWindow::capFrame()
 	switch (m_capMethod) {
 	case methodRead:
 		s = read(m_frameData, m_capSrcFormat.fmt.pix.sizeimage);
+		if (s < 0) {
+			if (errno != EAGAIN) {
+				error("read");
+				m_capStartAct->setChecked(false);
+			}
+			return;
+		}
 		if (useWrapper())
-			memcpy(m_capImage->bits(), m_frameData, m_capSrcFormat.fmt.pix.sizeimage);
+			memcpy(m_capImage->bits(), m_frameData, s);
 		else
 			err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat,
-				m_frameData, m_capSrcFormat.fmt.pix.sizeimage,
+				m_frameData, s,
 				m_capImage->bits(), m_capDestFormat.fmt.pix.sizeimage);
 		break;
 
@@ -227,6 +234,9 @@ void ApplicationWindow::capFrame()
 		qbuf(buf);
 		break;
 	}
+	if (err == -1)
+		error(v4lconvert_get_error_message(m_convertData));
+
 	m_capture->setImage(*m_capImage);
 	if (m_capture->frame() == 1)
 		refresh();
-- 
1.7.3.2


[-- Attachment #3: 0002-qv4l2-When-in-wrapped-mode-memcpy-the-actual-framesi.patch --]
[-- Type: text/plain, Size: 1241 bytes --]

>From 4a3587e7466274f74d89a6608999887f3c62e66a Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 31 Dec 2010 11:55:44 +0100
Subject: [PATCH 2/2] qv4l2: When in wrapped mode memcpy the actual framesize

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 utils/qv4l2/qv4l2.cpp |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp
index 1876b3c..bd1db3e 100644
--- a/utils/qv4l2/qv4l2.cpp
+++ b/utils/qv4l2/qv4l2.cpp
@@ -202,7 +202,7 @@ void ApplicationWindow::capFrame()
 
 		if (useWrapper())
 			memcpy(m_capImage->bits(), (unsigned char *)m_buffers[buf.index].start,
-					m_capSrcFormat.fmt.pix.sizeimage);
+					buf.bytesused);
 		else
 			err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat,
 				(unsigned char *)m_buffers[buf.index].start, buf.bytesused,
@@ -225,7 +225,7 @@ void ApplicationWindow::capFrame()
 
 		if (useWrapper())
 			memcpy(m_capImage->bits(), (unsigned char *)buf.m.userptr,
-					m_capSrcFormat.fmt.pix.sizeimage);
+					buf.bytesused);
 		else
 			err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat,
 				(unsigned char *)buf.m.userptr, buf.bytesused,
-- 
1.7.3.2


  parent reply	other threads:[~2010-12-31 14:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-22 11:30 nasty bug at qv4l2 Mauro Carvalho Chehab
2010-12-24 14:19 ` Hans de Goede
2010-12-24 14:20   ` Hans Verkuil
2010-12-24 14:41     ` Hans de Goede
2010-12-24 18:54       ` Hans Verkuil
2010-12-25  9:14         ` Mauro Carvalho Chehab
2010-12-25 14:09           ` Mauro Carvalho Chehab
2010-12-28 22:53             ` Hans de Goede
2010-12-29 18:40               ` Hans Verkuil
2010-12-25  8:54       ` Mauro Carvalho Chehab
2010-12-31 15:02     ` Hans de Goede [this message]
2010-12-31 15:08       ` Hans Verkuil
2010-12-31 16:18         ` Mauro Carvalho Chehab
2010-12-24 20:06   ` [PATCH] Adds the Lego Bionicle to existing sq905c Theodore Kilgore
2010-12-24 19:55     ` Hans de Goede
2010-12-25  9:20       ` Mauro Carvalho Chehab
2010-12-25  9:36         ` Hans de Goede
2010-12-25  9:52           ` Jean-Francois Moine
2010-12-25 10:24             ` Mauro Carvalho Chehab
2010-12-25 18:14             ` Theodore Kilgore
2010-12-25 18:44               ` Jean-Francois Moine
2010-12-25 17:59           ` Theodore Kilgore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D1DF072.7080408@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).