dsh-watch-together 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -599,7 +599,8 @@ node scripts/install-dev.mjs # 把本包同步进 DSH profile(副本
599
599
  社区提的改动按 PR 记在这里(storyboard 那边的完整名单在 `dsh-video-storyboard/CREDITS.md`):
600
600
 
601
601
  - [@ggfgfgf-on](https://github.com/ggfgfgf-on) —— 插件设置页([PR #11](https://github.com/SAOS-3624/dsh-watch-together/pull/11),设置直接渲染在插件详情页);
602
- 核心改走 runtime-ports、悬浮窗气泡与折叠重做([PR #22](https://github.com/SAOS-3624/dsh-watch-together/pull/22))
602
+ 核心改走 runtime-ports、悬浮窗气泡与折叠重做([PR #22](https://github.com/SAOS-3624/dsh-watch-together/pull/22));
603
+ 小框边缘模糊过渡、CPU 补色散与运动混合、麦克风回到玻璃帧合成([PR #28](https://github.com/SAOS-3624/dsh-watch-together/pull/28))
603
604
  - [@DreamDLYY](https://github.com/DreamDLYY) —— 悬浮窗拖出屏幕后抓屏越界、日志每帧刷错、背景永久花屏的复现与修复([PR #23](https://github.com/SAOS-3624/dsh-watch-together/pull/23))
604
605
 
605
606
  ## 许可
package/dsh.plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-watch-together",
3
3
  "description": "Watch a video together with a text-only agent: follow the user's real playback position and hand over one segment at a time, just before the segment ends.",
4
- "version": "0.2.3",
4
+ "version": "0.2.5",
5
5
  "entry": {
6
6
  "name": "dsh-watch-together",
7
7
  "inject": [
@@ -2,6 +2,14 @@
2
2
 
3
3
  GPU 伴生文件按原始 PR 的布局 `import glass_window as G`;这里的窗口已经改名为
4
4
  `window.py`(交互补全都在里面),所以用这个别名保持 GPU 路径可直接运行。
5
+
6
+ 不再 `from window import *`:那样会在导入时复制一份全局量(W/H/SHAPES/
7
+ OVERLAY/BOX_MAPS),窗口缩放或气泡按文字改宽后,GPU 仍拿旧坐标合成,
8
+ 表现就会和 CPU 不一致。这里改成动态代理,每次访问都回到 window.py。
5
9
  """
6
10
 
7
- from window import * # noqa: F401,F403 (GPU companion expects module-level names)
11
+ import window as _window
12
+
13
+
14
+ def __getattr__(name):
15
+ return getattr(_window, name)
@@ -108,8 +108,11 @@ void main() {
108
108
  float e = texelFetch(edge, p, 0).r;
109
109
  vec2 ec = texelFetch(coord, p, 0).rg + offset;
110
110
  ivec2 ep = clamp(ivec2(floor(ec + 0.5)), ivec2(0), ivec2(src_size) - 1);
111
+ // 边缘从小框自己的原始帧取,避免 warped 在贴边小框上采到黑边。
111
112
  vec3 edgep = texelFetch(raw, ep, 0).rgb;
112
- vec3 patch = mix(strong, edgep, e);
113
+ // CPU 里 edge_w=0 是边缘(取折射样本),=1 是中心(取强模糊);
114
+ // 这里方向必须一致,否则内框边缘反而没有扭曲。
115
+ vec3 patch = mix(edgep, strong, e);
113
116
  frag = vec4(mix(base, patch, a), 1.0);
114
117
  }
115
118
  """
@@ -213,6 +216,7 @@ class GPULens:
213
216
  self._motion = 0.0
214
217
  self.src = None
215
218
  self.geo = None
219
+ self.geo_version = -1
216
220
  self.fbos = {}
217
221
  self.texs = {}
218
222
 
@@ -292,6 +296,7 @@ class GPULens:
292
296
  t = self._tex("union", (HW, HH), 1, "f1", union.tobytes())
293
297
  t.filter = (moderngl.LINEAR, moderngl.LINEAR)
294
298
  self.geo = (W, H, hw, hh, HW, HH)
299
+ self.geo_version = G.SHAPES_VERSION
295
300
  self.fbos.clear()
296
301
  self.texs = {k: v for k, v in self.texs.items()
297
302
  if k in ("alpha", "edge", "coord", "warpcoord", "overlay", "union")}
@@ -306,8 +311,9 @@ class GPULens:
306
311
  self.src.repeat_y = False
307
312
  self.src.write(data)
308
313
 
309
- def render(self, bgra, size, px, py, motion=0.0):
310
- if self.geo is None or self.geo[:2] != (G.W, G.H):
314
+ def render(self, bgra, size, px, py, motion=0.0, moved=False):
315
+ if (self.geo is None or self.geo[:2] != (G.W, G.H)
316
+ or getattr(self, "geo_version", -1) != G.SHAPES_VERSION):
311
317
  self._build_geo()
312
318
  W, H, hw, hh, HW, HH = self.geo
313
319
  gw, gh = size
@@ -370,10 +376,17 @@ class GPULens:
370
376
  src_size=(float(bw), float(bh)))
371
377
  p.vao.render(moderngl.TRIANGLES)
372
378
 
379
+ # 单独拷一份 blur(1.45) 给边缘采样;直接把 small 的 render target
380
+ # 当 sampler 会触发驱动崩溃。
381
+ edgeblur = self._fbo("edgeblur", (bw, bh))
382
+ edgeblur.use(); self.ctx.viewport = (0, 0, bw, bh)
383
+ small.color_attachments[0].use(0)
384
+ p = self.progs["final"]; p["tex"] = 0; p.vao.render(moderngl.TRIANGLES)
385
+
373
386
  lens.use(); self.ctx.viewport = (0, 0, hw, hh)
374
387
  warped.color_attachments[0].use(0)
375
388
  strongw.color_attachments[0].use(1)
376
- (small if self.native else box_raw).color_attachments[0].use(2)
389
+ edgeblur.color_attachments[0].use(2)
377
390
  self.texs["alpha"].use(3)
378
391
  self.texs["edge"].use(4)
379
392
  self.texs["coord"].use(5)
@@ -407,8 +420,11 @@ class GPULens:
407
420
  prev.color_attachments[0].use(1)
408
421
  p = self.progs["post"]
409
422
  p["texel"] = (1.0 / W, 1.0 / H)
410
- p["blend"] = float(0.55 * max(0.0, min(1.0, motion)) if getattr(self, "_prev_valid", False) else 0.0)
411
- p["chroma"] = 3.6 * (W / 900.0)
423
+ # 和 CPU 一致:只在“本帧检测到移动”时混上一帧,停下立刻干净;
424
+ # 移动帧跳过色散,先把拖动/滚动响应保住。
425
+ p["blend"] = float(0.35 * max(0.0, min(1.0, motion))
426
+ if moved and getattr(self, "_prev_valid", False) else 0.0)
427
+ p["chroma"] = 0.0 if moved else 3.6 * (W / 900.0)
412
428
  self._set(p, curr=0, prev=1)
413
429
  p.vao.render(moderngl.TRIANGLES)
414
430
  self.ctx.copy_framebuffer(prev, out)
@@ -450,20 +466,28 @@ def capture_gpu(self, sct):
450
466
  moved = bool(float(d.mean()) > 0.01 or float(d.max()) > 0.5)
451
467
  if moved:
452
468
  self._last_motion = now
453
- _gpu._motion = min(1.0, _gpu._motion * 0.60 + 0.40)
469
+ _gpu._motion = min(1.0, _gpu._motion * 0.50 + 0.50)
454
470
  else:
455
- _gpu._motion *= 0.80
471
+ _gpu._motion *= 0.55
456
472
  if (not G.FORCE and not moved and box == self._sig_bbox
457
473
  and now - getattr(self, "_last_motion", 0.0) > 0.30):
458
474
  self._sig = sig
459
475
  _gpu._motion = 0.0
476
+ _gpu._prev_valid = False
460
477
  return None
461
478
  self._sig = sig
462
479
  self._sig_bbox = box
463
480
 
464
- panel = _gpu.render(shot.bgra, shot.size, px, py, motion=_gpu._motion)
465
- # 麦克风由 window.py 的 Canvas 图标绘制,GPU 路径不再叠第二层。
466
- return G.finish(panel.convert("RGB"))
481
+ panel = _gpu.render(shot.bgra, shot.size, px, py,
482
+ motion=_gpu._motion, moved=moved)
483
+ out = panel.copy()
484
+ mic_box = out.crop((G.MIC_POS[0], G.MIC_POS[1],
485
+ G.MIC_POS[0] + 28, G.MIC_POS[1] + 28)).convert("L")
486
+ mic_bg = float(np.median(np.asarray(mic_box))) / 255.0
487
+ out = out.convert("RGBA")
488
+ icon = G.MIC_LIGHT if mic_bg < 0.48 else G.MIC_DARK
489
+ out.paste(icon, G.MIC_POS, icon)
490
+ return G.finish(out.convert("RGB"))
467
491
  except Exception as exc:
468
492
  print("GPU capture failed, falling back to CPU:", repr(exc), flush=True)
469
493
  return _orig_capture(self, sct)