#19 Index was outside the bounds of the array

open-accepted
manusse
8
2008-06-28
2007-12-03
Kacizi
No

SubtitleCreator 2.2 can't handle VobSub files containing PACKs with stuffing bytes in their headers.

The attached .zip file contains a VobSub subtitle that has 3 PACKs with 1 stuffing byte each, a .txt file with the timestamp and filepos of the PACKs, and a .md5 file.

In SubtitleCreator 2.2, Tools > Manipulate SUP or VobSub file doesn't load the subtitle, and Tools > Translate SUP or VobSub to SRT shows the message "Index was outside the bounds of the array". The cause of this bug seems to be the code starting at line 1100 in the file SUP.cs: after finding a new 0x00 0x00 0x01 0xBA header (pack_start_code), the next 14 bytes are skipped, and the next 2 bytes are considered to be PES_packet_length. The 14 skipped bytes are supposed to be the bytes 4..13 as described in http://dvd.sourceforge.net/dvdinfo/packhdr.html and bytes 0..3 as described in http://dvd.sourceforge.net/dvdinfo/pes-hdr.html. Table 2-33 in http://neuron2.net/library/mpeg2/iso13818-1.pdf specifies that stuffing bytes (stuffing_byte = 0xFF) are added to the PACK header when pack_stuffing_length is not 0.

In a VobSub .sub file (and DVD VOBs), a PACK is always 0x0800 bytes long. If the subpicture (or video/audio) PES_packet_length is 0x07E6..0x07EB, there can't be a padding stream PES in the current PACK because the minimum length of a padding stream PES packet is 7 (0x00 0x00 0x01 0xBE 0x00 0x01 0xFF). In this case pack_stuffing_length is not 0 and padding bytes are added to the PACK header so that the length of the PACK is 0x0800.

To make SubtitleCreator 2.2 process these PACKs, hex edit the VobSub .sub file, cut the stuffing bytes from the PACK header and paste them before the next PACK header.

Results in other programs using the attached VobSub subtitle:
- VLC 0.8.6c displays all the subpictures when the subtitle is muxed in a .mkv file or is loaded as an external subtitle when opening a .avi file.
- The ZoomPlayer version in CCCP 2007-07-22 displays all the subpictures when the subtitle is muxed in a .mkv file and shows nothing (the subpicture is one PES packet in a PACK with stuffing bytes in header) or random pixels (the last PES packet of the subpicture is in a PACK with stuffing bytes in header) when it is loaded as an external subtitle.
- SubToSup 0.9 can't open the subtitle.
- VobEdit 0.6 lists the PACKs that have a pack_stuffing_length greater than 0 as "LBA n [Unknown Pack], zzzz" (don't click on this line in VobEdit, the program will crash).
- SubRip 1.50b4 with 'Use VOB's subtitle map' and 'Use IDX's file offset' options unchecked skips the subpicture (the subpicture is one PES packet in a PACK with stuffing bytes in header) and causes time overlapping in the .srt file or shows the subpicture interlaced/displays the warning "This subtitle item can't be processed" (the last PES packet of the subpicture is in a PACK with stuffing bytes in header).

Discussion

  • Kacizi

    Kacizi - 2007-12-03

    VobSub subtitle

     
  • manusse

    manusse - 2007-12-25

    Logged In: YES
    user_id=1344166
    Originator: NO

    Hi,

    I'll try to implement your request ASAP especially if it's simple to do.

    Cheers
    Manusse

     
  • manusse

    manusse - 2008-05-21

    Logged In: YES
    user_id=1344166
    Originator: NO

    The last two days I had a look at the bug you've found. Thanks to your very detailed explanation, I could fix it. However the new version of SC exhibits a new bug with this file but it is not due to the pack_stuffing_length being different from 0 anymore. After fixing this bug I'm quite convinced that the opposite bug exists when writing a VobSub file. I'll have to have a look some day.

    Thnaks again for your positive and very detailed feedback.

     
  • manusse

    manusse - 2008-05-21

    Logged In: YES
    user_id=1344166
    Originator: NO

    The last two days I had a look at the bug you've found. Thanks to your very detailed explanation, I could fix it. However the new version of SC exhibits a new bug with this file but it is not due to the pack_stuffing_length being different from 0 anymore. After fixing this bug I'm quite convinced that the opposite bug exists when writing a VobSub file. I'll have to have a look some day.

    Thnaks again for your positive and very detailed feedback.

     
  • manusse

    manusse - 2008-05-22
    • priority: 5 --> 9
    • assigned_to: nobody --> manusse
     
  • manusse

    manusse - 2008-05-22
    • labels: --> VobSub manipulation
     
  • manusse

    manusse - 2008-05-22
    • status: open --> open-fixed
     
  • manusse

    manusse - 2008-05-25
    • status: open-fixed --> open-accepted
     
  • manusse

    manusse - 2008-06-28
    • priority: 9 --> 8
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks