From: Hans Verkuil Date: Thu, 8 Aug 2013 11:50:46 +0000 (+0200) Subject: Revert "qv4l2: add aspect ratio support" X-Git-Tag: v4l-utils-1.2.0~418 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b60f5805afbeb5c049ccdd2af62eb0431aac7568;p=platform%2Fupstream%2Fv4l-utils.git Revert "qv4l2: add aspect ratio support" This reverts commit 6b6a5ec8e0b1caa9f4f87b4aa7397b869bdd6f69. --- diff --git a/utils/qv4l2/capture-win-gl.cpp b/utils/qv4l2/capture-win-gl.cpp index 628aaec..edae60f 100644 --- a/utils/qv4l2/capture-win-gl.cpp +++ b/utils/qv4l2/capture-win-gl.cpp @@ -43,15 +43,6 @@ void CaptureWinGL::stop() #endif } -void CaptureWinGL::resizeEvent(QResizeEvent *event) -{ - QSize margins = getMargins(); -#ifdef ENABLE_GL - m_videoSurface.setSize(width() - margins.width(), height() - margins.height()); -#endif - event->accept(); -} - void CaptureWinGL::setFrame(int width, int height, __u32 format, unsigned char *data, const QString &info) { #ifdef ENABLE_GL @@ -118,22 +109,11 @@ void CaptureWinGLEngine::initializeGL() checkError("InitializeGL"); } -void CaptureWinGLEngine::setSize(int width, int height) -{ - QSize sizedFrame = CaptureWin::scaleFrameSize(QSize(width, height), QSize(m_frameWidth, m_frameHeight)); - - width = sizedFrame.width(); - height = sizedFrame.height(); - - if (width > 0 && height > 0) { - setMaximumSize(width, height); - resizeGL(width, height); - } -} void CaptureWinGLEngine::resizeGL(int width, int height) { - glViewport(0, 0, width, height); + // Resizing is disabled by setting viewport equal to frame size + glViewport(0, 0, m_frameWidth, m_frameHeight); } void CaptureWinGLEngine::setFrame(int width, int height, __u32 format, unsigned char *data) @@ -143,6 +123,8 @@ void CaptureWinGLEngine::setFrame(int width, int height, __u32 format, unsigned m_frameWidth = width; m_frameHeight = height; m_frameFormat = format; + + QGLWidget::setMaximumSize(m_frameWidth, m_frameHeight); } m_frameData = data; diff --git a/utils/qv4l2/capture-win-gl.h b/utils/qv4l2/capture-win-gl.h index ef06d0b..08e72b2 100644 --- a/utils/qv4l2/capture-win-gl.h +++ b/utils/qv4l2/capture-win-gl.h @@ -21,9 +21,6 @@ #include "qv4l2.h" #include "capture-win.h" -#include -#include - #ifdef ENABLE_GL #define GL_GLEXT_PROTOTYPES #include @@ -43,7 +40,6 @@ public: void stop(); void setFrame(int width, int height, __u32 format, unsigned char *data); bool hasNativeFormat(__u32 format); - void setSize(int width, int height); protected: void paintGL(); @@ -92,10 +88,6 @@ public: bool hasNativeFormat(__u32 format); static bool isSupported(); - protected: - void resizeEvent(QResizeEvent *event); - -private: #ifdef ENABLE_GL CaptureWinGLEngine m_videoSurface; #endif diff --git a/utils/qv4l2/capture-win-qt.cpp b/utils/qv4l2/capture-win-qt.cpp index 0f6964b..63c77d5 100644 --- a/utils/qv4l2/capture-win-qt.cpp +++ b/utils/qv4l2/capture-win-qt.cpp @@ -22,9 +22,8 @@ CaptureWinQt::CaptureWinQt() : m_frame(new QImage(0, 0, QImage::Format_Invalid)) { + CaptureWin::buildWindow(&m_videoSurface); - m_scaledFrame.setWidth(0); - m_scaledFrame.setHeight(0); } CaptureWinQt::~CaptureWinQt() @@ -32,19 +31,6 @@ CaptureWinQt::~CaptureWinQt() delete m_frame; } -void CaptureWinQt::resizeEvent(QResizeEvent *event) -{ - if (m_frame->bits() == NULL) - return; - - QPixmap img = QPixmap::fromImage(*m_frame); - m_scaledFrame = scaleFrameSize(QSize(m_videoSurface.width(), m_videoSurface.height()), - QSize(m_frame->width(), m_frame->height())); - img = img.scaled(m_scaledFrame.width(), m_scaledFrame.height(), Qt::IgnoreAspectRatio); - m_videoSurface.setPixmap(img); - QWidget::resizeEvent(event); -} - void CaptureWinQt::setFrame(int width, int height, __u32 format, unsigned char *data, const QString &info) { QImage::Format dstFmt; @@ -55,8 +41,6 @@ void CaptureWinQt::setFrame(int width, int height, __u32 format, unsigned char * if (m_frame->width() != width || m_frame->height() != height || m_frame->format() != dstFmt) { delete m_frame; m_frame = new QImage(width, height, dstFmt); - m_scaledFrame = scaleFrameSize(QSize(m_videoSurface.width(), m_videoSurface.height()), - QSize(m_frame->width(), m_frame->height())); } if (data == NULL || !supported) @@ -65,11 +49,7 @@ void CaptureWinQt::setFrame(int width, int height, __u32 format, unsigned char * memcpy(m_frame->bits(), data, m_frame->numBytes()); m_information.setText(info); - - QPixmap img = QPixmap::fromImage(*m_frame); - img = img.scaled(m_scaledFrame.width(), m_scaledFrame.height(), Qt::IgnoreAspectRatio); - - m_videoSurface.setPixmap(img); + m_videoSurface.setPixmap(QPixmap::fromImage(*m_frame)); } bool CaptureWinQt::hasNativeFormat(__u32 format) diff --git a/utils/qv4l2/capture-win-qt.h b/utils/qv4l2/capture-win-qt.h index 6029109..d192045 100644 --- a/utils/qv4l2/capture-win-qt.h +++ b/utils/qv4l2/capture-win-qt.h @@ -25,7 +25,6 @@ #include #include -#include class CaptureWinQt : public CaptureWin { @@ -40,14 +39,10 @@ public: bool hasNativeFormat(__u32 format); static bool isSupported() { return true; } -protected: - void resizeEvent(QResizeEvent *event); - private: bool findNativeFormat(__u32 format, QImage::Format &dstFmt); QImage *m_frame; QLabel m_videoSurface; - QSize m_scaledFrame; }; #endif diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp index 415829a..435c19b 100644 --- a/utils/qv4l2/capture-win.cpp +++ b/utils/qv4l2/capture-win.cpp @@ -30,7 +30,6 @@ #define MIN_WIN_SIZE_HEIGHT 120 bool CaptureWin::m_enableScaling = true; -double CaptureWin::m_pixelAspectRatio = 1.0; CaptureWin::CaptureWin() : m_curWidth(-1), @@ -74,14 +73,6 @@ void CaptureWin::resetSize() resize(w, h); } -int CaptureWin::actualFrameWidth(int width) -{ - if (m_enableScaling) - return (int)((double)width * m_pixelAspectRatio); - else - return width; -} - QSize CaptureWin::getMargins() { int l, t, r, b; @@ -103,14 +94,6 @@ void CaptureWin::enableScaling(bool enable) delete event; } -void CaptureWin::setPixelAspectRatio(double ratio) -{ - m_pixelAspectRatio = ratio; - QResizeEvent *event = new QResizeEvent(QSize(width(), height()), QSize(width(), height())); - QCoreApplication::sendEvent(this, event); - delete event; -} - void CaptureWin::resize(int width, int height) { // Dont resize window if the frame size is the same in @@ -122,7 +105,7 @@ void CaptureWin::resize(int width, int height) m_curHeight = height; QSize margins = getMargins(); - width = actualFrameWidth(width) + margins.width(); + width += margins.width(); height += margins.height(); QDesktopWidget *screen = QApplication::desktop(); @@ -144,15 +127,12 @@ void CaptureWin::resize(int width, int height) QSize CaptureWin::scaleFrameSize(QSize window, QSize frame) { - int actualFrameWidth; + int actualFrameWidth = frame.width();; int actualFrameHeight = frame.height(); if (!m_enableScaling) { window.setWidth(frame.width()); window.setHeight(frame.height()); - actualFrameWidth = frame.width(); - } else { - actualFrameWidth = CaptureWin::actualFrameWidth(frame.width()); } double newW, newH; diff --git a/utils/qv4l2/capture-win.h b/utils/qv4l2/capture-win.h index eded9e0..1bfb1e1 100644 --- a/utils/qv4l2/capture-win.h +++ b/utils/qv4l2/capture-win.h @@ -76,10 +76,9 @@ public: static bool isSupported() { return false; } void enableScaling(bool enable); - void setPixelAspectRatio(double ratio); static QSize scaleFrameSize(QSize window, QSize frame); - public slots: +public slots: void resetSize(); protected: @@ -100,11 +99,6 @@ protected: */ static bool m_enableScaling; - /** - * @note Aspect ratio it taken care of by scaling, frame size is for square pixels only! - */ - static double m_pixelAspectRatio; - signals: void close(); diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp index be28748..5cfaf07 100644 --- a/utils/qv4l2/general-tab.cpp +++ b/utils/qv4l2/general-tab.cpp @@ -53,7 +53,6 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) m_tvStandard(NULL), m_qryStandard(NULL), m_videoTimings(NULL), - m_pixelAspectRatio(NULL), m_qryTimings(NULL), m_freq(NULL), m_vidCapFormats(NULL), @@ -211,20 +210,6 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) connect(m_qryTimings, SIGNAL(clicked()), SLOT(qryTimingsClicked())); } - if (!isRadio() && !isVbi()) { - m_pixelAspectRatio = new QComboBox(parent); - m_pixelAspectRatio->addItem("Autodetect"); - m_pixelAspectRatio->addItem("Square"); - m_pixelAspectRatio->addItem("NTSC/PAL-M/PAL-60"); - m_pixelAspectRatio->addItem("NTSC/PAL-M/PAL-60, Anamorphic"); - m_pixelAspectRatio->addItem("PAL/SECAM"); - m_pixelAspectRatio->addItem("PAL/SECAM, Anamorphic"); - - addLabel("Pixel Aspect Ratio"); - addWidget(m_pixelAspectRatio); - connect(m_pixelAspectRatio, SIGNAL(activated(int)), SIGNAL(pixelAspectRatioChanged())); - } - if (m_tuner.capability) { QDoubleValidator *val; double factor = (m_tuner.capability & V4L2_TUNER_CAP_LOW) ? 16 : 16000; @@ -1120,27 +1105,6 @@ void GeneralTab::updateFrameSize() updateFrameInterval(); } -double GeneralTab::getPixelAspectRatio() -{ - if (m_pixelAspectRatio->currentText().compare("Autodetect") == 0) { - v4l2_cropcap ratio; - ratio.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - if (ioctl(VIDIOC_CROPCAP, &ratio) < 0) - return 1.0; - - return (double)ratio.pixelaspect.denominator / ratio.pixelaspect.numerator; - } - if (m_pixelAspectRatio->currentText().compare("NTSC/PAL-M/PAL-60") == 0) - return 10.0/11.0; - if (m_pixelAspectRatio->currentText().compare("NTSC/PAL-M/PAL-60, Anamorphic") == 0) - return 40.0/33.0; - if (m_pixelAspectRatio->currentText().compare("PAL/SECAM") == 0) - return 12.0/11.0; - if (m_pixelAspectRatio->currentText().compare("PAL/SECAM, Anamorphic") == 0) - return 16.0/11.0; - return 1.0; -} - void GeneralTab::updateFrameInterval() { v4l2_frmivalenum frmival; diff --git a/utils/qv4l2/general-tab.h b/utils/qv4l2/general-tab.h index 0a182f5..6c51016 100644 --- a/utils/qv4l2/general-tab.h +++ b/utils/qv4l2/general-tab.h @@ -57,7 +57,6 @@ public: void setAudioDeviceBufferSize(int size); int getAudioDeviceBufferSize(); bool hasAlsaAudio(); - double getPixelAspectRatio(); bool get_interval(struct v4l2_fract &interval); int width() const { return m_width; } int height() const { return m_height; } @@ -91,7 +90,6 @@ public slots: signals: void audioDeviceChanged(); - void pixelAspectRatioChanged(); private slots: void inputChanged(int); @@ -184,7 +182,6 @@ private: QComboBox *m_tvStandard; QPushButton *m_qryStandard; QComboBox *m_videoTimings; - QComboBox *m_pixelAspectRatio; QPushButton *m_qryTimings; QLineEdit *m_freq; QComboBox *m_freqTable; diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index cdeed91..c3d9b86 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -103,7 +103,7 @@ ApplicationWindow::ApplicationWindow() : m_saveRawAct->setChecked(false); connect(m_saveRawAct, SIGNAL(toggled(bool)), this, SLOT(saveRaw(bool))); - m_showFramesAct = new QAction(QIcon(":/video-television.png"), "&Show Frames", this); + m_showFramesAct = new QAction(QIcon(":/video-television.png"), "Show &Frames", this); m_showFramesAct->setStatusTip("Only show captured frames if set."); m_showFramesAct->setCheckable(true); m_showFramesAct->setChecked(true); @@ -137,12 +137,12 @@ ApplicationWindow::ApplicationWindow() : toolBar->addSeparator(); toolBar->addAction(quitAct); - m_scalingAct = new QAction("&Enable Video Scaling", this); + 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 = new QAction("Resize to Frame Size", this); m_resetScalingAct->setStatusTip("Resizes the capture window to match frame size"); m_resetScalingAct->setShortcut(Qt::CTRL+Qt::Key_F); @@ -169,13 +169,13 @@ ApplicationWindow::ApplicationWindow() : #ifdef HAVE_ALSA captureMenu->addSeparator(); - m_showAllAudioAct = new QAction("Show All Audio &Devices", this); + m_showAllAudioAct = new QAction("Show All Audio Devices", this); m_showAllAudioAct->setStatusTip("Show all audio input and output devices if set"); m_showAllAudioAct->setCheckable(true); m_showAllAudioAct->setChecked(false); captureMenu->addAction(m_showAllAudioAct); - m_audioBufferAct = new QAction("Set Audio &Buffer Size...", this); + m_audioBufferAct = new QAction("Set Audio Buffer Capacity...", this); m_audioBufferAct->setStatusTip("Set audio buffer capacity in amout of ms than can be stored"); connect(m_audioBufferAct, SIGNAL(triggered()), this, SLOT(setAudioBufferSize())); captureMenu->addAction(m_audioBufferAct); @@ -216,6 +216,8 @@ void ApplicationWindow::setDevice(const QString &device, bool rawOpen) newCaptureWin(); + m_capture->setMinimumSize(150, 50); + QWidget *w = new QWidget(m_tabs); m_genTab = new GeneralTab(device, *this, 4, w); @@ -231,7 +233,6 @@ void ApplicationWindow::setDevice(const QString &device, bool rawOpen) } #endif - connect(m_genTab, SIGNAL(pixelAspectRatioChanged()), this, SLOT(updatePixelAspectRatio())); m_tabs->addTab(w, "General"); addTabs(); if (caps() & (V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_CAPTURE)) { @@ -362,7 +363,6 @@ void ApplicationWindow::newCaptureWin() break; } - m_capture->setPixelAspectRatio(1.0); m_capture->enableScaling(m_scalingAct->isChecked()); connect(m_capture, SIGNAL(close()), this, SLOT(closeCaptureWin())); connect(m_resetScalingAct, SIGNAL(triggered()), m_capture, SLOT(resetSize())); @@ -811,12 +811,6 @@ void ApplicationWindow::enableScaling(bool enable) m_capture->enableScaling(enable); } -void ApplicationWindow::updatePixelAspectRatio() -{ - if (m_capture != NULL && m_genTab != NULL) - m_capture->setPixelAspectRatio(m_genTab->getPixelAspectRatio()); -} - void ApplicationWindow::startAudio() { #ifdef HAVE_ALSA @@ -898,7 +892,6 @@ void ApplicationWindow::capStart(bool start) m_vbiTab->slicedFormat(fmt.fmt.sliced); m_vbiSize = fmt.fmt.sliced.io_size; m_frameData = new unsigned char[m_vbiSize]; - updatePixelAspectRatio(); if (startCapture(m_vbiSize)) { m_capNotifier = new QSocketNotifier(fd(), QSocketNotifier::Read, m_tabs); connect(m_capNotifier, SIGNAL(activated(int)), this, SLOT(capVbiFrame())); @@ -967,7 +960,6 @@ void ApplicationWindow::capStart(bool start) m_capSrcFormat = copy; } - updatePixelAspectRatio(); 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) diff --git a/utils/qv4l2/qv4l2.h b/utils/qv4l2/qv4l2.h index 970a0e1..511a652 100644 --- a/utils/qv4l2/qv4l2.h +++ b/utils/qv4l2/qv4l2.h @@ -132,8 +132,6 @@ private slots: void openRawFile(const QString &s); void rejectedRawFile(); void setAudioBufferSize(); - void enableScaling(bool enable); - void updatePixelAspectRatio(); void about(); @@ -176,7 +174,6 @@ private: void updateStandard(); void updateFreq(); void updateFreqChannel(); - bool showFrames(); GeneralTab *m_genTab; VbiTab *m_vbiTab; @@ -187,8 +184,6 @@ private: QAction *m_useGLAct; QAction *m_showAllAudioAct; QAction *m_audioBufferAct; - QAction *m_scalingAct; - QAction *m_resetScalingAct; QString m_filename; QSignalMapper *m_sigMapper; QTabWidget *m_tabs; @@ -200,6 +195,7 @@ private: WidgetMap m_widgetMap; ClassMap m_classMap; bool m_haveExtendedUserCtrls; + bool m_showFrames; int m_vbiSize; unsigned m_vbiWidth; unsigned m_vbiHeight;