Fix for bug 245. Patch by Todd Schmuland (see AUTHORS).
Explanation from Todd:
I tried using mkvextract to get VobSub tracks out of a mkv to make sure I
muxed in the correct subtitle stream. What I noticed is that programs like
Subtitle Creator and VobSubStrip would error out on one particular sub file.
After looking into it, the issue is in how mkvextract handles padding
lengths of 1 to 7.
There are two methods, the one mkvextract currently uses is to use the 00 00
01 BA packet where the 3 least significant bits of the last header byte
indicate how many padding FF bytes follow. There's nothing wrong with this,
however, many programs don't decode this properly and error out since they
are expecting the next bytes to be 00 00 01.
The other method is to pad the 00 00 01 BD packet header with FF bytes and
simply increase the header length byte to include the pad count. For
example where padding = 5:
method 1
00 00 01 BA 44 32 4C 46 44 01 01 89 C3 FD FF FF FF FF FF
00 00 01 BD 07 E7 81 80 05 21 0C 93 11 91 <payload>
becomes
method 2
00 00 01 BA 44 32 4C 46 44 01 01 89 C3 F8
00 00 01 BD 07 EC 81 80 0A 21 0C 93 11 91 FF FF FF FF FF <payload>
Notice the 00 00 01 BD total packet length increased from 07E7 to 07EC and
the packet header length increased from 05 to 0A. The benefit of this is
that the 00 00 01 BD header length includes the pad length with no
additional work by a program's decoder, so the SUB file is always properly
parsed while decoding. In fact the DVD this particular VobSub came from
used method 2.