diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-08-04 17:33:29 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-10-07 22:35:56 +0200 |
commit | 452089ee23312ceab28baf9f83fb7dff472e7d82 (patch) | |
tree | af8ca737a93d89a68138d1392e518dc435c74435 /libavcodec/hevc_refs.c | |
parent | 6695c0af0e5431e50c5059ad01862e399af6607d (diff) | |
download | ffmpeg-452089ee23312ceab28baf9f83fb7dff472e7d82.tar.gz |
avcodec/hevcdec: Use RefStruct API for RefPicListTab buffer
Given that the RefStruct API relies on the user to know
the size of the objects and does not provide a way to get it,
we need to store the number of elements allocated ourselves;
but this is actually better than deriving it from the size
in bytes.
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/hevc_refs.c')
-rw-r--r-- | libavcodec/hevc_refs.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 8f49704b54..ae464e8e6d 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -45,7 +45,8 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) av_buffer_unref(&frame->tab_mvf_buf); frame->tab_mvf = NULL; - av_buffer_unref(&frame->rpl_buf); + ff_refstruct_unref(&frame->rpl); + frame->nb_rpl_elems = 0; av_buffer_unref(&frame->rpl_tab_buf); frame->rpl_tab = NULL; frame->refPicList = NULL; @@ -95,9 +96,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s) if (ret < 0) return NULL; - frame->rpl_buf = av_buffer_allocz(s->pkt.nb_nals * sizeof(RefPicListTab)); - if (!frame->rpl_buf) + frame->rpl = ff_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl)); + if (!frame->rpl) goto fail; + frame->nb_rpl_elems = s->pkt.nb_nals; frame->tab_mvf_buf = av_buffer_pool_get(s->tab_mvf_pool); if (!frame->tab_mvf_buf) @@ -110,7 +112,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s) frame->rpl_tab = (RefPicListTab **)frame->rpl_tab_buf->data; frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height; for (j = 0; j < frame->ctb_count; j++) - frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data; + frame->rpl_tab[j] = frame->rpl; if (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD) frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST; @@ -295,11 +297,11 @@ static int init_slice_rpl(HEVCContext *s) int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr]; int i; - if (s->slice_idx >= frame->rpl_buf->size / sizeof(RefPicListTab)) + if (s->slice_idx >= frame->nb_rpl_elems) return AVERROR_INVALIDDATA; for (i = ctb_addr_ts; i < ctb_count; i++) - frame->rpl_tab[i] = (RefPicListTab *)frame->rpl_buf->data + s->slice_idx; + frame->rpl_tab[i] = frame->rpl + s->slice_idx; frame->refPicList = (RefPicList *)frame->rpl_tab[ctb_addr_ts]; |