Hi there,

I've been trying to fix an issue when playing certain streams in Kodi with inputstream.adaptive and I'm starting to get a bit stuck. (related issue - https://github.com/xbmc/inputstream.adaptive/issues/1007)

In the attached sample files when trying to create a `CencSampleInfoTable` it runs into an issue that eventually leads to a crash.
The `saiz` box holds a default sample info size of 30 which seems to be at odds with the actual content of the `senc` box:

![image](https://user-images.githubusercontent.com/11909320/185789461-9bc46b6b-5570-4b67-9da3-f8a7df195367.png)

![image](https://user-images.githubusercontent.com/11909320/185789448-fe44995d-9e5d-4a28-be22-b55b5a7b64d2.png)

So yes it appears the source video is 'wrong', however other players seem to handle it fine.

One though I had was to do a more step-by-step reading of the aux info data instead of trusting the default length here: https://github.com/axiomatic-systems/Bento4/blob/df9ba99a3d7f37547ab610c84166239fde012cdf/Source/C%2B%2B/Core/Ap4CommonEncryption.cpp#L2915-L2938

Something like (psuedo code):
* if per sample IV, read IV
* read subsample count
* for each subsample read clear bytes, encrypted bytes

If however I'm wrong by any measure please advise, I know a little about this library but not much.

Grateful for your help on this

Thanks

Glenn

[cbcs.zip](https://github.com/axiomatic-systems/Bento4/files/9388988/cbcs.zip)


Not handling (seemingly) incorrect DefaultSampleInfoSize
This is a GitHub Issue
repo:Bento4
owner:axiomatic-systems
Title : Not handling (seemingly) incorrect DefaultSampleInfoSize
Issue date:

--- start body ---
Hi there,

I've been trying to fix an issue when playing certain streams in Kodi with inputstream.adaptive and I'm starting to get a bit stuck. (related issue - https://github.com/xbmc/inputstream.adaptive/issues/1007)

In the attached sample files when trying to create a `CencSampleInfoTable` it runs into an issue that eventually leads to a crash.
The `saiz` box holds a default sample info size of 30 which seems to be at odds with the actual content of the `senc` box:

![image](https://user-images.githubusercontent.com/11909320/185789461-9bc46b6b-5570-4b67-9da3-f8a7df195367.png)

![image](https://user-images.githubusercontent.com/11909320/185789448-fe44995d-9e5d-4a28-be22-b55b5a7b64d2.png)

So yes it appears the source video is 'wrong', however other players seem to handle it fine.

One though I had was to do a more step-by-step reading of the aux info data instead of trusting the default length here: https://github.com/axiomatic-systems/Bento4/blob/df9ba99a3d7f37547ab610c84166239fde012cdf/Source/C%2B%2B/Core/Ap4CommonEncryption.cpp#L2915-L2938

Something like (psuedo code):
* if per sample IV, read IV
* read subsample count
* for each subsample read clear bytes, encrypted bytes

If however I'm wrong by any measure please advise, I know a little about this library but not much.

Grateful for your help on this

Thanks

Glenn

[cbcs.zip](https://github.com/axiomatic-systems/Bento4/files/9388988/cbcs.zip)


--- end body ---
