Skip to content

Commit

Permalink
render2: Align DTS of PUs right before rendering. Push version.
Browse files Browse the repository at this point in the history
  • Loading branch information
cubicibo committed Nov 20, 2024
1 parent 19ba779 commit 42ad3c1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion SUPer/__metadata__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

__MAJOR = 0
__MINOR = 2
__REVISION = 6
__REVISION = 7

__name__ = "SUPer"
__version__ = '.'.join(map(str, [__MAJOR, __MINOR, __REVISION]))
Expand Down
38 changes: 33 additions & 5 deletions SUPer/render2.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ def analyze(self):
durs, nodes = self.get_durations()
states, flags, cboxes = self.shape_stream(durs, nodes, pgobjs)

#if there's a discarded event, perform buffer layout optimisation.
#if next(filter(lambda f: f < 0, flags), None) is not None:
# ...

r_states, r_durs, r_nodes, r_flags = self.roll_nodes(nodes, durs, flags, states)
return self._convert(r_states, pgobjs, r_durs, r_flags, r_nodes)

Expand Down Expand Up @@ -279,9 +275,41 @@ def shape_stream(self,
self.shift_forward_overlay(nodes, states, absolutes, acqs, allow_overlaps, pts_delta)

self.filter_events(nodes, states, flags, absolutes, durs, pts_delta, allow_normal_case, allow_overlaps)
__class__.verify_palette_usage(nodes, states, flags, allow_overlaps)
cls = __class__
if allow_overlaps:
cls.align_palette_updates(nodes, states, flags)
cls.verify_palette_usage(nodes, states, flags, allow_overlaps)
return states, flags, cboxes

def align_palette_updates(
nodes: list['DSNode'],
states: list[PCS.CompositionState],
flags: list[int],
) -> None:
f_ticks = lambda ts: round(ts*PGDecoder.FREQ)
first_possible_dts = f_ticks(nodes[0].dts_end())
for ck, node in enumerate(nodes[1:], 1):
if flags[ck] < 0:
continue
if states[ck] == 0 and node.nc_refresh:
last_possible_dts = np.inf
current_dts = node.dts()
if f_ticks(current_dts) < first_possible_dts and first_possible_dts < f_ticks(node.pts()):
for ckf, flag in enumerate(flags[ck+1:],ck+1):
if flag >= 0:
last_possible_dts = f_ticks(nodes[ckf].dts())
break
if first_possible_dts < last_possible_dts:
node.set_dts(min((first_possible_dts+1)/PGDecoder.FREQ, last_possible_dts/PGDecoder.FREQ))
logger.debug(f"Shifted DTS of PU at {node.tc_pts}={node.pts():.03f} from {current_dts:.04f} to {node.dts():.04f}.")
else:
logger.error(f"Required to drop a PU at {node.tc_pts}={node.pts():.03f} to ensure a monotonic DTS.")
flags[ck] = -1
continue
first_possible_dts = f_ticks(node.dts_end())
####for ck
####

def shift_forward_overlay(self,
nodes: list['DSNode'],
states: list[PCS.CompositionState],
Expand Down

0 comments on commit 42ad3c1

Please sign in to comment.