From patchwork Wed Dec 29 18:40:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 439761 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBUMBEkY000490 for ; Thu, 30 Dec 2010 22:11:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753558Ab0L2SlM (ORCPT ); Wed, 29 Dec 2010 13:41:12 -0500 Received: from smtp-vbr1.xs4all.nl ([194.109.24.21]:1543 "EHLO smtp-vbr1.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753519Ab0L2SlL convert rfc822-to-8bit (ORCPT ); Wed, 29 Dec 2010 13:41:11 -0500 Received: from durdane.localnet (marune.xs4all.nl [82.95.89.49]) (authenticated bits=0) by smtp-vbr1.xs4all.nl (8.13.8/8.13.8) with ESMTP id oBTIesSi046039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 29 Dec 2010 19:40:55 +0100 (CET) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: Hans de Goede Subject: Re: nasty bug at qv4l2 Date: Wed, 29 Dec 2010 19:40:53 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.37-rc7-durdane; KDE/4.4.5; x86_64; ; ) Cc: Mauro Carvalho Chehab , Linux Media Mailing List References: <4D11E170.6050500@redhat.com> <4D15FB27.7080302@redhat.com> <4D1A6A54.8050401@redhat.com> In-Reply-To: <4D1A6A54.8050401@redhat.com> MIME-Version: 1.0 Message-Id: <201012291940.53929.hverkuil@xs4all.nl> X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Dec 2010 22:11:43 +0000 (UTC) diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index 5646bcf..a085f86 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -178,7 +178,10 @@ void ApplicationWindow::capFrame() switch (m_capMethod) { case methodRead: s = read(m_frameData, m_capSrcFormat.fmt.pix.sizeimage); - err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat, + if (useWrapper()) + memcpy(m_capImage->bits(), m_frameData, m_capSrcFormat.fmt.pix.sizeimage); + else + err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat, m_frameData, m_capSrcFormat.fmt.pix.sizeimage, m_capImage->bits(), m_capDestFormat.fmt.pix.sizeimage); break; @@ -190,7 +193,11 @@ void ApplicationWindow::capFrame() return; } - err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat, + if (useWrapper()) + memcpy(m_capImage->bits(), (unsigned char *)m_buffers[buf.index].start, + m_capSrcFormat.fmt.pix.sizeimage); + else + err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat, (unsigned char *)m_buffers[buf.index].start, buf.bytesused, m_capImage->bits(), m_capDestFormat.fmt.pix.sizeimage); @@ -209,7 +216,11 @@ void ApplicationWindow::capFrame() && buf.length == m_buffers[i].length) break; - err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat, + if (useWrapper()) + memcpy(m_capImage->bits(), (unsigned char *)buf.m.userptr, + m_capSrcFormat.fmt.pix.sizeimage); + else + err = v4lconvert_convert(m_convertData, &m_capSrcFormat, &m_capDestFormat, (unsigned char *)buf.m.userptr, buf.bytesused, m_capImage->bits(), m_capDestFormat.fmt.pix.sizeimage); @@ -410,6 +421,11 @@ void ApplicationWindow::capStart(bool start) } m_capMethod = m_genTab->capMethod(); g_fmt_cap(m_capSrcFormat); + if (useWrapper()) { + m_capSrcFormat.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; + s_fmt(m_capSrcFormat); + g_fmt_cap(m_capSrcFormat); + } m_frameData = new unsigned char[m_capSrcFormat.fmt.pix.sizeimage]; m_capDestFormat = m_capSrcFormat; m_capDestFormat.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; @@ -421,11 +437,13 @@ void ApplicationWindow::capStart(bool start) break; } } - v4lconvert_try_format(m_convertData, &m_capDestFormat, &m_capSrcFormat); - // v4lconvert_try_format sometimes modifies the source format if it thinks - // that there is a better format available. Restore our selected source - // format since we do not want that happening. - g_fmt_cap(m_capSrcFormat); + if (!useWrapper()) { + v4lconvert_try_format(m_convertData, &m_capDestFormat, &m_capSrcFormat); + // v4lconvert_try_format sometimes modifies the source format if it thinks + // that there is a better format available. Restore our selected source + // format since we do not want that happening. + g_fmt_cap(m_capSrcFormat); + } m_capture->setMinimumSize(m_capDestFormat.fmt.pix.width, m_capDestFormat.fmt.pix.height); m_capImage = new QImage(m_capDestFormat.fmt.pix.width, m_capDestFormat.fmt.pix.height, dstFmt); m_capImage->fill(0);