This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit f017d0eefb27af25d260c34bc96aeaae3bbd8159
Author:     guy-with-a-why <[email protected]>
AuthorDate: Tue Aug 25 14:09:37 2026 +0100
Commit:     Timo Rothenpieler <[email protected]>
CommitDate: Mon Aug 31 18:13:21 2026 +0000

    avcodec/h264_slice: parse slice_id from partition A
    
    7.3.2.9.1 appends slice_id to the slice header of a partition A. It is
    what partitions B and C refer back to, so it has to be read and range
    checked before they can be matched to their A. 7.4.2.9.1 bounds it by
    PicSizeInMbs, which is half the frame size for a field picture and for
    MBAFF.
    
    Data partitioning belongs to the Extended profile, which does not allow
    CABAC, so a PPS asking for it is rejected here.
    
    Signed-off-by: guy-with-a-why <[email protected]>
---
 libavcodec/h264_slice.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index a13047ffe8..3a94781219 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2077,6 +2077,32 @@ static int h264_slice_init(H264Context *h, 
H264SliceContext *sl,
     return 0;
 }
 
+/* slice_id follows slice_header() in a partition A (7.3.2.9.1). */
+static int h264_parse_slice_id(const H264Context *h, H264SliceContext *sl)
+{
+    const PPS *pps = h->ps.pps_list[sl->pps_id];
+    const SPS *sps = pps->sps;
+    unsigned nb_slice_ids = sps->mb_width * sps->mb_height;
+
+    if (pps->cabac) {
+        av_log(h->avctx, AV_LOG_ERROR, "Data partitioning requires CAVLC\n");
+        return AVERROR_INVALIDDATA;
+    }
+
+    if (sl->picture_structure != PICT_FRAME || sps->mb_aff)
+        nb_slice_ids /= 2;
+
+    sl->slice_id = get_ue_golomb_long(&sl->gb);
+    if (sl->slice_id >= nb_slice_ids) {
+        av_log(h->avctx, AV_LOG_ERROR, "slice_id %u out of range\n", 
sl->slice_id);
+        return AVERROR_INVALIDDATA;
+    }
+
+    sl->data_partitioning = 1;
+
+    return 0;
+}
+
 int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal)
 {
     H264SliceContext *sl = h->slice_ctx + h->nb_slice_ctx_queued;
@@ -2085,10 +2111,20 @@ int ff_h264_queue_decode_slice(H264Context *h, const 
H2645NAL *nal)
 
     sl->gb = nal->gb;
 
+    sl->data_partitioning = 0;
+    sl->dpb_available     = 0;
+    sl->dpc_available     = 0;
+
     ret = h264_slice_header_parse(h, sl, nal);
     if (ret < 0)
         return ret;
 
+    if (nal->type == H264_NAL_DPA) {
+        ret = h264_parse_slice_id(h, sl);
+        if (ret < 0)
+            return ret;
+    }
+
     // discard redundant pictures
     if (sl->redundant_pic_count > 0) {
         sl->ref_count[0] = sl->ref_count[1] = 0;

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to