avcodec/h264_parser: recognise partition A as a picture start

parse_nal_units() takes slice_type and the POC fields from the first
VCL NAL of a picture, but recognised only plain and IDR slices. A
partition A opens with a slice header too, so until now a partitioned
stream left the parser reporting no picture type at all. It needs the
same leading bytes as any other VCL NAL, so it gets the same source
length cap rather than having its whole RBSP extracted.

Signed-off-by: guy-with-a-why <aaron@iterationlab.io>
This commit is contained in:
guy-with-a-why authored and Timo Rothenpieler committed 2026-08-31 18:13:21 +00:00
1 parent 0e00e1b3d8
commit 3e59635d1e
1 file changed
+2
+2
View File
@@ -314,6 +314,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
switch (state & 0x1f) {
case H264_NAL_SLICE:
case H264_NAL_IDR_SLICE:
case H264_NAL_DPA:
// Do not walk the whole buffer just to decode slice header
if ((state & 0x1f) == H264_NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
/* IDR or disposable slice
@@ -360,6 +361,7 @@ static inline int parse_nal_units(AVCodecParserContext *s,
p->poc.prev_poc_lsb = 0;
av_fallthrough;
case H264_NAL_SLICE:
case H264_NAL_DPA: // starts with a slice header too
get_ue_golomb_long(&nal.gb); // skip first_mb_in_slice
slice_type = get_ue_golomb_31(&nal.gb);
s->pict_type = ff_h264_golomb_to_pict_type[slice_type % 5];