summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_ht/ht_video_widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_tracker_ht/ht_video_widget.cpp')
-rw-r--r--ftnoir_tracker_ht/ht_video_widget.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/ftnoir_tracker_ht/ht_video_widget.cpp b/ftnoir_tracker_ht/ht_video_widget.cpp
index c6d59b34..1c5f565c 100644
--- a/ftnoir_tracker_ht/ht_video_widget.cpp
+++ b/ftnoir_tracker_ht/ht_video_widget.cpp
@@ -14,31 +14,44 @@ using namespace std;
void HTVideoWidget::update_image(unsigned char *frame, int width, int height)
{
QMutexLocker foo(&mtx);
- memcpy(fb, frame, width * height * 3);
- this->width = width;
- this->height = height;
+ if (!fresh)
+ {
+ memcpy(fb, frame, width * height * 3);
+ this->width = width;
+ this->height = height;
+ fresh = true;
+ }
}
void HTVideoWidget::update_and_repaint()
{
- QMutexLocker foo(&mtx);
- if (width*height <= 0)
- return;
- QImage qframe = QImage(width, height, QImage::Format_RGB888);
- uchar* data = qframe.bits();
- const int pitch = qframe.bytesPerLine();
- for (int y = 0; y < height; y++)
+ QImage qframe;
{
- const int part = y*width;
- for (int x = 0; x < width; x++)
+ QMutexLocker foo(&mtx);
+ if (width*height <= 0 || !fresh)
+ return;
+ fresh = false;
+ qframe = QImage(width, height, QImage::Format_RGB888);
+ uchar* data = qframe.bits();
+ const int pitch = qframe.bytesPerLine();
+ for (int y = 0; y < height; y++)
{
- const int pos = 3 * (part + x);
- data[y * pitch + x * 3 + 0] = fb[pos + 2];
- data[y * pitch + x * 3 + 1] = fb[pos + 1];
- data[y * pitch + x * 3 + 2] = fb[pos + 0];
+ const int part = y*width;
+ for (int x = 0; x < width; x++)
+ {
+ const int pos = 3 * (part + x);
+ const int x_ = x * 3;
+ data[x_ + 0] = fb[pos + 2];
+ data[x_ + 1] = fb[pos + 1];
+ data[x_ + 2] = fb[pos + 0];
+ }
+ data += pitch;
}
}
- auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
- texture = qframe2;
+ qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ {
+ QMutexLocker foo(&mtx);
+ texture = qframe;
+ }
update();
}