Message ID | 20200709192022.9412-4-andreas.rheinhardt@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,1/7] avformat/avc: Fix undefined shift and assert when reading exp-golomb num | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
diff --git a/libavformat/avc.c b/libavformat/avc.c index 98462940ad..17fcd1e73f 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -104,6 +104,7 @@ const uint8_t *ff_avc_parse_nalu(const uint8_t **start, const uint8_t **nal_end, p += 3; } +search_again: next = avc_find_startcode_internal(p, end); if (next) { @@ -112,6 +113,12 @@ const uint8_t *ff_avc_parse_nalu(const uint8_t **start, const uint8_t **nal_end, } else { *nal_end = end; } + if (*nal_end == p) { + if (!next) + return NULL; + p = next; + goto search_again; + } *start = next; return p; }
When an empty annex B NAL unit (i.e. 0x000001 immediately followed by a three or four-byte start code) is encountered during annex B->mp4 conversion, a NAL unit of size zero is created; this is invalid. Furthermore, several functions simply presumed all NAL units to be nonempty and treated the first byte as the NAL unit type. Ticket #7200 contains a sample with such NAL units. This commit skips empty NAL units during annex B->mp4 conversion, ensuring that the callers don't need to check for themselves. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavformat/avc.c | 7 +++++++ 1 file changed, 7 insertions(+)