qv4l2: add OpenGL rendering and window fixes
v2 cover qv4l2: add OpenGL rendering and window fixes
The qv4l2 test utility now supports OpenGL-accelerated display of video. This allows for using the graphics card to render the video content to screen and to perform color space conversion.
The OpenGL implementation requires OpenGL and QtOpenGL libraries as well as an OpenGL driver (typically from the graphics driver). If OpenGL support is not present,
then the program will fall back to using the CPU to display.
Changelog v2 FINAL:
- Restructured the patch series
- Preview menu is now Capture menu which contains both capture controls and audio/video settings for capture.
- Corrected the license description for CaptureWinGL
- Add doxygen documentation to capture-win.h
Changelog v2:
- Cleaned up the capture win code and classes
- CaptureWin is now a base class that can be used to implement different ways of displaying video.
- setMinimumSize is now more reliable
- Small code tweaks and improvements, including cleaner display flow
- Changed the OpenGL abbreviation from OGL to GL
Some of the changes/improvements:
- Moved the ctrlEvent() function in qv4l2.cpp to be grouped with GUI function and to group capFrame() and capVbiFrame() together.
- OpenGL acceleration for supported systems.
- Option to change between GPU or CPU based rendering.
- CaptureWin's setMinimumSize() sets the minimum size for the video frame viewport and not for the window itself. If the minimum size is larger than the monitor resolution, it will reduce the minimum size to match this.
- Added a new menu option 'Preview' for controlling the CaptureWin's behavior.
- Added a couple of hotkeys:
CTRL + V : When main window is selected start capture.
This gives an option other than the button to start recording, as this is a frequent operation when using the utility.
CTRL + W : When CaptureWin is selected close capture window.
It makes it easier to deal with high resolutions video on small screen, especially when the window close button may
be outside the monitor when repositioning the window.
Known issues:
- Repositioning, scaling or switching windows while the capture is recording will reduce the framerate. This is a limitation of Qt and not OpenGL.
- Using 4 streams of RGB3 1080p60 can at random times cease to render correctly
and reduce the framerate to half. A restart solves this though.
- OpenGL is limited to 60fps. Disabling V-sync might allow for faster framerates.
- Resizing or scaling is not supported, mainly because the YUY2 shader renders the image incorrectly when the canvas size is not equal to the frame size.
- Some of the supported OpenGL formats may use the CPU for colorspace conversion, but this is driver dependant.
Supported formats for OpenGL render:
- Native supported and accelerated:
V4L2_PIX_FMT_RGB32
V4L2_PIX_FMT_BGR32
V4L2_PIX_FMT_RGB24
V4L2_PIX_FMT_BGR24
V4L2_PIX_FMT_RGB565
V4L2_PIX_FMT_RGB555
V4L2_PIX_FMT_YUYV
V4L2_PIX_FMT_YVYU
V4L2_PIX_FMT_UYVY
V4L2_PIX_FMT_VYUY
V4L2_PIX_FMT_YVU420
V4L2_PIX_FMT_YUV420- All formats supported by V4L conversion library,
but they will use the CPU to convert to RGB3 before being displayed with OpenGL.
Performance:
All tests are done on an Intel i7-2600S (with Turbo Boost disabled) using the integrated Intel HD 2000 graphics processor. The mothreboard is an ASUS P8H77-I with 2x2GB CL 9-9-9-24 DDR3 RAM. The capture card is a Cisco test card with 4 HDMI inputs connected using PCIe2.0x8. All video input streams used for testing are progressive HD (1920x1080) with 60fps.
FPS for every input for a given number of streams:
1 STREAM 2 STREAMS 3 STREAMS 4 STREAMS
RGB3 60 60 60 60 BGR3 60 60 60 50 YUYV 60 60 60 48 YU12 60 60 60 52 YV12 60 60 60 52
PATCH v2 1/6 qv4l2: move function ctrlEvent
Moved the ctrlEvent() function in qv4l2.cpp to be grouped with GUI function and to group capFrame() and capVbiFrame() together.
--- utils/qv4l2/qv4l2.cpp | 94 +++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 47 deletions(-)
utils/qv4l2/qv4l2.cpp +47 -47
@@ -202,6 +202,53 @@ void ApplicationWindow::openrawdev() setDevice(d.selectedFiles().first(), true); } +void ApplicationWindow::ctrlEvent() +{ + v4l2_event ev; + + while (dqevent(ev)) { + if (ev.type != V4L2_EVENT_CTRL) + continue; + m_ctrlMap[ev.id].flags = ev.u.ctrl.flags; + m_ctrlMap[ev.id].minimum = ev.u.ctrl.minimum; + m_ctrlMap[ev.id].maximum = ev.u.ctrl.maximum; + m_ctrlMap[ev.id].step = ev.u.ctrl.step; + m_ctrlMap[ev.id].default_value = ev.u.ctrl.default_value; + m_widgetMap[ev.id]->setDisabled(m_ctrlMap[ev.id].flags & CTRL_FLAG_DISABLED); + switch (m_ctrlMap[ev.id].type) { + case V4L2_CTRL_TYPE_INTEGER: + case V4L2_CTRL_TYPE_INTEGER_MENU: + case V4L2_CTRL_TYPE_MENU: + case V4L2_CTRL_TYPE_BOOLEAN: + case V4L2_CTRL_TYPE_BITMASK: + setVal(ev.id, ev.u.ctrl.value); + break; + case V4L2_CTRL_TYPE_INTEGER64: + setVal64(ev.id, ev.u.ctrl.value64); + break; + default: + break; + } + if (m_ctrlMap[ev.id].type != V4L2_CTRL_TYPE_STRING) + continue; + queryctrl(m_ctrlMap[ev.id]); + + struct v4l2_ext_control c; + struct v4l2_ext_controls ctrls; + + c.id = ev.id; + c.size = m_ctrlMap[ev.id].maximum + 1; + c.string = (char *)malloc(c.size); + memset(&ctrls, 0, sizeof(ctrls)); + ctrls.count = 1; + ctrls.ctrl_class = 0; + ctrls.controls = &c; + if (!ioctl(VIDIOC_G_EXT_CTRLS, &ctrls)) + setString(ev.id, c.string); + free(c.string); + } +} + void ApplicationWindow::capVbiFrame() { __u32 buftype = m_genTab->bufType();
@@ -305,53 +352,6 @@ void ApplicationWindow::capVbiFrame() refresh(); } -void ApplicationWindow::ctrlEvent() -{ - v4l2_event ev; - - while (dqevent(ev)) { - if (ev.type != V4L2_EVENT_CTRL) - continue; - m_ctrlMap[ev.id].flags = ev.u.ctrl.flags; - m_ctrlMap[ev.id].minimum = ev.u.ctrl.minimum; - m_ctrlMap[ev.id].maximum = ev.u.ctrl.maximum; - m_ctrlMap[ev.id].step = ev.u.ctrl.step; - m_ctrlMap[ev.id].default_value = ev.u.ctrl.default_value; - m_widgetMap[ev.id]->setDisabled(m_ctrlMap[ev.id].flags & CTRL_FLAG_DISABLED); - switch (m_ctrlMap[ev.id].type) { - case V4L2_CTRL_TYPE_INTEGER: - case V4L2_CTRL_TYPE_INTEGER_MENU: - case V4L2_CTRL_TYPE_MENU: - case V4L2_CTRL_TYPE_BOOLEAN: - case V4L2_CTRL_TYPE_BITMASK: - setVal(ev.id, ev.u.ctrl.value); - break; - case V4L2_CTRL_TYPE_INTEGER64: - setVal64(ev.id, ev.u.ctrl.value64); - break; - default: - break; - } - if (m_ctrlMap[ev.id].type != V4L2_CTRL_TYPE_STRING) - continue; - queryctrl(m_ctrlMap[ev.id]); - - struct v4l2_ext_control c; - struct v4l2_ext_controls ctrls; - - c.id = ev.id; - c.size = m_ctrlMap[ev.id].maximum + 1; - c.string = (char *)malloc(c.size); - memset(&ctrls, 0, sizeof(ctrls)); - ctrls.count = 1; - ctrls.ctrl_class = 0; - ctrls.controls = &c; - if (!ioctl(VIDIOC_G_EXT_CTRLS, &ctrls)) - setString(ev.id, c.string); - free(c.string); - } -} - void ApplicationWindow::capFrame() { __u32 buftype = m_genTab->bufType();
Signature · 1 line
1.8.3.2
PATCH v2 2/6 qv4l2: add hotkeys for common operations
In reply to Bård Eirik WintherCTRL + V : When main window is selected start capture.
This gives an option other than the button to start recording, as this is a frequent operation when using the utility.
CTRL + W : When CaptureWin is selected close capture window
It makes it easier to deal with high resolutions video on small screen, especially when the window close button may be outside the monitor when repositioning the window.
--- utils/qv4l2/capture-win.cpp | 8 ++++++++ utils/qv4l2/capture-win.h | 4 +++- utils/qv4l2/qv4l2.cpp | 1 + 3 files changed, 12 insertions(+), 1 deletion(-)
utils/qv4l2/capture-win.cpp +8 -0
@@ -35,6 +35,14 @@ CaptureWin::CaptureWin() vbox->addWidget(m_label); vbox->addWidget(m_msg); + + hotkeyClose = new QShortcut(Qt::CTRL+Qt::Key_W, this); + QObject::connect(hotkeyClose, SIGNAL(activated()), this, SLOT(close())); +} + +CaptureWin::~CaptureWin() +{ + delete hotkeyClose; } void CaptureWin::setImage(const QImage &image, const QString &status)
utils/qv4l2/capture-win.h +3 -1
@@ -21,6 +21,7 @@#define CAPTURE_WIN_H #include <QWidget> +#include <QShortcut> #include <sys/time.h> class QImage;
@@ -32,7 +33,7 @@ class CaptureWin : public QWidget public:CaptureWin (); - virtual ~CaptureWin() {} + ~CaptureWin (); void setImage(const QImage &image, const QString &status);
@@ -45,6 +46,7 @@ signals: private:QLabel *m_label;QLabel *m_msg; + QShortcut *hotkeyClose; };#endif
utils/qv4l2/qv4l2.cpp +1 -0
@@ -78,6 +78,7 @@ ApplicationWindow::ApplicationWindow() : m_capStartAct->setStatusTip("Start capturing"); m_capStartAct->setCheckable(true); m_capStartAct->setDisabled(true); + m_capStartAct->setShortcut(Qt::CTRL+Qt::Key_V); connect(m_capStartAct, SIGNAL(toggled(bool)), this, SLOT(capStart(bool))); m_snapshotAct = new QAction(QIcon(":/snapshot.png"), "&Make Snapshot", this);
Signature · 1 line
1.8.3.2
Re: [PATCHv2 FINAL 2/6] qv4l2: add hotkeys for common operations
Hi Bård/Hans,
Em Tue, 30 Jul 2013 10:15:20 +0200
Bård Eirik Winther <[email protected]> escreveu:
Quoted 7 lines
CTRL + V : When main window is selected start capture.
This gives an option other than the button to start recording, as this is a frequent operation when using the utility.
CTRL + W : When CaptureWin is selected close capture window
It makes it easier to deal with high resolutions video on small screen, especially when the window close button may be outside the monitor when repositioning the window.
It would be great if you could also add some documentation for qv4l2, adding there the supported hot keys.
IMO, the better is to write it as a man page. If you need an example, you could take a look at utils/keytable/ir-keytable.1.
At the building system, all that it is needed is to add something like what's there at utils/keytable/Makefile.am:
man_MANS = ir-keytable.1
Thanks,
Mauro
Quoted 68 lines
Signed-off-by Bård Eirik Winther <[email protected]>--- utils/qv4l2/capture-win.cpp | 8 ++++++++ utils/qv4l2/capture-win.h | 4 +++- utils/qv4l2/qv4l2.cpp | 1 + 3 files changed, 12 insertions(+), 1 deletion(-)utils/qv4l2/capture-win.cpp +8
-0@@ -35,6 +35,14 @@ CaptureWin::CaptureWin() vbox->addWidget(m_label); vbox->addWidget(m_msg); + + hotkeyClose = new QShortcut(Qt::CTRL+Qt::Key_W, this); + QObject::connect(hotkeyClose, SIGNAL(activated()), this, SLOT(close())); +} + +CaptureWin::~CaptureWin() +{ + delete hotkeyClose; } void CaptureWin::setImage(const QImage &image, const QString &status)utils/qv4l2/capture-win.h +3
-1@@ -21,6 +21,7 @@#define CAPTURE_WIN_H #include <QWidget> +#include <QShortcut> #include <sys/time.h> class QImage;@@ -32,7 +33,7 @@ class CaptureWin : public QWidget public:CaptureWin (); - virtual ~CaptureWin() {} + ~CaptureWin (); void setImage(const QImage &image, const QString &status);@@ -45,6 +46,7 @@ signals: private:QLabel *m_label;QLabel *m_msg; + QShortcut *hotkeyClose; };#endif utils/qv4l2/qv4l2.cpp +1
-0@@ -78,6 +78,7 @@ ApplicationWindow::ApplicationWindow() : m_capStartAct->setStatusTip("Start capturing"); m_capStartAct->setCheckable(true); m_capStartAct->setDisabled(true); + m_capStartAct->setShortcut(Qt::CTRL+Qt::Key_V); connect(m_capStartAct, SIGNAL(toggled(bool)), this, SLOT(capStart(bool))); m_snapshotAct = new QAction(QIcon(":/snapshot.png"), "&Make Snapshot", this);
Signature · 2 lines
Cheers, Mauro
PATCH v2 3/6 qv4l2: fix minimum size in capture win to frame size
In reply to Bård Eirik WintherCaptureWin's setMinimumSize() sets the minimum size for the video frame viewport and not for the window itself. If the minimum size is larger than the monitor resolution, it will reduce the minimum size to match this.
--- utils/qv4l2/capture-win.cpp | 29 +++++++++++++++++++++++++++++ utils/qv4l2/capture-win.h | 1 + 2 files changed, 30 insertions(+)
utils/qv4l2/capture-win.cpp +29 -0
@@ -21,6 +21,8 @@ #include <QImage> #include <QVBoxLayout> #include <QCloseEvent> +#include <QApplication> +#include <QDesktopWidget> #include "qv4l2.h" #include "capture-win.h"
@@ -45,6 +47,33 @@ CaptureWin::~CaptureWin() delete hotkeyClose; } +void CaptureWin::setMinimumSize(int minw, int minh) +{ + QDesktopWidget *screen = QApplication::desktop(); + QRect resolution = screen->screenGeometry(); + QSize maxSize = maximumSize(); + + int l, t, r, b; + layout()->getContentsMargins(&l, &t, &r, &b); + minw += l + r; + minh += t + b + m_msg->minimumSizeHint().height() + layout()->spacing(); + + if (minw > resolution.width()) + minw = resolution.width(); + if (minw < 150) + minw = 150; + + if (minh > resolution.height()) + minh = resolution.height(); + if (minh < 100) + minh = 100; + + QWidget::setMinimumSize(minw, minh); + QWidget::setMaximumSize(minw, minh); + updateGeometry(); + QWidget::setMaximumSize(maxSize.width(), maxSize.height()); +} + void CaptureWin::setImage(const QImage &image, const QString &status) { m_label->setPixmap(QPixmap::fromImage(image));
utils/qv4l2/capture-win.h +1 -0
@@ -35,6 +35,7 @@ public:CaptureWin (); ~CaptureWin (); +void setMinimumSize (int minw,int minh); void setImage(const QImage &image, const QString &status); protected:
Signature · 1 line
1.8.3.2
PATCH v2 4/6 qv4l2: add Capture menu
In reply to Bård Eirik WintherCreated a new Capture menu that contains both capture controls and audio/video settings for capture.
--- utils/qv4l2/qv4l2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
utils/qv4l2/qv4l2.cpp +4 -2
@@ -111,10 +111,8 @@ ApplicationWindow::ApplicationWindow() : fileMenu->addAction(openAct); fileMenu->addAction(openRawAct); fileMenu->addAction(closeAct); - fileMenu->addAction(m_capStartAct); fileMenu->addAction(m_snapshotAct); fileMenu->addAction(m_saveRawAct); - fileMenu->addAction(m_showFramesAct); fileMenu->addSeparator(); fileMenu->addAction(quitAct);
@@ -128,6 +126,10 @@ ApplicationWindow::ApplicationWindow() : toolBar->addSeparator(); toolBar->addAction(quitAct); + QMenu *captureMenu = menuBar()->addMenu("&Capture"); + captureMenu->addAction(m_capStartAct); + captureMenu->addAction(m_showFramesAct); + QMenu *helpMenu = menuBar()->addMenu("&Help"); helpMenu->addAction("&About", this, SLOT(about()), Qt::Key_F1);
Signature · 1 line
1.8.3.2
PATCH v2 5/6 qv4l2: new modular capture window design
In reply to Bård Eirik WintherThe display of video has been divided into classes to easier implement other ways to render frames on screen.
--- utils/qv4l2/Makefile.am | 4 +- utils/qv4l2/capture-win-qt.cpp | 89 +++++++++++++++++++++++++++++++++++++++ utils/qv4l2/capture-win-qt.h | 47 +++++++++++++++++++++ utils/qv4l2/capture-win.cpp | 45 ++++++++++---------- utils/qv4l2/capture-win.h | 24 ++++++----- utils/qv4l2/qv4l2.cpp | 94 +++++++++++++++++++----------------------- utils/qv4l2/qv4l2.h | 1 + 7 files changed, 219 insertions(+), 85 deletions(-) create mode 100644 utils/qv4l2/capture-win-qt.cpp create mode 100644 utils/qv4l2/capture-win-qt.h
utils/qv4l2/Makefile.am +2 -2
@@ -1,6 +1,7 @@ bin_PROGRAMS = qv4l2 qv4l2_SOURCES = qv4l2.cpp general-tab.cpp ctrl-tab.cpp vbi-tab.cpp v4l2-api.cpp capture-win.cpp \ + capture-win-qt.cpp capture-win-qt.h \ raw2sliced.cpp qv4l2.h capture-win.h general-tab.h vbi-tab.h v4l2-api.h raw2sliced.h nodist_qv4l2_SOURCES = moc_qv4l2.cpp moc_general-tab.cpp moc_capture-win.cpp moc_vbi-tab.cpp qrc_qv4l2.cpp qv4l2_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la ../libv4l2util/libv4l2util.la
@@ -37,5 +38,4 @@ install-data-local: $(INSTALL_DATA) -D -p "$(srcdir)/qv4l2_24x24.png" "$(DESTDIR)$(datadir)/icons/hicolor/24x24/apps/qv4l2.png" $(INSTALL_DATA) -D -p "$(srcdir)/qv4l2_32x32.png" "$(DESTDIR)$(datadir)/icons/hicolor/32x32/apps/qv4l2.png" $(INSTALL_DATA) -D -p "$(srcdir)/qv4l2_64x64.png" "$(DESTDIR)$(datadir)/icons/hicolor/64x64/apps/qv4l2.png" - $(INSTALL_DATA) -D -p "$(srcdir)/qv4l2.svg" "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/qv4l2.svg" - + $(INSTALL_DATA) -D -p "$(srcdir)/qv4l2.svg" "$(DESTDIR)$(datadir)/icons/hicolor/scalable/apps/qv4l2.svg"
utils/qv4l2/capture-win-qt.cpp new file +89 -0
89 lines not on this page · raw message
utils/qv4l2/capture-win-qt.h new file +47 -0
47 lines not on this page · raw message
utils/qv4l2/capture-win.cpp +23 -22
77 lines not on this page · raw message
utils/qv4l2/capture-win.h +14 -10
@@ -20,12 +20,11 @@#ifndef CAPTURE_WIN_H #define CAPTURE_WIN_H +#include "qv4l2.h" +#include <QWidget> #include <QShortcut> -#include <sys/time.h> - -class QImage; -class QLabel; +#include <QLabel> class CaptureWin : public QWidget {
@@ -36,18 +35,23 @@ public: ~CaptureWin ();void setMinimumSize (int minw,int minh); - void setImage(const QImage &image, const QString &status); + virtual void setFrame(int width, int height, __u32 format, + unsigned char *data, const QString &info) = 0; + + virtual bool hasNativeFormat(__u32 format) = 0; +static bool isSupported () {return false; } protected: - virtual void closeEvent(QCloseEvent *event); +void closeEvent (QCloseEvent *event); +void buildWindow (QWidget *videoSurface); + +QLabel m_information; signals:void close (); private: -QLabel *m_label; -QLabel *m_msg; - QShortcut *hotkeyClose; -}; + QShortcut *m_hotkeyClose; +};#endif
utils/qv4l2/qv4l2.cpp +43 -51
180 lines not on this page · raw message
utils/qv4l2/qv4l2.h +1 -0
@@ -33,6 +33,7 @@#include "v4l2-api.h" #include "raw2sliced.h" +#include "capture-win.h" class QComboBox;class QSpinBox;
Signature · 1 line
1.8.3.2
PATCH v2 6/6 qv4l2: add OpenGL rendering
In reply to Bård Eirik WintherAdds OpenGL-accelerated display of video.
This allows for using the graphics card to render
the video content to screen and to perform color space conversion.
--- configure.ac | 8 +- utils/qv4l2/Makefile.am | 8 +- utils/qv4l2/capture-win-gl.cpp | 553 +++++++++++++++++++++++++++++++++++++++++ utils/qv4l2/capture-win-gl.h | 96 +++++++ utils/qv4l2/capture-win-qt.h | 1 + utils/qv4l2/capture-win.h | 39 +++ utils/qv4l2/qv4l2.cpp | 54 +++- utils/qv4l2/qv4l2.h | 10 + 8 files changed, 765 insertions(+), 4 deletions(-) create mode 100644 utils/qv4l2/capture-win-gl.cpp create mode 100644 utils/qv4l2/capture-win-gl.h
configure.ac +7 -1
@@ -128,7 +128,12 @@ if test "x$qt_pkgconfig" = "xtrue"; then AC_SUBST(UIC) AC_SUBST(RCC) else - AC_MSG_WARN(Qt4 is not available) + AC_MSG_WARN(Qt4 or higher is not available) +fi + +PKG_CHECK_MODULES(QTGL, [QtOpenGL >= 4.4 gl], [qt_pkgconfig_gl=true], [qt_pkgconfig_gl=false]) +if test "x$qt_pkgconfig_gl" = "xfalse"; then + AC_MSG_WARN(Qt4 OpenGL or higher is not available) fi AC_SUBST([JPEG_LIBS])
@@ -237,6 +242,7 @@ AM_CONDITIONAL([WITH_LIBDVBV5], [test x$enable_libdvbv5 = xyes]) AM_CONDITIONAL([WITH_LIBV4L], [test x$enable_libv4l != xno]) AM_CONDITIONAL([WITH_V4LUTILS], [test x$enable_v4lutils != xno]) AM_CONDITIONAL([WITH_QV4L2], [test ${qt_pkgconfig} = true -a x$enable_qv4l2 != xno]) +AM_CONDITIONAL([WITH_QV4L2_GL], [test WITH_QV4L2 -a ${qt_pkgconfig_gl} = true]) AM_CONDITIONAL([WITH_V4L_PLUGINS], [test x$enable_libv4l != xno -a x$enable_shared != xno]) AM_CONDITIONAL([WITH_V4L_WRAPPERS], [test x$enable_libv4l != xno -a x$enable_shared != xno])
utils/qv4l2/Makefile.am +7 -1
@@ -1,12 +1,18 @@ bin_PROGRAMS = qv4l2 qv4l2_SOURCES = qv4l2.cpp general-tab.cpp ctrl-tab.cpp vbi-tab.cpp v4l2-api.cpp capture-win.cpp \ - capture-win-qt.cpp capture-win-qt.h \ + capture-win-qt.cpp capture-win-qt.h capture-win-gl.cpp capture-win-gl.h \ raw2sliced.cpp qv4l2.h capture-win.h general-tab.h vbi-tab.h v4l2-api.h raw2sliced.h nodist_qv4l2_SOURCES = moc_qv4l2.cpp moc_general-tab.cpp moc_capture-win.cpp moc_vbi-tab.cpp qrc_qv4l2.cpp qv4l2_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la ../libv4l2util/libv4l2util.la + +if WITH_QV4L2_GL +qv4l2_CPPFLAGS = $(QTGL_CFLAGS) -DENABLE_GL +qv4l2_LDFLAGS = $(QTGL_LIBS) +else qv4l2_CPPFLAGS = $(QT_CFLAGS) qv4l2_LDFLAGS = $(QT_LIBS) +endif EXTRA_DIST = exit.png fileopen.png qv4l2_24x24.png qv4l2_64x64.png qv4l2.png qv4l2.svg snapshot.png \ video-television.png fileclose.png qv4l2_16x16.png qv4l2_32x32.png qv4l2.desktop qv4l2.qrc record.png \
utils/qv4l2/capture-win-gl.cpp new file +553 -0
553 lines not on this page · raw message
utils/qv4l2/capture-win-gl.h new file +96 -0
96 lines not on this page · raw message
utils/qv4l2/capture-win-qt.h +1 -0
@@ -35,6 +35,7 @@ public:void setFrame (int width,int height,__u32 format, unsigned char *data, const QString &info); +void stop (){}bool hasNativeFormat (__u32 format);static bool isSupported () {return true; }
utils/qv4l2/capture-win.h +39 -0
@@ -35,16 +35,55 @@ public: ~CaptureWin ();void setMinimumSize (int minw,int minh); + +/** +* @brief Set a frame into the capture window. +* +* When called the capture stream is +* either already running or starting for the first time. +* +* @param width Frame width in pixels +* @param height Frame height in pixels +* @param format The frame's format, given as a V4L2_PIX_FMT. +* @param data The frame data. +* @param info A string containing capture information. +*/ virtual void setFrame(int width, int height, __u32 format, unsigned char *data, const QString &info) = 0; +/** +* @brief Called when the capture stream is stopped. +*/ + virtual void stop() = 0; + +/** +* @brief Queries the current capture window for its supported formats. +* +* Unsupported formats are converted by v4lconvert_convert(). +* +* @param format The frame format question, given as a V4L2_PIX_FMT. +* @return true if the format is supported, false if not. +*/ virtual bool hasNativeFormat(__u32 format) = 0; + +/** +* @brief Defines wether a capture window is supported. +* +* By default nothing is supported, but derived classes can override this. +* +* @return true if the capture window is supported on the system, false if not. +*/ static bool isSupported () {return false; } protected:void closeEvent (QCloseEvent *event);void buildWindow (QWidget *videoSurface); +/** +* @brief A label that can is used to display capture information. +* +* @note This must be set in the derived class' setFrame() function. +*/ QLabel m_information; signals:
utils/qv4l2/qv4l2.cpp +52 -2
91 lines not on this page · raw message
utils/qv4l2/qv4l2.h +10 -0
@@ -60,6 +60,11 @@ enum CapMethod {methodUser }; +enum RenderMethod { +QV4L2_RENDER_GL , +QV4L2_RENDER_QT +}; +struct buffer {void *start;size_t length;
@@ -92,6 +97,8 @@ private:void stopCapture ();void startOutput (unsigned buffer_size);void stopOutput (); +void newCaptureWin (); +struct buffer *m_buffers;struct v4l2_format m_capSrcFormat;struct v4l2_format m_capDestFormat;
@@ -101,6 +108,7 @@ private:bool m_mustConvert;CapMethod m_capMethod;bool m_makeSnapshot; +RenderMethod m_renderMethod; private slots:void capStart (bool );
@@ -109,6 +117,7 @@ private slots:void snapshot ();void capVbiFrame ();void saveRaw (bool ); +void setRenderMethod ();// gui private slots:
@@ -166,6 +175,7 @@ private:QAction *m_snapshotAct;QAction *m_saveRawAct;QAction *m_showFramesAct; +QAction *m_useGLAct;QString m_filename;QSignalMapper *m_sigMapper;QTabWidget *m_tabs;
Signature · 1 line
1.8.3.2
Re: [PATCHv2 FINAL 6/6] qv4l2: add OpenGL rendering
Quoted 2 lines · you
[PATCHv2 FINAL 6/6] qv4l2: add OpenGL rendering
From505e803da95dd7c4aeb9d7ec4661c83bb743da1eMon Sep 17 00:00:00 2001
Message-Id: <505e803da95dd7c4aeb9d7ec4661c83bb743da1e.1375355021.git.bwinther@cisco.com>
From: =?UTF-8?q?B=C3=A5rd=20Eirik=20Winther?= <[email protected]>
Date: Thu, 1 Aug 2013 13:02:43 +0200
Subject: [PATCH] qv4l2: fix compile error
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes a compile error caused when opengl is not available
--- utils/qv4l2/capture-win-gl.cpp | 2 ++ 1 file changed, 2 insertions(+)
utils/qv4l2/capture-win-gl.cpp +2 -0
@@ -26,7 +26,9 @@ CaptureWinGL::CaptureWinGL() { +#ifdef ENABLE_GL CaptureWin::buildWindow(&m_videoSurface); +#endif CaptureWin::setWindowTitle("V4L2 Capture (OpenGL)"); }
Signature · 1 line
1.8.3.2
Em Tue, 30 Jul 2013 10:15:18 +0200
Bård Eirik Winther <[email protected]> escreveu:
...
Quoted 6 lines
Performance:
All tests are done on an Intel i7-2600S (with Turbo Boost disabled) using the integrated Intel HD 2000 graphics processor. The mothreboard is an ASUS P8H77-I with 2x2GB CL 9-9-9-24 DDR3 RAM. The capture card is a Cisco test card with 4 HDMI inputs connected using PCIe2.0x8. All video input streams used for testing are progressive HD (1920x1080) with 60fps.
I did a quick test here with a radeon HD 7750 GPU on a i7-3770 CPU, using an UVC camera at VGA resolution and nouveau driver (Kernel 3.10.3).
qv4l2 CPU usage dropped from 13% to 3,75%.
It sounds a nice improvement!
Signature · 2 lines
Cheers, Mauro
Quoted 12 lines · you
Em Tue, 30 Jul 2013 10:15:18 +0200
Bård Eirik Winther <[email protected]> escreveu:...
Quoted 6 lines
Performance:
All tests are done on an Intel i7-2600S (with Turbo Boost disabled) using the integrated Intel HD 2000 graphics processor. The mothreboard is an ASUS P8H77-I with 2x2GB CL 9-9-9-24 DDR3 RAM. The capture card is a Cisco test card with 4 HDMI inputs connected using PCIe2.0x8. All video input streams used for testing are progressive HD (1920x1080) with 60fps.
Quoted 8 lines
I did a quick test here with a radeon HD 7750 GPU on a i7-3770 CPU, using an UVC camera at VGA resolution and nouveau driver (Kernel 3.10.3).
qv4l2 CPU usage dropped from 13% to 3,75%.
It sounds a nice improvement!
That is good to hear. My results where achived using the 3.9 and 3.10 kernels although I belive that the hardware and opengl driver affects performance the most.
With such a good hardware and relatively low resolution, you wont see that much of a differance :-), but it is a nice improvement indeed. Anyway, nice to get additional tests!
Quoted 18 lines · Bård Eirik Winther
Quoted 17 lines · you
Em Tue, 30 Jul 2013 10:15:18 +0200
Bård Eirik Winther <[email protected]> escreveu:...
Quoted 6 lines
Performance:
All tests are done on an Intel i7-2600S (with Turbo Boost disabled) using the integrated Intel HD 2000 graphics processor. The mothreboard is an ASUS P8H77-I with 2x2GB CL 9-9-9-24 DDR3 RAM. The capture card is a Cisco test card with 4 HDMI inputs connected using PCIe2.0x8. All video input streams used for testing are progressive HD (1920x1080) with 60fps.I did a quick test here with a radeon HD 7750 GPU on a i7-3770 CPU, using an UVC camera at VGA resolution and nouveau driver (Kernel 3.10.3).
qv4l2 CPU usage dropped from 13% to 3,75%.
Quoted 7 lines
Quoted 3 lines
It sounds a nice improvement!
That is good to hear. My results where achived using the 3.9 and 3.10 kernels although I belive that the hardware and opengl driver affects performance the most.
With such a good hardware and relatively low resolution, you wont see that much of a differance :-),
Yes, I know ;)
Quoted 1 line
but it is a nice improvement indeed. Anyway, nice to get additional tests!
Yeah, that was mainly the reason for the tests: to reproduce it with a different setup than yours.
Cheers,
Mauro