-
Notifications
You must be signed in to change notification settings - Fork 4
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
cut_merge
broken
#16
Comments
I had the wrong assumption that every subtitle would end with an empty sequence of PCS/WDS/END, however in case a subtitle is right after the previous one, temporally speaking, then no empty sequence is needed and the previous pic will end at the beginning of the subsequent. Right now in the code you'll see variable like foundBegin and foundEnd, but those are wrong as based on this wrong assumption, I never took some time to think of a proper solution as I have other way to achieve the same result, namely this one which I generate using another application I've developed in private which take a sequence of frame number and generate the cut parameter for different kinds of track types (sup, ass, dts, ac3, flac) |
Okay, thanks for the information. I might look into it and create a PR if I found a solution. |
Selur from Doom9 sent me the source code of SeCut, you can take a look at it if you want |
Using your if we trace the original file we can see this
The first subpic is by itself with a sequence of
When we have an additional Hope this will be of help :) |
If you slice & merge the stream you must ensure that:
Whenever you cut in the middle of an epoch, you need to track object IDs and object redefinition: Another painful case: The sanest approach is to drop every
And that will cover most existing streams. |
@cubicibo Thanks for that detailed rundown! Helped me better understand how this format is supposed to work …
Is that really necessary? My idea would be the following:
Now we don't have to worry about following NCs referencing unknown objects since we copied all the ODS and WDS they could reference. For 2. and 3.: A timestamp is not inside an epoch if the DS immediately before is a NC and immediately after is an ES. What I don't fully understand is this:
|
Depends of the desired cut-merge code complexity ;)
This is too conservative. Just find the last dropped AP (or ES else) and accumulate data from there. Or, continuously accumulate data from ES and reset every time you find an AP or ES. Both AP and ES states mean that any preceding data shall not be used.
Palettes need to be tracked in an additive fashion. Each PDS content is ORed to the specified palette (palette ID in PDS). Your new ES DS must have a PDS that include all palette entries of palette ID defined so far in the decoder. Once you have your new ES DS inserted and you take proper care of the PDS data, palette updates will work naturally.
All version number starts from zero within an epoch, any redefinition (ODS) or change (PDS) should increase the version number.
Yes, there can be multiple compositions. Furthermore, the composition number is strictly increasing in the data stream, regardless of the composition state. It only goes back to zero when the field overflows after 0xFFFF.
No idea what you mean by merge. But that seems correct.
Disc space is not the issue, decoding time is. PGS bitmaps decoders are slow, do not throw objects at them if you don't need them! And, that is the last and hardest point of that cut process: compute correctly DTS of the new DisplaySets and verify all decoding constraints. Now, let's be honest, you DON'T want to go in this rabbit hole. These conditions are sufficient:
If you indeed want to go in the rabbit hole and inflict yourself endless pain, here are the key constraints in 90 kHz ticks:
Not permitted. See constraint 2. |
Here's an exotic sample for your tests. It contains palette updates, long epochs, assigns different palettes and object IDs, overlapping display sets in decoder, as well as NC with ODS. The datastream complies with the PGS decoder model for a 59.94p video (possible on UHD BD). |
Thanks again for that valuable information. And the sample file!
Ah, that clears things up!
The current cut&merge mode cuts out a section and then also closes that gap ("merge") by subtracting the duration of the section from subsequent PTS.
my method (5.) for undisplaying a previous composition at the same time as starting a new epoch seems not valid and I will have to find something different. I guess either leave a 1/90sec ∆t in-between or do it correctly (?) with an AP.
I ignored DTS so far because of this comment at thescorpius' documentation:
I guess that make sense, if you set them all to zero, you just tell the player to decode them all ASAP and keep the whole stream in memory. Not efficient but that would let me not have to care about that problem … |
@MonoS Currently, you can only specify sections to remove (blacklist) and the gaps are always closed. So I'm thinking about making that behaviour more customizable, something like Of course, I could also find a solution that's backwards compatible with the current syntax. What do you think? Maybe I'll have some time to take a crack at this this week. If not, then in two weeks. |
DTS = 0 is seen in the wild occasionally. Basic streams where a single subtitle is displayed and undisplayed every other second do not need to have a DTS. Complex streams need it as we must ensure that every packet enters the decoder at the right time. Without DTS, packets could be stored way before they are needed, and this would overflow the decoder, or corrupt screen updates. Consistency is key: if SupMover cuts a stream where DTS is set, your new DS must have a proper DTS too to pass the fifth constraint. Similarly, a stream where DTS is zero shouldn't suddently have a DTS != 0. TheScorpius doc is excellent, but there are a few errors. E.g
No need. The Epoch Start process itself will remove any graphic visible on the screen, that undisplay DS is redundant. |
Agreed, that's what I was thinking as well: look at the DTS around the new DS and adapt accordingly.
Good to know! I will fix my code for the
Right 🤦 |
As to some omission:
|
Coincidentally, I also figured that out myself yesterday when testing my ODS reading implementation
Thanks, another thing to fix! |
@cubicibo I found another interesting diversion, according to this source file from BDSup2Sub, there is also a fourth composition state: "Epoch Continue" ( Do you know if this is really a thing? |
It is only found in seamless branching streams with subtitles active during the branch. When both epoch start and acquisition point flags are set, the decoder additionally check for composition number equality with the last decoded display set. If equal, the decoder assumes the presentation is continuous and will not decode the DisplaySet. If not, the decoder performs an epoch start procedure. Patent US7660516B2 describes the process fairly well. In any case, this is something the authoring software should handles, as it it tied to m2ts muxing. Frankly, I have never seen a sample in the wild, demuxer are supposed to discard that display set, and I don't even know how that would work on complex streams akin to the sample posted above. |
You mentioned that the
cut_merge
mode is broken and shouldn't be used.What is broken? I want to use it.
The text was updated successfully, but these errors were encountered: