Skip to content

Fix cue render order for ass/ssa. #2137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

peerless2012
Copy link

This should fix #2124

  • Add layer in cue and output.
  • Add layer support for ssa parser.

@tonihei
Copy link
Collaborator

tonihei commented Feb 21, 2025

@icbaker Could you take a look? Thanks!

try {
return Integer.parseInt(intString.trim());
} catch (Exception exception) {
return C.LENGTH_UNSET;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should default to 0 here for layer, same as Cue

That probably means you need to either return null here, or take a default value as a parameter, or don't define this general purpose function and just in-line it for the layer case.

I'd suggest in-lining

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseInt is a general method, and I will set layer to 0 when the result is unset in line 333.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseInt may be trying to be a general method, but LENGTH_UNSET (-1) is not a generally safe 'invalid' value for all possible integer fields (i.e. there may be some integer fields where we expect to read -1 from the file). In fact, tbh it's not clear to me that -1 (or any negative number) is an invalid value for layer. The SSA "spec" I'm reading says:

Layer (any integer)

Which could reasonably be interpreted to include negative numbers.

So please either in-line this method (my preference) or return null when the parsing fails.

@icbaker icbaker linked an issue Feb 25, 2025 that may be closed by this pull request
1 task
@peerless2012 peerless2012 requested a review from icbaker February 26, 2025 16:38
@peerless2012
Copy link
Author

@icbaker hello, please make a review for the new commit, and hope this pr can merge to 1.6.0 final release.

@peerless2012 peerless2012 marked this pull request as draft March 25, 2025 02:06
@peerless2012 peerless2012 marked this pull request as ready for review March 25, 2025 02:07
@icbaker
Copy link
Collaborator

icbaker commented Apr 29, 2025

Please can you add some tests for this?

I suggest:

  1. Some parsing tests in SsaParserTest (including negative & unparseable layer values) - assert that the right value ends up in Cue.zIndex
  2. An end-to-end test in SubtitlePlaybackTest? This will cover both your parsing code and the re-ordering in the CueGroup constructor.

For (2) I suggest you craft an SSA test file that has cues overlapping in time with different layer values, to demonstrate why the re-ordering has to be done 'outside' SsaParser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ASS render in a wrong order.
3 participants