From 5c4ae96417ef434444d8bf93a0b135d0d5aa9013 Mon Sep 17 00:00:00 2001 From: =?utf8?q?B=C3=A5rd=20Eirik=20Winther?= Date: Mon, 5 Aug 2013 07:56:55 +0000 Subject: [PATCH] qv4l2: add video scaling for CaptureWin MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: BÃ¥rd Eirik Winther Signed-off-by: Hans Verkuil --- utils/qv4l2/qv4l2.cpp | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index 68fcf45..fd52788 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -137,9 +137,20 @@ ApplicationWindow::ApplicationWindow() : toolBar->addSeparator(); toolBar->addAction(quitAct); + m_scalingAct = new QAction("Enable Video Scaling", this); + m_scalingAct->setStatusTip("Scale video frames to match window size if set"); + m_scalingAct->setCheckable(true); + m_scalingAct->setChecked(true); + connect(m_scalingAct, SIGNAL(toggled(bool)), this, SLOT(enableScaling(bool))); + m_resetScalingAct = new QAction("Resize to Frame Size", this); + m_resetScalingAct->setStatusTip("Resizes the capture window to match frame size"); + QMenu *captureMenu = menuBar()->addMenu("&Capture"); captureMenu->addAction(m_capStartAct); captureMenu->addAction(m_showFramesAct); + captureMenu->addAction(m_scalingAct); + captureMenu->addAction(m_resetScalingAct); + if (CaptureWinGL::isSupported()) { m_renderMethod = QV4L2_RENDER_GL; @@ -351,7 +362,9 @@ void ApplicationWindow::newCaptureWin() break; } - connect(m_capture, SIGNAL(close()), this, SLOT(closeCaptureWin())); + m_capture->enableScaling(m_scalingAct->isChecked()); + connect(m_capture, SIGNAL(close()), this, SLOT(closeCaptureWin())); + connect(m_resetScalingAct, SIGNAL(triggered()), m_capture, SLOT(resetSize())); } void ApplicationWindow::capVbiFrame() @@ -791,6 +804,12 @@ void ApplicationWindow::stopOutput() { } +void ApplicationWindow::enableScaling(bool enable) +{ + if (m_capture != NULL) + m_capture->enableScaling(enable); +} + void ApplicationWindow::startAudio() { #ifdef HAVE_ALSA @@ -901,7 +920,7 @@ void ApplicationWindow::capStart(bool start) m_vbiHeight = fmt.fmt.vbi.count[0] + fmt.fmt.vbi.count[1]; m_vbiSize = m_vbiWidth * m_vbiHeight; m_frameData = new unsigned char[m_vbiSize]; - m_capture->setMinimumSize(m_vbiWidth, m_vbiHeight); + m_capture->resize(m_vbiWidth, m_vbiHeight); m_capImage = new QImage(m_vbiWidth, m_vbiHeight, dstFmt); m_capImage->fill(0); m_capture->setFrame(m_capImage->width(), m_capImage->height(), @@ -931,8 +950,8 @@ void ApplicationWindow::capStart(bool start) m_mustConvert = false; } else { m_mustConvert = true; + v4l2_format copy = m_capSrcFormat; - 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 @@ -940,7 +959,7 @@ void ApplicationWindow::capStart(bool start) m_capSrcFormat = copy; } - m_capture->setMinimumSize(dstPix.width, dstPix.height); + m_capture->resize(dstPix.width, dstPix.height); // Ensure that the initial image is large enough for native 32 bit per pixel formats if (dstPix.pixelformat == V4L2_PIX_FMT_RGB32 || dstPix.pixelformat == V4L2_PIX_FMT_BGR32) dstFmt = QImage::Format_ARGB32; -- 2.7.4