This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: qv4l2: fix broken fps determination Author: Hans Verkuil <hverk...@xs4all.nl> Date: Wed Aug 4 13:07:27 2010 +0200 The fps determination was done based on a 2s-period timer. However, this timer would become unreliable if there is a heavy CPU load. Replaced the timer with gettimeofday calculations. Signed-off-by: Hans Verkuil <hverk...@xs4all.nl> utils/qv4l2/capture-win.cpp | 29 ++++++++++++----------------- utils/qv4l2/capture-win.h | 8 ++------ utils/qv4l2/qv4l2.cpp | 1 - 3 files changed, 14 insertions(+), 24 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=70c36440159d1986e226dde98d51bada4f217837 diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp index 4acf465..6628b94 100644 --- a/utils/qv4l2/capture-win.cpp +++ b/utils/qv4l2/capture-win.cpp @@ -16,10 +16,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - +#include <stdio.h> #include <QLabel> #include <QImage> -#include <QTimer> #include <QVBoxLayout> #include <QCloseEvent> @@ -33,8 +32,6 @@ CaptureWin::CaptureWin() m_frame = 0; m_label = new QLabel(); m_msg = new QLabel("No frame"); - m_timer = new QTimer(this); - connect(m_timer, SIGNAL(timeout()), this, SLOT(update())); vbox->addWidget(m_label); vbox->addWidget(m_msg); @@ -47,25 +44,23 @@ void CaptureWin::setImage(const QImage &image, bool init) m_frame = m_lastFrame = m_fps = 0; m_msg->setText("No frame"); } else { - if (m_frame == 0) { - m_timer->start(2000); + struct timeval tv, res; + + if (m_frame == 0) + gettimeofday(&m_tv, NULL); + gettimeofday(&tv, NULL); + timersub(&tv, &m_tv, &res); + if (res.tv_sec) { + m_fps = (100 * (m_frame - m_lastFrame)) / + (res.tv_sec * 100 + res.tv_usec / 10000); + m_lastFrame = m_frame; + m_tv = tv; } m_msg->setText(QString("Frame: %1 Fps: %2") .arg(++m_frame).arg(m_fps)); } } -void CaptureWin::stop() -{ - m_timer->stop(); -} - -void CaptureWin::update() -{ - m_fps = (m_frame - m_lastFrame + 1) / 2; - m_lastFrame = m_frame; -} - void CaptureWin::closeEvent(QCloseEvent *event) { QWidget::closeEvent(event); diff --git a/utils/qv4l2/capture-win.h b/utils/qv4l2/capture-win.h index 5546056..51e554d 100644 --- a/utils/qv4l2/capture-win.h +++ b/utils/qv4l2/capture-win.h @@ -21,10 +21,10 @@ #define CAPTURE_WIN_H #include <QWidget> +#include <sys/time.h> class QImage; class QLabel; -class QTimer; class CaptureWin : public QWidget { @@ -35,15 +35,11 @@ public: virtual ~CaptureWin() {} void setImage(const QImage &image, bool init = false); - void stop(); unsigned frame() const { return m_frame; } protected: virtual void closeEvent(QCloseEvent *event); -private slots: - void update(); - signals: void close(); @@ -53,7 +49,7 @@ private: unsigned m_frame; unsigned m_lastFrame; unsigned m_fps; - QTimer *m_timer; + struct timeval m_tv; }; #endif diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index 82fd691..2931cae 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -370,7 +370,6 @@ void ApplicationWindow::stopCapture() } free(m_buffers); m_buffers = NULL; - m_capture->stop(); refresh(); } _______________________________________________ linuxtv-commits mailing list linuxtv-commits@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits