From 88dcdf503556d8bc2c962036e5b192d552d05539 Mon Sep 17 00:00:00 2001 From: q Date: Tue, 23 Sep 2025 16:16:25 +0300 Subject: [PATCH] make sure interpolated values within limits --- tsmark/video_annotator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsmark/video_annotator.py b/tsmark/video_annotator.py index c6cf04f..e260b79 100755 --- a/tsmark/video_annotator.py +++ b/tsmark/video_annotator.py @@ -861,10 +861,10 @@ class World: w2 = max(1, a[3] / 2) h2 = max(1, a[4] / 2) return { - "x0": int(a[1] - w2), - "y0": int(a[2] - h2), - "x1": int(a[1] + w2), - "y1": int(a[2] + h2), + "x0": max(0, int(a[1] - w2)), + "y0": max(0, int(a[2] - h2)), + "x1": min(self.video_res[0] - 1, int(a[1] + w2)), + "y1": min(self.video_res[1] - 1, int(a[2] + h2)), "type": "interp", "visible": visible, }