History

avcodec/h264dec: add ref_pic_marking and pic_order_cnt bit_size to slice context

The V4L2_CID_STATELESS_H264_DECODE_PARAMS control require following: - dec_ref_pic_marking_bit_size Size in bits of the dec_ref_pic_marking() syntax element. - pic_order_cnt_bit_size Combined size in bits of the picture order count related syntax elements: pic_order_cnt_lsb, delta_pic_order_cnt_bottom, delta_pic_order_cnt0, and delta_pic_order_cnt1. Save the bit sizes while parsing for later use in hwaccel, similar to short/long_term_ref_pic_set_size in hevcdec.

Boris Brezillon committed 2 years ago

Commit 21285231 parent 4f3a3592 files · +7 −1Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/h264_slice.c +5 −1
  2. libavcodec/h264dec.h +2 −0
libavcodec/h264_slice.c+5−1
@@ -1701,7 +1701,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, · 1700 unmodified lines
1701 unsigned int slice_type, tmp, i;1701 unsigned int slice_type, tmp, i;
1702 int field_pic_flag, bottom_field_flag;1702 int field_pic_flag, bottom_field_flag;
1703 int first_slice = sl == h->slice_ctx && !h->current_slice;1703 int first_slice = sl == h->slice_ctx && !h->current_slice;
1704 int picture_structure;1704 int picture_structure, pos;
1705 1705
1706 if (first_slice)1706 if (first_slice)
1707 av_assert0(!h->setup_finished);1707 av_assert0(!h->setup_finished);
@@ -1792,6 +1792,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, · 84 unmodified lines
1792 1792
1793 sl->poc_lsb = 0;1793 sl->poc_lsb = 0;
1794 sl->delta_poc_bottom = 0;1794 sl->delta_poc_bottom = 0;
1795 pos = get_bits_left(&sl->gb);
1795 if (sps->poc_type == 0) {1796 if (sps->poc_type == 0) {
1796 sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);1797 sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb);
1797 1798
@@ -1806,6 +1807,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, · 8 unmodified lines
1806 if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME)1807 if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME)
1807 sl->delta_poc[1] = get_se_golomb(&sl->gb);1808 sl->delta_poc[1] = get_se_golomb(&sl->gb);
1808 }1809 }
1810 sl->pic_order_cnt_bit_size = pos - get_bits_left(&sl->gb);
1809 1811
1810 sl->redundant_pic_count = 0;1812 sl->redundant_pic_count = 0;
1811 if (pps->redundant_pic_cnt_present)1813 if (pps->redundant_pic_cnt_present)
@@ -1845,9 +1847,11 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, · 33 unmodified lines
1845 1847
1846 sl->explicit_ref_marking = 0;1848 sl->explicit_ref_marking = 0;
1847 if (nal->ref_idc) {1849 if (nal->ref_idc) {
1850 pos = get_bits_left(&sl->gb);
1848 ret = ff_h264_decode_ref_pic_marking(sl, &sl->gb, nal, h->avctx);1851 ret = ff_h264_decode_ref_pic_marking(sl, &sl->gb, nal, h->avctx);
1849 if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))1852 if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
1850 return AVERROR_INVALIDDATA;1853 return AVERROR_INVALIDDATA;
1854 sl->ref_pic_marking_bit_size = pos - get_bits_left(&sl->gb);
1851 }1855 }
1852 1856
1853 if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) {1857 if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) {
libavcodec/h264dec.h+2−0
@@ -324,6 +324,7 @@ typedef struct H264SliceContext { · 323 unmodified lines
324 MMCO mmco[H264_MAX_MMCO_COUNT];324 MMCO mmco[H264_MAX_MMCO_COUNT];
325 int nb_mmco;325 int nb_mmco;
326 int explicit_ref_marking;326 int explicit_ref_marking;
327 int ref_pic_marking_bit_size;
327 328
328 int frame_num;329 int frame_num;
329 int idr_pic_id;330 int idr_pic_id;
@@ -332,6 +333,7 @@ typedef struct H264SliceContext { · 2 unmodified lines
332 int delta_poc[2];333 int delta_poc[2];
333 int curr_pic_num;334 int curr_pic_num;
334 int max_pic_num;335 int max_pic_num;
336 int pic_order_cnt_bit_size;
335} H264SliceContext;337} H264SliceContext;
336 338
337/**339/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t