mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-26 09:12:33 +00:00
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>
This commit is contained in:
parent
6695c0af0e
commit
452089ee23
@ -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];
|
||||
|
||||
|
@ -3414,9 +3414,8 @@ static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
|
||||
goto fail;
|
||||
dst->rpl_tab = src->rpl_tab;
|
||||
|
||||
dst->rpl_buf = av_buffer_ref(src->rpl_buf);
|
||||
if (!dst->rpl_buf)
|
||||
goto fail;
|
||||
dst->rpl = ff_refstruct_ref(src->rpl);
|
||||
dst->nb_rpl_elems = src->nb_rpl_elems;
|
||||
|
||||
dst->poc = src->poc;
|
||||
dst->ctb_count = src->ctb_count;
|
||||
|
@ -417,7 +417,8 @@ typedef struct HEVCFrame {
|
||||
|
||||
AVBufferRef *tab_mvf_buf;
|
||||
AVBufferRef *rpl_tab_buf;
|
||||
AVBufferRef *rpl_buf;
|
||||
RefPicListTab *rpl; ///< RefStruct reference
|
||||
int nb_rpl_elems;
|
||||
|
||||
void *hwaccel_picture_private; ///< RefStruct reference
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user