Commit a47ceb3
committed
Use cv::swap and copyTo to eliminate redundant frame copies
Replace clone() with cv::swap() in video_tick for both background
and enhance filters. Swap is O(1) — it transfers buffer ownership
to the tick thread instead of deep-copying ~8 MB per frame.
In the render thread, use copyTo() instead of clone() for the stage
surface data. copyTo reuses the existing cv::Mat allocation when
dimensions match, avoiding a fresh heap allocation every frame.
Add a newFrameAvailable flag (protected by inputBGRALock) so the
tick thread only processes genuinely new frames and doesn't
re-process stale data after swap empties the shared buffer.
Signed-off-by: Xavier Ruiz <github@xav.ie>1 parent d27ae15 commit a47ceb3
4 files changed
Lines changed: 13 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
539 | | - | |
540 | | - | |
| 539 | + | |
541 | 540 | | |
542 | 541 | | |
543 | | - | |
| 542 | + | |
| 543 | + | |
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | 250 | | |
255 | 251 | | |
256 | 252 | | |
257 | 253 | | |
258 | 254 | | |
259 | 255 | | |
260 | 256 | | |
261 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | | - | |
72 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
| |||
0 commit comments