dholroyd / h264-reader

Rust reader for H264 bitsream syntax
Apache License 2.0
72 stars 25 forks source link

Wrong Bounds Check for pic_parameter_set_id #56

Closed wrv closed 6 months ago

wrv commented 1 year ago

The pic_parameter_set_id is a ParamSetId struct, which checks if the ID is within [0, 31]: https://github.com/dholroyd/h264-reader/blob/master/src/nal/pps.rs#L218

Valid bitstreams can have pic_parameter_set_ids in the range [0, 255].

dholroyd commented 1 year ago

This arises from mistakenly sharing a single ParamSetId type between seq_parameter_set_rbsp() and pic_parameter_set_rbsp() syntax. Will need to break this into two separate Id types.

astraw commented 11 months ago

Is there a need for a video in which this gets triggered? I can provide one.

dholroyd commented 6 months ago

@astraw yes please - I would be happy to add a real PPS as a unit test

astraw commented 6 months ago

Here is an MP4 file containing an h264 video track that triggers the issue for me. (I moved my .h264 file into an .mp4 file with ffmpeg -i movie20221006_115500.885150194-issue56.h264 -vcodec copy movie20221006_115500.885150194-issue56.mp4 because github didn't accept an .h264 upload. I verified the .h264 file extracted with ffmpeg -i movie20221006_115500.885150194-issue56.mp4 -vcodec copy extract.h264 still triggers the issue for me.)