[FFmpeg-devel] [PATCH 0/1] avcodec/h264_parser: fix start of packet for some broken

Nicolas Gaullier nicolas.gaullier at cji.paris
Tue Mar 26 17:09:45 EET 2024


This is a patch from my patch serie https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=10999
Maybe it is easier to review it this way, independantly.
This patch shows some benefits by itself, but most importantly, it is required for my patch serie to avoid any regression with some invalid streams.

This patch is active in mpegts/h264 when the NAL Access Unit Delimiter is missing the zero_byte (= a invalid stream case).
In such a case, if it happens that the last data byte from the previous frame is a null byte, this byte is "kidnaped" to form the full NAL_AUD...
This is not good, but even worser, with my patch serie above applied, it means that the start of the editunit is in the previous frame,
which means the pts has to be taken in it, which is not the expected behaviour in such a missleading scenario.

Michael sent me a sample from the wild but it can't be shared, so here it is:
I have another sample of my own with NAL_AUD missing zero_byte similarly, but it is missing the ending null byte,
so I have patched/inserted the null byte (I shrinked the adaptation field) to show how the code behave.

Sample original (invalid NAL_AUDs):
https://0x0.st/Xs9Q.ts
Same sample modified to exhibit the issue (invalid NAL_AUDs + an available null ending byte at 0x291F):
https://0x0.st/Xs9j.ts

I use this simple command line and then compare the xml, it seems quite clear:
ffprobe xxx.ts -show_packets -show_data -print_format xml

Nicolas Gaullier (1):
  avcodec/h264_parser: fix start of packet for some broken streams

 libavcodec/h264_parser.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

-- 
2.30.2



More information about the ffmpeg-devel mailing list