Log in

View Full Version : PGS Bitstream Question: Cropping + Abrupt Packet End


wswartzendruber
3rd April 2022, 03:29
What on God's green earth does it mean when a composition object declares cropping flag 0x40 and then abruptly ends?

And while we're at it, who the hell came up with this god-forsaken format, anyway?! I haven't been hit in the head with a metal pipe anywhere near enough times to think this is a rational way of going about things!

nevcairiel
3rd April 2022, 15:37
cropping flag is a single bit, it can't be 0x40?

In some software, the entire flag field is called "composition flags" (2 valid bits, 6 reserved ones, as far as I know), with 0x80 being cropping, and 0x40 being "forced on", eg. used for forced/alien subtitles.
Only in the first case, composition flag being 0x80 (or rather, including 0x80, its a bitmask), would the crop rectangle be present.

wswartzendruber
3rd April 2022, 17:09
All right, going by The Phantom Menace (2011 U.S. Blu-ray) subtitles, that indeed makes sense. I've also checked the original Ghost in the Shell anime (4K U.S. release) and it makes sense there as well.

I can't find any mention of this in the patent that defines PGS.

nevcairiel
3rd April 2022, 17:42
Patents are often out of date with any future development of the format - they are not meant to implement against, afterall. The Blu-ray specs include proper documentation for the format.

wswartzendruber
3rd April 2022, 17:45
Are the Blu-ray specs available anywhere?

cubicibo
3rd April 2022, 23:26
Of course not. You have to pay or request them for an evaluation period.

VLC specifically masks the composition flag with 0x80 for cropping. If the flag is set, then it fetches 4xint16 additional values from the stream (which I find surprising, I would assume those 8 bytes being present whatsoever, with garbage or zero value – "stream consistency"). The function header also claims the cropping is a "TODO" so who knows if that's correct at all.
The patent also claims that there can be numerous cropping_rectangle_information for a single window, but it doesn't make sense whatsoever (see sheet 8).

[...] and 0x40 being "forced on", eg. used for forced/alien subtitles.
Can you elaborate on that? How can a specific subtitle be forced if that can be defined at the stream level? Also, if a given subtitle track is selected, it will be displayed anyway. I don't see the purpose at all so I must me missunderstanding the point.

wswartzendruber
4th April 2022, 00:13
Of course not. You have to pay or request them for an evaluation period.
I'm thinking the community could benefit from a reverse-engineered open specification. This "format" has been in widespread use since 2006.

The function header also claims the cropping is a "TODO" so who knows if that's correct at all.
I have yet to encounter any subtitles that set 0x80.

The patent also claims that there can be numerous cropping_rectangle_information for a single window, but it doesn't make sense whatsoever (see sheet 8).
This can be done by defining multiple composition objects against the same object/window combination.

Can you elaborate on that? How can a specific subtitle be forced if that can be defined at the stream level? Also, if a given subtitle track is selected, it will be displayed anyway. I don't see the purpose at all so I must me missunderstanding the point.
It's a fundamentally irrational proposition given how subtitles are packaged in practice. Meaning, every disc I have puts "forced" subtitles and "all" subtitles in distinct tracks.

I do have some titles that use forced captions, however. For a track dedicated to foreign translation, all captions are forced. For tracks that contain all dialogue, only the captions that appear in the translated captions are forced. Ergo, the captions marked as "force" are the same between the two.

EDIT: Here's a link to my work:

https://github.com/wswartzendruber/pgs-tools

Maybe someday I'll publish this as a Rust crate. I was worried about someone grabbing the "pgs" name, but now that I think about it, I'm probably going to call it "brain-damage" or some-such.

nevcairiel
4th April 2022, 07:11
VLC specifically masks the composition flag with 0x80 for cropping. If the flag is set, then it fetches 4xint16 additional values from the stream (which I find surprising, I would assume those 8 bytes being present whatsoever, with garbage or zero value – "stream consistency").


Optional elements are very much standard once you go beyond the very basics of compressed bitstreams.



Can you elaborate on that? How can a specific subtitle be forced if that can be defined at the stream level?

This is just a feature of PGS subtitles, there is no "how" - and its actually used on a variety of discs, but not all of them (many don't even have an forced subs to begin with, anyway). A bunch of events are marked forced, and a player can decide if it wants to display all or only the forced events. On a Blu-ray disc the Menu logic would control this.
If you rip from a Blu-ray disc, you can also choose to filter the subtitles and put the forced ones into a separate track if that makes it more convenient for your target container - eg. MakeMKV offers that as an option.

cubicibo
4th April 2022, 07:43
I'm thinking the community could benefit from a reverse-engineered open specification. This "format" has been in widespread use since 2006.
You can always try your luck (https://blu-raydisc.info/format-spec/study-eval-how-to.php), but they specifically state you have no right to reproduce it or share any element so it would only be for you.

This is just a feature of PGS subtitles, there is no "how" - and its actually used on a variety of discs, but not all of them (many don't even have an forced subs to begin with, anyway). A bunch of events are marked forced, and a player can decide if it wants to display all or only the forced events. On a Blu-ray disc the Menu logic would control this.
If you rip from a Blu-ray disc, you can also choose to filter the subtitles and put the forced ones into a separate track if that makes it more convenient for your target container - eg. MakeMKV offers that as an option.
Thanks, I had never encountered a Blu-Ray disc with this flag and only had seen forced caption tracks as a whole.

EDIT: May I ask for a sample containing solely the Epoch DSs where the said flag is set?

wswartzendruber
4th April 2022, 14:31
You can always try your luck (https://blu-raydisc.info/format-spec/study-eval-how-to.php), but they specifically state you have no right to reproduce it or share any element so it would only be for you.
I'll pass on ever laying eyes on any of their licensed documentation.

May I ask for a sample containing solely the Epoch DSs where the said flag is set?
Here is the entirety of the last subtitle track for Ghost in the Shell (1995, anime). This is from the Blu-ray disc that accompanies the 4K disc. The sum total of time it involves is 15 seconds. There are four epochs.

http://wswartzendruber.net/uploads/ghost-in-the-shell-1995-eng-forced.sup

EDIT: Here's the documentation for the Rust library:

http://wswartzendruber.net/doc/pgs-tools/pgs/

cubicibo
4th April 2022, 18:23
Many thanks ! Good to have another implementation to cross-check.

wswartzendruber
4th April 2022, 18:36
Many thanks ! Good to have another implementation to cross-check.
Don't assume my work here is correct.

Assume the opposite.