Skip to content

Commit

Permalink
render2: fix WDS screen wipe timing before acquisition.
Browse files Browse the repository at this point in the history
pgstream: log TC of faulty PTS-DTS displaysets.
  • Loading branch information
cubicibo committed Nov 25, 2023
1 parent 9f56b87 commit 5f99fdd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 10 additions & 12 deletions SUPer/pgstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ def check_pts_dts_sanity(epochs: list[Epoch], fps: float, ndf_ntsc: bool = False
is_compliant = True
prev_pts = prev_dts = -99999999
min_dts_delta = 99999999
faults_pts = []

if ndf_ntsc:
to_tc = lambda pts: TC.s2tc(pts/1.001, fps)
Expand All @@ -412,30 +411,29 @@ def check_pts_dts_sanity(epochs: list[Epoch], fps: float, ndf_ntsc: bool = False
is_compliant &= diff > 0 and diff < PTS_DIFF_BOUND

for l, ds in enumerate(epoch):
ds_comply = True
#Check for minimum DTS delta between DS, ideally this should be bigger than 0
min_dts_delta = min((ds.pcs.tdts - prev_dts) & PTS_MASK, min_dts_delta)
if ds.pcs.tdts - prev_dts == 0:
faults_pts.append(ds.pcs.pts)
if ds.wds:
# WDS action requires pts_delta margin from previous DS
diff = (ds.pcs.tpts - prev_pts) & PTS_MASK
is_compliant &= diff > pts_delta and diff < PTS_DIFF_BOUND
is_compliant &= (ds.pcs.tpts - ds.wds.tpts) & PTS_MASK <= pts_delta
is_compliant &= (ds.wds.tpts - ds.wds.tdts) & PTS_MASK <= wipe_duration*2
ds_comply &= diff > pts_delta and diff < PTS_DIFF_BOUND
ds_comply &= (ds.pcs.tpts - ds.wds.tpts) & PTS_MASK <= pts_delta
ds_comply &= (ds.wds.tpts - ds.wds.tdts) & PTS_MASK <= wipe_duration*2
else:
# Palette update and others requires one frame duration as margin
is_compliant &= round(PGDecoder.FREQ*(ds.pcs.tpts - prev_pts + 4/PGDecoder.FREQ)) & PTS_MASK > np.ceil(PGDecoder.FREQ/fps)
ds_comply &= round(PGDecoder.FREQ*(ds.pcs.tpts - prev_pts + 4/PGDecoder.FREQ)) & PTS_MASK > np.ceil(PGDecoder.FREQ/fps)
for pds in ds.pds:
is_compliant &= pds.tpts == pds.tdts
ds_comply &= pds.tpts == pds.tdts
for seg in ds:
diff = (seg.tdts - prev_dts) & PTS_MASK
is_compliant &= diff >= 0 and diff < PTS_DIFF_BOUND
ds_comply &= diff >= 0 and diff < PTS_DIFF_BOUND
prev_dts = seg.tdts
prev_pts = ds.pcs.tpts
if not ds_comply:
logger.error(f"Incorrect PTS-DTS intervals at {to_tc(ds.pcs.pts)}, stream is out of spec.")
is_compliant &= ds_comply
####ds
####epochs

is_compliant &= min_dts_delta >= 0
for fault_pts in faults_pts:
logger.warning(f"Found DTS(PCS(DSn)) == DTS(END(DSn-1)) @ {to_tc(fault_pts)}, decoder has no margin left !!")
return is_compliant
12 changes: 7 additions & 5 deletions SUPer/render2.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,10 @@ def get_palette_data(pal_manager: PaletteManager, node: DSNode) -> tuple[int, in
assert i > 0
assert nodes[i].parent is not None
w_pts = get_pts(TC.tc2s(self.events[i-1].tc_out, self.bdn.fps))
if np.ceil(((nodes[i].parent.write_duration() + 10)/PGDecoder.FREQ)*self.target_fps) <= durs[i][1] and not nodes[i].parent.is_custom_dts():
wds_doable = (nodes[i].parent.write_duration() + 3)/PGDecoder.FREQ < 1/self.target_fps
if wds_doable and not nodes[i].parent.is_custom_dts():
uds, pcs_id = self._get_undisplay(w_pts, pcs_id, wds_base, last_palette_id, pcs_fn)
logger.debug(f"Writing screen clear with WDS before an acquisition at PTS={self.events[i-1].tc_out}")
logger.debug(f"Writing screen clear with WDS at PTS={self.events[i-1].tc_out} before an acquisition.")
else:
p_id, p_vn = get_palette_data(palette_manager, nodes[i].parent)
nodes[i].parent.palette_id = p_id
Expand Down Expand Up @@ -721,12 +722,13 @@ def get_palette_data(pal_manager: PaletteManager, node: DSNode) -> tuple[int, in
if insert_acqs > 0 and len(pals[0]) > insert_acqs and flags[k-1] != -1:
t_diff = TC.tc2s(self.events[k-1].tc_out, self.bdn.fps) - TC.tc2s(self.events[k-1].tc_in, self.bdn.fps)
if t_diff > 0.5:
dts_end = nodes[k-1].dts_end() + 5/PGDecoder.FREQ
dts_end = nodes[k-1].dts_end() + 2/PGDecoder.FREQ
npts = nodes[k-1].pts() + 2/PGDecoder.FREQ
nodes[k-1].nc_refresh = False
while nodes[k-1].dts() < dts_end:
while nodes[k-1].dts() < dts_end or nodes[k-1].pts() < nodes[k-1].write_duration()/PGDecoder.FREQ + npts:
nodes[k-1].tc_pts = TC.add_framestc(nodes[k-1].tc_pts, self.bdn.fps, 1)
if nodes[k-1].dts() - dts_end < 0.25:
logger.info(f"INS Acquisition: PTS={nodes[k-1].tc_pts}={c_pts:.03f} from event at {self.events[k-1].tc_in}.")
logger.debug(f"INS Acquisition: PTS={nodes[k-1].tc_pts}={c_pts:.03f} from event at {self.events[k-1].tc_in}.")
c_pts = get_pts(TC.tc2s(nodes[k-1].tc_pts, self.bdn.fps))

r = self._generate_acquisition_ds(k-1, k, pgobs_items, windows, nodes[k-1], double_buffering,
Expand Down

0 comments on commit 5f99fdd

Please sign in to comment.