johnoneil / arib

Japan Association of Radio Industries and Businesses (ARIB) MPEG2 Transport Stream Closed Caption Decoding Tools
Apache License 2.0
56 stars 9 forks source link

Incorrect subtitle horizontal alignment #27

Closed johnoneil closed 7 years ago

johnoneil commented 7 years ago

detective_conan_846- 00 00 40 336 -0003

からはし ごうたろう 唐橋剛太郎氏の 盗まれた遺言状の行方と➡
johnoneil commented 7 years ago

Okay. This is not documented but it's becoming clear to me that font characters interpret horizontal position data differently than other font sizes.

In the above example the characters at row: 5 col: 2 (からはし ごうたろう) probably needs to have its horizontal position doubled to line up with the text it's annotating (唐橋剛太郎 at row 13 (5.5), col 4). This probably means its horizontal position is doubled from col: 2 to col 4.

This makes some sense as Arib smaller font characters should be half the width and height of large size characters. See the image below image

johnoneil commented 7 years ago

Some really bad examples of this turn up in Dragon Ball Z .ts files. See the example below. dragon ball z - 001 002 animax 1440x1080 mpeg2 aac - 00 03 35 941 -0004

File elapsed time seconds: 211.0304
<CS:"7 S"><CS:"620;480 V"><CS:"170;30 _"><CS:"4 X"><CS :"24 Y"><CS:"36;36 W"><CS:"8 n"><CS:"1;0000 c"><Small Text>
<Screen Posiiton to 10,5>そん  ごくう
<Screen Posiiton to 10,14>かつやく
<Screen Posiiton to 12,5><Normal Text>孫<Medium Text> <Normal Text>悟空の活躍によって
<Screen Posiiton to 6,3><Small Text>みごと<Medium Text>
<Screen Posiiton to 6,11><Small Text>う<Medium Text>
<Screen Posiiton to 6,15><Small Text>くだ<Medium Text>
<Screen Posiiton to 7,5><Normal Text>見事に打ち砕かれ➡
johnoneil commented 7 years ago

dragonball_z- 00 03 35 607 -0001

Getting better. Still some issues but the crux is that:

  • Vertical and horizontal position units for APS is determined by (stateful) LAST TEXT SIZE SET * If normal text was last set, position is normal. If medium text was last set, horizontal position value must be halved If small text was last set, both horizontal and medium position values must be halved

That's the basics. There appears to be some subtlety, but this is working well overall.

johnoneil commented 7 years ago

Okay original issue fixed. Still some oddness due to the alignment of fonts but I'm satisfied for now. detective_conan_846- 00 00 40 036 -0001