mp4 esds box parsing of descriptor length is incorrect

Issue #348 new
Former user created an issue

Bug is in file Mp4EsdsBox.java function:

  • public int processSectionHeader(ByteBuffer dataBuffer):

The use of 'filler' bytes is not correct when parsing the esds box descriptors. If you look at the formal specification document (14496-1), the length field for each descriptor is a variable length of 1-4 bytes.

Annex E of 14496-1 indicates how to properly parse for length. In the event you do not have access to 14496-1 annex E - the MSB of each byte is a flag indicating if more length bytes follow. The lower 7-bits of each byte are actual length values. Section E.4 also shows the ES_Descriptor with a variable length field.

Length examples:

  • 1-byte length of value 2: 0x02
  • 2-byte length of value 2: 0x8002
  • 3-byte length of value 2: 0x808002
  • 4-byte length of value 2: 0x80808002
  • 2-byte length of value 127: 0x807F
  • 2-byte length of value 128: 0x8100
  • 2-byte length of value 129: 0x8101

Bug flagged as 'major' as the code will work in 99% of cases (as the lengths for the descriptors are generally less than 128 bytes).

Comments (0)

  1. Log in to comment