[FFmpeg-devel] [PATCH 4/5] h264dec: add ref_pic_marking and pic_order_cnt bit_size to slice context

Jonas Karlman jonas at kwiboo.se
Wed Dec 9 22:25:17 EET 2020


From: Boris Brezillon <boris.brezillon at collabora.com>

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
 libavcodec/h264_slice.c | 6 +++++-
 libavcodec/h264dec.h    | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 8a3ce1a688..5ad1c347ed 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1742,7 +1742,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
     unsigned int slice_type, tmp, i;
     int field_pic_flag, bottom_field_flag;
     int first_slice = sl == h->slice_ctx && !h->current_slice;
-    int picture_structure;
+    int picture_structure, pos;
 
     if (first_slice)
         av_assert0(!h->setup_finished);
@@ -1826,6 +1826,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
     if (nal->type == H264_NAL_IDR_SLICE)
         sl->idr_pic_id = get_ue_golomb_long(&sl->gb);
 
+    pos = sl->gb.index;
     if (sps->poc_type == 0) {
         sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
 
@@ -1839,6 +1840,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
         if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME)
             sl->delta_poc[1] = get_se_golomb(&sl->gb);
     }
+    sl->pic_order_cnt_bit_size = sl->gb.index - pos;
 
     sl->redundant_pic_count = 0;
     if (pps->redundant_pic_cnt_present)
@@ -1876,12 +1878,14 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl,
             return ret;
     }
 
+    pos = sl->gb.index;
     sl->explicit_ref_marking = 0;
     if (nal->ref_idc) {
         ret = ff_h264_decode_ref_pic_marking(sl, &sl->gb, nal, h->avctx);
         if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
             return AVERROR_INVALIDDATA;
     }
+    sl->ref_pic_marking_bit_size = sl->gb.index - pos;
 
     if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) {
         tmp = get_ue_golomb_31(&sl->gb);
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 2ca9965b41..ad5a20ff8e 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -328,6 +328,7 @@ typedef struct H264SliceContext {
     MMCO mmco[MAX_MMCO_COUNT];
     int  nb_mmco;
     int explicit_ref_marking;
+    int ref_pic_marking_bit_size;
 
     int frame_num;
     int poc_lsb;
@@ -336,6 +337,7 @@ typedef struct H264SliceContext {
     int curr_pic_num;
     int max_pic_num;
     int idr_pic_id;
+    int pic_order_cnt_bit_size;
 } H264SliceContext;
 
 /**
-- 
2.17.1



More information about the ffmpeg-devel mailing list